Developer answers about SwapVM, the programmable execution engine behind 1inch Aqua. Questions are phrased as real search queries and answered for engineers who build, quote, test and index strategies. This set feeds llms.txt and carries FAQPage JSON-LD for AI-answer citation. For maker / provide-liquidity questions, see the Aqua FAQ.
What is SwapVM?
SwapVM is the programmable execution engine behind 1inch Aqua. It runs a strategy's instruction program (a stream of opcodes) inside the on-chain AquaSwapVMRouter during quote() and swap(). The same engine also powers the 1inch Limit Order and Fusion routers. A strategy is a byte-addressable program identified by its strategyHash.
What is the difference between 1inch Aqua and SwapVM?
They are two separate products that work together. 1inch Aqua is the shared liquidity layer: the registry, custody and accounting where a maker keeps inventory in their own wallet, ships and docks strategies, and controls who can take (virtual balances, the Shared Liquidity Ratio, access & resolvers). SwapVM is the execution engine: the VM that prices and executes a strategy's opcode program. A strategy is a SwapVM program registered in the Aqua registry — Aqua supplies the liquidity and access, SwapVM supplies the pricing logic. See Access & resolvers (Aqua) and the SwapVM engine.
What is a SwapVM strategy (program)?
A strategy is a compact byte program — a sequence of [opcode][argsLength][args] instructions the VM executes. It is wrapped in an Order and registered on-chain via Aqua ship(). The strategyHash is keccak256 of the ABI-encoded Order, and it equals the router's orderHash emitted in Swapped — so fills join to strategies on that key. See Program, order and strategy.
What opcodes does SwapVM support?
On the deployed Aqua router the executable subset is Controls, XYCSwap, XYCConcentrate, Decay, Fee, PeggedSwap and Extruction, verified against AquaOpcodes. The SDK can encode the full instruction set, but the AquaProgramBuilder rejects an unregistered opcode at build time (OpcodeNotFound). At runtime there is no named error: a reserved gap index is a no-op (_notInstruction) and an index past the registered table reverts with a Solidity array-out-of-bounds Panic(0x32). The full directory (index, function, byte schema) is the Opcode gallery; to add your own, see Write your own opcode.
How do I build a SwapVM strategy?
Use @1inch/swap-vm-sdk — e.g. AquaXYCAmmStrategy.new()...build() or AquaProgramBuilder — or write the opcode bytes directly. Then wrap it in an Order and ship() it. The fastest path is the copy-paste Strategy template (Foundry + TypeScript); for a custom pricing contract see Build an AquaApp.
How do I quote and swap against a SwapVM strategy?
Call the deployed AquaSwapVMRouter v1.0.2 (0x111111338c5091e8440b67b168bae16a668ac0de). Both quote and swap take (Order order, address tokenIn, address tokenOut, uint256 amount, bytes takerTraitsAndData) and return (amountIn, amountOut, orderHash). The explicit tokenIn/tokenOut pair sets the swap direction. quote() is a free staticcall preview; swap() executes. Full surface: Events & interfaces.
What version of SwapVM is deployed?
AquaSwapVMRouter v1.0.2. Its quote/swap take explicit tokenIn/tokenOut (five arguments; selectors 0x44aa5f14 and 0xf4d2d412), and an order's data holds only hooks and the program (no token prefix). The 1inch/swap-vm main branch has an unreleased refactor with a different signature — build against v1.0.2, which matches the on-chain router and the published SDK.
How do I test a SwapVM strategy?
Fork-test with Foundry. The contracts compile with solc 0.8.30, the cancun EVM target, the optimizer and viaIR. The Strategy template ships a runnable forge test --fork-url that ships, quotes, swaps and docks, asserting every protocol event by its topic0 hash. The Debug opcode helps trace execution during development.
How do I control who can swap against my strategy?
Prepend a Controls guard to the program. For example onlyTxOriginTokenBalanceNonZero pointed at a credential token (the Fusion KycNFT) gates the strategy to holders only; the check runs on-chain before pricing, so unauthorized takers revert first. This is the Conditional Access pattern. See Access, resolvers & Pathfinder and the Conditional access pattern.
Is it called a strategy or a position?
On-chain and in the API it is a strategy (strategyHash, /strategies, the Strategy DTO, ship/dock). "Position" is the user-facing label in the consumer dApp only. Developer docs and code use strategy throughout.
Is SwapVM open source and where is the code?
Yes. The contracts are in 1inch/swap-vm and the SDKs (@1inch/aqua-sdk, @1inch/swap-vm-sdk) in 1inch/sdks. SwapVM and Aqua have been audited by OpenZeppelin, Bailsec, Hexens, Nethermind, Theori, Decurity, Hashlock and MixBytes. Audits reduce risk, they do not remove it: the code is audited, but new.
Can I run SwapVM from a script or SDK?
Yes. Use @1inch/swap-vm-sdk for building and encoding strategies and @1inch/aqua-sdk for the registry (ship/dock), and broadcast through your own RPC endpoint. See the SDK overview.
Which chains is SwapVM deployed on?
13 EVM chains: Ethereum, Arbitrum, Base, Optimism, Polygon, BNB Chain, Avalanche, Gnosis, zkSync Era, Linea, Unichain, Sonic and Robinhood. Addresses are the same across chains for the registry and router; verify per chain and do not hardcode. See Supported chains. Robinhood 4663 joined the Aqua chain set with the 2026-07-16 redeploy.
Does SwapVM cost gas?
quote() is a free static call (eth_call). swap(), ship() and dock() are transactions and cost gas like any on-chain action. Because a maker's tokens stay in their wallet and move only when a swap fills, there is no redeposit cost between strategies.
Does providing liquidity through SwapVM pay yield?
There is no guaranteed yield, APY or return. A maker earns swap fees when swaps fill against their strategy; those fees are not guaranteed and do not offset impermanent loss in every market. See Risks & disclosures and the worked fee and net-P&L examples.
Are there hosted SwapVM APIs, MCP or agent endpoints?
These developer docs cover the self-service, on-chain protocol and SDKs. Hosted API endpoints, MCP and x402 are KYB/KYC-gated, payable products under 1inch Business — see the Aqua API for where to go.
FAQPage JSON-LD
Machine-readable twin of the questions above; ship it with the page for AI-answer citation.
JSON
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
{
"@context": "https://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is SwapVM?",
"acceptedAnswer": {
"@type": "Answer",
"text": "SwapVM is the programmable execution engine behind 1inch Aqua. It runs a strategy's instruction program (a stream of opcodes) inside the on-chain AquaSwapVMRouter during quote() and swap(). The same engine also powers the 1inch Limit Order and Fusion routers. A strategy is a byte-addressable program identified by its strategyHash."
}
},
{
"@type": "Question",
"name": "What is the difference between 1inch Aqua and SwapVM?",
"acceptedAnswer": {
"@type": "Answer",
"text": "They are two separate products that work together. 1inch Aqua is the shared liquidity layer: the registry, custody and accounting where a maker keeps inventory in their own wallet, ships and docks strategies, and controls who can take (virtual balances, the Shared Liquidity Ratio, access & resolvers). SwapVM is the execution engine: the VM that prices and executes a strategy's opcode program. A strategy is a SwapVM program registered in the Aqua registry — Aqua supplies the liquidity and access, SwapVM supplies the pricing logic. See Access & resolvers (Aqua) and the SwapVM engine."
}
},
{
"@type": "Question",
"name": "What is a SwapVM strategy (program)?",
"acceptedAnswer": {
"@type": "Answer",
"text": "A strategy is a compact byte program — a sequence of [opcode][argsLength][args] instructions the VM executes. It is wrapped in an Order and registered on-chain via Aqua ship(). The strategyHash is keccak256 of the ABI-encoded Order, and it equals the router's orderHash emitted in Swapped — so fills join to strategies on that key. See Program, order and strategy."
}
},
{
"@type": "Question",
"name": "What opcodes does SwapVM support?",
"acceptedAnswer": {
"@type": "Answer",
"text": "On the deployed Aqua router the executable subset is Controls, XYCSwap, XYCConcentrate, Decay, Fee, PeggedSwap and Extruction, verified against AquaOpcodes. The SDK can encode the full instruction set, but the AquaProgramBuilder rejects an unregistered opcode at build time (OpcodeNotFound). At runtime there is no named error: a reserved gap index is a no-op (_notInstruction) and an index past the registered table reverts with a Solidity array-out-of-bounds Panic(0x32). The full directory (index, function, byte schema) is the Opcode gallery; to add your own, see Write your own opcode."
}
},
{
"@type": "Question",
"name": "How do I build a SwapVM strategy?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Use @1inch/swap-vm-sdk — e.g. AquaXYCAmmStrategy.new()...build() or AquaProgramBuilder — or write the opcode bytes directly. Then wrap it in an Order and ship() it. The fastest path is the copy-paste Strategy template (Foundry + TypeScript); for a custom pricing contract see Build an AquaApp."
}
},
{
"@type": "Question",
"name": "How do I quote and swap against a SwapVM strategy?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Call the deployed AquaSwapVMRouter v1.0.2 (0x111111338c5091e8440b67b168bae16a668ac0de). Both quote and swap take (Order order, address tokenIn, address tokenOut, uint256 amount, bytes takerTraitsAndData) and return (amountIn, amountOut, orderHash). The explicit tokenIn/tokenOut pair sets the swap direction. quote() is a free staticcall preview; swap() executes. Full surface: Events & interfaces."
}
},
{
"@type": "Question",
"name": "What version of SwapVM is deployed?",
"acceptedAnswer": {
"@type": "Answer",
"text": "AquaSwapVMRouter v1.0.2. Its quote/swap take explicit tokenIn/tokenOut (five arguments; selectors 0x44aa5f14 and 0xf4d2d412), and an order's data holds only hooks and the program (no token prefix). The 1inch/swap-vm main branch has an unreleased refactor with a different signature — build against v1.0.2, which matches the on-chain router and the published SDK."
}
},
{
"@type": "Question",
"name": "How do I test a SwapVM strategy?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Fork-test with Foundry. The contracts compile with solc 0.8.30, the cancun EVM target, the optimizer and viaIR. The Strategy template ships a runnable forge test --fork-url that ships, quotes, swaps and docks, asserting every protocol event by its topic0 hash. The Debug opcode helps trace execution during development."
}
},
{
"@type": "Question",
"name": "How do I control who can swap against my strategy?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Prepend a Controls guard to the program. For example onlyTxOriginTokenBalanceNonZero pointed at a credential token (the Fusion KycNFT) gates the strategy to holders only; the check runs on-chain before pricing, so unauthorized takers revert first. This is the Conditional Access pattern. See Access, resolvers & Pathfinder and the Conditional access pattern."
}
},
{
"@type": "Question",
"name": "Is it called a strategy or a position?",
"acceptedAnswer": {
"@type": "Answer",
"text": "On-chain and in the API it is a strategy (strategyHash, /strategies, the Strategy DTO, ship/dock). \"Position\" is the user-facing label in the consumer dApp only. Developer docs and code use strategy throughout."
}
},
{
"@type": "Question",
"name": "Is SwapVM open source and where is the code?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. The contracts are in 1inch/swap-vm and the SDKs (@1inch/aqua-sdk, @1inch/swap-vm-sdk) in 1inch/sdks. SwapVM and Aqua have been audited by OpenZeppelin, Bailsec, Hexens, Nethermind, Theori, Decurity, Hashlock and MixBytes. Audits reduce risk, they do not remove it: the code is audited, but new."
}
},
{
"@type": "Question",
"name": "Can I run SwapVM from a script or SDK?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes. Use @1inch/swap-vm-sdk for building and encoding strategies and @1inch/aqua-sdk for the registry (ship/dock), and broadcast through your own RPC endpoint. See the SDK overview."
}
},
{
"@type": "Question",
"name": "Which chains is SwapVM deployed on?",
"acceptedAnswer": {
"@type": "Answer",
"text": "13 EVM chains: Ethereum, Arbitrum, Base, Optimism, Polygon, BNB Chain, Avalanche, Gnosis, zkSync Era, Linea, Unichain, Sonic and Robinhood. Addresses are the same across chains for the registry and router; verify per chain and do not hardcode. See Supported chains. Robinhood 4663 joined the Aqua chain set with the 2026-07-16 redeploy."
}
},
{
"@type": "Question",
"name": "Does SwapVM cost gas?",
"acceptedAnswer": {
"@type": "Answer",
"text": "quote() is a free static call (eth_call). swap(), ship() and dock() are transactions and cost gas like any on-chain action. Because a maker's tokens stay in their wallet and move only when a swap fills, there is no redeposit cost between strategies."
}
},
{
"@type": "Question",
"name": "Does providing liquidity through SwapVM pay yield?",
"acceptedAnswer": {
"@type": "Answer",
"text": "There is no guaranteed yield, APY or return. A maker earns swap fees when swaps fill against their strategy; those fees are not guaranteed and do not offset impermanent loss in every market. See Risks & disclosures and the worked fee and net-P&L examples."
}
},
{
"@type": "Question",
"name": "Are there hosted SwapVM APIs, MCP or agent endpoints?",
"acceptedAnswer": {
"@type": "Answer",
"text": "These developer docs cover the self-service, on-chain protocol and SDKs. Hosted API endpoints, MCP and x402 are KYB/KYC-gated, payable products under 1inch Business — see APIs, MCP & agents for where to go."
}
}
]
}