Borrow on lending protocols and combine with Enso’s routing
deposit
route
const fromAddress = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045"; const USDC_ADDRESS = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"; const AUSDC_ADDRESS = "0x98C23E9d8f34FEFb1B7BD6a91B7FF122F4e16F5c"; const WETH_ADDRESS = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"; const AAVE_V3 = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2"; const usdcAmountIn = parseUnits("10000", 6).toString(); const wethAmountOut = parseUnits("0.025", 18).toString(); const chainId = 1; const bundle = await client.getBundleData( { chainId, fromAddress, routingStrategy: "delegate", receiver: fromAddress, }, [ { protocol: "enso", action: "route", args: { amountIn: usdcAmountIn, tokenIn: USDC_ADDRESS, tokenOut: AUSDC_ADDRESS, }, }, { protocol: "aave-v3", action: "borrow", args: { primaryAddress: AAVE_V3, collateral: USDC_ADDRESS, tokenOut: WETH_ADDRESS, amountOut: wethAmountOut, }, }, ] ); console.log(JSON.stringify(bundle.bundle, null, 2)); await sendEoa(approvalData.tx, approvalData.gas); // sending the actual transaction await sendEoa(bundle.tx, bundle.gas);
Was this page helpful?