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

Account

Description

The Account is a per-user sub-contract of a pool, with a deterministic address derived from {user, pool}. It acts as a barrier that collects the two token deposits of a mint independently of the order in which they arrive: it accumulates amount0/amount1, and once both satisfy the order's thresholds it sends the reforge (mint) request to the Pool. The pool funds it and returns excess/refunds to it; the owning user can set the pending order or reclaim excess gas. Because the address encodes the user, funds can only ever reach the rightful owner's Account.

Interface

get_account_data

(address, address, coins, coins, int, Cell?, Cell) get_account_data ()

This function provides current state of the user account

Return Values

#TypeDescription
0addressaccount::user_address Address of the owner of the account
1addressaccount::pool_address Address of the pool that this account is attached to
2coinsaccount::amount0 Amount of jetton0 that was deposited for mint
3coinsaccount::amount1 Amount of jetton1 that was deposited for mint
4intaccount::posCount Number of positions currently stored in the account
5Cell?account::order Pending mint order cell, or null if none
6Cellaccount::positions Cell with the stored burn positions

Messages

ACCOUNT_ADD_LIQUIDITY

Opcode : 0x3ebe5431

This operation adds liquidity and a minting request to the account. This contract is used as a barrier to collect together data about the proofs of funding two tokens and the request to mint some liquidity. Common usage is as follows - send one jetton with the mint instructions and the second jetton with the mint instructions. And as soon as they will both arrive AccountV3 would trigger the minting request in the pool. This makes minting independent of the order in which jettons arrive. Account refers to jettons in the pool order
Access Rights: Accepted only from the pool this Account belongs to. The pool relays each verified jetton deposit here, and once both sides satisfy the order the Account triggers the mint in the pool.

PathMnemonicTypeDescription
op Uint(32),op
query_id Uint(64) queryid as of the TON documentation
new_amount0 Coins(124) Amount of jetton0 that is funded for the mint
new_amount1 Coins(124) Amount of jetton1 that is funded for the mint
enough0 Coins(124) When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger
enough1 Coins(124) When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger
needPos Uint(64) Amount of positions that are enough for the order to be executed
passthrough Uint(4) Amount of positions that will be untouched
target_action Uint(32) Routing of the reforge result (ACTION_TARGET_DEFAULT / ACTION_TARGET_ALM) — see target_action in ACCOUNT_SET_ORDER for details
0 Maybe Cell(1) MintOrder0 Cell with mint order
0 op0 Uint(32) Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details
0 liquidity0 Uint(128) Amount of liquidity to mint
0 tickLower0 Int(24) lower bound of the range in which to mint
0 tickUpper0 Int(24) upper bound of the range in which to mint
0 receiver0 Address(267) Address of receiver of the NFT
1 Maybe Cell(1) MintOrder1 Cell with mint order
1 op1 Uint(32) Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details
1 liquidity1 Uint(128) Amount of liquidity to mint
1 tickLower1 Int(24) lower bound of the range in which to mint
1 tickUpper1 Int(24) upper bound of the range in which to mint
1 receiver1 Address(267) Address of receiver of the NFT
2 Maybe Cell(1) MintOrder2 Cell with mint order
2 op2 Uint(32) Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details
2 liquidity2 Uint(128) Amount of liquidity to mint
2 tickLower2 Int(24) lower bound of the range in which to mint
2 tickUpper2 Int(24) upper bound of the range in which to mint
2 receiver2 Address(267) Address of receiver of the NFT
3 Maybe Cell(1) MintOrder3 Cell with mint order
3 op3 Uint(32) Mint mode (MINT_NOT_LESS / MINT_AS_MUCH_AS_POSSIBLE) — see mintOp in ACCOUNT_SET_ORDER for details
3 liquidity3 Uint(128) Amount of liquidity to mint
3 tickLower3 Int(24) lower bound of the range in which to mint
3 tickUpper3 Int(24) upper bound of the range in which to mint
3 receiver3 Address(267) Address of receiver of the NFT
TL-B Description This is a preliminary tl-b - subject to change **Tlb for ACCOUNT_ADD_LIQUIDITY**
ACCOUNT_ADD_LIQUIDITY#3ebe5431 
    query_id:uint64
    new_amount0:(VarUInteger 16)
    new_amount1:(VarUInteger 16)
    enough0:(VarUInteger 16)
    enough1:(VarUInteger 16)
    needPos:uint64
    passthrough:uint4
    target_action:uint32
    MintOrder0:(Maybe ^MintOrder0Type)
    MintOrder1:(Maybe ^MintOrder1Type)
    MintOrder2:(Maybe ^MintOrder2Type)
    MintOrder3:(Maybe ^MintOrder3Type)
= ContractMessages;
_ 
    op0:uint32
    liquidity0:uint128
    tickLower0:int24
    tickUpper0:int24
    receiver0:MsgAddress
= MintOrder0Type;
_ 
    op1:uint32
    liquidity1:uint128
    tickLower1:int24
    tickUpper1:int24
    receiver1:MsgAddress
= MintOrder1Type;
_ 
    op2:uint32
    liquidity2:uint128
    tickLower2:int24
    tickUpper2:int24
    receiver2:MsgAddress
