Accept a quote
POST/rfqs/{rfq_id}/accept
Accepts the winning quote before closes_at. sig signs the quote's trade_template; see TradeTemplate. CRX submits the trade on chain; you send no transaction. The result arrives on GET /trades as trade.opened or trade.refused.
Authentication
x-crx-addressx-crx-tsx-crx-sigx-crx-addressx-crx-signerx-crx-tsx-crx-sigx-crx-session
Parameters
| Name | In | Type | Description |
|---|---|---|---|
rfq_id required | path | string | RFQ ID, 32-byte hex. |
Request body
| Field | Type | Description |
|---|---|---|
quote_id required | string |
|
sig | string | Your account key's |
Responses
200
Quote accepted.
The accepted quote. Follow the trade on GET /trades until trade.opened with no provisional key, or trade.refused.
| Field | Type | Description |
|---|---|---|
rfq_id required | string | |
quote_id required | string |
400
bad_request, seat_not_ready, invalid_signature. bad_request with details.limit tenor: the fixing is too soon for the trade to open; open a new RFQ with a later expiry. notional_below_minimum: at the quote's rate, the trade is below the pair minimum.
code bad_request seat_not_ready notional_below_minimum invalid_signature
401
unauthorized: a header is missing or malformed, x-crx-ts is out of range, the call was already used, the signature does not match, or the caller lacks access.
code unauthorized
403
not_whitelisted: the account is not approved for this call.
code not_whitelisted
404
unknown_rfq: no such RFQ, or no such quote on it that you can read.
code unknown_rfq
408
timeout: no trade sent within 30 seconds. Resend the same body with a new x-crx-ts; it never opens a second trade.
code timeout
409
trade_stale: sign details.trade_template and send again. quote_dropped: the maker withdrew or replaced the quote; details.best is the current winning quote with its trade_template, or null. quote_not_yours: you are not the RFQ's taker, or the quote belongs to another RFQ. rejected: the trade cannot open on this quote; cite details.reject_code to CRX. own_round_open: your previous trade is still in progress; details.rfq_id names it and details.until (Unix time in seconds) is the earliest it clears. market_paused: the pair is paused or delisted. platform_paused: CRX is paused. conflict: the RFQ accepts no more, the trade is on chain, or CRX cannot submit it now and trade.refused follows. nonce_collision.
code trade_stale quote_dropped quote_not_yours rejected own_round_open round_closed market_paused platform_paused conflict nonce_collision
410
rfq_expired, quote_expired.
code rfq_expired quote_expired
413
payload_too_large: the body is over 2 MiB.
code payload_too_large
415
unsupported_media_type: send content-type: application/json.
code unsupported_media_type
422
unprocessable_entity: a field has the wrong type. insufficient_collateral: your free collateral does not cover the margin at the quote's rate. rate_out_of_band: the rate is outside the chain's off-market band from CRX's mark; details carries pair, rate, mark and band_bps. Open a new RFQ.
code unprocessable_entity insufficient_collateral rate_out_of_band
429
rate_limited: retry after Retry-After seconds.
code rate_limited
| Header | Type | Description |
|---|---|---|
Retry-After | integer | Seconds until the next call is accepted. |
ratelimit-limit | integer | Maximum calls in a burst. |
ratelimit-remaining | integer | Calls remaining before the limit. |
ratelimit-reset | integer | Seconds until the full limit is restored. |
ratelimit-refill | integer | Calls restored per minute. |
500
internal: an internal error.
code internal
502
upstream: a chain read failed. Retry shortly.
code upstream
503
collateral_unverified: no current collateral figure. mark_unavailable: no current mark for the pair, or the off-market band cannot be checked yet; details carries pair, plus price_expected_by and price_expected_by_at while the price updates. Retry shortly. withdraw_pending: a pending withdrawal blocks the collateral check; details carries step, reason, expected_by and expected_by_at. service_unavailable: CRX cannot accept a trade now; no trade was sent.
code collateral_unverified mark_unavailable withdraw_pending service_unavailable
Schemas
TradeTemplate
The Trade to sign to accept this quote, as an eth_signTypedData_v4 object in typed_data (see TradeTypedData).
Build your own Trade from your RFQ and this quote. Sign only if every check holds:
- Domain.
nameCRX,versionrulebook-1.0;chainIdandverifyingContractequal thechain_idandcorethatGET /healthserves for your chain. - Type.
primaryTypeisTradeandtypes.Tradeis exactly theTradetype string. - Terms.
pair,side,notionalE6andmaturityequal your RFQ;rateE6equals the quote'srate;premiumBpsequals your RFQ'spremium_bps, within the chain's cap;summaryis the line those fields format to. - Leg ID.
ownLegIdbytes 24–31, big-endian, equal the RFQ'squote_expiry_max. - Nonce.
ownNonceis at most now + 24 hours, in Unix time (milliseconds).
Sign your own object with eth_signTypedData_v4 and send the 65-byte signature, low s and v 27 or 28, as sig to POST /rfqs/{rfq_id}/accept. A wallet that signs only a hash rebuilds the digest from typed_data and compares it with its own first. pairC and ownSalt are used as served.
| Field | Type | Description |
|---|---|---|
typed_data required | object | The An |
typed_data.types required | object | |
typed_data.primaryType required | string |
|
typed_data.domain required | object | |
typed_data.message required | object | The struct's fields. For |
{
"typed_data": {
"domain": {
"chainId": 1,
"name": "CRX",
"verifyingContract": "<core>",
"version": "rulebook-1.0"
},
"message": {
"maturity": "1798732800",
"notionalE6": "5000000000000",
"ownLegId": "0x111111111111111111111111111111111111111111111111000000006ab13dd8",
"ownNonce": "1790000000123",
"ownSalt": "0x3131313131313131313131313131313131313131313131313131313131313131",
"pair": "USD/BRL",
"pairC": "0x3bb28decf99b625916b2a3c41517a2035273e731a71df7b0e9d5c115ce899795",
"premiumBps": "0",
"rateE6": "5410000",
"side": "buy",
"summary": "buy 5 000 000 USD vs BRL at 5.41 BRL per USD, matures 2026-12-31T16:00:00Z, upfront none"
},
"primaryType": "Trade",
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Trade": [
{
"name": "summary",
"type": "string"
},
{
"name": "pair",
"type": "string"
},
{
"name": "side",
"type": "string"
},
{
"name": "notionalE6",
"type": "uint256"
},
{
"name": "rateE6",
"type": "uint64"
},
{
"name": "premiumBps",
"type": "int16"
},
{
"name": "maturity",
"type": "uint40"
},
{
"name": "pairC",
"type": "bytes32"
},
{
"name": "ownLegId",
"type": "bytes32"
},
{
"name": "ownNonce",
"type": "uint64"
},
{
"name": "ownSalt",
"type": "bytes32"
}
]
}
}
}
TradeTypedData
The Trade struct, one line, no space after a comma:
Trade(string summary,string pair,string side,uint256 notionalE6,uint64 rateE6,int16 premiumBps,uint40 maturity,bytes32 pairC,bytes32 ownLegId,uint64 ownNonce,bytes32 ownSalt)
Typehash 0x2a4f432dd51178481baaacab72453a149e29560e5d366c2ebb93bb767fab4630. Build each field from your own RFQ and the quote:
| Field | From | Form |
|---|---|---|
summary | the fields below | one line, rules below |
pair | the RFQ pair | slash form, USDBRL → USD/BRL |
side | the RFQ side | 1 → buy, -1 → sell: your side, in the first currency |
notionalE6 | the RFQ notional | × 10^6, exact; refuse more than 6 decimal places |
rateE6 | the quote rate | × 10^6, exact |
premiumBps | the RFQ premium_bps | signed. Positive: you pay |
maturity | the RFQ expiry | Unix time in seconds, floor(expiry / 1000) |
pairC, ownSalt | the template | as served |
ownLegId | the template | bytes 24–31 equal the RFQ's quote_expiry_max |
ownNonce | the template | at most now + 24 hours, Unix time in milliseconds |
summary: <side> <size> <BASE> vs <QUOTE> at <rate> <QUOTE> per <BASE>, matures <date>, upfront <up>. <size> and <rate> are the integer part, then . and the fraction with trailing zeros cut (no . when whole). <size> groups thousands with one space; <rate> is not grouped. <date> is YYYY-MM-DDTHH:MM:SSZ, UTC. <up> is none, taker pays <P> % or maker pays <P> %. <P> is the premium in basis points / 100, with two decimal places. ASCII only, one space between words, no trailing space.
QuoteTypedData
The Quote a maker signs for POST /rfqs/{rfq_id}/quotes, as an eth_signTypedData_v4 object (see TypedData). The struct, one line, no space after a comma:
Quote(address seat,bytes32 legId,bytes32 pair,int8 side,uint256 notional,uint64 rate,int16 premiumBps,uint40 expiry,uint64 nonce,bytes32 salt,bytes32 takerRef)
Typehash 0x00fc8b1401eebfc809c01d3a7351526ef07cfd5902793c3d279de280c0aec2cb. Domain: name CRX, version rulebook-1.0, and the chain_id and core from GET /health, whose chains[].domain is the separator. Build each field from the RFQ and your quote:
| Field | From | Form |
|---|---|---|
seat | your account | x-crx-address |
legId | your leg_id | 24 random bytes, then quote_expiry_max as 8 bytes big endian |
pair | the RFQ pair | keccak256 of the slash form: USDBRL → keccak256("USD/BRL") |
side | the RFQ side | your side, as the RFQ shows it to you: 1 long base, -1 short |
notional | the RFQ notional | × 10^6, exact |
rate | your rate | × 10^6, exact; refuse more than 6 decimal places |
premiumBps | the RFQ premium_bps | signed |
expiry | the RFQ expiry | Unix time in seconds, floor(expiry / 1000) |
nonce | your leg_id | bytes 16–23, big endian. The body does not send it |
salt | your salt | as sent |
takerRef | the RFQ taker_ref | as served |
Test vector on chain ID 1, with an example core that is not deployed. This schema's example is its typed data; the request example of POST /rfqs/{rfq_id}/quotes is its body.
seat 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
legId 0x555555555555555555555555555555555555555555555555000000006ab13dd8
pair 0x644668ae48a22c7afafcf35ff66ebf9c8af2c396ae03de0795d66bde06cdf851 (keccak256("USD/BRL"))
side -1
notional 5000000000000
rate 5410000
premiumBps 0
expiry 1798732800
nonce 6148914691236517205
salt 0x6161616161616161616161616161616161616161616161616161616161616161
takerRef 0x4f412fb92304015b744b7a32155b5879b48aa8cbb0076b8234640f8891c53b0b
(taker account 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266,
taker leg id 0x111111111111111111111111111111111111111111111111000000006ab13dd8)
chainId 1
core 0x1111111111111111111111111111111111111111
domain 0xc10b07f28873cb547d1ab61e8cacb2c0084fc537ac932f55d21f403a0194785c
structHash 0xfc12020df46e5a207618f5dd4b960ca5dfb75bc5f279d0b168355b5402cbd089
digest 0x66ed64dcb1c180844db51855479f4be2557a3686c64da3c2474f261b4d59d3fc
sig 0xa060dd5965ab39968e1e6f5772969e8617ab2de88eb069e6bee0b67dc07b19600d52812d18a34fa708bbee1755ba6e4d74953120d4e0af7e6b14911510cba9131c
(signed by the seat: the public anvil test key 1)
{
"domain": {
"chainId": 1,
"name": "CRX",
"verifyingContract": "0x1111111111111111111111111111111111111111",
"version": "rulebook-1.0"
},
"message": {
"expiry": "1798732800",
"legId": "0x555555555555555555555555555555555555555555555555000000006ab13dd8",
"nonce": "6148914691236517205",
"notional": "5000000000000",
"pair": "0x644668ae48a22c7afafcf35ff66ebf9c8af2c396ae03de0795d66bde06cdf851",
"premiumBps": "0",
"rate": "5410000",
"salt": "0x6161616161616161616161616161616161616161616161616161616161616161",
"seat": "0x70997970c51812dc3a010c7d01b50e0d17dc79c8",
"side": "-1",
"takerRef": "0x4f412fb92304015b744b7a32155b5879b48aa8cbb0076b8234640f8891c53b0b"
},
"primaryType": "Quote",
"types": {
"EIP712Domain": [
{
"name": "name",
"type": "string"
},
{
"name": "version",
"type": "string"
},
{
"name": "chainId",
"type": "uint256"
},
{
"name": "verifyingContract",
"type": "address"
}
],
"Quote": [
{
"name": "seat",
"type": "address"
},
{
"name": "legId",
"type": "bytes32"
},
{
"name": "pair",
"type": "bytes32"
},
{
"name": "side",
"type": "int8"
},
{
"name": "notional",
"type": "uint256"
},
{
"name": "rate",
"type": "uint64"
},
{
"name": "premiumBps",
"type": "int16"
},
{
"name": "expiry",
"type": "uint40"
},
{
"name": "nonce",
"type": "uint64"
},
{
"name": "salt",
"type": "bytes32"
},
{
"name": "takerRef",
"type": "bytes32"
}
]
}
}