Market Makers / Protocol
Market Makers
Crebit broadcasts every partner quote as an anonymized RFQ (request for quote) to onboarded market makers. You bid; Crebit sends collateral + fee upfront to your wallet; you hold both for the life of the contract; on customer exercise you cover the FX delta from that collateral and keep the fee regardless; on expiry you return the collateral and keep the fee. The protocol is fully async webhooks + idempotent HTTP; there are no long-lived sessions and no sync-response gating of the partner quote path.
Day 0: you give Crebit one HTTPS endpoint under your control (see Onboarding for everything else Crebit needs on Day 0). From that point on, Crebit POSTs every quote broadcast (rfq.issued) and every lifecycle event (mm.*) to that one URL. You dispatch on event_type, run your pricing on RFQs, POST back to Crebit when you need to act (bid, confirm a funding tx, broadcast a payout). No other transport. Verifying inbound signatures and sending outbound auth headers is §Auth & signatures.
Slice= one MM's share of a contract's notional. Co-MMs = other winners on the same contract; their identities and rates are never disclosed, but co_mm_count on your allocation tells you how many. Every webhook, SLA, and default in this doc is scoped to your slice.
For the partner-side view of the same contract (quote, create, exercise, payout_settled), see API endpoints — the fx_contract_id and crebit_contract_referenceyou receive match the partner's view exactly.
Full Lifecycle
Read top to bottom. Phases 1 and 2 always happen. Once the contract is active, it ends one of two ways: the customer exercises (3a) or the window closes unused (3c). A margin call (3b) can come at any point while it is active.
- 1. RFQ and auction
rfq.issued
Pair, notional, execution window
POST /api/v1/fx/mm/bids
During the ~5 s auction
- Winner chosen by price, then time (price-time waterfall).
rfq.allocated
- 2. Funding
Collateral + fee, on-chain
One transaction, within 3 min of allocation
mm.funding_sent → mm.funding_confirmed
- Contract active. The MM holds the collateral; the customer can exercise any time in the execution window.
- 3a. Customer exercises → settled
Exercise
Through the partner's app
mm.exercise_called
POST /api/v1/fx/mm/payouts
Plus the FX delta on-chain
mm.payout_confirmed
Status: settled
- 3b. Margin call (any time while active)
POST /api/v1/fx/mm/margin-calls
crebit.margin_call_ack → crebit.topup_sent
Top-up on-chain → mm.funding_confirmed
No top-up: auto-unwind at mark-to-market
- 3c. Window ends, no exercise → expired
mm.contract_expired
POST /api/v1/fx/mm/payouts
Collateral returned on-chain
mm.payout_confirmed
Status: expired; the MM keeps the fee
And the same seven phases as a reference table. Slice phase is the internal label; the public contract_status on webhooks only reports active, settled, expired, defaulted.
| Phase | Who | What happens | Slice phase after |
|---|---|---|---|
| 1. RFQ | Crebit → MM | POST rfq.issued to your webhook with the full quote shape and bidding_closes_at (default +5 s). | rfq_received |
| 2. Bid | MM → Crebit | POST /api/v1/fx/mm/bids with quote_id, quoted_rate, settlement + payout wallets, min/max fill. Resubmit to replace; last valid bid before close wins. | bid_submitted |
| 3. Allocation | Crebit → winning MMs | Price-time waterfall. Each winner gets POST rfq.allocated with their mm_allocation_id, slice notional, and funding instructions. Multiple MMs may share one fx_contract_id. | allocated |
| 4. Funding | Crebit → MM (on-chain) | Crebit sends (collateral + fee) in one upfront tx to the MM's receive_wallet_address — amounts come straight from the winning bid. MM holds for the life of the contract. Crebit POSTs mm.funding_sent, indexer confirms via mm.funding_confirmed. | funding_pending → active |
| 5. Active | — | Lock is live. Customer may exercise any moment inside the execution window. | active |
| 6a. Exercise | Crebit → MM | Partner POSTed contract_exercised. Crebit sends mm.exercise_called with payout_due amount and due_by (10 min SLA). | exercise_called |
| 6b. Payout | MM → Crebit (on-chain) | MM broadcasts the delta to Crebit's payout escrow, POSTs /api/v1/fx/mm/payouts with the tx hash. Crebit confirms, pays the customer out of reserve. | payout_submitted → payout_confirmed → settled |
| 7a. Expiry | MM → Crebit | Window ended, no exercise. Forwards: Crebit emits mm.contract_expired with a collateral_return_due block; the MM broadcasts the held collateral back to Crebit's payout escrow (same POST /payouts endpoint as exercise) within 1 h; Crebit confirms via mm.payout_confirmed. Options: notification only, MM keeps premium. | expired → collateral_returned (forwards) |
| 7b. Default | Crebit → MM | MM missed payout SLA. Crebit covers customer from reserve; no MM collateral to slash so loss is unrecovered until pursued legally. Rating hit, graduated throttling, eventual suspension. Event: mm.defaulted. | defaulted |
Economics
Who pays whom, when (all on-chain stablecoin transfers):
FORWARDS (collateral_quote > 0)
Allocation: Crebit ──(collateral + fee)──▶ MM [one tx, both amounts]
Exercise: MM ──(FX delta)──▶ Crebit [may net vs held collateral]
Expiry: MM ──(return collateral)──▶ Crebit [fee retained regardless]
Margin call: MM ──(call)──▶ Crebit ──(top-up)──▶ MM
OR auto-unwind at MTM
OPTIONS (collateral_quote = 0, fee_quote = your premium share)
Allocation: Crebit ──(premium share)──▶ MM
Exercise: MM ──(FX delta)──▶ Crebit [no collateral held]
Expiry: nothing — MM keeps premium
All exercise deltas pay out in the MM's declared payout_currency
(USDC / USDT / BRLA) on the MM's declared payout_chain.- Market-move risk is yours. Your bid is priced against
reference_market.rateat RFQ issuance; between then andoracle_live_execution_rateat exercise you own the exposure. Hedge on your own venues. - Crebit's take is the spread between the partner-facing rate and your winning bid. Not disclosed per-contract.
- Worst-case per-slice loss. Forwards:
allocated_notional × adverse_FX_move − collateral_quote(margin calls usually clip this). Options:allocated_notional × max(0, settlement − locked) − premium_share— unmargined, price the tail intofee_quote.
Onboarding
Send your Crebit integration lead the seven items below. Item 1— the webhook URL where Crebit POSTs every RFQ and lifecycle event to you — is the thing that makes Crebit able to send you anything at all; the other six configure what kind of traffic you'll receive and where Crebit can reach you on-chain.
- 1. Webhook URL. A single HTTPS endpoint under your control. Crebit POSTs every
rfq.*(quote broadcasts) andmm.*(lifecycle events: allocation, funding, exercise, payout, expiry, default) here. Dispatch onevent_type. No RFQs reach you until this URL is registered and passes a sandbox smoke test. - 2. Supported corridors. Any subset of
BRL_TO_USD / USD_TO_BRL / MXN_TO_USD / USD_TO_MXN / NGN_TO_USD / USD_TO_NGN. Crebit only RFQs you on corridors you declared. - 3. Supported chains.
solana / base / arbitrum / polygon / tron. Pick any subset. Ethereum L1 is intentionally excluded (finality is too slow for the 3-min funding SLA); partner RFQs on ethereum never reach you, Crebit internalizes those. Per-chain confirmation depths are in Chain confirmation targets. - 4. Settlement rail profiles. Per declared chain, one tuple: (
receive_wallet_addressfor Crebit's funding tx,payout_wallet_addressfor your exercise / expiry broadcasts, accepted funding / payout currencies). Funding (collateral + fee or premium share):USDC / USDT. Payout:USDC / USDT / BRLA. Register profiles to keep bid payloads minimal; override per-bid when you need to. - 5. Supported oracles. Any subset of
redstone / chainlink. Oracle is agreed at contract creation and is authoritative for exercise — price off the same tape. - 6. Capacity limits. Max notional per RFQ, max open exposure, max concurrent contracts. Crebit skips fan-out that would breach any of them.
- 7. Hot-wallet float for payouts.On exercise you broadcast the FX delta to Crebit's payout escrow within 10 min (see SLAs). Keep sized USDC/USDT float on every declared chain so you can broadcast immediately. If you're low on a chain, pause that corridor until you re-stock — repeated payout misses are what graduate you off the platform.
No per-contract MM collateral is required — the model is trust-based. Crebit posts per-contract collateral (forwards) or sends premium up front (options); the MM pays exercise deltas from own hot wallet within SLA. Repeated payout misses trigger rating hits, throttling, and suspension (see Default handling).
Once those seven land, Crebit mints two separate credentials, one per traffic direction — store and rotate them independently:
- Inbound (receive-side): an HMAC-SHA256
webhook_signing_secretyou use to verify every Crebit → MM webhook'sX-Crebit-Signatureheader. Never sent on the wire — Crebit signs, you verify. - Outbound (push-side): an
X-Crebit-Mm-Key-Id/X-Crebit-Mm-Key-Secretpair you send on every MM → Crebit POST (bids, payouts, margin-calls, disputes, pause). Scoped to outbound auth only; cannot be used to forge inbound webhook signatures.
Compromise of one does not compromise the other — rotate the affected credential alone. See §Auth & signatures for rotation mechanics.
IDs You'll See
Easy to confuse at integration time. Keep this table handy:
| ID | Shape | Scope | Use it for |
|---|---|---|---|
| rfq_id | ULID (rfq_01H...) | One auction | Correlating your bid to the RFQ. Stable within an auction; new one per RFQ. |
| quote_id | UUID | One partner quote | The Crebit quote this RFQ is for. Required on your bid; echoed on allocation. Same quote_id visible partner-side. |
| bid_id | Your string | One bid you submitted | Your reference. Returned on allocation so you can reconcile which bid won. |
| mm_allocation_id | ULID (mma_01H...) | Your slice of one contract | Address every downstream event (funding, exercise, payout, expiry, default) by this. Unique per MM per contract. |
| fx_contract_id | UUID | The contract itself | Shared across co-MMs when partially filled. Partner sees the same id. |
| crebit_contract_reference | Human string (CREBIT-YYYYMMDD-XXX) | Same contract, friendlier | Use in dashboards and ops; partner sees it too. |
| event_id | evt_... per event | One webhook delivery | Idempotency key for inbound webhooks. Crebit may redeliver — dedupe on this. |
1. RFQ Webhook (Crebit → MM)
One POST per partner quote. Return any 2xx; Crebit ignores the body. Not responding is a valid "pass".
curl -sS -X POST "https://your-mm.example.com/crebit/rfq" \
-H "Content-Type: application/json" \
-H "X-Crebit-Event: rfq.issued" \
-H "X-Crebit-Signature: t=1722780121000,v1=5a3f…" \
-H "X-Crebit-Api-Version: 2026-08-01" \
-H "X-Crebit-Rfq-Id: rfq_01HNAZK3YQW7PM6T4D8X2V5B9C" \
-d '{"event_type":"rfq.issued","rfq_id":"rfq_01HNAZK3YQW7PM6T4D8X2V5B9C","quote_id":"22222222-2222-4222-8222-222222222222","issued_at":"2026-08-04T13:42:00.812Z","bidding_closes_at":"2026-08-04T13:42:05.812Z","partner_handle":"partner_8f3a","product":{"contract_type":"forward","direction":"USD_TO_BRL","strike_mode":"cip_fair","target_strike":null},"notional":{"currency":"USD","amount":"100000.00"},"execution_window":{"window_start":"2026-08-11T00:00:00Z","window_end":"2026-08-18T00:00:00Z","duration_days":7},"requested_settlement":{"chain":"polygon","currency":"USDC","payout_chain":"polygon","payout_currency":"USDC"},"reference_market":{"rate":"5.4180","oracle":"redstone","captured_at":"2026-08-04T13:41:59.780Z"},"submit_bid_url":"https://lock-apis-sandbox.crebitpay.com/api/v1/fx/mm/bids"}'Every field is the same as the partner-facing quote, with the partner identity anonymized to a stable partner_handle. requested_settlement is what the partner asked for; bid on those rails if you can. submit_bid_url is the Crebit endpoint for your bid (same for every RFQ in a given environment). strike_mode: cip_fair (default), partner_mid, or custom — target_strike is populated only on custom.
2. Submit a Bid (MM → Crebit)
POST to submit_bid_url before bidding_closes_at. Resubmitting with the same Idempotency-Key is a no-op; a new key with the same rfq_id replaces the previous bid.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/mm/bids" \
-H "Content-Type: application/json" \
-H "X-Crebit-Mm-Handle: mm_acme" \
-H "X-Crebit-Mm-Key-Id: mmk_sbx_…" \
-H "X-Crebit-Mm-Key-Secret: mms_…" \
-H "X-Crebit-Environment: sandbox" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"bid_id":"bid_acme_2026-08-04_000142","rfq_id":"rfq_01HNAZK3YQW7PM6T4D8X2V5B9C","quote_id":"22222222-2222-4222-8222-222222222222","quoted_rate":"5.4312","spread_bps_vs_reference":24,"collateral_quote":"5000.00","fee_quote":"500.00","margin_terms":{"maintenance_margin_pct":70,"call_cure_minutes":30},"settlement":{"chain":"polygon","currency":"USDC","receive_wallet_address":"0xAcmeMmReceiveWallet","payout_chain":"polygon","payout_currency":"USDC","payout_wallet_address":"0xAcmeMmPayoutWallet"},"valid_until":"2026-08-04T13:42:10.000Z","min_fill_notional":"10000.00","max_fill_notional":"50000.00"}'{
"bid_id": "bid_acme_2026-08-04_000142",
"rfq_id": "rfq_01HNAZK3YQW7PM6T4D8X2V5B9C",
"status": "accepted",
"received_at": "2026-08-04T13:42:01.004Z"
}You quote three economic terms: quoted_rate (the FX rate), collateral_quote (how much collateral you want Crebit to post to your wallet; can be 0), and fee_quote (your compensation, kept regardless of outcome). Crebit scores bids on the blended cost of the hedge across all three; the best-total-cost bid wins. On allocation, Crebit broadcasts (collateral_quote + fee_quote) to your receive_wallet_address in one tx.
You also pre-commit margin terms in margin_terms: maintenance_margin_pct (fire a margin call to Crebit when your posted collateral drops below this % of required), call_cure_minutes (how long Crebit has to top up before the slice auto-unwinds). These terms are locked into the contract at allocation — no surprises later. See Margin calls.
Oracle is fixed by the RFQ. The reference_market.oracleon the RFQ is the settlement tape for the contract's entire life — margin-call MTM and exercise pricing both read from it. The bid has no oracle field; submitting a bid implies acceptance. If you don't trade on that oracle, pass on the RFQ.
Other field notes. spread_bps_vs_reference is signed: positive = quoted_rate is worse for the partner than reference_market.rate (your edge). Must agree with quoted_rate within 0.5 bps or the bid is rejected with 422 spread_inconsistent. Idempotency-Key is a UUID you mint (8–256 chars), per the idempotency rules.
Choosing Your Settlement Rails
Three mutually-exclusive shapes, in order of preference:
- Default — match the RFQ. Send
settlementwith the same chain / currencies the partner requested. Shown in the main example above. - Onboarded rails — omit both. Skip
settlementandalternate_settlementand Crebit resolves from your onboarded profiles. Rejected with422 no_matching_railif no profile matches the RFQ or any partner-allowed fallback. - Alternate chains —
alternate_settlement. If you can't settle on the requested chain, send a list of (chain, wallets) you can settle on. Crebit considers the bid only when the partner opted into fallback rails for that corridor.
{
"bid_id": "bid_acme_2026-08-04_000144",
"rfq_id": "rfq_01HNAZK3YQW7PM6T4D8X2V5B9C",
"quote_id": "22222222-2222-4222-8222-222222222222",
"quoted_rate": "5.4312",
"spread_bps_vs_reference": 24,
"collateral_quote": "5000.00",
"fee_quote": "500.00",
"margin_terms": {
"maintenance_margin_pct": 70,
"call_cure_minutes": 30
},
"valid_until": "2026-08-04T13:42:10.000Z",
"min_fill_notional": "10000.00",
"max_fill_notional": "50000.00"
}{
"bid_id": "bid_acme_2026-08-04_000143",
"rfq_id": "rfq_01HNAZK3YQW7PM6T4D8X2V5B9C",
"quote_id": "22222222-2222-4222-8222-222222222222",
"quoted_rate": "5.4305",
"spread_bps_vs_reference": 23,
"collateral_quote": "5000.00",
"fee_quote": "500.00",
"margin_terms": {
"maintenance_margin_pct": 70,
"call_cure_minutes": 30
},
"alternate_settlement": [
{
"chain": "solana",
"currency": "USDC",
"receive_wallet_address": "So11111111111111111111111111111111111111112",
"payout_chain": "solana",
"payout_currency": "USDC",
"payout_wallet_address": "So11111111111111111111111111111111111111113"
},
{
"chain": "polygon",
"currency": "USDT",
"receive_wallet_address": "0xAcmeMmPolygonCollateral",
"payout_chain": "polygon",
"payout_currency": "USDT",
"payout_wallet_address": "0xAcmeMmPolygonPayout"
}
],
"valid_until": "2026-08-04T13:42:10.000Z",
"min_fill_notional": "10000.00",
"max_fill_notional": "50000.00"
}Partial Fills
min_fill_notional and max_fill_notionaltogether describe the slice you'll accept:
- All-or-nothing (default): omit
min_fill_notionalor set it equal tomax_fill_notional. You only get filled if you can take the whole RFQ. - Partial-fill eligible: set
min_fill_notionalbelowmax_fill_notional. Crebit may fill any amount inside[min, max]; the exact slice is on the allocation asallocated_notional. - Bidding bigger than the RFQ: fine, and in fact encouraged.
max_fill_notional>RFQ notional means you're willing to take the whole ticket; Crebit caps at the RFQ size.
Collateral, premium, and payout amounts on every subsequent event are computed on your allocated slice, not the full RFQ. Each MM on a partially-filled contract gets their own mm_allocation_id and their own stream of funding / exercise / payout events; co-MM rates and identities are not disclosed.
3. Allocation (Crebit → Winning MMs)
At bidding_closes_at Crebit runs a price-time waterfall: best quoted_ratefor the partner first, fill up to that bid's max_fill_notional, move to next-best, repeat until the RFQ notional is covered. Ties on price broken by earliest bid receipt. A bid is skipped if the remaining RFQ notional is below its min_fill_notional; if every remaining bid is skipped (no viable slices left) Crebit internalizes the residual.
Each winning MM receives one rfq.allocated webhook keyed on a unique mm_allocation_id. The fx_contract_id is shared across co-MMs on the same contract — always address downstream events (funding, exercise, payout) by mm_allocation_id to target your slice unambiguously. Non-winners are not notified and can assume they lost once bidding_closes_at + 5s passes with no allocation.
allocation_share carries total_contract_notional, your_share_pct, co_mm_count (OTHER MMs; may hold unequal shares), and fill_type (full or partial). Funding is always Crebit → MM. Return 2xx within 10 s; otherwise Crebit retries with exponential backoff for up to 24 h.
{
"event_id": "evt_mm_alloc_9c2f8b1d6a3e4a7e",
"event_type": "rfq.allocated",
"delivered_at": "2026-08-04T13:42:05.900Z",
"rfq_id": "rfq_01HNAZK3YQW7PM6T4D8X2V5B9C",
"quote_id": "22222222-2222-4222-8222-222222222222",
"bid_id": "bid_acme_2026-08-04_000142",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260524-7F3A9C2B1D",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"contract_type": "forward",
"allocated_notional": "50000.00",
"allocated_rate": "5.4312",
"allocation_share": {
"total_contract_notional": "100000.00",
"your_share_pct": 50,
"co_mm_count": 1,
"fill_type": "partial"
},
"funding": {
"total_amount": "5500.00",
"collateral_amount": "5000.00",
"fee_amount": "500.00",
"currency": "USDC",
"chain": "polygon",
"due_by": "2026-08-04T13:45:00.812Z",
"confirmation_target": 50,
"source_wallet_address": "0xCrebitPaymentsWallet",
"destination_wallet_address": "0xAcmeMmReceiveWallet"
},
"margin_terms": {
"maintenance_margin_pct": 70,
"call_cure_minutes": 30
},
"payout_rails": {
"chain": "polygon",
"currency": "USDC",
"source_wallet_address": "0xAcmeMmPayoutWallet",
"destination_wallet_address": "0xCrebitMmPayoutEscrow"
}
}4. Funding Leg
One direction, every time: Crebit broadcasts (collateral_quote + fee_quote)from the winning bid to the MM's receive_wallet_address in a single on-chain tx, POSTs mm.funding_sent with the hash, and fires mm.funding_confirmedonce Crebit's indexer reaches the chain's confirmation_target. The contract flips to active only after confirmation. For options where the MM quoted collateral_quote: 0, the mechanics are identical — the amount sent is just the premium share.
Chain Confirmation Targets
Solana: finalized Tower-BFT commitment. Tron: SR-confirmations (Super Representative signatures, Tron's finality primitive). Base: block depth to reorg-safe (Base inherits L1 anchoring but Crebit watches L2 depth). Arbitrum: L2 sequencer-block depth past acknowledgment. Polygon: block depth to practical-safety threshold (full Heimdall finality is ~256 blocks and governs reorg-claim resolution deeper than 50; the 50-block target keeps funding and payout confirmations inside the 3-min broadcast SLA on normal days). Crebit's indexer applies the number below before firing mm.funding_confirmed; the same targets govern mm.payout_confirmedfor the MM's exercise and expiry-return broadcasts.
| Chain | Confirmation target |
|---|---|
| solana | 32 confirmations (finalized) |
| base | 30 blocks |
| arbitrum | 180 blocks |
| polygon | 50 blocks |
| tron | 19 SR-confirmations |
The 3-Min Broadcast SLA (due_by)
Everywhere in this doc, "3 minutes" means 3 minutes measured from allocation_time — the UTC timestamp Crebit stamps on the rfq.allocated event when the auction closes. Not from when your webhook receives it (delivery adds a few hundred ms) and not from any local clock. Crebit computes the deadline against allocation_time; your clock is only used to schedule the broadcast against that deadline.
funding.due_by on the allocation is min(allocation_time + 3 min, window_start − 30 s). Miss it and the allocation reverts automatically — a Crebit-side SLA miss, no MM rating impact. Pre-fund the chains you declared; bridges are not reliable inside the 3-min window.
Crebit Sends Collateral + Fee to You, in One Tx
At allocation Crebit broadcasts a single on-chain payment to your receive_wallet_address: total_amount = collateral_amount + fee_amount, both taken directly from your winning bid. You hold both for the life of the contract. Collateral is returned to Crebit on expiry (or netted against FX delta on exercise). Fee is yours to keep regardless. For options allocations where you quoted collateral_quote: "0", this is just the premium share.
Crebit broadcasts within 3 min of allocation_time and POSTs mm.funding_sent with the transaction_hash:
{
"event_id": "evt_mm_funding_sent_a1b2c3",
"event_type": "mm.funding_sent",
"delivered_at": "2026-08-04T13:42:12.000Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260524-7F3A9C2B1D",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"funding": {
"total_amount": "5500.00",
"collateral_amount": "5000.00",
"fee_amount": "500.00",
"currency": "USDC",
"chain": "polygon",
"transaction_hash": "0xa1b2c3d4e5f6…",
"source_wallet_address": "0xCrebitPaymentsWallet",
"destination_wallet_address": "0xAcmeMmReceiveWallet",
"submitted_at": "2026-08-04T13:42:11.800Z",
"confirmation_target": 50
}
}Crebit's indexer then fires mm.funding_confirmed once confirmation_target is reached, which flips the contract to active. If Crebit misses the 3-min broadcast SLA, the allocation reverts automatically at no cost to the MM (Crebit-side SLA, your rating is unaffected).
{
"event_id": "evt_mm_funding_confirmed_b2c3d4",
"event_type": "mm.funding_confirmed",
"delivered_at": "2026-08-04T13:44:15.000Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260524-7F3A9C2B1D",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"funding": {
"total_amount": "5500.00",
"collateral_amount": "5000.00",
"fee_amount": "500.00",
"currency": "USDC",
"chain": "polygon",
"transaction_hash": "0xa1b2c3d4e5f6…",
"block_number": 21400150,
"confirmations": 50,
"confirmed_at": "2026-08-04T13:44:12.000Z"
},
"contract_status": "active"
}Margin Calls (MM → Crebit)
Forwards only.Margin calls apply when the MM is holding Crebit's collateral (collateral_quote > 0). Options bids (collateral_quote: "0") still send margin_terms on the wire — Crebit ignores them on options allocations and never emits crebit.margin_call_ack. The 422 margin_terms_missing rejection only applies to forward bids.
You hold Crebit's collateral. As the contract marks to market (MTM — the running revaluation of your exposure at current oracle), your posted_collateral / required_collateral ratio changes. If it drops below the maintenance_margin_pct you committed in your bid, you fire a margin call to Crebit. Crebit then has call_cure_minutes (also from your bid) to either top up or unwind the slice.
POST the Margin Call
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/mm/margin-calls" \
-H "Content-Type: application/json" \
-H "X-Crebit-Mm-Handle: mm_acme" \
-H "X-Crebit-Mm-Key-Id: mmk_sbx_…" \
-H "X-Crebit-Mm-Key-Secret: mms_…" \
-H "X-Crebit-Environment: sandbox" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"fx_contract_id":"33333333-3333-4333-8333-333333333333","mm_allocation_id":"mma_01HNAZK3Z7X8Y9P2M4N6V8B9C","called_at":"2026-08-05T14:30:00.000Z","mtm":{"reference_rate_at_call":"5.4680","oracle_source":"redstone","posted_collateral":"5000.00","required_collateral_at_mtm":"7500.00","cushion_pct":67},"requested_top_up_amount":"2500.00","currency":"USDC","chain":"polygon","destination_wallet_address":"0xAcmeMmReceiveWallet"}'Crebit's Decision
Crebit acks via crebit.margin_call_ack within seconds. Two possible decisions:
decision: "topping_up"— Crebit will broadcast the top-up to your receive wallet beforetop_up.due_by. Tx hash follows viacrebit.topup_sent; confirmation viamm.funding_confirmed.decision: "unwinding"— Crebit closes the slice at the current MTM. You keep the collateral you already hold plus any delta owed to you; the slice moves tounwound. No MM-side penalty.
{
"event_id": "evt_mm_margin_ack_b8c9d0",
"event_type": "crebit.margin_call_ack",
"delivered_at": "2026-08-05T14:30:04.000Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"margin_call_received_at": "2026-08-05T14:30:00.000Z",
"decision": "topping_up",
"top_up": {
"amount": "2500.00",
"currency": "USDC",
"chain": "polygon",
"destination_wallet_address": "0xAcmeMmReceiveWallet",
"due_by": "2026-08-05T15:00:00.000Z"
}
}Top-Up Sent
{
"event_id": "evt_mm_topup_sent_c9d0e1",
"event_type": "crebit.topup_sent",
"delivered_at": "2026-08-05T14:35:00.000Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"top_up": {
"amount": "2500.00",
"currency": "USDC",
"chain": "polygon",
"transaction_hash": "0xd4e5f6a7b8c9…",
"source_wallet_address": "0xCrebitPaymentsWallet",
"destination_wallet_address": "0xAcmeMmReceiveWallet",
"confirmation_target": 50
}
}If Crebit misses top_up.due_by after promising to top up, the slice auto-unwinds at MTM as if Crebit had chosen "unwinding" upfront — you're made whole from the collateral already in your wallet plus any shortfall owed. Crebit-side SLA; your rating is unaffected.
Margin call racing exercise. If mm.exercise_called fires while a margin top-up is in-flight, Crebit cancels the pending top-up and treats the exercise as the authoritative settlement. Any already-broadcast top-up amount is netted by Crebit against the exercise obligation; the MM does not owe or expect anything on the cancelled cure leg.
Race Conditions
- Window starts before Crebit funding confirms. If Crebit's funding tx is still unconfirmed at
execution_window.window_start, Crebit reverts the allocation, internalizes the exposure, and firesmm.allocation_reverted(fields:event_id,event_type: "mm.allocation_reverted",fx_contract_id,mm_allocation_id,revert_reason["funding_not_confirmed_by_window_start"|"exercise_before_funding_confirmed"|"crebit_internalized"]). The collateral stays with Crebit — if the funding tx later confirms on-chain, Crebit sweeps it back. Crebit-side issue; MM rating unaffected. - Exercise fires before funding confirms. Same as above — allocation reverted, Crebit internalizes, no MM payout obligation. The partner path is unaffected.
- Chain reorg after funding_confirmed. Crebit reverts the
funding_confirmedstate if the tx un-finalizes before the chain's hard-finality depth, and re-emitsmm.funding_confirmedonce a replacement tx reconfirms. Partner-side events do not fire while reorged. - Chain reorg after payout_confirmed.Crebit watches the MM's payout tx to the same hard-finality depth. If it un-finalizes, the slice flips back to
payout_submittedand Crebit emitsmm.payout_rebroadcast_requestedwith a fresh grace window matching the chain's typical wall time. Only rebroadcast on receipt of that event — a spontaneous rebroadcast risks a double-spend from the MM's payout wallet. - Expiry during an open dispute.
mm.contract_expiredfires on schedule regardless of dispute status, but thecollateral_return_due.due_byclock stays paused untilmm.dispute_resolved; the MM may hold the collateral in the interim without default risk. - Allocation reverts are never re-auctioned. Crebit internalizes any reverted slice; the RFQ does not re-fan to other MMs and your co-MMs' allocations are unaffected.
- MM webhook down for > 1 h. Crebit auto-pauses your corridor (same semantics as
POST /pause) and stops issuing RFQs until you ack three consecutive health probes. In-flight contracts still deliver via the 24-h retry queue; a webhook outage does not by itself trigger a default. - Duplicate allocation. Crebit may re-deliver
rfq.allocatedif your 2xx was lost. Dedupe onevent_id; the second delivery carries identical funding instructions. - Insufficient liquidity. If the waterfall fills less than 100% of the RFQ and the partner allowed it, Crebit internalizes the residual silently. You are only notified about your own slice; the total shown on your allocation (
total_contract_notional) may be less than the partner's requested notional. - Co-MM default. Another MM on the same contract missing their payout does NOT affect your slice. Crebit covers the customer from reserve and settles with that MM independently; your
mm.exercise_calledandmm.payout_confirmedcycle is unchanged.
5. Contract Active
The lock is live. The customer may exercise at any moment between execution_window.window_start and execution_window.window_end. Nothing happens on the MM side until exercise or expiry.
6. Exercise & Payout
When the partner POSTs contract_exercised, Crebit computes the FX delta against the agreed oracle and, if the lock was favorable to the customer (MM owes something), fires mm.exercise_called. The MM must broadcast payout_due.amountto Crebit's payout escrow by payout_due.due_by— the SLA is on broadcast time, not confirmation; chain confirmation follows at the chain's typical wall. Crebit pays the customer out of its own reserve immediately — the MM's payout backfills that reserve. If the lock settled customer-unfavorable (MM owes nothing), mm.exercise_called does not fire and the slice goes directly to settled on the exercise event; the MM keeps the fee and the full held collateral is returned under the same expiry path.
Formula is corridor-directional. For a USD_TO_X lock (customer sold USD): payout = notional_amount × max(0, settlement_rate_used − locked_rate). For an X_TO_USD lock (customer bought USD): payout = notional_amount × max(0, locked_rate − settlement_rate_used). Crebit computes and sends the signed amount; the MM should not re-derive from the rates.
Partial partner exercise. If the partner exercises only part of the total notional, every co-MM gets their own mm.exercise_called pro-rata: notional_amount = allocated_notional × exercise_fraction, echoed in exercise.exercise_fraction on the event. A later exercise on the remaining notional fires a second mm.exercise_called with a new event_id and the residual fraction.
{
"event_id": "evt_mm_exercise_called_c3d4e5",
"event_type": "mm.exercise_called",
"delivered_at": "2026-08-14T13:42:00.812Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260524-7F3A9C2B1D",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"exercise": {
"locked_rate": "5.4312",
"partner_live_execution_rate": "5.5100",
"oracle_source": "redstone",
"oracle_live_execution_rate": "5.5080",
"oracle_stale": false,
"settlement_rate_used": "5.5100",
"oracle_clamp_applied": false,
"notional_amount": "50000.00",
"notional_currency": "USD",
"total_contract_notional": "100000.00",
"exercise_fraction": 1,
"executed_at": "2026-08-14T13:41:58.000Z"
},
"payout_due": {
"amount": "3940.00",
"currency": "USDC",
"chain": "polygon",
"destination_wallet_address": "0xCrebitMmPayoutEscrow",
"due_by": "2026-08-14T13:52:00Z",
"confirmation_target": 50,
"calculation_formula": "payout = notional_amount × max(0, settlement_rate_used - locked_rate) // USD_TO_BRL direction"
}
}oracle_live_execution_rateis Crebit's oracle read at exercise time and is authoritative. The oracle per corridor is fixed at contract creation and reported on oracle_source: Redstone for BRL and stablecoin pairs (USDC/USDT); Chainlinkfor major fiat FX (EUR, CHF, JPY, GBP). MMs should pull from the same feed before broadcasting. Chainlink's fiat FX feeds follow traditional market hours (Sun 18:00 ET → Fri 17:00 ET); during the weekend closeoracle_live_execution_rate holds the last Friday value and oracle_stale: true is set on the event. Price your fiat-corridor bids with this in mind. settlement_rate_usedis the partner's reported rate, clamped to within a configured band of the oracle (oracle_clamp_applied: true if the clamp fired). If your own read from the same source differs from oracle_live_execution_rate by more than 10 bps, hold payout and open a dispute (see Disputes) BEFORE payout_due.due_by; otherwise the SLA clock continues and a miss is a default. Partner-side math is at /settlement-preview.oracle_clamp_applied: true) the clamp bounds the partner, not the oracle — a disagreement between your own oracle read and oracle_live_execution_rate remains disputable.Payout Tx Submission
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/mm/payouts" \
-H "Content-Type: application/json" \
-H "X-Crebit-Mm-Handle: mm_acme" \
-H "X-Crebit-Mm-Key-Id: mmk_sbx_…" \
-H "X-Crebit-Mm-Key-Secret: mms_…" \
-H "X-Crebit-Environment: sandbox" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"fx_contract_id":"33333333-3333-4333-8333-333333333333","crebit_contract_reference":"CREBIT-20260524-7F3A9C2B1D","mm_allocation_id":"mma_01HNAZK3Z7X8Y9P2M4N6V8B9C","amount":"3940.00","currency":"USDC","chain":"polygon","transaction_hash":"0xc3d4e5f6a7b8…","source_wallet_address":"0xAcmeMmPayoutWallet","destination_wallet_address":"0xCrebitMmPayoutEscrow","broadcast_at":"2026-08-14T13:44:20.000Z"}'Payout Confirmed
Fired once Crebit's indexer reaches the chain's confirmation target. After this event the MM's obligation on this slice is discharged. Netting is MM-side: you've been holding Crebit's collateral the whole time, so most MMs pay just max(0, payout_due.amount − collateral_amount) out of their own wallet and keep the remaining collateral as Crebit's refund (what they'd otherwise return on expiry). Either way the payout_due.amount Crebit expects on-chain is the full FX delta — net on your side before broadcasting.
{
"event_id": "evt_mm_payout_confirmed_d4e5f6",
"event_type": "mm.payout_confirmed",
"delivered_at": "2026-08-14T13:46:25.000Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260524-7F3A9C2B1D",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"payout": {
"amount": "3940.00",
"currency": "USDC",
"chain": "polygon",
"transaction_hash": "0xc3d4e5f6a7b8…",
"block_number": 21832250,
"confirmations": 50,
"confirmed_at": "2026-08-14T13:46:22.000Z"
},
"contract_status": "settled"
}Disputes
Open when you have concrete evidence the exercise settlement is wrong — oracle divergence, chain reorg, or wallet compromise. Opening BEFORE the live due_by pauses the SLA clock (any of payout_due, collateral_return_due, top_up, or the margin cure window via category: "other"). Opening after has no effect.
Inline proof only. Attach evidence as structured JSON under proof (oracle reads, tx hashes, any numeric observations). Crebit does not fetch external URLs you supply — SSRF hardening — so a payload_proof_url link is ignored and will delay review. Anything requiring a file (OFAC screenshots, legal letters) goes through your integration-lead channel out of band. Max proof size is 32 KB serialized.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/mm/disputes" \
-H "Content-Type: application/json" \
-H "X-Crebit-Mm-Handle: mm_acme" \
-H "X-Crebit-Mm-Key-Id: mmk_sbx_…" \
-H "X-Crebit-Mm-Key-Secret: mms_…" \
-H "X-Crebit-Environment: sandbox" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"fx_contract_id":"33333333-3333-4333-8333-333333333333","event_reference":"CREBIT-20260524-7F3A9C2B1D","category":"oracle_rate_spike","mm_observed_rate":"5.4904","mm_observed_at":"2026-08-14T13:41:58.000Z","mm_observed_source":"redstone","proof":{"oracle_reads":[{"source":"redstone","block_number":21831990,"rate":"5.4904","observed_at":"2026-08-14T13:41:57.800Z"},{"source":"redstone","block_number":21831991,"rate":"5.4910","observed_at":"2026-08-14T13:41:59.900Z"},{"source":"redstone","block_number":21831992,"rate":"5.5076","observed_at":"2026-08-14T13:42:01.200Z"}],"tx_hashes":["0xa1b2c3d4e5f6…"],"notes":"Three-block spike in redstone before correction."},"comment":"Redstone feed spiked 32 bps for 3 blocks before correcting; disputing settlement_rate_used."}'Crebit acks synchronously with { dispute_id, status: \"under_review\", sla_clock_paused: true, opened_at }. event_reference on the request echoes crebit_contract_reference and is used by Crebit ops ticketing — pasting it into the shared Slack opens the same ticket as the dispute . Resolution happens out of band (ops ticket, typically minutes for operational disputes, longer for compromise claims). While a dispute is open, the MM-side slice status is disputed and no SLA breaches accrue. On resolution Crebit emits mm.dispute_resolved with resolution set to upheld (payout voided or re-priced per the ticket) or rejected (SLA clock resumes with a grace of 5 min).
7. Terminal States
Expired (No Exercise)
Window ended without the customer transacting. For options, the MM keeps the premium and the webhook is a terminal notification. For forwards, Crebit fires mm.contract_expired with a collateral_return_dueblock; the MM broadcasts the held collateral back to Crebit's payout escrow using the same POST /api/v1/fx/mm/payouts endpoint as exercise and posts the tx hash. The contract reaches collateral_returnedonce Crebit's indexer confirms. A miss is a default — same consequence as a payout-SLA miss. The longer 1 h window (vs 10 min on exercise) is deliberate: no customer is waiting on an expiry return, so the SLA is sized for operational slack rather than customer UX.
{
"event_id": "evt_mm_expired_e5f6a7",
"event_type": "mm.contract_expired",
"delivered_at": "2026-08-18T00:01:30.000Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260524-7F3A9C2B1D",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"contract": {
"contract_type": "forward",
"expired_at": "2026-08-18T00:00:00Z"
},
"collateral_return_due": {
"amount": "5000.00",
"currency": "USDC",
"chain": "polygon",
"destination_wallet_address": "0xCrebitMmPayoutEscrow",
"due_by": "2026-08-18T01:00:00Z",
"confirmation_target": 50
},
"contract_status": "expired"
}Settled
Terminal success after exercise and payout confirmation. No separate webhook; the mm.payout_confirmed event carries contract_status: "settled".
Default Handling
Crebit alwaysfronts the customer payout from its own operating reserve the moment exercise fires — customer UX is never gated on an MM's tx. The MM's on-chain payout backfills that reserve inside the payout SLA. A default is what happens when the backfill never arrives:
- MM missed
payout_due.due_by→ Crebit auto-nets whatever collateral the MM was still holding (for forwards, up to the full held amount; for options, 0) against the amount owed. - Any remaining shortfall is Crebit's unrecovered loss on that slice, pursued through MM rating + legal recourse under the master services agreement.
- Defaults are scoped to the MM allocation, not the contract — co-MMs on the same
fx_contract_idare unaffected and continue through their ownmm.payout_confirmedcycle.
{
"event_id": "evt_mm_default_f6a7b8",
"event_type": "mm.defaulted",
"delivered_at": "2026-08-14T13:53:00.000Z",
"fx_contract_id": "33333333-3333-4333-8333-333333333333",
"crebit_contract_reference": "CREBIT-20260524-7F3A9C2B1D",
"mm_allocation_id": "mma_01HNAZK3Z7X8Y9P2M4N6V8B9C",
"default_reason": "payout_sla_missed",
"default_detail": "No payout tx broadcast by due_by 2026-08-14T13:52:00Z.",
"unrecovered_amount": {
"amount": "3940.00",
"currency": "USDC",
"recourse": "legal"
},
"mm_rating_impact": -25,
"contract_status": "defaulted"
}Repeated defaults trigger graduated throttling: first default in a 30-day window is a rating hit only; second pauses RFQ fan-out for 24 h; third suspends pending review. Suspension stops new fan-out but in-flight slices run to terminal state; POST /bids returns 403 mm_suspended. rating on the snapshot runs 0–1000 (new MMs start at 1000); fan-out weight halves below 900 and the MM is suspended below 700.
Pause & Unpause
Step out cleanly instead of silently ignoring RFQs. In-flight contracts continue; RFQs already delivered to you before pause remain eligible to bid on; no NEW RFQs are issued to you (optionally scoped to specific corridors) until you unpause or expires_at passes. Paused is not defaulted, there is no rating impact.
curl -sS -X POST "https://lock-apis-sandbox.crebitpay.com/api/v1/fx/mm/pause" \
-H "Content-Type: application/json" \
-H "X-Crebit-Mm-Handle: mm_acme" \
-H "X-Crebit-Mm-Key-Id: mmk_sbx_…" \
-H "X-Crebit-Mm-Key-Secret: mms_…" \
-H "X-Crebit-Environment: sandbox" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"reason":"scheduled_maintenance","comment":"Deploying new pricing model; back online 14:30 UTC.","expires_at":"2026-08-04T14:30:00Z","scope":{"corridors":["USD_TO_BRL","BRL_TO_USD"]}}'POST /api/v1/fx/mm/unpause (empty body, same headers) resumes immediately. Omit scope.corridors to pause globally; omit expires_at for an indefinite pause that only unpause clears.
SLAs by Phase
| Phase | SLA | Breach consequence |
|---|---|---|
| RFQ webhook ack | 2xx within 10 s — receipt ack only; the bid-submission deadline is bidding_closes_at (≈ 5 s), not this ack. | RFQ counted as a miss; throttles fan-out below 95% 7-day. |
| Bid submission | Any time before bidding_closes_at (≈ 5 s auction) | Bid excluded; no penalty for passing. |
| Funding (Crebit → MM) | Crebit broadcasts collateral + fee within 3 min of allocation_time (the timestamp on the rfq.allocated event, not webhook receipt), POSTs mm.funding_sent, confirmation within the chain's wall time. | Crebit-side SLA. Allocation auto-reverts; MM rating unaffected. |
| Margin-call top-up (Crebit → MM) | Crebit broadcasts the top-up within the MM's bid-committed call_cure_minutes, POSTs crebit.topup_sent with tx hash. | Slice auto-unwinds at MTM; MM made whole from the collateral already held plus any shortfall. No MM penalty. |
| Payout broadcast (exercise, MM → Crebit) | Broadcast within 10 min of mm.exercise_called. May be netted against the collateral you're already holding. | Default: Crebit covers customer from own reserve; pursues unrecovered portion via legal recourse + MM rating hit + graduated throttling. |
| Collateral return (MM → Crebit, expiry) | MM broadcasts the held collateral back to Crebit's payout escrow within 1 h of mm.contract_expired (collateral_return_due.due_by). | Default — same consequence as a payout miss: Crebit pursues legally, MM rating hit + graduated throttling. |
Reconciliation
GET /api/v1/fx/mm/positions/snapshot?as_of=YYYY-MM-DDreturns an authoritative end-of-day position snapshot, use this to reconcile against your own books. Available 15 min after 23:59 UTC each day; last 90 days kept online.
{
"mm_handle": "mm_acme",
"api_version": "2026-08-01",
"as_of": "2026-08-04T23:59:59Z",
"open_contracts": 47,
"open_exposure": {
"USD_TO_BRL": {
"notional_usd_equivalent": "1250000.00",
"worst_case_payout_usdc": "62500.00"
},
"USD_TO_MXN": {
"notional_usd_equivalent": "480000.00",
"worst_case_payout_usdc": "24000.00"
}
},
"crebit_collateral_you_are_holding": {
"USDC": "235000.00"
},
"ytd_fees_received": {
"USDC": "150000.00"
},
"settled_today": {
"contracts": 12,
"volume_usd_equivalent": "420000.00",
"pnl_usdc": "3214.50"
},
"defaulted_today": 0,
"rating": 982
}Operations
- Event replay / catch-up.
GET /api/v1/fx/mm/events?since=<event_id>&limit=<N>returns up toN(max 500) events delivered to your webhook since the given id, oldest first; emptysincestarts at the 24-h retention cutoff. When more events remain the response carriesnext_since; call again with that value to page through. Use this to recover from a webhook outage, drive a one-off resync, or verify a specific event you suspect you missed. Response shape matches what Crebit POSTed; the signature header is re-computed, so verify as usual. Events older than 24 h fall off the hot store — reconcile via the daily snapshot above. - Payload versioning. All webhook bodies and API responses are strictly additive within a major version; unknown fields never appear without a version bump. Crebit sends
X-Crebit-Api-Version: YYYY-MM-DDon every webhook and every API response; pin or log it. Breaking changes ship as a new dated version with a minimum 90-day overlap during which both versions are served. The currently-targeted version is also echoed in your/positions/snapshotresponse asapi_versionfor quick inspection. - Pricing reference. Realized spreads and partner-side execution rates across every live corridor are streamed on the internal Hedge dashboard and exported daily to your reconciliation snapshot (
settled_today.pnl_usdc). Crebit does not publish a targetfee_quoteorcollateral_quote— price your own cost of carry + hedge slippage. Reference-market mid is on every RFQ asreference_market.rate. - Support for non-dispute issues.Disputes are for oracle / reorg / wallet compromise with an in-flight SLA clock. For anything else — 5xx responses, double-charges you can't trace to a specific contract, webhook-ack mismatches, onboarding changes — email
jensen@getcrebit.comor ping your integration lead in the shared Slack. Include at minimum:event_idorcrebit_contract_reference, timestamps (UTC with ms), chain tx hashes, and the exact request /response your service recorded.
Sandbox & Testing
Sandbox mirrors production on separate hosts and keys. No real stablecoin moves; faucet-funded addresses and a deterministic oracle let you exercise every branch of the lifecycle in CI. The /testing/* endpoints below exist only on the sandbox host; they return 404 not_in_production if called against prod.
- Faucet addresses — per chain, published on request. The faucet pre-funds your onboarded receive / payout wallets with sandbox USDC on registration and tops them up nightly.
- Replay partner traffic: ask ops to enable
mm_rfq_replayand Crebit will re-fan the last 24 h of anonymized production RFQs to your sandbox endpoint, letting you pressure-test pricing at real rates / volumes. - Force a lifecycle branch:
POST /api/v1/fx/mm/testing/force-exercisewith{ fx_contract_id, settlement_rate_override? }firesmm.exercise_calledon demand (usesettlement_rate_overrideto drive a specific payout_due amount or triggeroracle_clamp_applied: true). Sibling endpoints:/testing/force-expire,/testing/force-reorg(payload specifies depth and the tx hash to un-finalize),/testing/force-default. - Deterministic oracle: in sandbox, Crebit's oracle-fetcher reads from an overridable store instead of the live feed. Pin a rate via
PUT /api/v1/fx/mm/testing/oracle/{source}with{ rate, valid_until }; the override is served tomm.exercise_called.oracle_live_execution_rateand to margin-call MTM untilvalid_until. Lets you reproduce an oracle-spike dispute scenario exactly. - CI patterns: wrap every integration test in a unique
Idempotency-Keyprefix so parallel runs don't collide, and dedupe your assertion harness onevent_id. The sandbox retry queue mirrors production (24 h, exponential backoff).
Scalability & Retries
- Throughput target: 10 RFQ/s per corridor sustained, bursts to 50 RFQ/s; 1 inbound webhook per contract on funding, exercise, and terminal events.
- Fan-out concurrency: Crebit fans each RFQ to all qualifying MMs in parallel. Expect up to
N × RFQ/stotal load where N is the number of MMs qualifying for a corridor. - RFQ idempotency: dedupe on
rfq_id. Crebit never retriesrfq.issued; a missed RFQ is a missed bid. - Allocation / funding / exercise / payout retries: exponential backoff for 24 h on any non-2xx. Use
event_idas your idempotency key — Crebit can and will deliver the same event twice. - Bid submission: send
Idempotency-Key. Same key + same body returns the original response; a new key with the samerfq_idreplaces the previous bid if the auction is still open. - Payout POST idempotency: keyed on
fx_contract_id + mm_allocation_id. Safe to retry after network blips; a differenttransaction_hashon the same key returns409 payout_already_declared. - Margin-call POST idempotency: keyed on
mm_allocation_id + called_at(ms precision). Resubmitting the same call within 60 s returns the original Crebit ack. A newcalled_aton the same allocation is treated as a separate call (only the latest pending call is honored). - Dispute POST idempotency: keyed on
fx_contract_id + mm_allocation_id + category. Resubmitting returns the originaldispute_idwhile the dispute is open; a new POST aftermm.dispute_resolvedopens a fresh ticket. - Pause / unpause idempotency: keyed on
scope.corridors(or global when omitted). Same body within 60 s is a no-op and returns the current pause state. Current state is queryable viaGET /api/v1/fx/mm/pause-status, which responds{ paused: true|false, scope: { corridors: [...] }, reason?, expires_at? }. - Crebit 5xx on MM POSTs: retry with the same
Idempotency-Keyusing exponential backoff (1 s, 2 s, 4 s, …, cap 60 s); honorRetry-Afteron any429. Treat a successful retry under the same key as the original submission for all SLA-clock purposes. - Partial fills. Opt-in by setting
min_fill_notional<max_fill_notional. Crebit waterfalls the RFQ across winning bids; any residual that no viable slice covers is internalized by Crebit. - Clock skew tolerance: ±5 s. Sign-and-verify will reject beyond that.
Auth & Signatures
- Inbound webhooks (receive-side, Crebit → MM) use the
webhook_signing_secret. Every outbound POST from Crebit carriesX-Crebit-Signature: t=<unix_ms>,v1=<hex>plusX-Crebit-Event: <event_type>for cheap routing without parsing the body. The MM MUST do three checks before trusting a payload: (1) body size ≤ 1 MiB and matchesContent-Lengthexactly (reject truncated or oversized bodies before any hashing); (2)twithin ±5 s of your NTP-synced clock; (3) constant-time comparev1againstHMAC-SHA256(webhook_signing_secret, "$t.$raw_body"). Reference implementation below. The RFQ example in §1 shows these headers; every other Crebit → MM webhook carries the same pair. The two-secret split (webhook vs API) follows the same pattern as Stripe and Square — keeping the keys scoped by direction means a leaked outbound API key cannot forge inbound webhooks, and vice versa. - Outbound POSTs (push-side, MM → Crebit) use the key pair. Four headers on every POST:
X-Crebit-Mm-Handle,X-Crebit-Mm-Key-Id,X-Crebit-Mm-Key-Secret, andX-Crebit-Environment(sandboxorproduction). The key pair is a different credential from thewebhook_signing_secretabove — they are minted separately at onboarding, rotated independently, and never cross-authorize. The handle is the stable anonymized id Crebit shows partners. Matches the partner API's auth shape exactly, see Authentication. The secret is sent as a plain header (not a body signature) to match the partner API; TLS 1.2+ is mandatory and Crebit will reject the connection otherwise. - Environment separation. Sandbox keys never authorize production endpoints and vice versa; mismatch returns
401 environment_mismatch. TheX-Crebit-Environmentheader must match the key row. Base URLs and env rules are the same as the partner API — see Environments. - IP allowlist (optional).Pass Crebit your egress CIDR range during onboarding to restrict bid / funding / payout POSTs to that source. Crebit's own egress IPs for outbound webhooks are published on request; pin them in your firewall.
- Wallet rotation. Compromised a wallet in a registered rail profile? Open a dispute with category
wallet_compromiseimmediately (freezes in-flight payout obligations on that rail), then email your Crebit integration lead to swap the wallet in the profile. Per-bid wallet overrides keep working in the meantime. - Secret rotation. The two credentials rotate independently — ask your integration lead to roll whichever one you need:
webhook_signing_secret(inbound verify). Crebit signs outbound webhooks with both the old and new secrets concurrently for a 48 h overlap; verify against either during the overlap and drop the old one when traffic settles.X-Crebit-Mm-Key-Id/X-Crebit-Mm-Key-Secret(outbound auth). Both old and new key pairs authorize POSTs for up to 48 h; cut over, then your integration lead revokes the old pair.
Verifying a Webhook (Node.js)
import crypto from "crypto";
// Hard caps — reject anything suspiciously large BEFORE hashing.
const MAX_BODY_BYTES = 1 * 1024 * 1024; // 1 MiB; no legitimate Crebit webhook exceeds this.
const CONTENT_LENGTH_SKEW_BYTES = 0; // bodies arrive intact; mismatch = truncation / tampering.
export function verifyCrebitSignature(
rawBody: Buffer,
headerValue: string,
contentLengthHeader: string | undefined,
webhookSigningSecret: string,
): boolean {
// 1. Length check. Reject oversize or Content-Length mismatches before
// any crypto work (defense-in-depth against truncation attacks and
// DoS via hashing giant bodies).
if (rawBody.byteLength > MAX_BODY_BYTES) return false;
if (contentLengthHeader !== undefined) {
const declared = Number(contentLengthHeader);
if (!Number.isInteger(declared) || declared < 0) return false;
if (Math.abs(declared - rawBody.byteLength) > CONTENT_LENGTH_SKEW_BYTES) return false;
}
// 2. Parse signature header.
const parts = Object.fromEntries(
headerValue.split(",").map((p) => p.split("=") as [string, string]),
);
const t = Number(parts.t);
const v1 = parts.v1;
if (!t || !v1) return false;
// 3. Timestamp window — reject anything more than 5 s off.
if (Math.abs(Date.now() - t) > 5000) return false;
// 4. HMAC over "t.rawBody" using the webhook_signing_secret (NOT the
// outbound X-Crebit-Mm-Key-Secret — those are different credentials).
const expected = crypto
.createHmac("sha256", webhookSigningSecret)
.update(`${t}.`)
.update(rawBody)
.digest();
const given = Buffer.from(v1, "hex");
// 5. Constant-time compare. Length check prevents timingSafeEqual throw.
if (expected.byteLength !== given.byteLength) return false;
return crypto.timingSafeEqual(expected, given);
}Keep the raw request body intact end-to-end — don't re-serialize before hashing. Expose it in your framework by disabling automatic JSON parsing on this route (Express: express.raw({ type: "*/*" }); Fastify: rawBody: true; Next.js API routes: read req.body as a stream).
Common Errors
You'll hit these during integration. Each is returned with { code, message, details }, matching the partner API's error envelope.
| Status | code | When | Fix |
|---|---|---|---|
| 401 | unauthenticated | Missing or wrong X-Crebit-Mm-Key-Id / Secret. | Check your env vars; secrets are per-environment. |
| 401 | environment_mismatch | X-Crebit-Environment header doesn't match the key row. | Sandbox keys only work on sandbox host, and vice versa. |
| 403 | mm_suspended | MM is suspended (rating < 700 or admin-held). In-flight slices still settle. | Resolve with ops; new RFQ fan-out and POST /bids stay refused until unsuspended. |
| 409 | rfq_closed | Bid arrived after bidding_closes_at. | Shorten your pricing loop, or bid earlier. |
| 422 | margin_terms_missing | Forward bid omitted margin_terms.maintenance_margin_pct or call_cure_minutes. | Set both before submitting; options bids (collateral_quote: 0) are exempt. |
| 409 | payout_already_declared | Same (fx_contract_id, mm_allocation_id), different transaction_hash on POST /payouts. | Either reuse the original tx_hash or open a dispute if you need to replace it. |
| 422 | spread_inconsistent | spread_bps_vs_reference disagrees with quoted_rate by > 0.5 bps. | Recompute spread against reference_market.rate before posting. |
| 422 | no_matching_rail | Onboarded-rails-shape bid with no profile matching the RFQ. | Register the rail, or send explicit `settlement` / `alternate_settlement`. |
| 422 | rail_mismatch | Bid's settlement.* doesn't match RFQ's requested_settlement.* (and no alternate opt-in). | Match the RFQ or use alternate_settlement. |
| 422 | margin_call_below_threshold | POST /margin-calls with cushion still above your committed maintenance_margin_pct. | Only call when (posted / required) < maintenance_margin_pct. |
| 422 | min_fill_too_high | min_fill_notional > remaining RFQ notional. | Lower min_fill_notional or accept smaller slices. |
| 422 | valid_until_too_short | valid_until is before bidding_closes_at + 1s. | Extend valid_until past the auction close. |
| 429 | rate_limited | Exceeded per-MM request cap. | Back off per Retry-After header. |
| 404 | not_in_production | /testing/* endpoint called against the production host. | Only available on the sandbox host; gate your test harness on env. |