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
| Index | Type | Size (b/r) | Cell | Name | Description |
|---|---|---|---|---|---|
| 1 | uint64 | 64 / 0 | 1 | positionv3::index | The position number. Also the nft index |
| 2 | addr | 267 / 0 | 1 | positionv3::pool_address | Address of the pool that created this NFT |
| 3 | addr | 267 / 0 | 1 | positionv3::user_address | Address of the user ton wallet that currently owns the position |
| 4 | cell | 0 / 1 | 1 | positionv3::content | NFT metadata that contains image url, name and description packed in standard format |
| 5 | uint128 | 128 / 0 | 1 | positionv3::liquidity | Position liquidity |
| 6 | int24 | 24 / 0 | 1 | positionv3::tickLower | Position lower tick number |
| 7 | int24 | 24 / 0 | 1 | positionv3::tickUpper | Position upper tick number |
| 8 | uint256 | 256 / 0 | 11 | positionv3::feeGrowthInside0LastX128 | Fees collected before the position was opened or updated for jetton0 (in pool terms) |
| 9 | uint256 | 256 / 0 | 11 | positionv3::feeGrowthInside1LastX128 | Fees collected before the position was opened or updated for jetton1 (in pool terms) |
Cells
| Name | Size | Free |
|---|---|---|
| 1 | 774 | 249 |
| 11 | 512 | 511 |
Interface
getPoolAddress
(slice) getPoolAddress ()
This function returns pool address that created this Position NFT
Return Values
| # | Type | Description |
|---|---|---|
| 0 | slice | address in question |
getUserAddress
(slice) getUserAddress ()
This function returns user address that owned created this Position NFT
Return Values
| # | Type | Description |
|---|---|---|
| 0 | slice | address 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
| # | Type | Description |
|---|---|---|
| 0 | int | liquidity that this position owns |
| 1 | int | lower tick of the position |
| 2 | int | upper tick of the position |
| 3 | int | fee growth of jetton0 in the given range at moment of the creation or latest collect of the NFT position |
| 4 | int | fee 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
| # | Type | Description |
|---|---|---|
| 0 | int | Is position active (in our case, if positionv3::liquidity != 0) |
| 1 | int | positionv3::index |
| 2 | slice | positionv3::pool_address |
| 3 | slice | Owner address (positionv3::user_address) |
| 4 | cell | Content 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\
| Path | Mnemonic | Type | Description |
|---|---|---|---|
| op | Uint(32),op | ||
| query_id | Uint(64) | queryid as of the TON documentation | |
| user_address | Address(267) | NFT owner | |
| liquidity | Uint(128) | Amount of the liquidity | |
| tickLower | Int(24) | Lower tick of the NFT | |
| tickUpper | Int(24) | Upper tick of the NFT | |
| 0 | Cell(0) old_fee_cell | Fee counters From | |
| 0 | feeGrowthInside0LastX128 | Uint(256),x128 | |
| 0 | feeGrowthInside1LastX128 | Uint(256),x128 | |
| 0 | nftIndex | Uint(64),Indexer | |
| 0 | jetton0Amount | Coins(124),Indexer | |
| 0 | jetton1Amount | Coins(124),Indexer | |
| 0 | tick | Int(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\
| Path | Mnemonic | Type | Description |
|---|---|---|---|
| op | Uint(32),op | ||
| query_id | Uint(64) | queryid as of the TON documentation | |
| nft_owner | Address(267) | NFT owner to receive funds | |
| liquidity2Burn | Uint(128) | Amount of the liquidity to burn, 0 is a valid amount, in this case only collected fees would be returned | |
| tickLower | Int(24) | Lower tick of the NFT. NFT would check that it is the same as in position | |
| tickUpper | Int(24) | Upper tick of the NFT. NFT would check that it is the same as in position | |
| 0 | Cell(0) old_fee_cell | Fee counters From | |
| 0 | feeGrowthInside0LastX128 | Uint(256),x128 | |
| 0 | feeGrowthInside1LastX128 | Uint(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\
| Path | Mnemonic | Type | Description |
|---|---|---|---|
| op | Uint(32),op | ||
| query_id | Uint(64) | queryid as of the TON documentation | |
| new_owner | Address(267) | New NFT owner | |
| response_destination | Address(267) | Address to receive response | |
| custom_payload | Cell(0),Maybe | Custom information for NFT. Ignored by our implementation | |
| forward_amount | Coins(124) | Amount of coins to forward for processing | |
| forward_payload | Cell(0),Either | Payload 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;