> For a complete index of Agora Finance documentation, fetch https://docs.agora.finance/llms.txt

# Fetching All Pairs

> Query the factory contract to retrieve all available trading pairs and their addresses

Every **AgoraStableSwapFactory** keeps an on-chain registry of every pair it deploys.

> **Note**
>
> If you want to run this example, be sure that you have followed the steps [here](/instant-settlement/guides/quick-start#setting-up-a-viem-wallet-client) to configure your Wallet Client.

The convenient view function **`getAllPairData()`** returns:

| Field             | Description                                            |
| ----------------- | ------------------------------------------------------ |
| `pairAddress`     | Proxy address of the pair contract                     |
| `token0 / token1` | Structs containing address, name, symbol, and decimals |

## Pick a factory address

```tsx
// AgoraStableSwapFactory contract on Sepolia
const TESTNET_FACTORY = '0x8468587Af422ad440F58a57E955eCA6A970b5375';
```

## Helper function to get all pairs

```tsx
/**
 * Returns an array of pair data for every pool created by the factory.
 */
async function getAllPairData(factory: `0x${string}`) {
  return await client.readContract({
    address: factory,
    abi: instantSettlementFactoryAbi,
    functionName: "getAllPairData",
  });
}
```

## Example use of the helper function

```tsx
(async () => {
  const allPairData = await getAllPairData(TESTNET_FACTORY);
  console.log(allPairData);
})();
```

### Returned Data

```tsx
[
  {
    pairAddress: '0x1Aa8958Aa34cEC8096EF4381cb335effe977b0ae',
    token0: {
      tokenAddress: '0x7BEb5D9DB0d85cBEa543C04f0dE8c23c2176cd9D',
      name: 'ConstantToken',
      symbol: 'CTK',
      decimals: 18n
    },
    token1: {
      tokenAddress: '0xa9012a055bd4e0eDfF8Ce09f960291C09D5322dC',
      name: 'AUSD',
      symbol: 'AUSD',
      decimals: 6n
    }
  }
]
```