Skip to content

swaps

Token swaps across DEXes: exact-in and exact-out swaps with automatic approvals, wrap/unwrap, quotes and prices, and venue selection via --using.

load swaps

Config variables are set with set (fully qualified, including the module prefix) and are only readable by their own module and the user script.

VariableTypeDefaultDescription
$swaps:deloraApiKeystringAPI key for the Delora swap venue.
CommandDescription
swaps:swapSell 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-toBuy 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:unwrapUnwrap the canonical wrapped-native token back into the native token (WETH to ETH, WXDAI to xDAI...).
swaps:wrapWrap the native token into its canonical wrapped form (ETH to WETH, xDAI to WXDAI...).
HelperReturnsDescription
@swaps:pricenumberSpot 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:quotenumberExpected 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.