> ## Documentation Index
> Fetch the complete documentation index at: https://docs.biconomy.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Vault to Vault

> Migrate DeFi positions between protocols and chains with one signature

Move positions between vaults without manual unwinding. Migrate from AAVE to Morpho, Yearn to Beefy, or any combination—even across chains. One signature handles everything.

## The Problem It Solves

Without Biconomy, migrating between vaults requires:

1. Approve withdrawal from source vault *(signature 1)*
2. Redeem shares *(signature 2)*
3. Bridge to destination chain *(wait, signature 3)*
4. Swap to destination vault's asset *(signature 4)*
5. Approve destination vault *(signature 5)*
6. Deposit into new vault *(signature 6)*

**With Biconomy:** One signature. Atomic execution. No funds left in limbo.

## How It Works

<Steps>
  <Step title="User Selects Migration">
    Choose source vault to exit and destination vault to enter
  </Step>

  <Step title="API Plans the Route">
    Biconomy calculates: redeem → swap (if needed) → bridge (if needed) → deposit
  </Step>

  <Step title="User Signs Once">
    Single signature authorizes the entire migration
  </Step>

  <Step title="Atomic Execution">
    All steps execute together—no partial states or stuck funds
  </Step>
</Steps>

## Quick Example

Migrate from AAVE on Polygon to Morpho on Base:

