# Pool Contract

### Info Methods <a href="#info-methods" id="info-methods"></a>

#### `token0` <a href="#token0" id="token0"></a>

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.
>>> 0x1234567890abcdef1234567890abcdef12345678
```

#### `token1` <a href="#token1" id="token1"></a>

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.
>>> 0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4
```

#### `reserve0` <a href="#reserve0" id="reserve0"></a>

Returns the reserve of the first token in the pool.

Example Usage:

Copy

```
uint reserveFirstToken = pool.reserve0();
// Returns the reserve amount of the first token in the pool.
>>> 0x0
```

#### `reserve1` <a href="#reserve1" id="reserve1"></a>

Returns the reserve of the second token in the pool.

Example Usage:

Copy

```
uint reserveSecondToken = pool.reserve1();
// Returns the reserve amount of the second token in the pool.
>>> 0x0
```

#### `getAssets` <a href="#getassets" id="getassets"></a>

Returns the addresses of the assets in the pool.

Example Usage:

Copy

```
address[] memory assets = pool.getAssets();
// Returns an array containing the addresses of the pool's assets.
>>> [0x1234567890abcdef1234567890abcdef12345678, 0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4]
```

#### `getReserves` <a href="#getreserves" id="getreserves"></a>

Returns the current reserves of the tokens in the pool.

Example Usage:

Copy

```
(uint reserve0, uint reserve1) = pool.getReserves();
// Returns the reserve amount of the first token and the second token in the pool.
>>> (0x0, 0x0)
```

#### `getA` <a href="#geta" id="geta"></a>

Returns the current amplification coefficient of the pool.

Example Usage:

Copy

```
uint64 amplificationCoefficient = pool.getA();
// Returns the current amplification coefficient of the pool.
>>> 2000
```

***

### Swap Methods <a href="#swap-methods" id="swap-methods"></a>

#### `swap` <a href="#swap" id="swap"></a>

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

```
bytes memory data = abi.encode(token0, userAddress, 0); // Encode the swap data
address sender = userAddress; // The address of the user initiating the swap
address callback = address(0); // No callback in this example
bytes memory callbackData = ""; // No callback data

TokenAmount memory result = pool.swap(data, sender, callback, callbackData);
// Returns the amount of tokens received after the swap as a TokenAmount struct.
>>> TokenAmount { token: 0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4, amount: 990 }
```

#### `getAmountOut` <a href="#getamountout" id="getamountout"></a>

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

Example Usage:

Copy

```
address tokenIn = token0;
uint amountIn = 1000;
address sender = userAddress;

uint amountOut = pool.getAmountOut(tokenIn, amountIn, sender);
// Returns the amount of output tokens for the given input amount.
>>> 990
```

***

### Add/Remove Liquidity Methods <a href="#add-remove-liquidity-methods" id="add-remove-liquidity-methods"></a>

#### `mint` <a href="#mint" id="mint"></a>

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

Example Usage:

Copy

```
bytes memory data = abi.encode(userAddress); // Encode the mint data
address sender = userAddress; // The address of the user initiating the mint
address callback = address(0); // No callback in this example
bytes memory callbackData = ""; // No callback data

uint lpTokensMinted = pool.mint(data, sender, callback, callbackData);
// Returns the amount of LP tokens minted.
>>> 500
```

#### `burn` <a href="#burn" id="burn"></a>

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

Example Usage:

Copy

```
bytes memory data = abi.encode(userAddress, 0); // Encode the burn data
address sender = userAddress; // The address of the user initiating the burn
address callback = address(0); // No callback in this example
bytes memory callbackData = ""; // No callback data

TokenAmount[] memory amounts = pool.burn(data, sender, callback, callbackData);
// Returns the amounts of tokens returned to the user as an array of TokenAmount structs.
>>> [TokenAmount { token: 0x1234567890abcdef1234567890abcdef12345678, amount: 500 }, TokenAmount { token: 0x3355df6d4c9c3035724fd0e3914de96a5a83aaf4, amount: 1000 }]
```

#### `burnSingle` <a href="#burnsingle" id="burnsingle"></a>

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

Example Usage:

Copy

```
bytes memory data = abi.encode(token0, userAddress, 0); // Encode the burn single data
address sender = userAddress; // The address of the user initiating the burn
address callback = address(0); // No callback in this example
bytes memory callbackData = ""; // No callback data

TokenAmount memory tokenAmount = pool.burnSingle(data, sender, callback, callbackData);
// Returns the amount of tokens received after the swap and burn as a TokenAmount struct.
>>> TokenAmount { token: 0x1234567890abcdef1234567890abcdef12345678, amount: 1500 }
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.syncswap.xyz/syncswap-technical-docs/stable-pool/pool-contract.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
