> For the complete documentation index, see [llms.txt](https://docs.yield.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yield.fi/earn-with-yieldfi/integration-sdk/contracts/vytoken-legacy.md).

# VyToken (Legacy)

> **Note**: This page documents legacy VyToken contracts. For v3 contracts, see Vault Contract.

VyToken contracts are volatile yield token contracts (vyUSD, vyBTC, vyETH) with enhanced yield optimization from earlier versions.

### Connecting to VyToken

#### Using Wagmi

```typescript
import { connectVyToken, getContractAddresses, Chain } from "yieldfi-sdk";
import { ethers } from "ethers";
import { useAccount, useWalletClient } from "wagmi";

function VyTokenExample() {
  const { address } = useAccount();
  const { data: walletClient } = useWalletClient();

  const connectVyTokenContract = async () => {
    if (!walletClient || !address) {
      throw new Error("Wallet not connected");
    }

    const provider = new ethers.BrowserProvider(walletClient);
    const signer = await provider.getSigner();

    const contracts = getContractAddresses(Chain.ETHEREUM);
    const vyUSD = connectVyToken(
      contracts.vyUSD,
      vyTokenAbi, // Your VyToken ABI
      signer
    );

    return vyUSD;
  };
}
```

#### Using Browser Provider

```typescript
import { connectVyToken, getContractAddresses, Chain } from "yieldfi-sdk";
import { ethers } from "ethers";

if (!window.ethereum) {
  throw new Error("No wallet found");
}

const provider = new ethers.BrowserProvider(window.ethereum);
const signer = await provider.getSigner();

const contracts = getContractAddresses(Chain.ETHEREUM);

const vyUSD = connectVyToken(
  contracts.vyUSD,
  vyTokenAbi, // Your VyToken ABI
  signer
);
```

### VyToken-Specific Operations

#### Deposit YToken

```typescript
// Approve yToken spending
await yUSD.approve(vyUSD.target, amount);

// Deposit yToken directly
await vyUSD.depositYToken(receiver, amount);
```

#### View Methods

```typescript
// Get underlying yToken
const yToken = await vyUSD.yToken();

// Get guardrail multiplier
const guardrail = await vyUSD.guardrailMultiplier();

// Get total yToken deposited
const totalYToken = await vyUSD.totalYToken();
```

### Inherited Operations

VyToken inherits all YToken operations (ERC-20 and ERC-4626):

```typescript
// ERC-20
const balance = await vyUSD.balanceOf(userAddress);
await vyUSD.transfer(recipient, amount);

// ERC-4626
const shares = await vyUSD.deposit(amount, receiver);
await vyUSD.redeem(shares, receiver, owner);
```

### Migration to V3

For new integrations, use v3 contracts:

* **Manager V3** - See Manager Contract
* **Vault Contract** - See Vault Contract
