---
title: getTradeContext
description: Load a market snapshot together with the account balances needed to quote and send.
---

> **For AI agents:** the complete documentation index is at [llms.txt](/llms.txt). Append `.md` to any page URL for its markdown version.

One block-pinned multicall for a trade ticket: market snapshot, wallet USDC and AVM balances, allowances to the market, permit nonces, whether the account is a contract, and cap headroom.

After this returns, repeated `quote*` calls on `context.snapshot` must not call RPC.

## Import

```ts
import { createSv3Client } from "@repo/contract-client";
```

## Usage

```ts
import { quoteBuyExactReserveIn } from "@repo/contract-client/math";
import { parseUsdc } from "@repo/contract-client";

const context = await sv3.market.getTradeContext(market, account);
const quote = quoteBuyExactReserveIn(context.snapshot, parseUsdc("1"));
```

For positions, use [getAccountContext](/developers/get-account-context) — it adds `position`, `freeCollateral`, and `borrowCapacity`.

## Return Value

`Promise<TradeContext>`

| Field                                   | Meaning                                |
| --------------------------------------- | -------------------------------------- |
| `snapshot`                              | Frozen `MarketSnapshot`                |
| `account`                               | Address you passed                     |
| `reserveBalance` / `avmBalance`         | Wallet balances                        |
| `reserveAllowance` / `avmAllowance`     | Allowance to the market                |
| `reservePermitNonce` / `avmPermitNonce` | EIP-2612 nonces                        |
| `codeSize`                              | `0n` for an EOA                        |
| `capHeadroom`                           | Remaining market backing and debt caps |

## Parameters

### market

- **Type:** `Address`

The FloorMarket proxy.

```ts
const context = await sv3.market.getTradeContext(market, account);
```

### account

- **Type:** `Address`

The wallet whose balances and allowances are included.

```ts
const context = await sv3.market.getTradeContext(market, "0x…");
```

## Tips

- Pass `context.reserveAllowance` and `context.reservePermitNonce` into [getRequirements](/developers/get-requirements). Do not issue a hidden approve.
- `codeSize > 0n` means a contract wallet. With default `permitCapability: 'none'`, that route is allowance, not permit.
