Developers

Create RFQ

Ask makers for private quotes on a stable funding perp (an RFQ), giving a size and optionally a side.

On this page

URLs and generated code samples on this page: Testnet (chain ID 326). Other code on this page doesn't change: it stays on testnet until you switch it in your code. Tutorials, signing cases and live tools always use testnet.

A taker solicits private quotes for one STABLE_PERP instrument by giving a size and, optionally, a direction (rfq.side; leave it out for a two-way request). The request is unsigned: creating an RFQ commits the taker to nothing.

End-to-end flow:

  1. The taker submits an RFQ here. (In the Grvt UI, entering a size on the trade page is the RFQ.)
  2. Grvt broadcasts the RFQ to qualified makers on the v1.rfq stream, with an anonymous id instead of the taker's account and without its side. Makers can add ECN orders bound to it (metadata.rfq_id).
  3. The v1.quote stream sends the taker, for each side of the book, the average fill price for the RFQ size and how much of it can fill, as the book changes.
  4. The taker accepts by signing an IOC limit order with create_order and metadata.rfq_id set (one leg; its side must match rfq.side when that is set). Or the taker walks away and lets the RFQ expire.

The created RFQ is returned in the response. A sub-account may hold at most one open RFQ per instrument. The RFQ lives until rfq.expiry; then Grvt expires it and cancels the makers' orders bound to it. The sub-account must be in multi-asset mode.

SDKclient.create_rfq(...)
HTTPPOST https://trades.testnet.grvt.io/full/v1/create_rfq, or /lite/v1/create_rfq for lite names (the SDKs' default)
WebSocketmethod v1/create_rfq on wss://trades.testnet.grvt.io/ws/full, or /ws/lite for lite names
AuthSession required (Authentication)
RetriesWrite: never retried automatically (why)
Contract idrfq.create_rfq (RPCCreateRfqV1)

Request

Body type ApiCreateRfqRequest. Fields the server fills are left out.

rfqlite name robject Rfqrequired#
The RFQ to create
  • sub_account_idlite name sastring (uint64)required#
    The sub-account initiating the RFQ
  • expirylite name estring (int64 unix ns)required#
    When the RFQ expires, in unix nanoseconds. Default 60s, cap 300s (per-instrument config)
  • instrumentlite name istring (instrument name)required#
    The instrument to trade. Must be kind = STABLE_PERP
  • sizelite name sstringrequired#
    Requested size (positive). Decimal string, e.g. "0.01"; up to the instrument's base_decimals.
  • sidelite name s1enum RfqSideoptional#
    Optional — omitted = two-way request. The Grvt UI always fills it; API takers may withhold direction and accept two-way quotes
    3 values
    UNSPECIFIED, BUY, SELL (details).

Response

Body type ApiCreateRfqResponse (the same object is the JSON-RPC result over WebSocket).

rfqlite name robject Rfqrequired#
The created RFQ
  • rfq_idlite name ristring (uint128)required#
    Set by the server. The exchange's 128-bit id for the RFQ.
  • sub_account_idlite name sastring (uint64)required#
    The sub-account initiating the RFQ
  • expirylite name estring (int64 unix ns)required#
    When the RFQ expires, in unix nanoseconds. Default 60s, cap 300s (per-instrument config)
  • instrumentlite name istring (instrument name)required#
    The instrument to trade. Must be kind = STABLE_PERP
  • sizelite name sstringrequired#
    Requested size (positive). Decimal string, e.g. "0.01"; up to the instrument's base_decimals.
  • sidelite name s1enum RfqSideoptional#
    Optional — omitted = two-way request. The Grvt UI always fills it; API takers may withhold direction and accept two-way quotes
    3 values
    UNSPECIFIED, BUY, SELL (details).

Errors

Errors come back as {"code", "message", "status"} (lite {"c", "m", "s"}) with the HTTP status. Codes this call can return (all error codes):

2061InstrumentNotSupported400
Unsupported Instrument Requested
2065InvalidContractGrainSize400
Order size too granular
2141RfqSubAccountDoesNotMatchLoggedInUser403
RFQ sub account does not match logged in user
2142RfqInstrumentNotStablePerp400
RFQ instrument must be a stable perpetual
2143RfqSizeBelowMinimum400
RFQ size is below the instrument minimum size
2144RfqSizeAboveMaximum400
RFQ size exceeds the instrument maximum position size
2145RfqInvalidExpiry400
RFQ expiry is invalid
2146RfqAlreadyExistsForAsset400
An open RFQ already exists for this sub account and instrument
2147StablePerpRequiresMultiAssetMode400
stable perp orders require a multi-asset-mode sub-account
7726SfpMarketClosed400
The Stable Funding Perpetual market is closed.
Plus 6 errors any call can return
1000Unauthorized401
You need to authenticate prior to using this functionality
1001Forbidden403
You are not authorized to access this functionality
1002InternalServer500
Internal Server Error
1003InvalidRequest400
Request could not be processed due to malformed syntax
1004NotFound404
Data Not Found
1006RateLimit429retryable
You have surpassed the allocated rate limit for your tier

Example

Example code
import os
from decimal import Decimal

from grvt import Grvt, Timestamp, models as m

with Grvt(
    env=os.environ.get("GRVT_ENV", "testnet"),
    api_key=os.environ["GRVT_API_KEY"],
) as client:
    resp = client.create_rfq(
        rfq=m.RfqInput(
            sub_account_id=os.environ["GRVT_SUB_ACCOUNT_ID"],
            expiry=Timestamp(int("1697788800000000000")),
            instrument="AAPL_USDC_SFP",
            size=Decimal("10.5"),
        ),
    )
    print(resp)

Raw HTTP (set GRVT_DOMAIN, see Environments; GRVT_COOKIE and GRVT_ACCOUNT_ID come from login):

With full field names:

curl -sS "https://trades.testnet.grvt.io/full/v1/create_rfq" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "rfq": {
    "sub_account_id": "$GRVT_SUB_ACCOUNT_ID",
    "expiry": "1697788800000000000",
    "instrument": "AAPL_USDC_SFP",
    "size": "10.5"
  }
}
EOF

With lite field names:

curl -sS "https://trades.testnet.grvt.io/lite/v1/create_rfq" \
  -H "Content-Type: application/json" \
  -H "Cookie: gravity=$GRVT_COOKIE" \
  -H "X-Grvt-Account-Id: $GRVT_ACCOUNT_ID" \
  --data @- <<EOF
{
  "r": {
    "sa": "$GRVT_SUB_ACCOUNT_ID",
    "e": "1697788800000000000",
    "i": "AAPL_USDC_SFP",
    "s": "10.5"
  }
}
EOF
Build request
esc

↑ ↓ move↵ open⇧↵ open .mdTry an error code like 2002

Keyboard shortcuts

⌘ K
Search the docs
/
Search
l
Next code language (Python → TypeScript → Go → Rust → curl → WebSocket)
j / k
Next / previous page
t
Light / dark theme
?
This help
Esc
Close dialogs and drawers