DEX Contracts
The AgentOS DEX contracts are the on-chain layer behind the DEX API. A quote from the API is a transaction that calls the Router; the Router takes the AgentOS fee in the sell token and hands the rest to the Executor, which runs the liquidity source's calldata.
The contracts are immutable (no proxy, no upgrade) and verified on the block explorers. They have not had a formal third-party audit.
Contracts
| Contract | Role |
|---|---|
AgentOSRouter | What users approve and call. Takes the fee, passes the rest to the Executor, and reverts unless the recipient received at least minAmountOut. It only ever moves tokens from the caller of that swap. |
AgentOSExecutor | Runs the liquidity source's calldata. Callable only by the Router, holds no approvals, and clears every allowance it grants before returning. Keeps the registry of sources. |
AgentOSWrapAdapter | The wrap source: wraps ETH to WETH and back. |
Deployments
The Router and Executor are at the same address on both chains.
| Contract | Base (8453) | Robinhood Chain (4663) |
|---|---|---|
AgentOSRouter | 0x4Cf93bac8920b1EFc92B0d2C84dcbE56802E530c | 0x4Cf93bac8920b1EFc92B0d2C84dcbE56802E530c |
AgentOSExecutor | 0x5118B3959192a6f79B05c8b2A50b58B0DA192FA6 | 0x5118B3959192a6f79B05c8b2A50b58B0DA192FA6 |
AgentOSWrapAdapter | 0x46b4f62A68F2Ee289215735F19d4f0e09802Cf66 | 0x4695326b3B2012b0BBF50843D97F1D5A325A912d |
The owner is a 2-of-3 Safe. The fee is 20 bps.
How a swap runs
- The caller approves the Router for
amountInof the sell token. Selling native ETH needs no approval; the ETH is sent as the transaction value. - The caller calls
Router.swap(params, callData)with the calldata from the API quote. - The Router takes the fee,
floor(amountIn * feeBps / 10000), in the sell token and sends the rest to the Executor. - The Executor runs the calldata against the registered source named by
sourceId. - The Router checks the recipient's balance grew by at least
minAmountOut, or the whole transaction reverts.
struct SwapParams {
bytes32 sourceId; // which registered source runs the swap
address tokenIn; // NATIVE (0xEeee…EEeE) for the chain's coin
address tokenOut;
uint256 amountIn; // gross amount taken from the caller, fee included
uint256 minAmountOut; // checked against what the recipient received
address recipient;
uint256 deadline;
bytes32 quoteId; // reference to the off-chain quote; emitted, never read
}
function swap(SwapParams calldata p, bytes calldata callData)
external
payable
returns (uint256 amountOut);
You normally do not build these arguments yourself: sign the transaction the API returns.
Liquidity sources
A source is an entry point the Executor is allowed to call, registered by the owner. Registered today on both chains: 0x, uniswap, uniswap-native and wrap. A source id is written once: it can be disabled, re-enabled or removed, but never edited or reused.
What the owner can change
| Change | Limit |
|---|---|
| Fee | 0 to 100 bps, a hard cap in the contract |
| Fee recipient | Set by the owner |
| Sources | Add, disable, re-enable or remove |
| Pause | The owner or a guardian can pause swaps; only the owner can unpause |
| Ownership | Two-step transfer |
Nobody can upgrade the contracts or move a user's tokens outside that user's own swap.
Known limits
- Tokens that tax every transfer revert when sold through the Router.
- Tokens sent to the Router by mistake cannot be recovered; it has no rescue function by design.
- Below
10000 / feeBpsbase units, the fee rounds down to zero. Swappedevents are not proof of volume: anyone can emit one with a token of their own making.