# 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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.yield.fi/earn-with-yieldfi/integration-sdk/contracts/vytoken-legacy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
