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.
Use Case: Swap and Deposit with a Custom Referral Code
Let’s explore a scenario where a user wants to swapUSDT for STAKED_HYPE, and then deposit it for LHYPE, through a contract whose deposit function requires a custom communityCode argument.
- EOA signing
- Smart wallet signing
When the transaction is from an EOA, the Enso Router contract executes the sequence.
This requires explicit approvals for the router to operate on input tokens.
Bundle Design
In pseudo-code, the bundle looks as follows:-
Setup: approve transaction. 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. -
Action 0:
enso:route. The router swapsUSDTforSTAKED_HYPE. Thereceiveris critically set to theENSO_ROUTERitself so it can hold the tokens for the next steps. -
Action 1:
erc20:approve. The Enso Router approves the finalHYPE_DEPOSITORcontract, using{ useOutputOfCallAt: 1 }to dynamically set the approval amount to the exact output from the previous swap. -
Action 2:
enso:call. The router calls the finaldepositfunction, passing the dynamic swap amount (again with{ useOutputOfCallAt: 1 }), the user’s address as the recipient, and the required staticcommunityCode.
routeCustomCallEOA.ts
Updated
