If the exit is a single path from a position into one token, use the Route API. If you need redeem or harvest in a fixed order, use the Bundle API, often with the delegate strategy.
Definition
A withdraw-and-swap takes the user out of a vault or position and delivers a different token in one transaction, instead of requiring a separate redeem and a later swap.
How it works
Start from the position token the user holds and the token they want to receive.
If the execution API can find a single path, one Route request can exit the position and swap to
tokenOut.If the exit must call
redeemorharvestin a fixed order, specify those actions in a bundle, then swap the proceeds.Show the quote, collect any required approval, and submit the returned transaction unchanged.
How Enso does this
Call POST https://api.enso.build/api/v1/shortcuts/route with tokenIn set to the position token and tokenOut set to the asset the user wants, plus amountIn and slippage. Use POST /api/v1/shortcuts/bundle when the order must be fixed. Some actions, including harvest, borrow, and repay, must use routingStrategy delegate. See Get Started, the FAQ, and Routing Strategies.
FAQ
Can the user receive a different token than the vault’s underlying asset?
Yes. Set tokenOut to the asset they want. Route will include any swap needed when it can find a path.
When is Bundle required?
When you must control action order or include actions such as harvest or redeem yourself, rather than asking Route to find a single path.
Related articles
How do I migrate a yield position between protocols?
How do I add a one-click zap into a vault?
When should I use the Bundle API instead of Route?
What is a routing strategy?
What is Enso Earn?
