Skip to main content

Overview

A sell converts the user’s $GOLD tokens back into USDC on Solana. The flow and signer set are identical to Buying Gold — the only differences are the endpoint (/v1/sell) and the input/output fields (you specify gold_amount instead of usdc_amount; min_usdc_out replaces min_gold_out). Because everything else is the same — three signers, blockhash TTL, stateless quote, indexer-driven row writes — this guide focuses on the differences.

Signers

Same as buy: GRAIL + partner + user. Three signatures required.

Step 1 — Quote

Response:

Sell-specific input fields

Sell-specific fee note

The quote’s fee_bps often differs from a buy quote — on-chain inti uses separate market_open_fee_bps and market_close_fee_bps values, with the applicable side depending on market state. A partner’s IntegratorV2 on-chain config can also have a market_fee_override that forces one or the other. You don’t need to manage this — GRAIL reads the effective rate from the partner’s on-chain config when it builds the quote.

Step 2 — Co-sign with partner + user

Identical to buy:
The only difference from a buy tx is the on-chain program’s internal direction — GOLD out of the user’s token account, USDC in. You don’t touch that; it’s baked into the partial-signed transaction.

Step 3 — Submit

Response:
Pure passthrough — no DB write. As with buys, you can also broadcast directly to any Solana RPC.

Step 4 — Wait and fetch

The response shape is identical to Get Trade, with side: "sell". usdc_amount is the output, gold_amount is the input.

End-to-end script

Same as the buy reference script in Buying Gold, with two changes:
  1. Quote endpoint → /v1/sell
  2. Quote body → {"grail_user_id":"...", "gold_amount":0.01, "slippage_bps":50}
Everything else — co-sign, submit endpoint (/v1/sell/$TRADE_ID/submit), indexer polling — is identical.

Next steps

Flow complete? Move on to Redeeming Physical Gold for physical fulfillment.