Depositing with leverage amplifies exposure by redepositing the same collateral:
  • deposits initial collateral (WETH),
  • borrows against it (USDC),
  • swaps the borrowed funds for more collateral (USDC → WETH),
  • and repeats this process.
const chainId = 1; 
const fromAddress = "0xd8da6bf26964af9d7eed9e03e53415d37aa96045";

// Token and Protocol Addresses
const WETH: Address = "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2";
const aWETH: Address = "0x4d5F47FA6A74757f35C14fD3a6Ef8E3C9BC514E8";
const USDC: Address = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const aaveV3Pool: Address = "0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2";

// Define amounts
const initialDeposit = parseUnits("1", 18);
const borrowAmount = parseUnits("1000", 6);

const bundle = await client.getBundleData(
  {
    chainId,
    fromAddress,
    routingStrategy: "delegate",
  },
  [
    {
      protocol: "aave-v3",
      action: "deposit",
      args: {
        tokenIn: WETH,
        tokenOut: aWETH,
        amountIn: initialDeposit.toString(),
        primaryAddress: aaveV3Pool,
      },
    },
    {
      protocol: "aave-v3",
      action: "borrow",
      args: {
        collateral: aWETH,
        tokenOut: USDC,
        amountOut: borrowAmount.toString(),
        primaryAddress: aaveV3Pool,
      },
    },
    {
      protocol: "enso",
      action: "route",
      args: {
        tokenIn: USDC,
        tokenOut: WETH,
        amountIn: borrowAmount.toString(), 
        slippage: "100",
      },
    },
    {
      protocol: "aave-v3",
      action: "deposit",
      args: {
        tokenIn: WETH,
        tokenOut: aWETH,
        amountIn: { useOutputOfCallAt: 2 },
        primaryAddress: aaveV3Pool,
      },
    },
  ]
);
console.log(JSON.stringify(bundle.bundle, null, 2));
await sendSmartWallet(bundle.tx, bundle.gas);