sol_storage! for
storage and #[public] for exposed methods.
AgentRegistry
AgentRegistry
On-chain registry of agent instances with capabilities bitmask,
revenue sharing, and reputation tracking.
Storage Layout
Capability Flags
Public Methods
register(capabilities: u64, revenue_share_bps: u16) -> Result<U256>
Register a new agent. Caller becomes the owner. Returns the agent ID.
Reverts if revenue_share_bps > 10000.update(agent_id: U256, capabilities: u64, revenue_share_bps: u16) -> Result<bool>
Update an agent’s capabilities and revenue share. Owner only. Returns
false if caller is not the owner.deactivate(agent_id: U256) -> bool
Deactivate an agent. Callable by owner or governance.update_reputation(agent_id: U256, new_score: U256) -> bool
Set an agent’s reputation score. Governance only.get_agent(agent_id: U256) -> (Address, U256, U256, U256, bool)
Returns (owner, capabilities, revenue_share_bps, reputation, active).total_agents() -> U256
Returns the total number of registered agents.has_capability(agent_id: U256, cap_flag: u64) -> bool
Check if an agent has a specific capability flag.set_governance(new_governance: Address) -> bool
Set the governance address. Can be called by anyone if governance is
unset (zero address), otherwise governance only.Events
LiquidationMonitor
LiquidationMonitor
Multi-protocol lending health scanner with dynamic protocol registry.
Supports Aave V3 with extensible dispatch for additional lending and
perp protocols.
Storage Layout
Public Methods
initialize(risk_threshold: U256) -> Result<()>
Initialize the contract. Sets caller as owner and configures the risk
threshold. Can only be called once.add_lending_protocol(pool_address: Address, protocol_type: u64) -> Result<U256>
Register a lending protocol. Owner only. Returns the registry index.remove_lending_protocol(index: U256) -> Result<()>
Soft-delete a lending protocol by index. Owner only.lending_protocol_count() -> U256
Returns the total number of registered lending protocols (including
inactive).get_lending_protocol(index: U256) -> (Address, U256, bool)
Returns (pool_address, protocol_type, is_active).add_perp_protocol(reader_address: Address, protocol_type: u64) -> Result<U256>
Register a perpetual protocol. Owner only.remove_perp_protocol(index: U256) -> Result<()>
Soft-delete a perp protocol by index. Owner only.perp_protocol_count() -> U256
Returns the total registered perp protocol count.get_health_factor(account: Address) -> Result<U256>
Query the health factor for an account across all active lending
protocols. Dispatches based on protocol type.Events
RouteOptimizer
RouteOptimizer
Multi-DEX route comparison engine with dynamic DEX registry. Evaluates
swap routes across registered DEXes to find the best output.
Storage Layout
DEX Type Constants
Public Methods
initialize() -> Result<()>
Initialize the contract. Sets caller as owner and seeds WETH + USDC as
default routing tokens.add_dex(dex_address: Address, dex_type: u64) -> Result<U256>
Register a DEX quoter. Owner only. Maximum 20 DEXes.remove_dex(index: U256) -> Result<()>
Soft-delete a DEX by index. Owner only.dex_count() -> U256
Returns the total registered DEX count.get_dex(index: U256) -> (Address, U256, bool)
Returns (dex_address, dex_type, is_active).add_routing_token(token: Address) -> Result<()>
Add an intermediate routing token. Owner only. Maximum 50 tokens. Rejects
duplicates.remove_routing_token(token: Address) -> Result<()>
Remove a routing token (swap-and-pop). Owner only.routing_token_count() -> U256
Returns the number of routing tokens.find_best_route(token_in: Address, token_out: Address, amount_in: U256) -> Result<(U256, Vec<Address>, Vec<u32>)>
Query all active DEXes and return the best route as
(best_amount_out, token_path, fee_tiers).Events
TimeboostVault
TimeboostVault
Manages ETH/USDC funds for TimeBoost express lane bidding and handles
payments for express lane resale.
Storage Layout
Public Methods
initialize(usdc: Address, bid_agent: Address, resale_price_usdc: U256) -> Result<()>
Initialize the vault with USDC address, bidding agent, and resale price.deposit_eth() -> Result<()> (payable)
Deposit ETH for bidding capital.deposit_usdc(amount: U256) -> Result<()>
Deposit USDC via transferFrom.record_round_win(round: U256, bid_cost_wei: U256) -> Result<()>
Record a round win. Agent or owner only. Sets controller status and
accumulates bid costs.end_round() -> Result<()>
Reset controller status at end of round. Agent or owner only.purchase_express_lane_access() -> Result<()>
Buy express lane access for the current round. Transfers
resale_price_usdc USDC from caller. Reverts if vault is not the
current controller.is_authorized_buyer(buyer: Address) -> bool
Check if an address has purchased access for the current round.get_stats() -> Result<(U256, U256, U256, U256, bool)>
Returns (eth_balance, usdc_balance, total_resale_earnings, total_bid_cost, is_controller).set_resale_price(new_price: U256) -> Result<()>
Update the resale price. Owner only.withdraw_eth(amount: U256) -> Result<()>
Withdraw ETH from the vault. Owner only.withdraw_usdc(amount: U256) -> Result<()>
Withdraw USDC from the vault. Owner only.