Router
This section contains api reference of the router contract
Last updated
This section contains api reference of the router contract
Last updated
get_pool_address
Returns an address of a pool for a specified pair of assets.
It's necessary to specify addresses of Jetton wallets of the router as the arguments of this method. These addresses can be retrieved with get_wallet_address
of the Jetton minter.
Key | Type | Index | Description |
---|---|---|---|
Returns single slice with the address of liquidity pool for specified pair of Jettons.
get_router_data
Returns the current state of the router: is the router locked, admin address, pending code or admin upgrades, pool contract code, lp wallet code, lp account code.
None
Returns current state of the Router
Result structure
transfer_notification
(0x7362d09c)Messages received from Jetton wallets belonging to the router upon getting a token transfer from a user. The user must include a custom payload with additional op code (either swap
or provide_lp
) and appropriate data in order for those messages to be processed correctly.
ref_msg_data
bodyNotes:
ref_msg_data
contains other fields depending on which op code is called
swap
(0x25938561)Swap tokens. This message is received when the Router's Jetton token wallet sends a message upon confirmation of token transfer from a user with a custom payload. The router then sends a swap
message to the appropriate pool contract address.
ref_msg_data
bodySends a message with op swap
to a liquidity pool
provide_lp
(0xfcf9e58f)Provide liquidity for a pool. This message is received when Router's token wallet sends a message upon confirmation of token transfer from a user with a custom payload. The router then sends a provide_lp
message to the appropriate pool contract address.
ref_msg_data
bodySends a message with op provide_lp
to a liquidity pool
On-chain counterparts of getter methods
getter_pool_address
(0xd1db969b)Sends a message with an address of a pool for a specified pair of assets; counterpart to get_pool_address
Sends a message back to the sender with the pool address
Handles governance message from admin to change pool parameters.
The admin can lock/unlock trading on all pools, change fees on a certain pool, upgrade the router code, etc.
Notes:
REQUIRED_TON_RESERVE
for the router is 100000
set_fees
(0x355423e5)Change fees of a pool including liquidity pool fees, protocol fees and referral fees. It's necessary to provide correct Jetton token addresses for a target liquidity pool.
ref_wallets
bodyNotes:
fee ratio is the value of fee divided by FEE_DIVIDER
(10000); so to set a fee to 1% the value must be 100
fees must be between MIN_FEE
(0) and MAX_FEE
(100)
Sends a message with op set_fees
to a liquidity pool.
collect_fees
(0x1fcb7d3d)Collect protocol fees from a pool. The appropriate Jetton wallet addresses must be provided.
Sends a message to a liquidity pool with collect_fees
op code.
lock
(0x878f9b0e)Stops all transfer_notification
messages from going through. Effectively blocks swap
and provide_lp
transactions through this router.
None.
None.
unlock
(0x6ae4b0ef)Allows all transfer_notification
messages to go through. Enables swap
and provide_lp
transactions through this router.
None
None.
init_code_upgrade
(0xdf1e233d)Initiates code upgrade for the router. An appropriate data with the new router code must be provided. The changes won't take effect until finalize_upgrades
is received by the router. The minimum delay between initiating code upgrade and finalizing the changes in seven days.
None
init_admin_upgrade
(0x2fb94384)Initiates admin change for the router. An appropriate address for a new router admin must be provided. The changes won't take effect until finalize_upgrades
is received by the router. The minimum delay between initiating admin change and finalizing the changes in two days.
None
cancel_admin_upgrade
(0xa4ed9981)Cancels an admin change if there's a pending admin change.
None
None
cancel_code_upgrade
(0x357ccc67)Cancels a code upgrade if there's a pending code change.
None
None
finalize_upgrades
(0x6378509f)Finalizes upgrades of the router code and admin change. In order for the changes to take effect an appropriate amount of time must pass since initializing and upgrade. For code upgrade the delay is seven days, for an admin change the delay is two days.
None
None
reset_gas
(0x42a0fb43)Updates the amount of $TON (in nanoTons) on the router to REQUIRED_TON_RESERVE
(100000) of the router. The remaining $TON will be sent to the router admin.
None
Sends an empty message back to admin with the remaining $TON
reset_pool_gas
(0xf6aa9737)Updates the amount of $TON (in nanoTons) on a pool to REQUIRED_TON_RESERVE
of a pool. Forwards this message to a pool contract for provided pair of Jetton tokens.
Sends a message to a liquidity pool with reset_gas
op code carrying remaining gas
pay_to
(0xf93bb43f)Initiates a Jetton token transfer from wallets belonging to this router, called from pools (on swap, liquidity providing, refund, etc).
ref_coins_data
bodySends transfer of amount0_out
tokens to owner
message to token0_address
wallet if amount0_out
> 0
Sends transfer of amount1_out
tokens to owner
message to token1_address
wallet if amount1_out
> 0
Key | Type | Index | Description |
---|---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|