```typescript theme={null}
const quote = await fetch('https://api.biconomy.io/v1/quote', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    mode: 'eoa',
    ownerAddress: userAddress,
    composeFlows: [{
      type: '/instructions/intent-vault',
      data: {
        srcChainId: 137,            // Polygon
        srcVault: '0xAavePolygonVault...',  // AAVE vault to exit
        dstChainId: 8453,           // Base
        dstVault: '0xMorphoBaseVault...',   // Morpho vault to enter
        amount: '5000000000000000000',      // Vault shares to migrate
        slippage: 0.01
      }
    }]
  })
}).then(r => r.json());

// Sign and execute
const signature = await wallet.signTypedData(quote.typedDataToSign);

const result = await fetch('https://api.biconomy.io/v1/execute', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    signedQuote: quote,
    signature
  })
}).then(r => r.json());

console.log('Track at:', `https://meescan.biconomy.io/details/${result.supertxHash}`);
```

## Same-Chain Migration

Move between vaults on the same chain—ideal for chasing better yields:

```typescript theme={null}
{
  type: '/instructions/intent-vault',
  data: {
    srcChainId: 8453,
    srcVault: AAVE_USDC_VAULT,     // Exit AAVE
    dstChainId: 8453,
    dstVault: MORPHO_USDC_VAULT,   // Enter Morpho
    amount: '10000000000000000000',
    slippage: 0.005                // Lower slippage for same-asset migration
  }
}
```

<Tip>
  When both vaults use the same underlying asset on the same chain, the migration is nearly lossless—just gas fees.
</Tip>

## Cross-Chain Migration

Move positions across chains to access better opportunities:

```typescript theme={null}
{
  type: '/instructions/intent-vault',
  data: {
    srcChainId: 1,                 // Ethereum
    srcVault: YEARN_ETH_VAULT,     // Yearn ETH vault on mainnet
    dstChainId: 42161,             // Arbitrum
    dstVault: GMX_ETH_VAULT,       // GMX vault on Arbitrum
    amount: '2000000000000000000', // 2 vault shares
    slippage: 0.02,
    allowBridgeProviders: 'across' // Fast bridging
  }
}
```

## Understanding the Response

```json theme={null}
{
  "outputAmount": "4950000000000000000",
  "minOutputAmount": "4900500000000000000",
  "route": {
    "type": "vault-to-vault",
    "summary": "vaultsfyi[aave-v3] => across => lifi[uniswap] => vaultsfyi[morpho]",
    "steps": [
      {
        "type": "vault-redeem",
        "provider": "vaultsfyi",
        "protocol": "aave-v3",
        "vaultAddress": "0x...",
        "chainId": 137,
        "inputAmount": "5000000000000000000",
        "outputAmount": "5000000000"
      },
      {
        "type": "bridge",
        "provider": "across",
        "srcChainId": 137,
        "dstChainId": 8453
      },
      {
        "type": "swap",
        "provider": "lifi",
        "tool": "uniswap"
      },
      {
        "type": "vault-deposit",
        "provider": "vaultsfyi",
        "protocol": "morpho",
        "vaultAddress": "0x...",
        "chainId": 8453,
        "inputAmount": "4960000000",
        "outputAmount": "4950000000000000000"
      }
    ],
    "totalGasFeesUsd": 0.35,
    "totalBridgeFeesUsd": 0.50,
    "estimatedTime": 180
  }
}
```

| Field           | Description                                 |
| --------------- | ------------------------------------------- |
| `route.type`    | Always `vault-to-vault` for migrations      |
| `vault-redeem`  | Exit from source vault (lossless)           |
| `bridge`        | Cross-chain transfer (if different chains)  |
| `swap`          | Asset conversion (if different underlyings) |
| `vault-deposit` | Entry into destination vault (lossless)     |

## Migration Strategies

<Tabs>
  <Tab title="Yield Chasing">
    Move to higher-yielding vaults as rates change:

    ```typescript theme={null}
    // Monitor yields, migrate when profitable
    if (morphoYield > aaveYield + migrationCost) {
      // Execute migration
    }
    ```
  </Tab>

  <Tab title="Risk Rebalancing">
    Diversify across protocols to reduce smart contract risk:

    ```typescript theme={null}
    // Split position across multiple vaults
    const migrations = [
      { dstVault: AAVE_VAULT, amount: position * 0.4 },
      { dstVault: MORPHO_VAULT, amount: position * 0.3 },
      { dstVault: COMPOUND_VAULT, amount: position * 0.3 }
    ];
    ```
  </Tab>

  <Tab title="Chain Optimization">
    Move to chains with lower fees or better incentives:

    ```typescript theme={null}
    // Migrate from Ethereum to L2 for lower gas
    {
      srcChainId: 1,        // Expensive mainnet
      dstChainId: 8453,     // Cheap Base
      // ...
    }
    ```
  </Tab>
</Tabs>

## Provider Control

Customize the routing for your migration:

```typescript theme={null}
{
  type: '/instructions/intent-vault',
  data: {
    srcChainId: 137,
    srcVault: SOURCE_VAULT,
    dstChainId: 8453,
    dstVault: DEST_VAULT,
    amount: '1000000000000000000',
    slippage: 0.01,
    
    // Fine-tune the route
    routeSelectionMode: 'cheap',     // Optimize for cost over speed
    allowBridgeProviders: 'across',  // Use Across for bridging
    allowSwapProviders: 'lifi',      // Use LiFi for swaps
  }
}
```

## Fee Structure

| Scenario                         | Fee (BPS) |
| -------------------------------- | --------- |
| Same-chain, same underlying      | 0         |
| Same-chain, different underlying | 10        |
| Cross-chain migration            | 15        |

## Best Practices

<Warning>
  Always check `minOutputAmount` before confirming a migration. Large positions may experience slippage on the swap steps.
</Warning>

**For large positions:**

* Consider splitting into multiple smaller migrations
* Use `routeSelectionMode: 'cheap'` for best rates
* Set appropriate slippage (1-2% for cross-chain, 0.5% for same-chain)

**For time-sensitive migrations:**

* Use `routeSelectionMode: 'fast-quote'`
* Prefer `allowBridgeProviders: 'across'` for speed

## Supported Vault Types

<CardGroup cols={2}>
  <Card title="Lending" icon="building-columns">
    AAVE ↔ Compound ↔ Morpho ↔ Venus ↔ Spark
  </Card>

  <Card title="Yield" icon="chart-line">
    Yearn ↔ Beefy ↔ Convex ↔ Sommelier
  </Card>

  <Card title="Staking" icon="coins">
    Lido ↔ Rocket Pool ↔ Frax ↔ Stakewise
  </Card>

  <Card title="LP Positions" icon="droplet">
    Uniswap ↔ Curve ↔ Balancer ↔ Velodrome
  </Card>
</CardGroup>

## Next Steps

<CardGroup cols={2}>
  <Card title="Token to Vault" icon="arrow-right-to-bracket" href="/zaps/token-to-vault">
    Deposit any token into vaults
  </Card>

  <Card title="Vault to Token" icon="arrow-right-from-bracket" href="/zaps/vault-to-token">
    Withdraw from vaults to any token
  </Card>
</CardGroup>
