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

# Maker Sync Fills

> How a maker confirms a selected quote and gives last look before an rfqFill quote settles

An `rfqFill` quote settles sync, in one transaction on the [RFQ order program](https://pond.dflow.net/equities/makers/async-fills.md#rfq-order-program). The first instruction opens an order that escrows the user's input, directly or through a swap. The second, `fill_rfq_order`, fills that order from the maker's inventory. The user signs, then DFlow sends the transaction to the maker's `/submit-transaction`. The maker co-signs and submits, and answers within 8 seconds.

## Selected Quote

DFlow calls `POST /selected` when it hands the transaction to the user. The call is a notification: DFlow does not wait for the answer, and the maker cannot refuse the selection. The maker declines at last look.

```json theme={null}
{
  "requestId": "<same across retries>",
  "quoteId": "<the maker's quote id>",
  "actionType": "rfqFill",
  "taker": "<user wallet, base58>",
  "orderAddress": "<base58>"
}
```

The maker checks that `quoteId` is one of its live quotes and stores the `orderAddress` against that quote. The fill must name that order.

* **Idempotent:** the same `quoteId` and `orderAddress` can arrive more than once.
* **Delivery:** DFlow retries once after 250 ms on a transport error, a timeout, `429` or `5xx`, with the same body, within 0.9 seconds. It logs any answer and the selection stands.
* **Unknown order:** a maker that has not stored the fill's order address rejects the fill at last look.

## Read the Fill Instruction

The fill is the RFQ order program's `fill_rfq_order` instruction, the same instruction an [async fill](https://pond.dflow.net/equities/makers/async-fills.md#fill-an-order) uses. A maker can decide whether to co-sign from this instruction alone. Its data states the price and the most the maker receives, and the program reverts the fill unless the order's terms are met or improved on. The maker co-signs only values it approves, and the instruction that opens the order cannot change them.

### Fill Instruction Data

The data is 24 bytes:

| Bytes | Field | Type | Meaning |
| - | - | - | - |
| 0-7 | Discriminator | `[50, 203, 135, 122, 42, 118, 61, 47]` | Identifies `fill_rfq_order`. |
| 8-15 | `quoted_in` | u64, little-endian | The most input the maker receives, after any input-side platform fee. |
| 16-23 | `quoted_out` | u64, little-endian | What the maker pays for `quoted_in`, before any output-side platform fee. |

### What the Fill Data Guarantees

* **Price:** `quoted_out ÷ quoted_in`. Platform fees never enter it.
* **Ceiling:** the maker receives at most `quoted_in` of the input mint and pays at most `quoted_out` of the output mint.
* **Payment:** the maker pays `received × quoted_out ÷ quoted_in`, rounded down, where `received` is what its receiving account gained. A smaller fill pays the same price. A fill that receives nothing reverts.
* **Terms:** the program reverts the fill unless `quoted_in` is above zero and at most the order's `quoted_in`, and `quoted_out` is at least the order's `quoted_out`, see [Price Improvement](https://pond.dflow.net/equities/makers/async-fills.md#price-improvement). DFlow builds this instruction with the order's own values, and the maker signs only values it approves of swapping, as in check 5 below.
* **What the opening instruction controls:** how much input the user escrowed, which sets how much arrives, up to the ceiling. It cannot change the price or the ceiling.
* **Destination:** where the payment goes does not change what the maker pays or receives.
* **Maker fee:** the order can carry a [maker fee](https://pond.dflow.net/equities/makers/maker-fees.md) that the maker pays DFlow in USDC, at most 5%. It is outside the fill data: it changes neither the price nor what the user receives.

### Fill Instruction Accounts

The instruction has the 18 fixed accounts of the async [`fill_rfq_order`](https://pond.dflow.net/equities/makers/async-fills#fill-instruction-accounts). An `rfqFill` order is opened with flag bit 1, and on such an order two of them differ:

| Position | Account | Writable | Meaning |
| - | - | - | - |
| 0 | `maker` | No, signer | Must be the order's maker. The maker's wallet is read-only in the whole transaction, so no instruction can debit its SOL. |
| 11 | `rent_recipient` | Yes, signer | The account that paid for the open. It signs the transaction and pays rent for any user token account the fill creates. The order's rent returns to it. |

The program reverts the fill with `RfqOrderMakerWritable` if the maker's wallet is writable in the transaction, and the open reverts with `RfqOrderMissingFill` unless the next instruction is the maker's fill of that order. The fee, maker fee and hook accounts follow account 17, as in the [async fill](https://pond.dflow.net/equities/makers/async-fills.md#fill-instruction-accounts).

DFlow keeps accounts 0, 1, 3, 4, 12 and 13 as static keys in the transaction. The others may come from address lookup tables, so the maker resolves lookups before reading them.

### Example: Reading a Fill

This instruction data is 24 bytes, shown by field:

```text theme={null}
32cb877a2a763d2f  4004fb0b00000000  4015e73b00000000
discriminator     quoted_in         quoted_out
```

`quoted_in` is 201,000,000 and `quoted_out` is 1,005,000,000, so the price is 5. The maker pays for the input its account receives:

| Input received | Output paid |
| - | - |
| 201,000,000 | 1,005,000,000 |
| 100,000,000 | 500,000,000 |
| 1 | 5 |

## Last Look

DFlow calls `POST /submit-transaction` with the user-signed transaction.

```json theme={null}
{ "requestId": "<id>", "transaction": "<base64 transaction>" }
```

The fill is the RFQ order program's `fill_rfq_order` instruction, described in [Read the Fill Instruction](#read-the-fill-instruction). Before co-signing, the maker checks that:

1. Exactly one instruction names the maker's wallet, and it is a `fill_rfq_order`.
2. The maker's wallet is read-only in the transaction: it is not the fee payer and no instruction marks it writable.
3. The fill names the `orderAddress` the maker stored from `/selected`. A fill for an unknown order is rejected.
4. The quote has not been co-signed already. An exact repeat of the same transaction bytes returns the same `txSignature`. Different bytes for a quote already used are rejected.
5. `quoted_in` is the quote request's `maxAmountIn`, or its `amount` when the request has none, and `quoted_out` is `quoted_in × amountOut ÷ amountIn`, rounded down.
6. The fill's mint accounts are the quote's `tokenIn` and `tokenOut`, and its token accounts are the quote's `makerInputTokenAccount` and `makerOutputTokenAccount`.
7. The quote has not expired.
8. The open's maker fee rate, bytes 88-89 of its data in ubps when it is 90 bytes long and 0 otherwise, is the quote request's `feeBps` × 100.
9. If the maker pays fees, the compute budget and priority fee instructions are within the maker's limits.

The maker does not need to read the order. The program reverts the fill unless the order names this maker and these mints, and the maker pays the order's price for the input it receives. [Maker Async Fills](https://pond.dflow.net/equities/makers/async-fills.md#fill-an-order) describes how the program prices and checks the fill. The maker should still simulate the transaction and compare its own balance changes with the quote, which differ from it only by any [maker fee](https://pond.dflow.net/equities/makers/maker-fees.md). The fill names the order's maker fee account after any fee recipient when the order has a maker fee.

The maker then co-signs, submits the transaction, and answers within 8 seconds. DFlow never retries `/submit-transaction`.

```json theme={null}
{ "state": "accepted", "txSignature": "<fee payer signature>" }
```

```json theme={null}
{ "state": "rejected", "rejectionCode": "terms_mismatch", "rejectionReason": "<text>" }
```

`accepted` requires `txSignature`. DFlow checks that it belongs to the transaction and does not confirm it. `rejectionReason` is logged and never shown to the integrator. `rejectionCode` is the only rejection detail the integrator sees:

| `rejectionCode` | When |
| - | - |
| `quote_expired` | The quote's lifetime has passed. |
| `quote_unknown` | The maker has no live quote or stored order address for the transaction. |
| `quote_already_used` | The quote was already filled. |
| `terms_mismatch` | The fill does not match the quoted terms. |
| `transaction_not_allowed` | Another instruction names the maker, the maker's wallet is writable, or the transaction has a disallowed fee payer or disallowed compute budget settings. |
| `declined` | The maker declined at last look. An absent or unrecognized code reads as `declined`. |
