Router
This section contains api reference of the router contract
Last updated
This section contains api reference of the router contract
Last updated
get_vault_address
Returns an address of a vault for a specified asset and user.
Key | Type | Index | Description |
---|---|---|---|
Returns VaultV2
object for Vault
's' address.
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 Pool
address.
get_router_data
Returns the current state of the Router
None
Returns RouterData
structure containing current state of the Router
.
RouterData
structure
Notes:
possible dex_type
values:
constant_product
stableswap
get_router_version
Returns the current Router
version
None
Returns VersionData
structure containing Router
version.
RouterData
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.
payload
bodyNotes:
payload
contains other fields depending on which op code is called
swap
(0x6664de2a)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.
Check examples for in-depth message flow.
payload
bodyadditional_data
bodyNotes:
swap will fail if a user should receive less than min_out
of tokens as a result
max allowed value of ref_fee
is 100 (1%)
Sends a message with op swap
to Pool
provide_lp
(0x37c096df)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.
Check examples for in-depth message flow.
payload
bodyadditional_data
bodySends a message with op provide_lp
to a liquidity pool
On-chain counterparts of getter methods
getter_pool_address
(0x2993ade0)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.
set_fees
(0x58274069)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.
additional_data
bodyNotes:
fee ratio is the value of fee divided by params::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.
update_status
(0x38a6022f)Changes Router
is_locked
var to the opposite value. If is_locked == 1
blocks transfer_notification
messages from going through. Effectively blocks swap
and provide_lp
transactions through this Router
.
None.
None.
init_code_upgrade
(0x03601fc8)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.
Excesses will be sent to admin_address
init_admin_upgrade
(0x0b02fd5b)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.
Excesses will be sent to admin_address
cancel_admin_upgrade
(0x72d6b3b4)Cancels an admin change if there's a pending admin change.
None
Excesses will be sent to admin_address
cancel_code_upgrade
(0x1f72111a)Cancels a code upgrade if there's a pending code change.
None
Excesses will be sent to admin_address
finalize_upgrades
(0x4e6707b7)Finalizes upgrades of the Router
code and admin changes. 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
(0x29d22935)Updates the amount of TON (in nanoTons) on the Router
to storage_fee::router
(100000) of the Router
. The remaining TON will be sent to the Router
admin.
None
Excesses will be sent to admin_address
reset_pool_gas
(0x66d0dff2)Updates the amount of TON (in nanoTons) on a pool to storage_fee::router
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
update_pool_status
(0x2af4607c)Changes Pool
is_locked
var to the opposite value. If is_locked == 1
blocks swaps and liquidity withdraws from this Pool
Excesses will be sent to excesses_address
pay_to
(0x657b54f5)Initiates a Jetton token transfer from wallets belonging to this Router
, called from pools (on swap, liquidity providing, refund, etc).
additional_data
bodySends transfer of amount0_out
tokens to owner
message to token0_address
wallet if amount0_out
> 0
or
Sends transfer of amount1_out
tokens to owner
message to token1_address
wallet if amount1_out
> 0
or
Sends swap
to some Pool
if custom_payload
is cross_swap
pay_vault
(0x63381632)Deposit a token amount into a Vault
contract; used if swap
was done with referral
additional_data
bodySends deposit_ref_fee
to a corresponding token Vault
of to_address
vault_pay_to
(0x2100c922)Initiates a Jetton token transfer from wallets belonging to this Router
, called from a Vault
when an owner withdraws their collected referral fees.
Sends transfer of amount_out
tokens to to_address
message to token_address
wallet
Use a normal swap payload as custom_payload
in the initial swap with the other Router
address as the receiver_address
. The value of fwd_gas
must be non-zero and enough to perform the next swap.
This payload allows chaining of swap operations on the same Router
; fwd_gas
is ignored.
custom_payload
bodyadditional_data
bodyKey | Type | Index | Description |
---|---|---|---|
Key | Type | Index | Description |
---|---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | 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 | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|