Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Position NFT

position_nft

Description

This is a modified NFT contract to store user position. To minimize data, actual content is not stored inside the contract so far kept empty by the pool. It is appended on the fly with nft values. Pool then adds all the other fields to form valid metadata.

Data Storage

IndexTypeSize (b/r)CellNameDescription
1uint6464 / 01positionv3::indexThe position number. Also the nft index
2addr267 / 01positionv3::pool_addressAddress of the pool that created this NFT
3addr267 / 01positionv3::user_addressAddress of the user ton wallet that currently owns the position
4cell0 / 11positionv3::contentNFT metadata that contains image url, name and description packed in standard format
5uint128128 / 01positionv3::liquidityPosition liquidity
6int2424 / 01positionv3::tickLowerPosition lower tick number
7int2424 / 01positionv3::tickUpperPosition upper tick number
8uint256256 / 011positionv3::feeGrowthInside0LastX128Fees collected before the position was opened or updated for jetton0 (in pool terms)
9uint256256 / 011positionv3::feeGrowthInside1LastX128Fees collected before the position was opened or updated for jetton1 (in pool terms)

Cells

NameSizeFree
1774249
11512511

Interface

getPoolAddress

(slice) getPoolAddress ()

This function returns pool address that created this Position NFT

Return Values

#TypeDescription
0sliceaddress in question

getUserAddress

(slice) getUserAddress ()

This function returns user address that owned created this Position NFT

Return Values

#TypeDescription
0sliceaddress in question

getPositionInfo

(int, int, int, int, int) getPositionInfo ()

This function returns data stored in Position NFT and is related to the position

Return Values

#TypeDescription
0intliquidity that this position owns
1intlower tick of the position
2intupper tick of the position
3intfee growth of jetton0 in the given range at moment of the creation or latest collect of the NFT position
4intfee growth of jetton1 in the given range at moment of the creation or latest collect of the NFT position

get_nft_data

(int, int, slice, slice, cell) get_nft_data ()

This function returns data of this Position NFT that is related to NFT as TEP-62 It also attaches some values to transfer them to pool

Return Values

#TypeDescription
0intIs position active (in our case, if positionv3::liquidity != 0)
1intpositionv3::index
2slicepositionv3::pool_address
3sliceOwner address (positionv3::user_address)
4cellContent of the NFT. The cell with a dict that has position data appended to the cell for the pool to parse

Messages

POSITIONNFTV3_POSITION_INIT

Opcode : 0xd5ecca2a

Initial message that pools sends to the NFT after state_init
Access Rights: This operation is allowed for positionv3::pool_address\

PathMnemonicTypeDescription
opUint(32),op
query_idUint(64)queryid as of the TON documentation
user_addressAddress(267)NFT owner
liquidityUint(128)Amount of the liquidity
tickLowerInt(24)Lower tick of the NFT
tickUpperInt(24)Upper tick of the NFT
0Cell(0) old_fee_cellFee counters From
0feeGrowthInside0LastX128Uint(256),x128
0feeGrowthInside1LastX128Uint(256),x128
0nftIndexUint(64),Indexer
0jetton0AmountCoins(124),Indexer
0jetton1AmountCoins(124),Indexer
0tickInt(24),Indexer
TL-B Description (TBD)

This is a preliminary tl-b - subject to change

Tlb for POSITIONNFTV3_POSITION_INIT

POSITIONNFTV3_POSITION_INIT#d5ecca2a 
    query_id:uint64
    user_address:MsgAddress
    liquidity:uint128
    tickLower:int24
    tickUpper:int24
    old_fee_cell:^[
        feeGrowthInside0LastX128:uint256
        feeGrowthInside1LastX128:uint256
        nftIndex:uint64
        jetton0Amount:(VarUInteger 16)
        jetton1Amount:(VarUInteger 16)
        tick:int24
    ]  
= ContractMessages;

POSITIONNFTV3_POSITION_BURN

Opcode : 0x46ca335a

Message from the pool that is part of burn process. This message carries new feeGrowthInside?Last values form the pool
Access Rights: This operation is allowed for positionv3::user_address\

PathMnemonicTypeDescription
opUint(32),op
query_idUint(64)queryid as of the TON documentation
nft_ownerAddress(267)NFT owner to receive funds
liquidity2BurnUint(128)Amount of the liquidity to burn, 0 is a valid amount, in this case only collected fees would be returned
tickLowerInt(24)Lower tick of the NFT. NFT would check that it is the same as in position
tickUpperInt(24)Upper tick of the NFT. NFT would check that it is the same as in position
0Cell(0) old_fee_cellFee counters From
0feeGrowthInside0LastX128Uint(256),x128
0feeGrowthInside1LastX128Uint(256),x128
TL-B Description (TBD)

This is a preliminary tl-b - subject to change

Tlb for POSITIONNFTV3_POSITION_BURN

POSITIONNFTV3_POSITION_BURN#46ca335a 
    query_id:uint64
    nft_owner:MsgAddress
    liquidity2Burn:uint128
    tickLower:int24
    tickUpper:int24
    old_fee_cell:^[
        feeGrowthInside0LastX128:uint256
        feeGrowthInside1LastX128:uint256
    ]  
= ContractMessages;

POSITIONNFTV3_NFT_TRANSFER

Opcode : 0x5fcc3d14

Transfer LP NFT to another user. Please be warned that some UI elements could be unable to track it. However with SDK it still can be burned
Access Rights: This operation is allowed for positionv3::user_address\

PathMnemonicTypeDescription
opUint(32),op
query_idUint(64)queryid as of the TON documentation
new_ownerAddress(267)New NFT owner
response_destinationAddress(267)Address to receive response
custom_payloadCell(0),MaybeCustom information for NFT. Ignored by our implementation
forward_amountCoins(124)Amount of coins to forward for processing
forward_payloadCell(0),EitherPayload for processing
TL-B Description (TBD)

This is a preliminary tl-b - subject to change

Tlb for POSITIONNFTV3_NFT_TRANSFER

POSITIONNFTV3_NFT_TRANSFER#5fcc3d14 
    query_id:uint64
    new_owner:MsgAddress
    response_destination:MsgAddress
    custom_payload:(Maybe ^Cell)
    forward_amount:(VarUInteger 16)
    forward_payload:(Either ^Cell Cell)
= ContractMessages;