= MintOrder2Type;
_ 
    op3:uint32
    liquidity3:uint128
    tickLower3:int24
    tickUpper3:int24
    receiver3:MsgAddress
= MintOrder3Type;

ACCOUNT_RESET_GAS

Opcode : 0x42a0fb43

This operation allows user to get back the gas it too much was sent
Access Rights: Allowed only for the user who owns this Account. Returns excess TON that accumulated on the contract.

PathMnemonicTypeDescription
op Uint(32),op
query_id Uint(64) queryid as of the TON documentation
TL-B Description This is a preliminary tl-b - subject to change **Tlb for ACCOUNT_RESET_GAS**
ACCOUNT_RESET_GAS#42a0fb43 
    query_id:uint64
= ContractMessages;

ACCOUNT_SET_ORDER

Opcode : 0x61d86ffe

This operation allows user to set an order (usually for minting or refunding) that will be executed if the preconditions are satisfied
Access Rights: Allowed only for the user who owns this Account. Sets the order (mint or refund) that runs once its preconditions are met.

PathMnemonicTypeDescription
op Uint(32),op
query_id Uint(64) queryid as of the TON documentation
enough0 Coins(124) When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger
enough1 Coins(124) When temporary storage (user account) satisfy both enough0/1 amounts - mint would trigger
needPos Uint(64) Amount of positions that are enough for the order to be executed
passthrough Uint(4) Amount of positions that will be untouched
target_action Uint(32) Routing of the reforge result: ACTION_TARGET_DEFAULT (0) sends minted NFT/refunds to the normal recipients; ACTION_TARGET_ALM (1) sends all coins to the pool's ALM role address (used by ALM flows). See action_target in pool_reforge.func
0 Maybe Cell(1) mint0 Cell with mint order 0
0 mintOp[0] Uint(32) Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).
0 liquidity[0] Uint(128) Amount of liquidity to mint for this order (interpreted per mintOp mode)
0 tickLower[0] Int(24) lower bound of the range in which to mint
0 tickUpper[0] Int(24) upper bound of the range in which to mint
0 nftReceiver[0] Address(267) Address that would receive the minted NFT, excesses and refunds
1 Maybe Cell(1) mint1 Cell with mint order 1
1 mintOp[1] Uint(32) Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).
1 liquidity[1] Uint(128) Amount of liquidity to mint for this order (interpreted per mintOp mode)
1 tickLower[1] Int(24) lower bound of the range in which to mint
1 tickUpper[1] Int(24) upper bound of the range in which to mint
1 nftReceiver[1] Address(267) Address that would receive the minted NFT, excesses and refunds
2 Maybe Cell(1) mint2 Cell with mint order 2
2 mintOp[2] Uint(32) Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).
2 liquidity[2] Uint(128) Amount of liquidity to mint for this order (interpreted per mintOp mode)
2 tickLower[2] Int(24) lower bound of the range in which to mint
2 tickUpper[2] Int(24) upper bound of the range in which to mint
2 nftReceiver[2] Address(267) Address that would receive the minted NFT, excesses and refunds
3 Maybe Cell(1) mint3 Cell with mint order 3
3 mintOp[3] Uint(32) Mint mode for this order. MINT_NOT_LESS (0): mint exactly `liquidity` units or fail and refund. MINT_AS_MUCH_AS_POSSIBLE (1): mint as much as the funded amounts allow, up to `liquidity`. The 'as much as possible' mode is only honored when the pool has FLAG_MINT_EX_MASK set; otherwise it is silently downgraded to MINT_NOT_LESS (see pool_mint.func).
3 liquidity[3] Uint(128) Amount of liquidity to mint for this order (interpreted per mintOp mode)
3 tickLower[3] Int(24) lower bound of the range in which to mint
3 tickUpper[3] Int(24) upper bound of the range in which to mint
3 nftReceiver[3] Address(267) Address that would receive the minted NFT, excesses and refunds
TL-B Description This is a preliminary tl-b - subject to change **Tlb for ACCOUNT_SET_ORDER**
ACCOUNT_SET_ORDER#61d86ffe 
    query_id:uint64
    enough0:(VarUInteger 16)
    enough1:(VarUInteger 16)
    needPos:uint64
    passthrough:uint4
    target_action:uint32
    mint0:(Maybe ^Mint0Type)
    mint1:(Maybe ^Mint1Type)
    mint2:(Maybe ^Mint2Type)
    mint3:(Maybe ^Mint3Type)
= ContractMessages;
_ 
    mintOp_0:uint32
    liquidity_0:uint128
    tickLower_0:int24
    tickUpper_0:int24
    nftReceiver_0:MsgAddress
= Mint0Type;
_ 
    mintOp_1:uint32
    liquidity_1:uint128
    tickLower_1:int24
    tickUpper_1:int24
    nftReceiver_1:MsgAddress
= Mint1Type;
_ 
    mintOp_2:uint32
    liquidity_2:uint128
    tickLower_2:int24
    tickUpper_2:int24
    nftReceiver_2:MsgAddress
= Mint2Type;
_ 
    mintOp_3:uint32
    liquidity_3:uint128
    tickLower_3:int24
    tickUpper_3:int24
    nftReceiver_3:MsgAddress
= Mint3Type;