Pool Contract
A Aqua pool consists of two non-pegged assets. The LP token is a ERC-20 token integrated directly into the liquidity pool.
Info methods
token0
token0
Returns the address of the first token in the pool.
Example Usage:
Copy
token1
token1
Returns the address of the second token in the pool.
Example Usage:
Copy
getReserves
getReserves
Returns the current reserves of the tokens in the pool.
Example Usage:
Copy
priceScale
priceScale
Returns the current price scale, which determines the price band around which liquidity is concentrated.
Example Usage:
Copy
xcpProfit
xcpProfit
Returns the current profit of the pool, used to calculate gains when adjusting liquidity.
Example Usage:
Copy
poolParams
poolParams
The poolParams
function returns the PoolParams
struct containing all the current pool parameters related to amplification and gamma ramping. This allows users to query the state of the pool's parameter adjustments and understand the timing and values associated with those adjustments.
Returns A PoolParams
struct containing the following fields:
Name | Type | Description |
---|---|---|
|
| The initial amplification coefficient. |
|
| The future amplification coefficient after ramping is complete. |
|
| The initial gamma value, which is related to the curvature of the pricing function. |
|
| The future gamma value after ramping is complete. |
|
| The timestamp when the ramping process started. |
|
| The timestamp when the ramping process is expected to finish. |
Example Usage:
Copy
Swap methods
swap
swap
Copy
The swap
function facilitates token exchanges within the pool by considering the current pool state, reserves, and applicable fees. It allows users to swap one token for another, ensuring that the pool remains balanced post-swap.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Encoded data containing the input token address, recipient address, and withdraw mode. See details below. |
|
| Address initiating the swap. |
|
| Address for the post-swap callback. |
|
| Additional data for the callback function. |
_data
Structure
The _data
parameter is expected to be an encoded tuple containing the following parameters:
Parameter | Type | Description |
---|---|---|
|
| The address of the token being swapped into the pool. |
|
| The address to receive the output token. |
|
| Specifies the mode for withdrawing the output token. Values: |
- | ||
- | ||
- |
Returns
Return Value | Type | Description |
---|---|---|
|
| A struct containing the output token address and the amount swapped. |
- | ||
- |
Example Usage
Copy
Event
Copy
Add/Remove Liquidity Methods
mint
mint
This function mints liquidity provider (LP) tokens by adding assets to the pool.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Encoded data containing the following fields: |
- | ||
|
| The address initiating the mint transaction. |
|
| The address of the callback contract. If non-zero, the function calls back this address after minting. |
|
| Additional data to pass to the callback function. |
Returns
Return Value | Type | Description |
---|---|---|
|
| The amount of liquidity (LP tokens) minted and sent to the specified address in |
Event
Copy
burn
burn
This function burns LP tokens, removing liquidity from the pool. It returns the proportional amount of underlying assets to the user, updating the pool's state accordingly.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Encoded data containing the following fields: |
- | ||
- | ||
|
| The address initiating the burn transaction. |
|
| The address of the callback contract. If non-zero, the function calls back this address after burning. |
|
| Additional data to pass to the callback function. |
Returns
Return Value | Type | Description |
---|---|---|
|
| An array of |
Event
Copy
burnSingle
burnSingle
This function burns LP tokens to withdraw a single type of token from the pool. It swaps one of the pool's assets for another, giving the user only one token as output.
Parameters
Parameter | Type | Description |
---|---|---|
|
| Encoded data containing the following fields: |
- | ||
- | ||
- | ||
|
| The address initiating the burn transaction. |
|
| The address of the callback contract. If non-zero, the function calls back this address after burning. |
|
| Additional data to pass to the callback function. |
Returns
Return Value | Type | Description |
---|---|---|
|
| A |
Last updated