1. CRX
  2. API reference
  3. RFQs
  4. Check an accept before you sign

Check an accept before you sign

GET/rfqs/{rfq_id}/accept-check

Runs the checks of POST /rfqs/{rfq_id}/accept on quote_id, in the same order and with the same refusals, without a sig. It reserves nothing and opens no trade. A pass returns the trade_template the accept takes a signature over. The state can change before the accept, and the accept runs every check again.

Authentication

  • x-crx-address x-crx-ts x-crx-sig
  • x-crx-address x-crx-signer x-crx-ts x-crx-sig
  • x-crx-session

Parameters

NameInTypeDescription
rfq_id requiredpathstring

RFQ ID, 32-byte hex.

quote_id requiredquerystring

The quote you are about to accept, quote.quote_id from the RFQ.

Responses

200

The accept takes this quote now.

The accept checks pass. Nothing is reserved.

FieldTypeDescription
ok requiredboolean true
rfq_id requiredstring
quote_id requiredstring
trade_template requiredobject

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:

  1. Domain. name CRX, version rulebook-1.0; chainId and verifyingContract equal the chain_id and core that GET /health serves for your chain.
  2. Type. primaryType is Trade and types.Trade is exactly the Trade type string.
  3. Terms. pair, side, notionalE6 and maturity equal your RFQ; rateE6 equals the quote's rate; premiumBps equals your RFQ's premium_bps, within the chain's cap; summary is the line those fields format to.
  4. Leg ID. ownLegId bytes 24–31, big-endian, equal the RFQ's quote_expiry_max.
  5. Nonce. ownNonce is 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.

trade_template.typed_data requiredobject

The Trade, ready for eth_signTypedData_v4. Compare it with your own before signing.

An eth_signTypedData_v4 object; types holds EIP712Domain and the struct. In message, integers are decimal strings, and bytes32 values and addresses are lowercase 0x hex. chainId is a number. Compare parsed values, not bytes. Domain: name CRX, version rulebook-1.0, and the chain_id and core from GET /health.

trade_template.typed_data.types requiredobject
trade_template.typed_data.primaryType requiredstring

Trade, or Quote for a maker.

trade_template.typed_data.domain requiredobject
trade_template.typed_data.message requiredobject

The struct's fields. For Trade, see TradeTypedData; for Quote, QuoteTypedData.

400

bad_request: the RFQ is a close round, which takes no check, or quote_id is not 32-byte hex; with details.limit tenor, the fixing is too soon for the trade to open. seat_not_ready. notional_below_minimum: at the quote's rate, the trade is below the pair minimum.

code bad_request seat_not_ready notional_below_minimum

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 answer within 30 seconds.

code timeout

409

trade_stale: the template is not current; details.trade_template is null. POST /rfqs/{rfq_id}/accept with no sig returns the current one. 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. market_paused: the pair is paused or delisted. platform_paused: CRX is paused. conflict: the RFQ is already accepted, or accepts no more.

code trade_stale quote_dropped quote_not_yours rejected own_round_open market_paused platform_paused conflict

410

rfq_expired, quote_expired.

code rfq_expired quote_expired

422

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.

code insufficient_collateral rate_out_of_band

429

rate_limited: retry after Retry-After seconds.

code rate_limited

HeaderTypeDescription
Retry-Afterinteger

Seconds until the next call is accepted.

ratelimit-limitinteger

Maximum calls in a burst.

ratelimit-remaininginteger

Calls remaining before the limit.

ratelimit-resetinteger

Seconds until the full limit is restored.

ratelimit-refillinteger

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. withdraw_pending: a pending withdrawal blocks the collateral check. service_unavailable: CRX cannot accept a trade now. Retry shortly.

code collateral_unverified mark_unavailable withdraw_pending service_unavailable

Schemas

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:

FieldFromForm
summarythe fields belowone line, rules below
pairthe RFQ pairslash form, USDBRL → USD/BRL
sidethe RFQ side1 → buy, -1 → sell: your side, in the first currency
notionalE6the RFQ notional× 10^6, exact; refuse more than 6 decimal places
rateE6the quote rate× 10^6, exact
premiumBpsthe RFQ premium_bpssigned. Positive: you pay
maturitythe RFQ expiryUnix time in seconds, floor(expiry / 1000)
pairC, ownSaltthe templateas served
ownLegIdthe templatebytes 24–31 equal the RFQ's quote_expiry_max
ownNoncethe templateat 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:

FieldFromForm
seatyour accountx-crx-address
legIdyour leg_id24 random bytes, then quote_expiry_max as 8 bytes big endian
pairthe RFQ pairkeccak256 of the slash form: USDBRL → keccak256("USD/BRL")
sidethe RFQ sideyour side, as the RFQ shows it to you: 1 long base, -1 short
notionalthe RFQ notional× 10^6, exact
rateyour rate× 10^6, exact; refuse more than 6 decimal places
premiumBpsthe RFQ premium_bpssigned
expirythe RFQ expiryUnix time in seconds, floor(expiry / 1000)
nonceyour leg_idbytes 16–23, big endian. The body does not send it
saltyour saltas sent
takerRefthe RFQ taker_refas 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"
      }
    ]
  }
}

TradeTemplate

{
  "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"
        }
      ]
    }
  }
}