TradingBuilder Codes

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 TypeMaximum Builder Fee
Perpetuals0.1% (10 bps / 100 deci-bps)
Spot1.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:

  1. Hold a minimum of 100 USDC in their perpetuals account balance
  2. Specify a fee rate that does not exceed the maximum for the target market type
  3. 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_rate that 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,000

Where 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.05

Example: 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.00

Workflow

  1. Builder registers: Deploys a frontend, registers their address with a chosen fee rate
  2. User approves: User signs an ApproveBuilderFee action specifying the builder address and their personal max fee
  3. Order submission: Builder’s frontend submits orders on behalf of the user with the builder code attached
  4. 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:

  1. Look up the builder’s registered fee rate
  2. Look up the user’s approval for that builder
  3. If no approval exists, the builder fee is zero (orders still execute, but the builder receives nothing)
  4. If approved, the effective rate is min(builder_rate, user_max_rate)
  5. 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