In the evolving landscape of decentralized trading, the ability to integrate directly with exchange infrastructure is rapidly becoming essential for developers building next-gen trading applications. Builder Codes on dYdX unlock this capability, enabling any application, from wallets and bots to frontends and trading terminals, to not only access perpetual markets but also earn revenue through seamless, onchain order routing.
What Are Builder Codes?
Builder Codes introduce a programmable pathway for monetizing onchain order flow. When an order is submitted to dYdX via the exchange’s APIs, a builder can attach metadata that includes a payout address and a fee, defined in parts per million (ppm). If the order is matched and filled, the builder automatically receives their fee.
This mechanism removes the need for traditional affiliate programs or manual tracking. Instead, monetization is embedded directly into the order message and enforced at the protocol level.
How It Works
At the core of Builder Codes is the BuilderCodeParameters object, an optional addition to the order message. This field includes:
- Builder Address: The address where earned fees will be routed.
- Fee (ppm): The fee rate to be charged when the order is filled, up to a maximum of 10,000 ppm (1%).
A simplified example from the protocol’s protobuf schema:
message BuilderCodeParameters {
string builder_address = 1;
uint32 fee_ppm = 2;
}
This metadata is nested inside the order message:
message Order {
OrderId order_id = 1;
...
BuilderCodeParameters builder_code_params = 12;
}
To ensure valid integration, the builder address must be correctly formatted, and the fee must fall within the allowed range. Orders with invalid builder code metadata will be rejected during validation.
Fully Onchain and Transparent
Every Builder Code interaction is visible onchain. The builder address and fee rate are recorded and retrievable via dYdX’s indexer endpoints:
- /orders: Shows the fee rate and builder address attached to an order.
- /fills: Displays the builder address along with the actual fee paid for each fill.
This transparency empowers developers to audit performance, track revenue, and refine routing logic based on precise data.
Why It Matters
Builder Codes represent a shift in how decentralized exchanges reward ecosystem participants. By giving developers a native way to earn from order flow, Builder Codes reduce reliance on centralized intermediaries and open a path toward more sustainable, community-aligned infrastructure.
Key benefits include:
- Access to 200+ perpetual markets
- Earnings on every filled order
- Built-in scalability with app usage
- No permissions or whitelisting required
- Clear, onchain attribution and accountability
Use Cases
The flexibility of Builder Codes supports a broad range of integrations:
- Trading Terminals: Embed direct dYdX access and monetize trades
- Mobile Wallets: Offer in-app perpetuals with native fee earning
- Telegram Bots: Automate order routing and generate revenue per fill
- Regional Frontends: Localize dYdX access and sustainably monetize user flow
Minimal changes are needed to existing routing logic. With a few lines of code, any order flow can be directed through dYdX while earning fees transparently.
Scaling with the Ecosystem
As adoption of onchain trading grows, Builder Codes scale effortlessly. More users and more fills translate directly into higher earnings, without additional infrastructure or maintenance. The fee logic is deterministic, enforced by the exchange, and settled directly onchain.
Builder Codes turn order routing into a revenue-generating component, helping builders capture value from the protocols they support.
Case Study: Crypto.com’s Onchain App
One notable example of Builder Codes in action is the integration by Crypto.com. Through its Onchain App, Crypto.com offers users fast, liquid, and self-custodial perpetuals powered by dYdX. Orders are routed directly onchain, and Builder Codes are used to embed monetization into the trading experience.
This approach enables Crypto.com to maintain full control over its mobile user interface while benefiting from dYdX’s high-performance infrastructure and fee attribution model. The integration highlights a shared commitment to self-custody, decentralization, and scalability, demonstrating how mainstream platforms can offer advanced trading capabilities without compromising user control.
Additional Resources
For implementation details, refer to the Builder Codes guide in the dYdX documentation:
📘 docs.dydx.xyz/interaction/integration/integration-builder-codes
Technical questions, support, and discussions with other builders are actively supported in the dYdX Discord: