Comment on page
LpAccount
This section contains op codes of the lp account contract as well as corresponding SDK methods
Returns current state of the lp account: owner address, pool address and amount of both Jetton tokens.
FunC
TypeScript
(slice, slice, int, int) get_lp_account_data() method_id;
async getData(): Promise<LpAccountData>
None
Returns
LpAccountData
structure containing current state of the lp account.LpAccountData
structureKey | Type | Index | Description |
---|---|---|---|
userAddress | Address | 0 | Owner's address |
poolAddress | Address | 1 | Pool's address |
amount0 | BN | 2 | Balance of the first Jetton token (in basic token units) |
amount1 | BN | 3 | Balance of the second Jetton token (in basic token units) |
On-chain counterparts of getter methods.
Name | Value | Description |
---|---|---|
getter_lp_account_data | 0x1d439ae0 | Sends a message with the current state of the pool |
Sends a message with current state of the lp account. On-chain equivalent of
get_lp_account_data
.getter_lp_account_data#1d439ae0 query_id:uint64 = InternalMsgBody;
None
Sends a message with current state of the lp account to
sender_address
Name | Type | Description |
---|---|---|
op | uint32 | Operation code equal to getter_lp_account_data |
query_id | uint64 | Query id |
storage::user_address | address | Owner's address |
storage::pool_address | address | Pool's address |
storage::amount0 | coins | Balance of the first Jetton token (in basic token units) |
storage::amount1 | coins | Balance of the second Jetton token (in basic token units) |
Handles incoming messages from a pool
Name | Value | Description |
---|---|---|
add_liquidity | 0x3ebe5431 | Add liquidity |
Stores the sent amount of tokens by the user to be added as new liquidity. Upon receiving an appropriate amount of both tokens sends a message with those amounts to a pool to be added as new liquidity. The automatic liquidity addition happens only if the amount of both tokens if greater than 1000 and non-zero
min_lp_out
was specified, otherwise the user can keep increasing the amount of stored tokens.add_liquidity#3ebe5431 query_id:uint64 new_amount0:Grams new_amount1:Grams min_lp_out:Grams = InternalMsgBody;
Name | Type | Description |
---|---|---|
new_amount0 | coins | Amount of the first Jetton tokens added (in basic token units) |
new_amount1 | coins | Amount of the second Jetton tokens added (in basic token units) |
min_lp_out | coins | Minimum required amount of received new liquidity tokens (in basic token units) |
Notes:
- addition of liquidity will fail if a user should receive less than
min_lp_out
of lp tokens as a result
Sends a message to the pool with
cb_add_liquidity
opName | Type | Description |
---|---|---|
op | uint32 | Operation code, equal to cb_add_liquidity |
query_id | uint64 | Query id |
storage::amount0 | coins | Amount of the first Jetton tokens added (in basic token units) |
storage::amount1 | coins | Amount of the second Jetton tokens added (in basic token units) |
storage::user_address | address | Owner's address |
min_lp_out | coins | Minimum amount of received liquidity tokens (in basic token units) |
Notes:
- addition of liquidity will fail if a user should receive less than
min_lp_out
of lp tokens as a result
Handles incoming messages from a user
Name | Value | Description |
---|---|---|
refund_me | 0xbf3f447 | Return previously sent tokens back to the user |
direct_add_liquidity | 0x4cf82803 | Directly add liquidity with specified amount of tokens and a minimum amount of received liquidity tokens |
reset_gas | 0x42a0fb43 | Reset gas |
Initiates a refund of stored tokens by
add_liquidity
if the user decides to cancel the addition of new liquidity. The amount of stored tokens will be sent to the pool which will initiate a transfer back to the user.refund_me#bf3f447 query_id:uint64 = InternalMsgBody;
None
Sends a message with
cb_refund_me
op code and amount of stored tokens to a pool. The pool will send a message to refund those tokens back to the user.Name | Type | Description |
---|---|---|
op | uint32 | Operation code |
query_id | uint64 | Query id |
storage::amount0 | coins | Amount of the first Jetton tokens (in basic token units) |
storage::amount1 | coins | Amount of the second Jetton tokens (in basic token units) |
storage::user_address | address | Owner's address |
Build
refund_me
transaction.TypeScript
async buildRefundTxParams(params?: {
queryId?: QueryIdType;
}): Promise<MessageData>
Key | Type | Description |
---|---|---|
queryId | QueryIdType | undefined | Optional; query id |
Name | Type | Description |
---|---|---|
to | Address | Address of the lp account |
payload | Cell | Payload created by createRefundBody |
gasAmount | BN | Recommended amount of $TON (in nanoTons) sent as gas |
Notes:
param
is entirely optional- the default value for
gasAmount
is equal to 0.5 $TON
Create a payload to initiate a
refund_me
transaction; params
structure is the same a the tx builder.TypeScript
async createRefundBody(params: {
queryId?: QueryIdType
}): Promise<Cell>
Initiates an addition of new liquidity to a pool with a specified amount of both tokens and a minimum amount of received liquidity. The operation is successful only if there's an equal or greater amount of both tokens stored in the account (the amount of both tokens must be greater than 1000). This method is useful if an automatic liquidity addition has not been triggered upon deposition of tokens.
direct_add_liquidity#4cf82803 query_id:uint64 amount0:Grams amount1:Grams min_lp_out:Grams = InternalMsgBody;
Name | Type | Description |
---|---|---|
amount0 | coins | Amount of the first Jetton tokens (in basic token units) |
amount1 | coins | Amount of the second Jetton tokens (in basic token units) |
min_lp_out | coins | Minimum amount of received liquidity tokens (in basic token units) |
Notes:
- addition of liquidity will fail if a user should receive less than
min_lp_out
of lp tokens as a result min_lp_out
value must be greater than zero for this operation to proceed
Sends a message with
cb_add_liquidity
op code and amount of both tokens to be added as new liquidity.Name | Type | Description |
---|---|---|
op | uint32 | Operation code |
query_id | uint64 | Query id |
am0 | coins | Amount of the first Jetton tokens (in basic token units) |
am1 | coins | Amount of the second Jetton tokens (in basic token units) |
storage::user_address | address | Owner's address |
min_lp_out | coins | Minimum amount of received liquidity tokens (in basic token units) |
Notes:
- addition of liquidity will fail if a user should receive less than
min_lp_out
of lp tokens as a result
Build
direct_add_liquidity
transaction.TypeScript
async buildDirectAddLiquidityTxParams(params: {
amount0: AmountType;
amount1: AmountType;
minimumLpToMint?: AmountType;
queryId?: QueryIdType;
}): Promise<MessageData>
Key | Type | Description |
---|---|---|
amount0 | AmountType | Amount of the first Jetton tokens (in basic token units) |
amount1 | AmountType | Amount of the second Jetton tokens (in basic token units) |
minimumLpToMint | AmountType | undefined | Optional; minimum amount of received liquidity tokens (in basic token units) |
queryId | QueryIdType | undefined | Optional; query id |
Name | Type | Description |
---|---|---|
to | Address | Address of the lp account |
payload | Cell | Payload created by createDirectAddLiquidityBody |
gasAmount | BN | Recommended amount of $TON (in nanoTons) sent as gas |
Notes:
- addition of liquidity will fail if a user should receive less than
minimumLpToMint
of lp tokens as a result - the default value for
gasAmount
is equal to 0.3 $TON
Create a payload to initiate a
direct_add_liquidity
transaction; params
structure is the same a the tx builder.TypeScript
async createDirectAddLiquidityBody(params: {
amount0: AmountType;
amount1: AmountType;
minimumLpToMint?: AmountType;
queryId?: QueryIdType;
}): Promise<Cell>
Updates the amount of $TON (in nanoTons) on the lp account to
REQUIRED_TON_RESERVE
(10000000) of the account. The remaining $TON will be sent back to the storage::user_address
reset_gas#42a0fb43 query_id:uint64 = InternalMsgBody;
None
Sends an empty message back to the user with the remaining $TON
Build
reset_gas
transaction.TypeScript
async buildResetGasTxParams(params?: {
queryId?: QueryIdType;
}): Promise<MessageData>
Key | Type | Description |
---|---|---|
queryId | QueryIdType | undefined | Optional; query id |
Name | Type | Description |
---|---|---|
to | Address | Address of the lp account |
payload | Cell | Payload created by createResetGasBody |
gasAmount | BN | Recommended amount of $TON (in nanoTons) sent as gas |
Notes:
param
is entirely optional- the default value for
gasAmount
is equal to 0.3 $TON
Create a payload to initiate a
reset_gas
transaction; params
structure is the same a the tx builder.TypeScript
async createResetGasBody(params: {
queryId?: QueryIdType
}): Promise<Cell>
Name | Value | Description |
---|---|---|
WORKCHAIN | 0 | Workchain id |
REQUIRED_TON_RESERVE | 10000000 | Amount of $TON (in nanoTons) to be left on the lp account contract as gas |
Last modified 9mo ago