swaps
Token swaps across DEXes, plus CoW TWAP orders from wallets and DAOs through reusable Safe accounts, with quotes, approvals, wrap/unwrap, and provider selection.
⚗️ Experimental — available at next.evmcrispr.com.
load swapsConfiguration variables
Section titled “Configuration variables”Config variables are set with set (fully qualified, including the module prefix) and are only readable by their own module and the user script.
| Variable | Type | Default | Description |
|---|---|---|---|
$swaps:deloraApiKey | string | — | API key for the Delora swap venue. |
Commands
Section titled “Commands”| Command | Description |
|---|---|
| swaps:swap | Sell an exact amount of one token for another on a DEX or aggregator, approving the venue automatically when needed. Slippage protection comes from --min, or --slippage applied to a quote (default 0.5%). |
| swaps:swap-to | Buy an exact amount of a token, spending as little as possible of another. The input is capped by --max, or --slippage applied to a quote (default 0.5%). Unspent input is refunded by the venue. |
| swaps:twap | Sell tokens in equal timed parts through CoW. A Safe @sender owns the order itself; any other @sender gets a reusable Safe it controls. Requires --parts, --every and exactly one of --min or --price-protection. Live preflight is required unless --offline is explicit. |
| swaps:twap-cancel | Cancel a CoW TWAP and revoke its sell-token allowance. Cancellation takes effect when mined; use twap-recover afterwards to return unused tokens. An order a Safe owns itself is only removed: its tokens never left the Safe, and the allowance its other CoW orders share stays. |
| swaps:twap-recover | Return residual TWAP sell tokens after cancellation, expiry, or proven complete settlement, removing authorization and clearing the allowance. Reads the current balance; run after prior actions are mined. |
| swaps:unwrap | Unwrap the canonical wrapped-native token back into the native token (WETH to ETH, WXDAI to xDAI...). |
| swaps:wrap | Wrap the native token into its canonical wrapped form (ETH to WETH, xDAI to WXDAI...). |
Helpers
Section titled “Helpers”| Helper | Returns | Description |
|---|---|---|
| @swaps:price | number | Spot price of 1 whole tokenA, expressed in base units of tokenB (the venue quote for selling 1 tokenA). Compare it against @token:amount(tokenB ...) values. |
| @swaps:quote | number | Expected output of an exact-in swap, in base units of tokenOut. Quotes the same venue swap would use (or the one given), so it feeds --min directly. |
| @swaps:twapParts | string | JSON page of TWAP parts with exact UIDs, trading windows, submission observations and verified settlement receipts. Offset defaults to 0; limit defaults to 100 (maximum 128). |
| @swaps:twapStatus | string | JSON TWAP status: independent registration, schedule, verified settlement totals, evidence coverage/finality, indexer discovery and current-part submission. Incomplete history reports unknown; expiry never proves fills. |