Router

router

Interface

getRouterState

(address, address, address, address?, int, int, int) getRouterState ()

returns router admin address

Return Values

#
Type
Description

0

address

router admin address

getPoolAddress

(address) getPoolAddress (jettonWallet0: address, jettonWallet1: address)

returns pool address for two given jetton_wallets belonging to the router

Parameters

#
Type
Name
Description

undefined

undefined

undefined

Address of the jetton 0 wallet belonging to router

undefined

undefined

undefined

Address of the jetton 1 wallet belonging to router

Return Values

#
Type
Description

0

address

pool address

getChildContracts

(cell, cell, cell, cell) getChildContracts ()

returns code of the child contracts deprecated

Return Values

#
Type
Description

0

cell

code of the pool contract

1

cell

code of the account contract

2

cell

code of the nft position contract

3

cell

code of the pool prototype contract

get_pending_timelocks

( int, int, address?, int, address?, int, int, int, cell?, int, cell?,) get_pending_timelocks ()

returns active router timelocks to monitor system state. Timestamp 0xFFFFFFFFFFFFFFFF means - never/timelock not active

Return Values

#
Type
Description

0

int

Timelock delay

1

int

Timestamp when new code can be committed

2

address?

Cell with new code

3

int

Timestamp when new Admin Address can be committed

4

address?

New Admin Address

5

int

Timestamp when new Proxy Ton Address can be committed

6

int

New Proxy Ton Address

7

int

Timestamp when new flags can be committed

8

cell?

New Flags

Messages

JETTON_TRANSFER_NOTIFICATION

Opcode : 0x7362d09c

Process router funding, payload determines if it is mint or swap

Path
Mnemonic
Type
Description

op

Uint(32),op

query_id

Uint(64)

queryid as of the TON documentation

jetton_amount

Coins(124)

Amount of coins sent to the router

from_user

Address(267)

User that originated the transfer

forward_payload

Cell(0),Either, Payload

Payload for processing

TL-B Description (TBD)

This is a preliminary tl-b - subject to change

Tlb for JETTON_TRANSFER_NOTIFICATION
JETTON_TRANSFER_NOTIFICATION#7362d09c 
    query_id:uint64
    jetton_amount:(VarUInteger 16)
    from_user:MsgAddress
    forward_payload:(Either ^Cell Cell)
= ContractMessages;

ROUTER_CREATE_POOL

Opcode : 0x2e3034ef

Operation that deploys and inits new Pool contract for two given jettons identified by their wallets. New pool would reorder the jettons to match the invariant slice_hash(jetton0_address) > slice_hash(jetton1_address).

Path
Mnemonic
Type
Description

op

Uint(32),op

query_id

Uint(64)

queryid as of the TON documentation

jetton_wallet0

Address(267)

Address of the jetton0 wallet. Used to compute pool address

jetton_wallet1

Address(267)

Address of the jetton1 wallet. Used to compute pool address

tick_spacing

Int(24)

Tick spacing to be used in the pool

initial_priceX96

Uint(160),PriceX96

Initial price for the pool

pool_active

Uint(1)

Should pool be created as active

protocol_fee

Uint(16),Fee

Liquidity provider fee. base in FEE_DENOMINATOR parts. If value is more than 10000 value would be default

lp_fee_base

Uint(16),Fee

Protocol fee in FEE_DENOMINATOR. If value is more than 10000 value would be default

lp_fee_current

Uint(16),Fee

Current value of the pool fee, in case of dynamic adjustment. If value is more than 10000 value would be default

0

Cell(0) roles_cell

Cell With Role

0

has_controller

Uint(1),Bool

Flag that shows if this message have a new controller address

0

controller_addr

Address(267)

Address that is allowed to change the fee. Can always be updated by admin.

0

has_creator

Uint(1),Bool

Flag that shows if this message have a new creator address

0

creator_addr

Address(267)

Address that is allowed to change the fee. Can always be updated by admin. If has_controller is false could be 00b

1

Cell(0) metadata_cell

Cell With Metainfo

1

nftv3_content

Cell(0),Metadata

