Bundle routing with non-standard ways to interact with protocols Enso supports
enso:route
isn’t enough for protocols with unique function signatures (e.g., requiring a referral code as an argument), you can use the /bundle
endpoint.
By chaining actions like enso:route
and enso:call
, you can combine optimal routing with custom contract calls
USDT
for STAKED_HYPE
, and then deposit it for LHYPE
, through a contract whose deposit
function requires a custom communityCode
argument.
receiver: SENDER
(or the spender address) is used for route
actions. This is because the Smart Wallet executes the bundle directly through delegate calls, and the wallet itself holds the tokens throughout the execution.When using the router routing strategy with EOAs (Externally Owned Accounts), receiver: ENSO_ROUTER
is required for route
actions. This is because the Enso Router contract needs to hold the intermediate tokens between actions
The router executes the sequence of actions and needs custody of tokens to pass them between stepsroutingStrategy: 'router'
)erc20:approve
. The user approves the Enso Router to spend their input USDT
, which is a required first step to grant the router permission for the swap.
enso:route
. The router swaps USDT
for STAKED_HYPE
. The receiver
is critically set to the ENSO_ROUTER
itself so it can hold the tokens for the next steps.
erc20:approve
. The Enso Router approves the final HYPE_DEPOSITOR
contract, using { useOutputOfCallAt: 1 }
to dynamically set the approval amount to the exact output from the previous swap.
enso:call
. The router calls the final deposit
function, passing the dynamic swap amount (again with { useOutputOfCallAt: 1 }
), the user’s address as the recipient, and the required static communityCode
.
routingStrategy: 'delegate'
)enso:route
. The Smart Wallet swaps USDT
for STAKED_HYPE
and receives the output tokens directly.
erc20:approve
. The Smart Wallet approves the final HYPE_DEPOSITOR
contract, using { useOutputOfCallAt: 0 }
to dynamically approve the exact amount received from the swap.
enso:call
. The Smart Wallet calls the custom deposit
function, passing the dynamic swap amount (again using { useOutputOfCallAt: 0 }
), the user’s address as the recipient, and the required static communityCode
.