Pool
This section contains api reference of the pool contract
Off-chain get methods
get_pool_data
get_pool_data
Returns the current state of the Pool
Arguments
None
Result (common)
Returns PoolData
structure containing current state of the pool. Typed pools may return additional arguments if present
PoolData
structure
Key | Type | Index | Description |
---|---|---|---|
|
| 0 | true if |
|
| 1 | Address of the |
|
| 2 | Total supply of lp tokens |
|
| 3 | Amount of the first token (in basic token units) |
|
| 4 | Amount of the second token (in basic token units) |
|
| 5 | Address of the first Jetton token |
|
| 6 | Address of the second Jetton token |
|
| 7 | Liquidity pool fee value |
|
| 8 | Protocol fee |
|
| 9 | Address for receiving protocol fees |
|
| 10 | Amount of collected protocol fees of the first token (in basic token units) |
|
| 11 | Amount of collected protocol fees of the second token (in basic token units) |
Notes:
fee ratio is the value of fee divided by
params::fee_divider
(10000); so a fee of 1% has a value of 100
get_lp_account_address
get_lp_account_address
Get the lp account address of a user
Arguments
Key | Type | Description |
---|---|---|
|
| Address of a user |
Result
Function getLpAccountAddress
returns the lp account address of a user
get_jetton_data
get_jetton_data
Standard jetton 'get' methods from TonWeb JettonMinter.
Arguments
None
Result
Returns a structure with Jetton data
JettonData
structure
Key | Type | Index | Description |
---|---|---|---|
|
| 0 | Total token supply of lp tokens (in basic token units) |
|
| 1 | always |
|
| 2 |
|
|
| 3 | Offchain uri with Jetton data |
|
| 4 | Code of the lp Jetton wallet |
get_wallet_address
get_wallet_address
Get lp wallet address of a user.
Arguments
Name | Type | Description |
---|---|---|
|
| Address of a user |
Result
Function getJettonWalletAddress
returns a calculated lp wallet address of a user
On-chain queries
On-chain counterparts of getter methods.
Operations table
Name | Value | Description |
---|---|---|
| 0x43c034e6 | Sends a message with the current state of the pool |
| 0x9163a98a | Sends a message with the lp account address of a user |
| 0x2c76b973 | Sends a message with the lp wallet address of a user |
getter_pool_data
(0x43c034e6)
getter_pool_data
(0x43c034e6)Sends a message with the current state of the pool. On-chain equivalent of get_pool_data
.
TL-B
Message body
None
Outgoing messages
Sends a message with current pool data to the sender_address
Response message body
Name | Type | Description |
---|---|---|
|
| Operation code is equal to |
|
| Query id |
|
| If this |
|
| Amount of the first token (in basic token units) |
|
| Amount of the second token (in basic token units) |
|
| Address of the first Jetton token |
|
| Address of the second Jetton token |
|
| Cell with additional data |
additional_data
body
additional_data
bodyName | Type | Description |
---|---|---|
|
| Liquidity pool fee value |
|
| Protocol fee |
|
| Address of the |
|
| Address for receiving protocol fees |
|
| Total amount of minted lp tokens |
|
| Amount of collected protocol fees of the first token (in basic token units) |
|
| Amount of collected protocol fees of the second token (in basic token units) |
getter_lp_account_address
(0x9163a98a)
getter_lp_account_address
(0x9163a98a)Sends a message with the lp account address of a user. On-chain equivalent of get_lp_account_address
.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| Address of a user |
Outgoing messages
Sends a message with the lp account address of a user to sender_address
Response message body
Name | Type | Description |
---|---|---|
|
| Operation code is equal to |
|
| Query id |
|
| lp account address of a user |
provide_wallet_address
(0x2c76b973)
provide_wallet_address
(0x2c76b973)Sends a message with the lp wallet address of a user. On-chain equivalent of get_wallet_address
.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| Address of a user |
|
| Include user address in the response message |
Outgoing messages
Sends a message back to sender with the calculated lp wallet address of a user
Response message body
Name | Type | Description |
---|---|---|
|
| Operation code is equal to |
|
| Query id |
|
| Calculated lp wallet address |
|
| Cell with data if |
additional_data
body
additional_data
bodyName | Type | Description |
---|---|---|
|
| Address of a user |
Jetton handlers
Handles operations sent from a Jetton wallet.
Operations table
Name | Value | Description |
---|---|---|
| 0x302e7dda | Sent by LP wallet after burning LP jettons to release liquidity |
burn_notification_ext
(0x302e7dda)
burn_notification_ext
(0x302e7dda)Sent by LpWallet
after burning LP jettons to release liquidity.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| Amount of liquidity tokens to burn (in basic token units) |
|
| User address |
|
| Address for a response message |
|
| Payloads for token0 and token1 |
custom_payloads
Name | Type | Description |
---|---|---|
|
| Payload used for |
|
| Payload used for |
Outgoing messages
Sends a message with op excesses
(0xd53276db) to response_address
Sends a message with a released amount of both tokens to be received by a user as a result of the burn operation to the router, which initiates pay_to
operation to from_address
Router internal message handlers
Handles messages from the router.
Operations table
Name | Value | Description |
---|---|---|
| 0x25938561 | Swap tokens |
| 0xfcf9e58f | Provide liquidity |
| 0x42a0fb43 | Reset gas |
| 0x355423e5 | Set new fee parameters |
swap
(0x25938561)
swap
(0x25938561)Swap tokens. This message is received from the router when the user initiates a token swap.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| User address |
|
| Amount of incoming first token |
|
| Amount of incoming second token |
|
| Cell with dex payload |
payload
body
payload
bodyName | Type | Description |
---|---|---|
|
| Swap op |
|
| Address of the other |
|
| Address where refund will be sent if swap fails |
|
| Address where TON excesses will be sent |
|
| Cell with additional data |
additional_data
body
additional_data
bodyName | Type | Description |
---|---|---|
|
| Minimum required amount of tokens to receive |
|
| Address where tokens will be sent after swap |
|
| Gas used to forward a message in |
|
| Payload sent in |
|
| Gas used to forward a message in |
|
| Payload sent in |
|
| Referral fee |
|
| Referral address |
Notes:
swap will fail if a user should receive less than
min_out
of tokens as a resultmax allowed value of
ref_fee
is 100 (1%)
Outgoing messages
Sends a message with an amount of the other tokens to be received by a user as a result of the swap to the router, which initiates pay_to
operation
Additionally may send a message with referral fees to the router, which initiates pay_vault
operation to Vault
of referral_address
provide_lp
(0xfcf9e58f)
provide_lp
(0xfcf9e58f)Provide liquidity for the pool. A user must submit an amount of both tokens to receive lp tokens and add new liquidity to a pool. This message is routed to liquidity pool account with add_liquidity
operation code.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| User address |
|
| Amount of incoming first token |
|
| Amount of incoming second token |
|
| Cell with dex payload |
payload
body
payload
bodyName | Type | Description |
---|---|---|
|
| Provide lp op |
|
| Address of the other |
|
| Address where refund will be sent if swap fails |
|
| Address where TON excesses will be sent |
|
| Cell with additional data |
additional_data
body
additional_data
bodyName | Type | Description |
---|---|---|
|
| Minimum required amount of lp tokens to receive |
|
| Address where lp tokens will be sent |
|
| Trigger liquidity deposit only if both token amounts are non-zero |
|
| Gas used to forward a message in |
|
| Payload sent in |
Outgoing messages
Sends a message to liquidity pool account with add_liquidity
operation code.
reset_gas
(0x42a0fb43)
reset_gas
(0x42a0fb43)Updates the amount of TON (in nanoTons) on the pool to storage_fee::pool
(10000000) of the pool. The remaining amount of TON will be sent to excesses_address
.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| Address where excess ton will be sent |
Outgoing messages
Sends a message to excesses_address
with the remaining TON
set_fees
(0x355423e5)
set_fees
(0x355423e5)Set new fee values including liquidity pool fees, protocol fees and referral fees as well as an address for receiving collected protocol fees.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| New liquidity pool fee ratio (multiplied by |
|
| New protocol fee ratio (multiplied by |
|
| Address for receiving protocol fees |
|
| Address where TON excesses will be sent |
Notes:
fee ratio is the value of fee divided by
params::fee_divider
(10000); so to set a fee to 1% the value must be 100fees must be between
params::min_fee
(0) andparams::max_fee
(100)
Outgoing messages
Sends a message to excesses_address
with the remaining TON
Protocol address internal message handlers
Handles messages from the protocol_fee_address
.
Operations table
Name | Value | Description |
---|---|---|
| 0x1fcb7d3d | Collect fees |
collect_fees
(0x1fcb7d3d)
collect_fees
(0x1fcb7d3d)Collect protocol fees. The amount of fees in both tokens will be sent to protocol_fee_address
address.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| Payload used for |
|
| Payload used for |
Outgoing messages
Sends a message with collected fees in both tokens to the router, which initiates pay_to
operation to protocol_fee_address
.
LP Account internal message handlers
Handles messages from an lp account.
Operations table
Name | Value | Description |
---|---|---|
| 0x56dfeb8a | Sent by user's lp_account after adding liquidity |
| 0x89446a42 | Sent by user's lp_account after adding liquidity |
cb_add_liquidity
(0x56dfeb8a)
cb_add_liquidity
(0x56dfeb8a)Add new liquidity to the pool. Sent by user's lp account after both or one amounts tokens is sent by a user. The resulting added liquidity must be greater than min_lp_out
for the operation to be successful.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| Amount of the first Jetton tokens added (in basic token units) |
|
| Amount of the second Jetton tokens added (in basic token units) |
|
| Owner's address |
|
| Minimum amount of received liquidity tokens (in basic token units) |
|
| Forward amount used to send |
|
| Payload sent in |
|
| See table below |
additional_data
Name | Type | Description |
---|---|---|
|
| Owner of new liquidity tokens |
|
| Address of the owner of |
|
| Address where all TON excesses will be sent |
Notes:
addition of liquidity will fail if a user should receive less than
min_lp_out
of lp tokens as a resultcannot add liquidity if a supply of either tokens becomes greater than
MAX_COINS
(2^120 - 1)
Outgoing messages
Sends a message with internal_transfer
(0x178d4519) op code to the lp wallet of to_address
with minted liquidity tokens
cb_refund_me
(0x89446a42)
cb_refund_me
(0x89446a42)Sent by user's lp account after a user initiates refund_me
operation to cancel addition of new liquidity. The amount of previously stored tokens will be sent back to the user.
TL-B
Message body
Name | Type | Description |
---|---|---|
|
| Amount of the first Jetton tokens (in basic token units) |
|
| Amount of the second Jetton tokens (in basic token units) |
|
| Owner's address |
|
| Payload used for |
|
| Payload used for |
Outgoing messages
Sends a message with amount0
of the first token and amount1
of the second token to the router, which initiates pay_to
operation
Constants
Name | Value | Description |
---|---|---|
| 10000000 | Amount of TON (in nanoTons) to be left on the pool contract as gas |
| 1001 | Minimum amount of liquidity required |
| 2^120 - 1 | Maximum amount of tokens (in basic token units) stored as liquidity |
| 20000000 | Additional gas (in nanoTons) for providing a wallet |
| 10000 | Fee values are divided by this value |
| 0 | Minimum fee allowed (0%) |
| 100 | Maximum fee allowed (1%) |
Last updated