Pool Contract
Info Methods
token0
token0Returns the address of the first token in the pool.
Example Usage:
Copy
address firstToken = pool.token0();
// Returns the address of the first token in the pool.
>>> 0x0000000000000000000000000000000000000000token1
token1Returns the address of the second token in the pool.
Example Usage:
Copy
address secondToken = pool.token1();
// Returns the address of the second token in the pool.
>>> 0x0000000000000000000000000000000000000000reserve0
reserve0Returns the reserve of the first token in the pool.
Example Usage:
Copy
reserve1
reserve1Returns the reserve of the second token in the pool.
Example Usage:
Copy
getAssets
getAssetsReturns the addresses of the assets in the pool.
Example Usage:
Copy
getReserves
getReservesReturns the current reserves of the tokens in the pool.
Example Usage:
Copy
Swap Methods
swap
swapSwaps one token for another within the pool. The function calculates the output amount based on the input amount and the current reserves, applies the swap fee, and updates the reserves accordingly.
Example Usage:
Copy
getAmountOut
getAmountOutCalculates the amount of output tokens received for a given input amount.
Example Usage:
Copy
Add/Remove Liquidity Methods
mint
mintMints LP tokens in exchange for adding liquidity to the pool.
Example Usage:
Copy
burn
burnBurns LP tokens in exchange for removing liquidity from the pool.
Example Usage:
Copy
burnSingle
burnSingleBurns LP tokens and swaps one of the output tokens for another, allowing the user to receive a single token.
Example Usage:
Copy
Last updated