Agent Vault Contract API

Overview of functions and security model of the AgentVault contract.

This page explains the on-chain functions a vault owner can call directly, plus the VaultOperator execution model used for agent-driven swaps.

VaultOperator Context

VaultOperator is an execution role in Authority used to submit swap transactions generated from agent decisions. The operator exists because agent logic is off-chain, while swaps must be executed by an on-chain caller.

In AgentVault, operator authority is intentionally narrow:

  • Can call swapV4(...) to execute Uniswap v4 swaps.
  • Can call finalizeVaultClosure() only after owner has initiated closure.
  • Cannot call owner fund-management functions.
  • Cannot withdraw ETH/WETH/tokens to itself.
  • Cannot call xcall(...).
  • Cannot change settings, strategies, or ownership.

Least-Privilege Security Model

Swaps are constrained on-chain by contract checks:

  • swapV4 is gated by onlyVaultOperator.
  • Vault owner can pause swaps at any time with pauseVault(true).
  • Protocol can globally disable operators via Authority.vaultOperatorsDisabled.
  • Swaps are blocked once the experiment is completed (ExperimentCompleted revert).
  • Pair must include WETH.
  • Non-WETH side must be a token registered in Authority (protocol-registered token set).
  • Minimum output (minAmountOut) is enforced.
  • Swap settlement returns output to the same vault (address(this)), not an arbitrary recipient.

Owner-Callable Functions

FunctionSignaturePurposeKey Requirements
Update settingsupdateSettings((uint256, uint256, uint8, uint8, uint8, uint8, uint8) settings_)Update agent risk/trading preferencesOwner only; validated bounds
Add strategyaddStrategy(string strategy, uint64 expiry, uint8 prio) returns (uint256)Add strategy metadataOwner only; non-empty; max length; valid expiry/priority
Disable strategydisableStrategy(uint256 id)Disable one strategyOwner only
Disable all strategiesdisableAllActiveStrategies()Disable all active strategiesOwner only
Deposit ETHdepositETH() payableWrap ETH into vault WETHOwner only; msg.value > 0
Withdraw ETHwithdrawETH(uint256 amount_)Unwrap WETH and withdraw ETHOwner only; sufficient WETH
Recover forced ETHrecoverEth(uint256 amount_)Withdraw raw ETH held by vaultOwner only; sufficient ETH balance
Enter presaleenterPresale(uint256 presaleId, uint256 amount)Contribute vault WETH to presaleOwner only; sufficient WETH
Swap staked NFTshmewieSwap(uint256 newAgentId_)Replace staked Agent NFTOwner only; new id must differ
Pause/unpause swapspauseVault(bool paused_) returns (bool)Enable/disable operator swap executionOwner only; vault not in closure
Initiate closurecloseVault()Start closure workflowOwner only; vault not in active presale
Close after experimentcloseVaultAfterExperiment()Owner-complete closure after graduationOwner only; experiment complete
Withdraw graduated tokenwithdrawGraduatedToken()Transfer graduated token balance to ownerOwner only; graduated token set
Arbitrary call (post-experiment)xcall(address target_, bytes data_) payable returns (bytes)Owner-directed integrations after experimentOwner only; experiment completed

Read Functions

  • vaultOwner()
  • agentId()
  • paused()
  • vaultClosureStep() (0=active, 1=closure initiated, 2=closure finalized)
  • agentSettings()
  • strategyCount()
  • isStrategyActive(uint256)
  • getStrategy(uint256)
  • getActiveStrategies()
  • getActiveStrategyIds()
  • AGENT(), AUTHORITY(), PRESALE(), WETH(), POOL_MANAGER()

Settings and Strategies

Agent Settings

updateSettings(AgentSettings settings_) validates all fields on-chain:

FieldTypeAllowed RangeNotes
maxTradeAmountuint256500 to 10_000BPS (5% to 100%)
slippageBpsuint25610 to 5_000BPS (0.10% to 50%)
tradingActivityuint81 to 5slider value
assetRiskPreferenceuint81 to 5slider value
tradeSizeuint81 to 5slider value
holdingStyleuint81 to 5slider value
diversificationuint81 to 5slider value

Strategy Constraints

addStrategy(string strategy, uint64 expiry, uint8 prio) rules:

  • Strategy text must be non-empty.
  • Max strategy length is 1024 bytes.
  • expiry must be 0 (no expiry) or a future unix timestamp.
  • Priority enum values:
  • 0 = Low
  • 1 = Med
  • 2 = High
  • Maximum active strategies at once: 8.

Active strategy definition:

  • enabled == true
  • and (expiry == 0 or expiry > block.timestamp)

When adding a strategy at the active limit, the vault attempts to prune expired active strategies first; if still full, the call reverts.

Last modified March 24, 2026: add resource page (1609a9d)