Builder Codes
Builder codes enable a permissionless frontend ecosystem for GX Exchange. Third-party developers can build trading interfaces, bots, and aggregators that earn a share of trading fees from users who opt in.
Overview
A builder is any address that registers a fee rate and receives a portion of the trading fees on orders submitted through their interface. Users explicitly approve builders and set a maximum fee they are willing to pay.
Fee Limits
Builder fees are capped by market type to prevent abuse:
| Market Type | Maximum Builder Fee |
|---|---|
| Perpetuals | 0.1% (10 bps / 100 deci-bps) |
| Spot | 1.0% (100 bps / 1,000 deci-bps) |
Builder fees are charged in addition to standard exchange trading fees.
Requirements
Builder Registration
To register a builder code, an address must:
- Hold a minimum of 100 USDC in their perpetuals account balance
- Specify a fee rate that does not exceed the maximum for the target market type
- Submit a registration transaction on GX Chain
User Approval
Users must explicitly approve each builder before fees can be collected:
- Each user can approve a maximum of 10 builders
- Approval specifies a
max_fee_ratethat caps the builder’s charge for that user - Approvals can be updated in place (updating an existing approval does not count against the 10-approval limit)
- The effective fee rate is
min(builder_fee_rate, user_max_fee_rate)
Fee Calculation
The builder fee for a matched order is:
builder_fee = order_notional_value * effective_fee_rate_deci_bps / 100,000Where 100,000 = 10,000 (bps denominator) x 10 (deci factor).
Example: A $100,000 USDC notional order with a 5 deci-bps (0.005%) builder fee:
fee = 100,000,000 (atomic USDC) * 50 / 100,000 = 50,000 atomic USDC = $0.05Example: A $100 USDC spot order at the maximum 1% builder fee:
fee = 100,000,000 * 1,000 / 100,000 = 1,000,000 atomic USDC = $1.00Workflow
- Builder registers: Deploys a frontend, registers their address with a chosen fee rate
- User approves: User signs an
ApproveBuilderFeeaction specifying the builder address and their personal max fee - Order submission: Builder’s frontend submits orders on behalf of the user with the builder code attached
- Fee collection: On order match, the exchange calculates and distributes the builder fee to the builder’s account
Effective Fee Resolution
When an order with a builder code is matched:
- Look up the builder’s registered fee rate
- Look up the user’s approval for that builder
- If no approval exists, the builder fee is zero (orders still execute, but the builder receives nothing)
- If approved, the effective rate is
min(builder_rate, user_max_rate) - The fee is computed and transferred from the user to the builder
Security Considerations
- Builder fees are enforced at the consensus layer — frontends cannot extract more than the approved rate
- The 100 USDC minimum balance requirement ensures builders have economic stake in the platform
- Users retain full control through the approval mechanism and can revoke or adjust approvals at any time
- The 10-approval cap prevents state bloat while supporting multi-frontend usage