Metadata for the NFT Collection

1

nftv3item_content

Cell(0),Metadata

Metadata for the NFT Item

2

Cell(0) minter_cell

Cell With Minters

2

jetton0_minter

Address(267)

Address of the jetton0 minter, used by indexer and frontend

2

jetton1_minter

Address(267)

Address of the jetton1 minter, used by indexer and frontend

TL-B Description (TBD)

This is a preliminary tl-b - subject to change

Tlb for ROUTER_CREATE_POOL
ROUTER_CREATE_POOL#2e3034ef 
    query_id:uint64
    jetton_wallet0:MsgAddress
    jetton_wallet1:MsgAddress
    tick_spacing:int24
    initial_priceX96:uint160
    pool_active:uint1
    protocol_fee:uint16
    lp_fee_base:uint16
    lp_fee_current:uint16
    roles_cell:^[
        has_controller:uint1
        controller_addr:MsgAddress
        has_creator:uint1
        creator_addr:MsgAddress
    ]  
    metadata_cell:^[
        nftv3_content:Cell
        nftv3item_content:Cell
    ]  
    minter_cell:^[
        jetton0_minter:MsgAddress
        jetton1_minter:MsgAddress
    ]  
= ContractMessages;

ROUTER_PAY_TO

Opcode : 0xa1daa96d

This message is the message that is sent to Router by the pool, an it would be accepted only from the pool:

Possible error codes

Operation
Error Core
Value
Meaning

SWAP

RESULT_SWAP_OK

200

Swap went fine

SWAP

RESULT_SWAP_OUTPUT_TOO_SMALL

230

minAmount was not reached, swap reverted

SWAP

RESULT_SWAP_INTERNAL_ERROR

231

Internal error, generally this should not happen

SWAP

RESULT_SWAP_POOL_LOCKED

232

Attempt to swap in the locked pool

SWAP

RESULT_SWAP_POOL_EMPTY

233

Attempt to swap in the empty pool

MINT

RESULT_MINT_OK

202

Mint went fine

MINT

RESULT_NO_LIQUIDITY

226

Minting Zero liquidity was asked (not always unintended)

MINT

RESULT_TICK_IMPOSSIBLE_LOW

220

One of the ticks is too low

MINT

RESULT_TICK_IMPOSSIBLE_HIGH

221

One of the ticks is too high

MINT

RESULT_WRONG_TICK_SPACING

222

One of ticks is not divisible by tick_spacing

MINT

RESULT_TOO_MANY_TICKS

223

Pool is full

MINT

RESULT_TOO_MUCH_LIQUIDITY

224

Too much liquidity in one tick

MINT

RESULT_NOT_ENOUGH_COINS

225

Not enough coins to mint

BURN

RESULT_BURN_OK

201

Burn went fine

Path
Mnemonic
Type
Description

op

Uint(32),op

query_id

Uint(64)

queryid as of the TON documentation

reciever0

Address(267)

Address of the first receiver of the funds

reciever1

Address(267)

Address of the second receiver of the funds

exit_code0

Uint(8),ErrorCode

Exit code for order 0

exit_code1

Uint(8),ErrorCode

Exit code for order 1

exit_code2

Uint(8),ErrorCode

Exit code for order 2

exit_code3

Uint(8),ErrorCode

Exit code for order 3

seqno

Uint(64),Indexer

Internal pool sequence number

0

Maybe Cell(1) coinsinfo_cell

Cell with info about the coins

0

jetton0_address

Address(267)

Jetton to be sent to receiver0 identified by the wallet that belongs to router

0

jetton1_address

Address(267)

Jetton to be sent to receiver1 identified by the wallet that belongs to router

0

amount0

Coins(124)

Amount of coins to be payed to receiver0

0

amount1

Coins(124)

Amount of coins to be payed to receiver1

0

0

Cell(0) indexer_swap_info_cell

Information about the payload

0->0

payload_amount0

Coins(124)

0->0

payload_0

Cell(1),Maybe, Payload

0->0

payload_amount1

Coins(124)

0->0

payload_1

Cell(1),Maybe, Payload

