Why Stylus
Stylus contracts execute as WASM inside the Arbitrum Nitro VM. This matters for an AI agent platform because:- Gas efficiency — iterating over DEX quotes or scanning lending positions across protocols involves tight loops and branching logic that WASM handles far more cheaply than the EVM.
- Rust safety —
no_stdenvironment with no heap allocator footguns, plus the full Rust type system for bitmask flags, bounds checking, and access control. - Interop — Stylus contracts live at regular Ethereum addresses and are callable from Solidity, viem, or any EVM-compatible client.
Contract Suite
Agent Registry
On-chain registry for agent instances with a capabilities bitmask, reputation
scoring, and governance controls.
Route Optimizer
Dynamic DEX registry with Uniswap V3 and AMM V2 dispatch, fee-aware quote
comparison, and multi-hop routing.
Liquidation Monitor
Multi-protocol health scanner for lending and perp positions with dynamic
protocol registries and tracked account management.
TimeBoost Vault
Bid funding and resale payments for Arbitrum express lane access, integrated
with the off-chain TimeBoost bidder.
Stylus SDK 0.10.0
All contracts target stylus-sdk 0.10.0. Key patterns used throughout:Storage declarations
Storage declarations
Storage uses Use
sol_storage! with Solidity-style types:address, uint256, bool, and mapping(K => V) — not
StorageAddress or StorageMap.Events and logging
Events and logging
Events are defined with
sol! and emitted via self.vm().log():Access control
Access control
self.vm().msg_sender() returns the caller address. All owner-gated
methods follow a common guard pattern:Private helpers
Private helpers
Methods that accept
&mut references to non-ABI types must live in a
separate impl block (not marked #[public]). The Stylus ABI generator
requires all public methods to use ABI-compatible parameter types.no_std Environment
Stylus contracts compile with #![no_std]. This means:
- No standard library collections — use
alloc::vec::Vec(requiresextern crate alloc;). - No
String— error messages useVec<u8>(e.g.b"not owner".to_vec()). - No filesystem, networking, or threads.
Off-Chain Integration
The agent’s TypeScript adapters interact with these contracts via viem v2readContract / writeContract calls. The typical
flow:
- Agent runner identifies an intent (e.g. “find the best swap route”).
- The corresponding adapter calls the Stylus contract on-chain to compute the
result (e.g.
RouteOptimizer.find_best_route). - The adapter interprets the result and either returns data to the user or chains into a follow-up transaction.
Running Tests
All four contracts share a single Cargo workspace. Run the full suite with:stylus_test::TestVM for mocking sender addresses, call data, and
static call responses. See each contract page for test coverage details.