> ## Documentation Index
> Fetch the complete documentation index at: https://tetrafi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# How a trade is funded, signed and settled

> Every trade runs through the same quote, order and follow calls. Each quote states how it is funded, who signs and how it settles; this page lists the five ways a trade can run.

Every trade runs quote, order, follow. Each quote states where the money comes from, who signs and when it settles, so you never choose them.

## At a glance

| You want to know | Read it on the quote |
| - | - |
| Where it trades from | `tradingSource`: an exchange or OTC account, or a wallet |
| How it is funded | `fundingModel`: `prefunded`, `credit` or `payIn` |
| How and when it settles | `settlement.method` and `settlement.timing` |
| Who signs, on an on-chain venue | `signing.mode`, rolling out: `tetrafi` or `you`. Today TetraFi signs. |
| What to do next | `next.kind`: `order` when it can be ordered |

**1. Quote**

`POST /api/v1/quotes` with what you sell, what you buy and one amount. `source` is optional: without it, each venue quotes from your [defaults](https://tetrafi.mintlify.site/trade/wallets-and-accounts.md).

**2. Pick a quote**

Read how it runs from the fields above. The quote fixes its source; to change it, [requote](https://tetrafi.mintlify.site/search/firmness-and-lifetime.md#requote-a-quote).

**3. Order**

`POST /api/v1/orders` with `quoteId`, an `Idempotency-Key`, and whatever that quote asks for (below). Lost the answer? [Recover it by quote](https://tetrafi.mintlify.site/trade/orders.md#retries-and-recovery), never with a new key.

**4. Follow**

Read `GET /api/v1/orders/{orderId}`, or receive [webhooks](https://tetrafi.mintlify.site/trade/webhooks.md), until `terminal` is `true` ([Order status](https://tetrafi.mintlify.site/trade/order-status.md)).

## The five ways a trade runs

| Way | The quote says | Before you order | At the order | When it settles | Status |
| - | - | - | - | - | - |
| [Exchange account](https://tetrafi.mintlify.site/recipes/exchange-account-order.md) | `prefunded`, `venueLedger` | Deposit into the account | `quoteId` | At once, inside the venue | Live |
| [OTC or credit account](https://tetrafi.mintlify.site/trade/settlement-and-credit.md#trade-on-a-credit-account) | `credit`, a `settlement.window` | Credit on the account | `quoteId`, `settlementWindowId` | In the window, netted | Live |
| [Pay-in venue](#pay-in-after-the-order) | `payIn` and its terms | Nothing | `quoteId` | When your payment is credited | Rolling out |
| [On-chain venue, TetraFi signs](https://tetrafi.mintlify.site/recipes/cross-chain-stablecoins.md) | `prefunded`, `dvp` or `fop` | Owners approve a signing grant | `quoteId` | On-chain, as its transactions confirm | Live |
| [On-chain venue, you sign](https://tetrafi.mintlify.site/trade/sign-with-your-own-wallet.md) | `signing.firstStep` | Nothing to register | `quoteId`, `firstStep` | On-chain, as its transactions confirm | Rolling out |

All five are **Basic**: execution at the venue, through its API or its own smart contracts. On-chain does not mean Advanced; Advanced (TetraFi's router and escrow) is not open yet.

> [accordion] Exchange account, prefunded
>
> Deposit first: `GET /api/v1/workspaces/{workspaceId}/venue-accounts/{venueAccountId}/deposit-instructions` says where. The trade spends the account's balance at the venue and settles on the venue's own ledger (`venueLedger`, `immediate`). A quote whose `next.kind` is `fund` has an account short by `readiness.amount` ([Before your first trade](https://tetrafi.mintlify.site/before-you-trade.md#fund-it)).

> [accordion] OTC or credit account
>
> The trade goes on the account's credit and is netted with your other trades in a settlement window. The quote carries `creditPortion`, `creditCheck` and `settlement.window`; your order consents to that window with `settlementWindowId`. A trade that spends only what the account already holds settles at once instead. A key only reads settlement actions ([they are for members](https://tetrafi.mintlify.site/trade/settlement-and-credit.md#settlement-actions-are-for-members)).

> [accordion] On-chain venue, TetraFi signs
>
> The trade runs from an organisation wallet on Turnkey or Privy. Its owners approve, once per venue, a signing grant with per-trade and per-day caps that the provider itself enforces, and the wallet is granted to your key ([Give a key organisation wallets](https://tetrafi.mintlify.site/before-you-trade.md#give-a-key-organisation-wallets)). TetraFi then signs each trade inside those caps, with no approval per trade. The wallet holds the funds and pays the gas.

> [accordion] On-chain venue, you sign
>
> Name your wallet's address in `source.tradingWallets`. Each on-chain quote carries `signing.firstStep`; you sign it and send it with the order, and sign any later step on `POST /api/v1/orders/{orderId}/steps/{stepId}`. You pay your own gas ([Sign with your own wallet](https://tetrafi.mintlify.site/trade/sign-with-your-own-wallet.md), [the recipe](https://tetrafi.mintlify.site/recipes/own-wallet-trade.md)).

> [accordion] Settlement method and timing
>
> | `settlement.method` | Meaning |
> | - | - |
> | `venueLedger` | Both sides move on the venue's own books. |
> | `dvp` | Delivery versus payment: what you pay and what you receive move together, as in one swap transaction. |
> | `fop` | Free of payment: one side moves first; `firstLeg` says whose. `taker` is you, as with a bridge deposit or a payment you send in. |
>
> `settlement.timing` is `immediate`, `byDeadline` (a pay-in, by its deadline) or `delayed` (in a settlement window, or whenever either side asks). Both lists can grow: treat a value you do not know as other.

> [accordion] Planned, not available yet
>
> People approving one trade elsewhere (`signing.mode` `owners` or `custodian`, with an order `next.kind` of `approve` and an `approvalUrl`), Solana and Tron steps, more venues for your own wallet, and custody wallets that TetraFi signs for ([Sign with your own wallet](https://tetrafi.mintlify.site/trade/sign-with-your-own-wallet.md), under What comes next). Keep following the order on any value you do not know.

## Pay in after the order

On a `payIn` quote you order first, then send the money over the venue's own rail, such as a bank transfer. The venue delivers once your payment is credited; the quote's `payIn` states the deadline and what happens to late money.

> [accordion] The payIn terms
>
> | Field | Meaning |
> | - | - |
> | `payBy` | The deadline: `seconds`, counted from the quote, and `clock`. `funds_arrived`: the money must be credited at the venue by then. `payment_started`: the payment must be started by then. `null`: the venue states no deadline, and the trade settles when the money arrives. |
> | `settlementGrace` | `no_grace`, or `within` with `seconds`: how long after the deadline a payment started in time may still be credited. It applies with the `payment_started` clock. |
> | `afterPayBy` | What the venue does with money credited after the deadline, in `action`: `returned`; `re_priced`, where it may execute at its current price instead of the quoted one until `untilSeconds` after the quote; `held`; or `handled_by_support`. `source` cites where the venue states the rule. |
>
> With a deadline, `settlement.timing` is `byDeadline`. Every value list can grow: treat an unknown one as other.

> [accordion] Follow the payment
>
> The trade's leg, in `legs[].tradeLeg` of `GET /api/v1/workspaces/{workspaceId}/trades/{tradeId}`, carries `fundingDeadlineAt` (the trade's own deadline, never later than the quote's terms), `status` (`awaiting_funds`, then `funds_received`, or `expired_unfunded` or `late_funds`), and `fundsReceivedAt` with `creditedAmount` once the venue credits it.

## Next

> [card] [Choose wallets and accounts](https://tetrafi.mintlify.site/trade/wallets-and-accounts.md)
>
> Name the source a quote trades from.

> [card] [Place an order](https://tetrafi.mintlify.site/trade/orders.md)
>
> Order a quote and retry safely.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.