Predicate

exit_code0 = 200

1

Maybe Cell(1) indexer_swap_info_cell

Information for indexer to process after the swap

1

liquidity

Uint(128),Indexer

Post-swap concentrated liquidity at current tick

1

price_sqrt

Uint(160),Indexer,PriceX96

Post-swap square root of the price stored as fixed point 64.96

1

tick

Int(24),Indexer

Post-swap current tick

1

feeGrowthGlobal0X128

Int(256),Indexer

Current range fee per unit of the liquidity for jetton0

1

feeGrowthGlobal1X128

Int(256),Indexer

Current range fee per unit of the liquidity for jetton1

Predicate

exit_code0 != 200

2

Maybe Cell(1) indexer_info_cell

Information for indexer to process after the burn

3

Maybe Cell(1) positions_cell

Cell with positions

3

0

Maybe Cell(1) burn0

Cell with burn number 0

3->0

index[0]

Uint(64)

3->0

subindex[0]

Uint(4)

Subindex

3->0

liquidity[0]

Uint(128)

3->0

tickLower[0]

Int(24)

lower bound of the range in which to mint

3->0

tickUpper[0]

Int(24)

upper bound of the range in which to mint

3->0

feeGrowthInside0LastX128[0]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->0

feeGrowthInside1LastX128[0]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3,0

0

Maybe Cell(1) new_fee_cell

Fee counters to collect to (Used by indexer)

3->0->0

feeGrowthInside0CurrentX128[0]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->0->0

feeGrowthInside1CurrentX128[0]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3->0

liquidity2Burn[0]

Uint(128)

3

1

Maybe Cell(1) burn1

Cell with burn number 1

3->1

index[1]

Uint(64)

3->1

subindex[1]

Uint(4)

Subindex

3->1

liquidity[1]

Uint(128)

3->1

tickLower[1]

Int(24)

lower bound of the range in which to mint

3->1

tickUpper[1]

Int(24)

upper bound of the range in which to mint

3->1

feeGrowthInside0LastX128[1]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->1

feeGrowthInside1LastX128[1]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3,1

0

Maybe Cell(1) new_fee_cell

Fee counters to collect to (Used by indexer)

3->1->0

feeGrowthInside0CurrentX128[1]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->1->0

feeGrowthInside1CurrentX128[1]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3->1

liquidity2Burn[1]

Uint(128)

3

2

Maybe Cell(1) burn2

Cell with burn number 2

3->2

index[2]

Uint(64)

3->2

subindex[2]

Uint(4)

Subindex

3->2

liquidity[2]

Uint(128)

3->2

tickLower[2]

Int(24)

lower bound of the range in which to mint

3->2

tickUpper[2]

Int(24)

upper bound of the range in which to mint

3->2

feeGrowthInside0LastX128[2]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->2

feeGrowthInside1LastX128[2]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3,2

0

Maybe Cell(1) new_fee_cell

Fee counters to collect to (Used by indexer)

3->2->0

feeGrowthInside0CurrentX128[2]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->2->0

feeGrowthInside1CurrentX128[2]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3->2

liquidity2Burn[2]

Uint(128)

3

3

Maybe Cell(1) burn3

Cell with burn number 3

3->3

index[3]

Uint(64)

3->3

subindex[3]

Uint(4)

Subindex

3->3

liquidity[3]

Uint(128)

3->3

tickLower[3]

Int(24)

lower bound of the range in which to mint

3->3

tickUpper[3]

Int(24)

upper bound of the range in which to mint

3->3

feeGrowthInside0LastX128[3]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->3

feeGrowthInside1LastX128[3]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3,3

0

Maybe Cell(1) new_fee_cell

Fee counters to collect to (Used by indexer)

3->3->0

feeGrowthInside0CurrentX128[3]

Int(256),x128

Fee counter inside position range for jetton0, per unit of liquidity, in 128.128 fixed point

3->3->0

feeGrowthInside1CurrentX128[3]

Int(256),x128

Fee counter inside position range for jetton1, per unit of liquidity, in 128.128 fixed point

3->3

