# Pair

The Pair contract represents a liquidity pool for a specific token pair.\
It manages token balances, tracks reserves, and handles the logic for token swaps within the PumpSpace protocol.

Each Pair is uniquely created by the Factory and is responsible for maintaining the state and rules of a single trading pair.

***

## Functions

#### token0

* Returns the address of the first token in the pair (sorted by address).

```solidity
function token0() external view returns (address);
```

#### token1

* Returns the address of the second token in the pair (sorted by address).

```solidity
function token1() external view returns (address);
```

#### getReserves

* Returns the current reserves of `token0` and `token1`, along with the timestamp of the last block in which the reserves were updated.

```solidity
function getReserves() external view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestampLast);
```

#### swap

* Swaps tokens within the pair contract. Either `amount0Out` or `amount1Out` must be non-zero.\
  Used internally during trades initiated via the Router.

```solidity
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
```


---

# 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://pumpspace.gitbook.io/docs/en/contract/pair.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.
