Skip to content

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:swap-to <amountOut> <tokenOut> <from> <tokenIn>
NameTypeDescription
amountOutnumberExact amount of tokenOut to buy, in base units (wei)
tokenOutaddressToken to buy
fromcommandKeyword from
tokenInaddressToken to spend (use @token(SYM); the native token resolves to the zero address)
NameTypeDescription
--maxnumberMaximum input in base units (overrides --slippage)
--slippagenumberMaximum slippage vs. the quote, in percent (default 0.5)
--usingswap-venueVenue: Delora, UniswapV4, UniswapV3, UniswapV2, Honeyswap, SushiSwap, Balancer, or CoWSwap (default: the best venue available on the chain)
--toaddressRecipient of the output (defaults to the connected account)
--deadlinenumberUnix timestamp after which the swap reverts (default: 20 minutes after the latest block)
--no-approveboolSkip the automatic allowance check and approve action
# Buy exactly 1 GNO with WXDAI on Honeyswap (Gnosis), spending at most the quote plus 0.5%
swaps:swap-to 1e18 0x9C58BAcC331c9aa871AFD802DB6379a98e80CEdb from 0xe91D153E0b41518A2Ce8Dd3D7944Fa863463a97d --using Honeyswap