liquidity2Burn[3]

Uint(128)

TL-B Description (TBD)

This is a preliminary tl-b - subject to change

Tlb for ROUTER_PAY_TO
ROUTER_PAY_TO#a1daa96d 
    query_id:uint64
    reciever0:MsgAddress
    reciever1:MsgAddress
    exit_code0:uint8
    exit_code1:uint8
    exit_code2:uint8
    exit_code3:uint8
    seqno:uint64
    coinsinfo_cell:(Maybe ^[
        jetton0_address:MsgAddress
        jetton1_address:MsgAddress
        amount0:(VarUInteger 16)
        amount1:(VarUInteger 16)
        indexer_swap_info_cell:^[
            payload_amount0:(VarUInteger 16)
            payload_0:(Maybe ^Cell)
            payload_amount1:(VarUInteger 16)
            payload_1:(Maybe ^Cell)
        ]  
    ]  
    (exit_code0 = 200)?(
        indexer_swap_info_cell:(Maybe ^[
            liquidity:uint128
            price_sqrt:uint160
            tick:int24
            feeGrowthGlobal0X128:int256
            feeGrowthGlobal1X128:int256
        ] ) 
    )
    (exit_code0 != 200)?(
        indexer_info_cell:(Maybe ^[
        ] ) 
        positions_cell:(Maybe ^[
            burn0:(Maybe ^[
                index[0]:uint64
                subindex[0]:uint4
                liquidity[0]:uint128
                tickLower[0]:int24
                tickUpper[0]:int24
                feeGrowthInside0LastX128[0]:int256
                feeGrowthInside1LastX128[0]:int256
                new_fee_cell:(Maybe ^[
                    feeGrowthInside0CurrentX128[0]:int256
                    feeGrowthInside1CurrentX128[0]:int256
                ] ) 
                liquidity2Burn[0]:uint128
            ] ) 
            burn1:(Maybe ^[
                index[1]:uint64
                subindex[1]:uint4
                liquidity[1]:uint128
                tickLower[1]:int24
                tickUpper[1]:int24
                feeGrowthInside0LastX128[1]:int256
                feeGrowthInside1LastX128[1]:int256
                new_fee_cell:(Maybe ^[
                    feeGrowthInside0CurrentX128[1]:int256
                    feeGrowthInside1CurrentX128[1]:int256
                ] ) 
                liquidity2Burn[1]:uint128
            ] ) 
            burn2:(Maybe ^[
                index[2]:uint64
                subindex[2]:uint4
                liquidity[2]:uint128
                tickLower[2]:int24
                tickUpper[2]:int24
                feeGrowthInside0LastX128[2]:int256
                feeGrowthInside1LastX128[2]:int256
                new_fee_cell:(Maybe ^[
                    feeGrowthInside0CurrentX128[2]:int256
                    feeGrowthInside1CurrentX128[2]:int256
                ] ) 
                liquidity2Burn[2]:uint128
            ] ) 
            burn3:(Maybe ^[
                index[3]:uint64
                subindex[3]:uint4
                liquidity[3]:uint128
                tickLower[3]:int24
                tickUpper[3]:int24
                feeGrowthInside0LastX128[3]:int256
                feeGrowthInside1LastX128[3]:int256
                new_fee_cell:(Maybe ^[
                    feeGrowthInside0CurrentX128[3]:int256
                    feeGrowthInside1CurrentX128[3]:int256
                ] ) 
                liquidity2Burn[3]:uint128
            ] ) 
        ] ) 
    )
= ContractMessages;

ROUTERV3_RESET_GAS

Opcode : 0x42a0fb43

This operation allows router owners the gas if too much accumulated on the contract Access Rights: This operation is allowed for router::admin_address

Path
Mnemonic
Type
Description

op

Uint(32),op

query_id

Uint(64)

queryid as of the TON documentation

TL-B Description (TBD)

This is a preliminary tl-b - subject to change

Tlb for ROUTERV3_RESET_GAS
ROUTERV3_RESET_GAS#42a0fb43 
    query_id:uint64
= ContractMessages;

Last updated