Skip to main content
Both sync and async equity orders settle on the RFQ order program: 8dybMBo3dhQR49ACuWzZej9WiRzPpNkmpdjH7iBk6ip3. The DFlow orchestrator program, DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH, executes the swap legs of a route that precedes the order.

Event Format

The program emits events with Anchor’s emit_cpi!: it invokes itself, and the event is the data of that inner instruction. Events do not appear in the transaction logs. To find events, read meta.innerInstructions[*].instructions[*] and keep the instructions whose program is the RFQ order program and whose data starts with the event tag. The program signs the inner instruction with its event authority PDA, derived from the seed "__event_authority". Each event’s data has this layout:
Read fill data from these events, not from the instructions that produced them.

Event Discriminators

Order Event Types

Each transition of an order emits exactly one RfqOrderEvent. Its event_type field records the transition: Every order has one Open event and, once a transaction closes it, one terminal event: Fill, Cancel, or Expire.

Order Event Byte Layout

RfqOrderEvent fields, with offsets after the 16-byte prefix. Add 16 for the offset in the instruction data. The event fields are 279 bytes, so the full instruction data is 295 bytes.

Detecting Async Order Outcomes

  1. Parse the Open event from the transaction the user signed. Read the order field, the onchain address of the order.
  2. Watch later transactions for an RfqOrderEvent with the same order and event_type = 2 (Fill).
  3. Handle the other terminal types: event_type = 3 (Cancel) or 4 (Expire) means the order did not fill.
Fill, Cancel, and Expire transactions include the order’s refund_wallet, so you can subscribe to transactions that mention it to detect closes.

Async Order Volume Calculation

In Fill events, use:
  • input_mint / input_amount
  • output_mint / output_amount
For an async order, one of the two mints is USDC. When USDC is the input, input_amount includes the fee that was charged, and a skipped fee is returned in refund_amount and not counted in input_amount; when USDC is the output, output_amount is net of the fee. A Fill transaction also emits a SwapEvent for the same amounts, with amm set to the RFQ order program ID. Count either the RfqOrderEvent or the SwapEvent for an async order, not both.

Fill Pricing

The price of an order is quoted_out ÷ quoted_in. It never includes the platform fee. The fee is platform_fee_ubps, charged in fee_mint: on the input when fee_mint equals input_mint, on the output when it equals output_mint. For an escrow of E: Take a quoted_in of 201,000,000, a quoted_out of 1,005,000,000, and a 1% fee:
  • Fee on the input, escrow of 200,000,000: the fee is 2,000,000, the maker receives 198,000,000, and the maker pays 990,000,000, all of which the user receives.
  • Fee on the output, escrow of 200,000,000: the maker receives 200,000,000 and pays 1,000,000,000. The fee is 10,000,000, so the user receives 990,000,000.
  • Fee on the input, escrow of 210,000,000: the fill takes 203,030,303 and the maker receives exactly 201,000,000. The remaining 6,969,697 returns to the user.

Async Order Fee Calculation

Fill events carry:
  • fee_mint
  • fee_amount
fee_amount is the platform fee charged on the fill. The same transaction emits a FeeEvent when a fee was paid; its amount is the amount that reached the fee account. Sum fee_amount for fees charged. For fees received, sum FeeEvent.amount over the events whose account is your fee account.

Sync Order Events

A sync response opens its order and fills it in the same transaction. The transaction emits an Open and a Fill RfqOrderEvent for the same order, a SwapEvent for the fill with amm set to the RFQ order program ID, and a FeeEvent for each transfer to the fee account. A buy that is routed into USDC first also emits a SwapEvent from the orchestrator for each routing leg. Read the equity amounts from the Fill event, and do not also count the fill’s SwapEvent. See Relevant IDL Fields for the layouts.

Relevant IDL Fields

SwapEvent fields, with offsets after the 16-byte prefix: FeeEvent fields, with offsets after the 16-byte prefix: RfqOrderEvent field meanings:

Example: Decoding Events

This example fetches a transaction with jsonParsed encoding, which lists each inner instruction’s programId, and decodes its RfqOrderEvent and FeeEvent entries.