Builder Codes (Front End Fee)
Build your own custom frontend and earn fees
Builder codes allow third-party integrators to permissionlessly earn fees on orders they submit on behalf of users. This enables trading platforms, referral programs, and white-label solutions to monetize their user traffic by providing order flow to the Aftermath ecosystem.
Overview
Builder codes provide a flexible fee-sharing mechanism for integrators building on Aftermath Perpetuals. The system works as follows:
User Authorization: Users approve specific integrators and set a maximum fee they're willing to pay
Order Submission: Integrators submit orders on behalf of users, specifying their fee (up to the approved maximum)
Fee Accumulation: Fees accumulate in per-market vaults as orders execute
Fee Collection: Integrators claim accumulated fees at any time
Unlike referral codes, builder codes are applied in real time as part of the onchain fee logic.
How It Works
For Users
Users maintain full control over which integrators can earn fees on their orders:
Approve integrators with a maximum fee cap per integrator
Revoke permissions at any time
Set different fee limits for different integrators
For Integrators
Integrators must complete a one-time setup before earning fees:
Create a fee vault for each market they want to support
Get users to approve them as integrators
Submit orders with their address and fee amount
Claim accumulated fees when desired
Fee Structure
Fees are proportional to taker volume generated by user orders
Integrators specify their fee when submitting orders (must not exceed user-approved maximum)
For Developers
TypeScript. We've integrated all required builder code functionality into our TypeScript SDK and detailed all functions in our docs.
API. For more information on how to interact with builder codes through our API, view our API reference.
API Endpoints
All builder code endpoints accept POST requests with a JSON body. Base URL: https://aftermath.finance
Read your configuration and fee vaults:
/api/perpetuals/builder-codes/integrator-config
/api/perpetuals/builder-codes/integrator-vaults
Build transactions for setup and fee collection:
/api/perpetuals/builder-codes/transactions/create-integrator-config
/api/perpetuals/builder-codes/transactions/create-integrator-vault
/api/perpetuals/builder-codes/transactions/claim-integrator-vault-fees
/api/perpetuals/builder-codes/transactions/remove-integrator-config
Example: Create a fee vault and handle the response
Transaction Flow
All transaction endpoints return a serialized transaction kind (txKind). To execute on-chain:
Call the transaction endpoint with your wallet address and parameters
Receive the txKind object in the JSON response
Build a TransactionBlock from the txKind using the Sui SDK
Sign the transaction with your wallet
Submit to the Sui network via sui_executeTransactionBlock
Integration Modes
There are three ways to integrate builder codes:
Native API (/api/perpetuals/*) — Recommended. Full feature set including vault management, fee claiming, and transaction builders.
TypeScript SDK (@aftermath-finance/sdk) — Typed helper methods for builder code operations. Best for TypeScript applications.
CCXT-compatible API (/api/ccxt/*) — Exchange-style endpoints for bot integrations that follow the CCXT standard.
Last updated