Pool
Operations
Operation provide_pool_state
Allows the retrieval of the pool's state in an on-chain manner.
When executed, the pool sends a take_pool_state message to the sender containing the requested details.
provide_pool_state#6e24728d query_id:uint64 include_assets:Bool = InMsgBody;
take_pool_state#bddd4954 query_id:uint64
reserve0:Coins reserve1:Coins total_supply:Coins
assets:(Maybe ^[ asset0:Asset asset1:Asset ]) = InMsgBody;
Operation configure_start_time
Sets the start_at parameter, defining the UNIX timestamp for the start of trading.
Swap attempts made before this timestamp will be rejected with the error code NOT_STARTED (exit code 306).
configure_start_time#7ed7f6ce query_id:uint64 start_at:Timestamp = InMsgBody;
Events
Event swap
swap#9c610de3 asset_in:Asset asset_out:Asset amount_in:Coins amount_out:Coins
^[ sender_addr:MsgAddressInt referral_addr:MsgAddress
reserve0:Coins reserve1:Coins ] = ExtOutMsgBody;
| Name | Type | Description |
|---|---|---|
asset_in | Asset | The asset provided by the user |
asset_out | Asset | The asset received by the user |
amount_in | Coins | Amount of asset_out received by the user |
amount_out | Coins | Amount of asset_out received by the user |
sender_addr | MsgAddressInt | Address of the contract that initiated the swap |
referral_addr | MsgAddress | referral_addr passed to SwapParams |
reserve0 | Coins | Amount of asset0 remaining in reserve after the swap |
reserve1 | Coins | Amount of asset1 remaining in reserve after the swap |
Event deposit
deposit#b544f4a4 sender_addr:MsgAddressInt amount0:Coins amount1:Coins
reserve0:Coins reserve1:Coins liquidity:Coins = ExtOutMsgBody;
| Name | Type | Description |
|---|---|---|
sender_addr | MsgAddressInt | Address of the contract that initiated the deposit |
amount0 | Coins | Amount of asset_out provided by the sender |
amount1 | Coins | Amount of asset_out provided by the sender |
reserve0 | Coins | Amount of asset0 remaining in reserve after the withdrawal |
reserve1 | Coins | Amount of asset1 remaining in reserve after the withdrawal |
liquidity | Coins | Amount of LP tokens issued for the sender |
Event withdrawal
withdrawal#3aa870a6 sender_addr:MsgAddressInt liquidity:Coins
amount0:Coins amount1:Coins
reserve0:Coins reserve1:Coins = ExtOutMsgBody;
| Name | Type | Description |
|---|---|---|
sender_addr | MsgAddressInt | Address of the contract that initiated the withdrawal |
liquidity | Coins | Amount of LP tokens burned by the sender |
amount0 | Coins | Amount of asset_out sent to the sender |
amount1 | Coins | Amount of asset_out sent to the sender |
reserve0 | Coins | Amount of asset0 remaining in reserve after the withdrawal |
reserve1 | Coins | Amount of asset1 remaining in reserve after the withdrawal |
Get-Methods
Method is_stable
Returns whether the pool operates as a stable-swap pool.
Returns
| Name | Type | Description |
|---|---|---|
is_stable | int (boolean) | Indicates if the pool is a stable-swap pool. |
Method get_assets
Returns the assets that constitute the pool.
Returns
| Name | Type | Description |
|---|---|---|
asset0 | slice (Asset) | The first asset in the pool. |
asset1 | slice (Asset) | The second asset in the pool. |
Each asset is represented as a slice and corresponds to an Asset structure.
Method get_trade_fee
Returns the trading fee details of the pool.
The trading fee is calculated as:
trade_fee = (trade_fee_numerator / trade_fee_denominator)
Returns
| Name | Type | Description |
|---|---|---|
trade_fee_numerator | int (uint16) | The numerator of the trading fee fraction. |
trade_fee_denominator | int (uint16) | The denominator of the trading fee fraction. |
Method get_reserves
Retrieves the current reserves of the assets in the pool.
Returns
| Name | Type | Description |
|---|---|---|
reserve0 | int (Coins) | The reserve amount of asset0. |
reserve1 | int (Coins) | The reserve amount of asset1. |
Method get_protocol_fees
Retrieves the amount of unclaimed protocol fees accrued from trading fees.
Returns
| Name | Type | Description |
|---|---|---|
protocol_fees0 | int (Coins) | The unclaimed protocol fees for asset0. |
protocol_fees1 | int (Coins) | The unclaimed protocol fees for asset1. |
Method get_decimals
Provides information about the decimal precision of the assets in the pool. This is applicable only to stable-swap
pools.
For volatile pools, the returned values are always 0.
Returns
| Name | Type | Description |
|---|---|---|
decimals0 | int (uint8) | The decimal precision of asset0. |
decimals1 | int (uint8) | The decimal precision of asset1. |
Method estimate_swap_out
Calculates the estimated output and associated fees for a given input amount during a swap.
Parameters
| Name | Type | Description |
|---|---|---|
asset_in | slice (Asset) | The asset being provided for the swap. |
amount_in | int (Coins) | The amount of asset_in being swapped. |
Returns
| Name | Type | Description |
|---|---|---|
asset_out | slice (Asset) | The asset being received from the swap. |
amount_out | int (Coins) | The estimated amount of asset_out to be received. |
trade_fee | int (Coins) | The fee deducted in terms of the asset_in provided. |
Method estimate_deposit_out
Estimates the output of assets and the corresponding LP tokens when depositing into the pool.
Parameters
| Name | Type | Description |
|---|---|---|
amount0 | int (Coins) | The amount of asset0 to be deposited. |
amount1 | int (Coins) | The amount of asset1 to be deposited. |
Returns
| Name | Type | Description |
|---|---|---|
amount0 | int (Coins) | The actual deposited amount of asset0. |
amount1 | int (Coins) | The actual deposited amount of asset1. |
fair_supply | int (Coins) | The amount of minted LP tokens received. |
Method get_start_at
Retrieves the start_at parameter, which specifies the UNIX timestamp for the start of trading.
This value can be updated using the configure_start_time operation.
By default, start_at is set to 0, indicating no start time is configured.
Returns
| Name | Type | Description |
|---|---|---|
start_at | int (Timestamp) | The UNIX timestamp for trading start. |