Developers

Builders

Earn a fee on the orders your app places for its users: authorize a builder and get an API key for the user's account, place builder orders and read builder fees.

On this page

URLs 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 builder is a Grvt account, usually an app or a bot, that places orders for its users and earns its own fee on them. Use this page if you run such an app.

How it fits together:

  • Builder account: your own Grvt main account. Builder fees are paid into it.
  • Authorization: each user signs once, naming your builder account and the highest builder fee they accept, one cap for futures (perpetuals included) and one for spot.
  • Builder order: an order with builder and builder_fee set. The user pays the builder fee on each fill, on top of the trading fee.

The calls for orders and builder fees are under Builders in the reference. Authorizing a builder has no SDK method yet: send it over HTTP as shown below.

Authorize a builder

When: a user connects your app for the first time, or you want to change their fee caps.

One call, POST /auth/builder/authorize on the edge host, works in two modes. What you send picks the mode:

ModeUse it whenThe user signsResponse
With an API keyyour app trades for the user with its own keyAddAccountSignerWithBuilder{"api_key": "..."}
Authorize onlyyour app already has a key, or the user changes their capsAuthorizeBuilder{}

Sending builder_api_key_signer and builder_api_key_permissions picks the first mode; leaving both out picks the second. The steps below are for the first.

  1. Get two main account IDs (0x addresses): the user's and your builder account's. funding_account_summary returns main_account_id for the account you are logged in to.
  2. Choose the caps, max_futures_fee_rate and max_spot_fee_rate. Each is a percentage string with at most 4 decimals: "0.1" means 0.1%.
  3. Generate a key pair in your app. Its address is the builder signer; it must not already be a signer on Grvt.
  4. Choose the key's permissions on the user's main account: names joined with & in this order: Admin, InternalTransfer, ExternalTransfer, Withdraw, VaultInvestor, Trade. For example "Trade" or "InternalTransfer&Trade". Ask only for what you need, usually Trade.
  5. Have the user sign AddAccountSignerWithBuilder (below) with an admin wallet of their main account (Funding Admin).
  6. Send it to the edge host. It needs no session: the signature authenticates it.
export GRVT_DOMAIN=testnet.grvt.io
curl -sS "https://edge.testnet.grvt.io/auth/builder/authorize" \
  -H "Content-Type: application/json" \
  --data @- <<'EOF'
{
  "main_account_id": "0x1111111111111111111111111111111111111111",
  "builder_account_id": "0x2222222222222222222222222222222222222222",
  "max_futures_fee_rate": "0.1",
  "max_spot_fee_rate": "0.05",
  "builder_api_key_signer": "0x4444444444444444444444444444444444444444",
  "builder_api_key_permissions": "Trade",
  "builder_api_key_label": "My trading app",
  "signature": {
    "signer": "0x3333333333333333333333333333333333333333",
    "r": "0x...",
    "s": "0x...",
    "v": 27,
    "expiration": "1767225600000000000",
    "nonce": 1001,
    "chain_id": "326"
  }
}
EOF

A success returns HTTP 200 and {"api_key": "..."}: an API key on the user's main account, tied to the builder signer. Log in with it (Authentication) and sign the user's orders with the builder signer's key. Permissions explains what each permission allows on a main account. get_authorized_builders, called on the user's session, lists your builder account with its caps.

Watch out:

  • Grvt keeps only a hash of the API key, so this response is the only time you see it. Store it right away.
  • To change the caps, use Authorize only with the new values; the first mode would add another API key. Authorizing again with the same caps fails with "the builder is already authorized for this main account".
  • Grvt sets a maximum for the caps. A cap above it, or a negative one, fails with "invalid builder fee rate".
  • Permission names out of order ("Trade&Admin") or unknown names fail with HTTP 400.

Authorize only

When: your app already has a way to trade for the user, or the user changes the caps of a builder they authorized before.

This mode only records your builder account and its caps on the user's main account. It creates no API key.

  1. Get the two main account IDs and choose the caps, as in steps 1 and 2 above.
  2. Have the user sign AuthorizeBuilder (below) with an admin wallet of their main account.
  3. Send it to the same route, without the builder_api_key_* fields.
