Migrate from Yearn yvDAI vault to yvUSDC vault

This use case enables 1-click migration between different vaults on the same platform to retain user capital. Try this route → Route Mechanics: The routing involves a three-step process.
  • It first redeems the yvDAI from the yearn-v2 vault to get DAI.
  • Then, it swaps the DAI for USDC using the odos protocol.
  • Finally, it deposits the USDC into the yearn-v2 vault to get the final yvUSDC position.
export async function migrateYearnDaiToUsdc(): Promise<{ route: any; tx: any }> {
  const yvDAI: Address = "0xda816459f1ab5631232fe5e97a05bbbb94970c95";
  const yvUSDC: Address = "0xa354f35829ae975e850e23e9615b11da1b3dc4de";

  const routeParams: RouteParams = {
    fromAddress: userAddress,
    receiver: userAddress,
    chainId: ETHEREUM_CHAIN,
    amountIn: ["1000000000000000000"], // 1 yvDAI
    tokenIn: [yvDAI],
    tokenOut: [yvUSDC],
    routingStrategy: 'router'
  };

  happyPathLog(routeParams);
  const route = await client.getRouteData(routeParams);
  await sendEoa(route.tx, route.gas);
  return route;
}