Pool
This section contains api reference of the pool contract
Last updated
This section contains api reference of the pool contract
Last updated
get_pool_data
Returns the current state of the Pool
None
Returns PoolData
structure containing current state of the pool. Typed pools may return additional arguments if present
PoolData
structure
Key | Type | Index | Description |
---|---|---|---|
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 the lp account address of a user
Function getLpAccountAddress
returns the lp account address of a user
get_jetton_data
Standard jetton 'get' methods from TonWeb JettonMinter.
None
Returns a structure with Jetton data
JettonData
structure
get_wallet_address
Get lp wallet address of a user.
Function getJettonWalletAddress
returns a calculated lp wallet address of a user
On-chain counterparts of getter methods.
getter_pool_data
(0x26df39fc)Sends a message with the current state of the pool. On-chain equivalent of get_pool_data
.
None
Sends a message with current pool data to the sender_address
additional_data
bodygetter_lp_account_address
(0x15fbca95)Sends a message with the lp account address of a user. On-chain equivalent of get_lp_account_address
.
Sends a message with the lp account address of a user to sender_address
provide_wallet_address
(0x2c76b973)Sends a message with the lp wallet address of a user. On-chain equivalent of get_wallet_address
.
Sends a message back to sender with the calculated lp wallet address of a user
additional_data
bodyHandles operations sent from a Jetton wallet.
burn_notification_ext
(0x297437cf)Sent by LpWallet
after burning LP jettons to release liquidity.
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
Handles messages from the router.
swap
(0x6664de2a)Swap tokens. This message is received from the router when the user initiates a token swap.
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 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
(0x37c096df)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.
payload
bodyadditional_data
bodySends a message to liquidity pool account with add_liquidity
operation code.
reset_gas
(0x29d22935)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
.
Sends a message to excesses_address
with the remaining TON
internal_set_fees
(0x75930d63)Set new fee values including liquidity pool fees, protocol fees and referral fees as well as an address for receiving collected protocol fees.
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 100
fees must be between params::min_fee
(0) and params::max_fee
(100)
Sends a message to excesses_address
with the remaining TON
Handles messages from the protocol_fee_address
.
collect_fees
(0x1ee4911e)Collect protocol fees. The amount of fees in both tokens will be sent to protocol_fee_address
address.
Sends a message with collected fees in both tokens to the router, which initiates pay_to
operation to protocol_fee_address
.
Handles messages from an lp account.
cb_add_liquidity
(0x06ecd527)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.
Notes:
addition of liquidity will fail if a user should receive less than min_lp_out
of lp tokens as a result
cannot add liquidity if a supply of either tokens becomes greater than MAX_COINS
(2^120 - 1)
Sends a message with internal_transfer
(0x178d4519) op code to the lp wallet of to_address
with minted liquidity tokens
cb_refund_me
(0x0f98e2b8)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.
Sends a message with amount0
of the first token and amount1
of the second token to the router, which initiates pay_to
operation
Key | Type | Description |
---|---|---|
Key | Type | Index | 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 | 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 |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Type | Description |
---|---|---|
Name | Value | Description |
---|---|---|
is_locked
bool
0
true if transfer_notification
operations are locked (swap
, provide_lp
)
router_address
address
1
Address of the Router
total_supply
coins
2
Total supply of lp tokens
reserve0
coins
3
Amount of the first token (in basic token units)
reserve1
coins
4
Amount of the second token (in basic token units)
token0_wallet_address
address
5
Address of the first Jetton token
token1_wallet_address
address
6
Address of the second Jetton token
lp_fee
uint16
7
Liquidity pool fee value
protocol_fee
uint16
8
Protocol fee
protocol_fee_address
address
9
Address for receiving protocol fees
collected_token0_protocol_fee
coins
10
Amount of collected protocol fees of the first token (in basic token units)
collected_token1_protocol_fee
coins
11
Amount of collected protocol fees of the second token (in basic token units)
owner_address
AddressType
Address of a user
total_supply
coins
0
Total token supply of lp tokens (in basic token units)
mintable
bool
1
always true
admin_address
address
2
Router
address
jetton_content_uri
string
3
Offchain uri with Jetton data
jetton_wallet_code
cell
4
Code of the lp Jetton wallet
owner_address
AddressType
Address of a user
getter_pool_data
0x26df39fc
Sends a message with the current state of the pool
getter_lp_account_address
0x15fbca95
Sends a message with the lp account address of a user
provide_wallet_address
0x2c76b973
Sends a message with the lp wallet address of a user
op
uint32
Operation code is equal to getter_pool_data
query_id
uint64
Query id
is_locked
uint1
If this Pool
is locked
reserve0
coins
Amount of the first token (in basic token units)
reserve1
coins
Amount of the second token (in basic token units)
token0_address
address
Address of the first Jetton token
token1_address
address
Address of the second Jetton token
additional_data
cell
Cell with additional data
lp_fee
uint16
Liquidity pool fee value
protocol_fee
uint16
Protocol fee
router_address
address
Address of the Router
protocol_fee_address
address
Address for receiving protocol fees
total_supply
coins
Total amount of minted lp tokens
collected_token0_protocol_fee
coins
Amount of collected protocol fees of the first token (in basic token units)
collected_token1_protocol_fee
coins
Amount of collected protocol fees of the second token (in basic token units)
user_address
address
Address of a user
op
uint32
Operation code is equal to getter_expected_outputs
query_id
uint64
Query id
lp_account_address
address
lp account address of a user
owner_address
address
Address of a user
include_address?
uint1
Include user address in the response message
op
uint32
Operation code is equal to take_wallet_address
(0xd1735400)
query_id
uint64
Query id
lp_wallet_address
address
Calculated lp wallet address
additional_data
maybe_ref
Cell with data if include_address?
evaluates to true
included_address
address
Address of a user
burn_notification_ext
0x297437cf
Sent by LP wallet after burning LP jettons to release liquidity
jetton_amount
coins
Amount of liquidity tokens to burn (in basic token units)
from_address
address
User address
response_address
address
Address for a response message
custom_payloads
maybe_ref
Payloads for token0 and token1
payload_1
maybe_ref
Payload used for amount0
; can be cross_swap
payload_2
maybe_ref
Payload used for amount1
; can be cross_swap
swap
0x6664de2a
Swap tokens
provide_lp
0x37c096df
Provide liquidity
reset_gas
0x29d22935
Reset gas
set_fees
0x58274069
Set new fee parameters
from_user
address
User address
amount0
coins
Amount of incoming first token
amount1
coins
Amount of incoming second token
payload
cell
Cell with dex payload
op
uint32
Swap op
other_token_wallet
address
Address of the other Router
token wallet
refund_address
address
Address where refund will be sent if swap fails
excesses_address
address
Address where TON excesses will be sent
additional_data
cell
Cell with additional data
min_out
coins
Minimum required amount of tokens to receive
receiver_address
address
Address where tokens will be sent after swap
fwd_gas
coins
Gas used to forward a message in transfer_notification
after swap if custom_payload
is present
custom_payload
maybe_ref
Payload sent in transfer_notification
after swap
refund_fwd_gas
coins
Gas used to forward a message in transfer_notification
if swap fails if refund_payload
is present
refund_payload
maybe_ref
Payload sent in transfer_notification
if swap fails
ref_fee
uint16
Referral fee
referral_address
address
Referral address
from_user
address
User address
amount0
coins
Amount of incoming first token
amount1
coins
Amount of incoming second token
payload
cell
Cell with dex payload
op
uint32
Provide lp op
other_token_wallet
address
Address of the other Router
token wallet
refund_address
address
Address where refund will be sent if swap fails
excesses_address
address
Address where TON excesses will be sent
additional_data
cell
Cell with additional data
min_lp_out
coins
Minimum required amount of lp tokens to receive
receiver_address
address
Address where lp tokens will be sent
both_positive
uint1
Trigger liquidity deposit only if both token amounts are non-zero
fwd_gas
coins
Gas used to forward a message in transfer_notification
after mint if custom_payload
is present
custom_payload
maybe_ref
Payload sent in transfer_notification
after lp mint
excesses_address
address
Address where excess ton will be sent
new_lp_fee
uint16
New liquidity pool fee ratio (multiplied by params::fee_divider
)
new_protocol_fee
uint16
New protocol fee ratio (multiplied by params::fee_divider
)
new_protocol_fee_address
address
Address for receiving protocol fees
excesses_address
address
Address where TON excesses will be sent
collect_fees
0x1ee4911e
Collect fees
payload_0
maybe_ref
Payload used for amount0
; can be cross_swap
payload_1
maybe_ref
Payload used for amount1
; can be cross_swap
cb_add_liquidity
0x06ecd527
Sent by user's lp_account after adding liquidity
cb_refund_me
0x0f98e2b8
Sent by user's lp_account after adding liquidity
amount0
coins
Amount of the first Jetton tokens added (in basic token units)
amount1
coins
Amount of the second Jetton tokens added (in basic token units)
user_address
address
Owner's address
min_lp_out
coins
Minimum amount of received liquidity tokens (in basic token units)
fwd_amount
coins
Forward amount used to send custom_payload
(if present) in transfer_notification
custom_payload
maybe_ref
Payload sent in transfer_notification
upon receiving tokens
additional_data
ref
See table below
to_address
address
Owner of new liquidity tokens
refund_address
address
Address of the owner of LpAccount
where tokens will be refunded if liquidity mint wasn't successful
excess_address
address
Address where all TON excesses will be sent
amount0
coins
Amount of the first Jetton tokens (in basic token units)
amount1
coins
Amount of the second Jetton tokens (in basic token units)
user_address
address
Owner's address
payload_0
maybe_ref
Payload used for amount0
; can be cross_swap
payload_1
maybe_ref
Payload used for amount1
; can be cross_swap
storage_fee::pool
10000000
Amount of TON (in nanoTons) to be left on the pool contract as gas
params::required_min_liquidity
1001
Minimum amount of liquidity required
MAX_COINS
2^120 - 1
Maximum amount of tokens (in basic token units) stored as liquidity
gas::pool::provide_wallet_address
20000000
Additional gas (in nanoTons) for providing a wallet
params::fee_divider
10000
Fee values are divided by this value
params::min_fee
0
Minimum fee allowed (0%)
params::max_fee
100
Maximum fee allowed (1%)