export GRVT_DOMAIN=testnet.grvt.io
curl -sS "https://edge.testnet.grvt.io/auth/builder/authorize" \
  -H "Content-Type: application/json" \
  --data @- <<'EOF'
{
  "main_account_id": "0x1111111111111111111111111111111111111111",
  "builder_account_id": "0x2222222222222222222222222222222222222222",
  "max_futures_fee_rate": "0.2",
  "max_spot_fee_rate": "0.05",
  "signature": {
    "signer": "0x3333333333333333333333333333333333333333",
    "r": "0x...",
    "s": "0x...",
    "v": 27,
    "expiration": "1767225600000000000",
    "nonce": 1002,
    "chain_id": "326"
  }
}
EOF

A success returns HTTP 200 and {}. The new caps apply to the user's next orders with your builder account. The cap, signature and same-caps errors are the same as in the first mode.

The signed message

The domain is the same as for every Grvt signature: {name: "GRVT Exchange", version: "0", chainId}, with the environment's chain ID (326 on testnet, 325 on production). Signing walks through the hashing.

With an API key, the user signs:

AddAccountSignerWithBuilder(address accountID,address signer,string permissions,address builderAccountID,uint32 maxFutureFeeRate,uint32 maxSpotFeeRate,uint32 nonce,int64 expiration)
FieldFrom the request
accountIDmain_account_id
signerbuilder_api_key_signer
permissionsbuilder_api_key_permissions, the same string (an EIP-712 string: its keccak256 hash is encoded)
builderAccountIDbuilder_account_id
maxFutureFeeRatemax_futures_fee_rate × 10^4: "0.1" → 1000, "0.001" → 10
maxSpotFeeRatemax_spot_fee_rate × 10^4
noncesignature.nonce, a random uint32
expirationsignature.expiration, unix nanoseconds, in the future and at most 30 days ahead

Authorize only, the user signs:

AuthorizeBuilder(address mainAccountID,address builderAccountID,uint32 maxFutureFeeRate,uint32 maxSpotFeeRate,uint32 nonce,int64 expiration)

The fields come from the request the same way: mainAccountID is main_account_id, and the rest match the table above.

Errors

Errors come back with an HTTP status and a message:

StatusMessageFix
400invalid main account ID / invalid builder account IDUse existing main account IDs (0x addresses).
400builder account ID cannot be the same as main account IDUse a separate builder account.
400invalid signature / signature has expired / signature expiration exceeds the maximum of 30 daysCheck the signed fields, the chain ID and expiration.
400signature nonce has already been usedSign again with a new nonce.
400the main account requires more signatures than providedThe account needs approvals from several admins (Approvals by several admins).
400the signer wallet is already in use; please choose a different oneGenerate a new builder signer.
400API key label cannot be empty when permissions or signer are providedSet builder_api_key_label.
401the signer in the signature is not authorized to represent the main accountSign with an admin wallet of the user's main account.

Place builder orders

When: your app places an order for a user who has authorized your builder account.

  1. Set order.builder to your builder main account ID.
  2. Set order.builder_fee to your fee for this order, a percentage string such as "0.05" (0.05%). It must be at most the user's cap for this market: the futures cap for perpetuals, the spot cap for spot swaps.
  3. Sign and send the order as usual. The SDKs sign OrderWithBuilderFee when builder is set; by hand, see Builder fee orders.

The builder fee is the order's builder fee rate times the trade's notional value, in the quote currency. It is charged on each fill and paid into your builder account. Spot buys carry no builder fee; spot sells do.

Watch out: these errors mean the order was rejected, not placed:

CodeNameCause
7504ErrBuilderNotAuthorizedThe user hasn't authorized this builder account.
7505ErrBuilderFeeExceedsAuthorizationLimitbuilder_fee is above the user's cap.
7506ErrBuilderMissingbuilder_fee is set without builder.
7501ErrBuilderFeeNegativebuilder_fee is negative.

See your builder fees

  • On the user's side, each fill has builder, builder_fee_rate and builder_fee (the amount paid, in the quote currency): fill_history.
  • On your side, builder_fill_history lists the fills where your account was the builder. Call it with a session for your builder account; other accounts get an empty list.
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