Pool Contract

Info Methods

token0

Returns 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.
>>> 0x0000000000000000000000000000000000000000

token1

Returns 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.
>>> 0x0000000000000000000000000000000000000000

reserve0

Returns the reserve of the first token in the pool.

Example Usage:

Copy

reserve1

Returns the reserve of the second token in the pool.

Example Usage:

Copy

getAssets

Returns the addresses of the assets in the pool.

Example Usage:

Copy

getReserves

Returns the current reserves of the tokens in the pool.

Example Usage:

Copy


Swap Methods

swap

Swaps 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

Calculates the amount of output tokens received for a given input amount.

Example Usage:

Copy


Add/Remove Liquidity Methods

mint

Mints LP tokens in exchange for adding liquidity to the pool.

Example Usage:

Copy

burn

Burns LP tokens in exchange for removing liquidity from the pool.

Example Usage:

Copy

burnSingle

Burns LP tokens and swaps one of the output tokens for another, allowing the user to receive a single token.

Example Usage:

Copy

Last updated