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

# Fetching Pair Price

> Get the current fixed price for a trading pair

> **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.

[`AgoraStableSwapPair`](/instant-settlement/smart-contracts/pair-contract) exposes two read functions for price discovery:

| Function                                                                                                   | When to use                                                                                                                                          |
| ---------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| **[`getPrice()`](/instant-settlement/smart-contracts/pair-contract#read-only-functions)** (no args)        | Current on-chain price at `block.timestamp`.                                                                                                         |
| **[`getPrice(uint256 timestamp)`](/instant-settlement/smart-contracts/pair-contract#read-only-functions)** | Future price, using the pair's base price + interest-rate oracle. Pass a **deadline** to model worst-case execution when one token accrues interest. |

## **Pick the pair address**

```tsx
// AUSD / CTK pair on Sepolia
const TESTNET_PAIR_AUSD_CTK = '0x1Aa8958Aa34cEC8096EF4381cb335effe977b0ae';
```

---

## Helper function to read the price

```tsx
/**
 * Returns the price token0 / token1 at a given timestamp.
 * Pass at=`undefined` to get the current block price.
 */
async function getPairPrice(
  pair: `0x${string}`,
  at?: number, // UNIX seconds
) {
  const args: readonly [] | readonly [bigint] = at ? [BigInt(at)] : [];
  return await client.readContract({
    address: pair,
    abi: instantSettlementAbi,
    functionName: "getPrice",
    args,
  });
}
```

---

## Example use of the helper function (with a 5-minute deadline)

```tsx
(async () => {
  // 5 minutes from now → worst-case price for interest-bearing pairs
  const deadline = Math.floor(Date.now() / 1000) + 300;

  const priceRaw = await getPairPrice(TESTNET_PAIR_AUSD_CTK, deadline);

  console.log("Raw price token0/token1 (18-dec):", priceRaw);
})();
```

### Returned Data

```
Raw price token0/token1 (18-dec): 1000000n
```

> **Token order in the pair**
>
> **Deadline logic**
>
> For pairs where `token1` is interest-bearing, passing a future timestamp guards against receiving fewer tokens than expected if block processing is delayed. For non-yield token pairs, `deadline` simply replays the current price.
>
> **Understanding Pricing**
>
> Since `token0` and `token1` might have different decimals, the pricing of the pair follows:
>
> $$
> Price=\frac{ 10^{\text{decToken}_0}} {10^{\text{decToken}_1}} \times 10^{18}
> $$