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
Help me with: 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.
Target environment: {environment} (chain ID {chainId}). Recorded signing cases keep their original environment.
{executionGuidance}
Read this first: {origin}/bundle/guides/builders.md (~22 KB, plain Markdown: this page plus the AGENTS.md rules, Environments).
Fetch other pages from the index at {origin}/llms.txt only as you need them. {origin}/downloads/contract.json is a machine-readable contract for tools, not for reading.
Rules: follow AGENTS.md; do not send requests without the user asking you to; read credentials from environment variables; never retry writes automatically; show me the code and how to run it. 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
builderandbuilder_feeset. 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:
| Mode | Use it when | The user signs | Response |
|---|---|---|---|
| With an API key | your app trades for the user with its own key | AddAccountSignerWithBuilder | {"api_key": "..."} |
| Authorize only | your app already has a key, or the user changes their caps | AuthorizeBuilder | {} |
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.
- Get two main account IDs (
0xaddresses): the user's and your builder account's. funding_account_summary returnsmain_account_idfor the account you are logged in to. - Choose the caps,
max_futures_fee_rateandmax_spot_fee_rate. Each is a percentage string with at most 4 decimals:"0.1"means 0.1%. - Generate a key pair in your app. Its address is the builder signer; it must not already be a signer on Grvt.
- 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, usuallyTrade. - Have the user sign
AddAccountSignerWithBuilder(below) with an admin wallet of their main account (Funding Admin). - 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.
- Get the two main account IDs and choose the caps, as in steps 1 and 2 above.
- Have the user sign
AuthorizeBuilder(below) with an admin wallet of their main account. - 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)
| Field | From the request |
|---|---|
accountID | main_account_id |
signer | builder_api_key_signer |
permissions | builder_api_key_permissions, the same string (an EIP-712 string: its keccak256 hash is encoded) |
builderAccountID | builder_account_id |
maxFutureFeeRate | max_futures_fee_rate × 10^4: "0.1" → 1000, "0.001" → 10 |
maxSpotFeeRate | max_spot_fee_rate × 10^4 |
nonce | signature.nonce, a random uint32 |
expiration | signature., 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:
| Status | Message | Fix |
|---|---|---|
| 400 | invalid main account ID / invalid builder account ID | Use existing main account IDs (0x addresses). |
| 400 | builder account ID cannot be the same as main account ID | Use a separate builder account. |
| 400 | invalid signature / signature has expired / signature expiration exceeds the maximum of 30 days | Check the signed fields, the chain ID and expiration. |
| 400 | signature nonce has already been used | Sign again with a new nonce. |
| 400 | the main account requires more signatures than provided | The account needs approvals from several admins (Approvals by several admins). |
| 400 | the signer wallet is already in use; please choose a different one | Generate a new builder signer. |
| 400 | API key label cannot be empty when permissions or signer are provided | Set builder_api_key_label. |
| 401 | the signer in the signature is not authorized to represent the main account | Sign 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.
- Set
order.builderto your builder main account ID. - Set
order.builder_feeto 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. - Sign and send the order as usual. The SDKs sign
OrderWithBuilderFeewhenbuilderis 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:
| Code | Name | Cause |
|---|---|---|
7504 | ErrBuilderNotAuthorized | The user hasn't authorized this builder account. |
7505 | ErrBuilderFeeExceedsAuthorizationLimit | builder_fee is above the user's cap. |
7506 | ErrBuilderMissing | builder_fee is set without builder. |
7501 | ErrBuilderFeeNegative | builder_fee is negative. |
See your builder fees
- On the user's side, each fill has
builder,builder_fee_rateandbuilder_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.