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:
initialA
uint32
The initial amplification coefficient.
futureA
uint32
The future amplification coefficient after ramping is complete.
initialGamma
uint64
The initial gamma value, which is related to the curvature of the pricing function.
futureGamma
uint64
The future gamma value after ramping is complete.
initialTime
uint32
The timestamp when the ramping process started.
futureTime
uint32
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
_data
bytes memory
Encoded data containing the input token address, recipient address, and withdraw mode. See details below.
_sender
address
Address initiating the swap.
_callback
address
Address for the post-swap callback.
_callbackData
bytes memory
Additional data for the callback function.
_data
Structure
The _data
parameter is expected to be an encoded tuple containing the following parameters:
tokenIn
address
The address of the token being swapped into the pool.
to
address
The address to receive the output token.
withdrawMode
uint8
Specifies the mode for withdrawing the output token. Values:
- 0
: Tokens are deposited into the vault.
- 1
: For wETH
, withdraws Ether and sends it to the recipient.
- 2
: Transfers tokens directly to the recipient.
Returns
_tokenAmount
TokenAmount memory
A struct containing the output token address and the amount swapped.
- token
: The address of the token received from the swap.
- amount
: The amount of the token received from the swap.
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
_data
bytes
Encoded data containing the following fields:
- address to
: The address to which the minted LP tokens will be sent.
_sender
address
The address initiating the mint transaction.
_callback
address
The address of the callback contract. If non-zero, the function calls back this address after minting.
_callbackData
bytes
Additional data to pass to the callback function.
Returns
liquidity
uint
The amount of liquidity (LP tokens) minted and sent to the specified address in _data
.
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
_data
bytes
Encoded data containing the following fields:
- address to
: The address to which the withdrawn assets will be sent.
- uint8 withdrawMode
: The mode of withdrawal (e.g., direct transfer, WETH unwrap, etc.).
_sender
address
The address initiating the burn transaction.
_callback
address
The address of the callback contract. If non-zero, the function calls back this address after burning.
_callbackData
bytes
Additional data to pass to the callback function.
Returns
_amounts
TokenAmount[]
An array of TokenAmount
structs indicating the amount of each token returned to the user after burning LP tokens.
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
_data
bytes
Encoded data containing the following fields:
- address tokenOut
: The address of the token the user wishes to receive.
- address to
: The address to which the withdrawn token will be sent.
- uint8 withdrawMode
: The mode of withdrawal (e.g., direct transfer, WETH unwrap, etc.).
_sender
address
The address initiating the burn transaction.
_callback
address
The address of the callback contract. If non-zero, the function calls back this address after burning.
_callbackData
bytes
Additional data to pass to the callback function.
Returns
_tokenAmount
TokenAmount
A TokenAmount
struct indicating the amount of the single token returned to the user after burning.
Last updated