YieldFi
  • Introduction
  • Problem & Solution
  • How It Works
  • FAQs
  • USPs
  • Technical Docs
    • YToken Vaults
      • YUSD
      • YETH
      • YBTC
      • YLP
    • Architecture
    • Smart Contract Interaction
  • Guides
    • Mint
    • Swap
  • Rewards Program
    • LP Program
  • Concepts
    • Transparency
    • Custody Solution
    • Risk Management
    • Reserve Fund
  • Resources
    • V2 Contract Addresses
      • Old Contract Addresses
    • Audits
    • Oracles
    • Brand Kit
    • General Risk Disclosures
    • Privacy Policy
    • Terms of Service
Powered by GitBook
On this page
  • Overview
  • Core Concepts
  • YTokenL1
  • 1. Yield Distribution and Vesting
  • 2. Asset Valuation
  • 3. Yield Vesting Mechanism
  • 4. Example: Yield Distribution and Vesting
  • YTokenL2
  • 1. Oracle-Based Exchange Rate
  • 2. Unique Asset Valuation in YTokenL2
  1. Technical Docs

YToken Vaults

Overview

YToken Vaults form the foundation of the YieldFi protocol, offering users tokenized exposure to sophisticated yield-generating strategies. Each YToken represents a proportional claim on the underlying assets plus accumulated yield, enabling users to earn returns while maintaining liquidity.

We've crafted two distinct implementations to serve different blockchain environments:

  • YToken (L1) - Our flagship implementation designed for Ethereum Mainnet, featuring full ERC4626 compliance and our innovative yield vesting mechanism that helps protect users from yield volatility.

  • YTokenL2 - Our streamlined implementation tailored specifically for Layer 2 networks, utilizing oracle-based pricing to minimize gas costs while maintaining the core benefits of YTokens.

Core Concepts

YTokenL1

1. Yield Distribution and Vesting

YToken vaults use a yield distribution mechanism that balances immediate value accrual with price stability.

When our strategies generate yield, the profits aren't immediately reflected in the token price. Instead, we gradually incorporate these profits into the exchange rate over a vesting period (typically 24 hours). This creates a steady increase in token value rather than sudden jumps.

The vesting mechanism serves several important purposes:

  • Prevents abrupt exchange rate changes that could be exploited

  • Protects against yield sniping where users deposit right before and withdraw right after yield distribution

  • Creates a more predictable experience for all users

2. Asset Valuation

The value of YTokens is calculated through:

  • Total Assets Tracking: We continuously account for all assets under management

  • Vesting-Aware Calculations: When determining the exchange rate, we consider both fully vested yield and the portion of recent yield still in the vesting period

This approach ensures that token values grow smoothly and predictably, while still accurately reflecting the true value of the underlying assets.

3. Yield Vesting Mechanism

When profit is distributed to the vault, it enters a vesting period where it's gradually incorporated into the asset valuation.

The vesting calculation uses a simple formula:

Unvested Amount = (Remaining Vesting Time / Total Vesting Period) × Vesting Amount

For example, if 1,000 USDC in yield was distributed 12 hours ago with a 24-hour vesting period, only 500 USDC would be reflected in the current exchange rate. The remaining 500 USDC would gradually vest over the next 12 hours.

This mechanism serves multiple purposes:

  • Prevents abrupt exchange rate changes

  • Protects against yield sniping attacks

  • Incentivizes long-term holding

  • Creates a more predictable user experience

4. Example: Yield Distribution and Vesting

When yield is distributed to a YToken vault, it goes through a specific process that ensures fair and predictable value accrual. Let's walk through a real-world example:

Imagine our yUSD vault has $100M worth of assets deployed across various lending protocols. On Monday at 3pm, these strategies collectively generate $100k in profit.

The distribution process follows these steps:

  1. The Yield contract calls the YToken's reward function, indicating that $100k in profit should be added to the vault

  2. The YToken contract records this new yield and starts the vesting clock, setting the current time (Monday 3pm) as the starting point for the 24-hour vesting period

  3. The yield begins to affect the exchange rate gradually. If we check the value right after distribution:

    • Unvested Amount = (24 hours / 24 hours) × 100k = $100k

    • None of the yield is reflected in the current exchange rate yet

  4. Six hours later (Monday 9pm):

    • Unvested Amount = (18 hours / 24 hours) × 100k = $75k

    • Only $25k of the yield is reflected in the exchange rate

  5. Twelve hours later (Tuesday 3am):

    • Unvested Amount = (12 hours / 24 hours) × 100k = $50k

    • Half of the yield ($50k) is now reflected in the exchange rate

  6. By Tuesday 3pm (24 hours after distribution):

    • Unvested Amount = (0 hours / 24 hours) × $100k = 0 USDC

    • The full $100k USDC yield is now incorporated into the exchange rate

This gradual incorporation creates a smooth, predictable increase in token value that makes it impossible for users to time deposits right before yield distribution and withdrawals right after. Whether you hold through the entire vesting period or not, you'll receive a fair proportion of the yield based on your holding duration.

YTokenL2

YTokenL2 is an oracle-based implementation optimized for layer 2 networks, where cross-chain compatibility are paramount.

1. Oracle-Based Exchange Rate

Unlike our L1 implementation, YTokenL2 doesn't directly track assets through internal accounting. This reflects a fundamental architectural difference: the actual assets backing YTokenL2 tokens exist on L1, not on the L2 network itself.

Here's how this works:

When users interact with YTokenL2 on an L2 network, our offchain mechanism keeps track of these relationships and ensures that the exchange rates accurately reflect the true value of the underlying assets.

The Manager contract plays a crucial role in this system, helping update and synchronize values between the L1 and L2 environments. These synchronization are handled by the role based executor that syncs the values on L1, therefore these changes are accounted on YToken on L1 and bypass the need to be reflected in the L2 token values without requiring expensive cross-chain messaging for each update on every L2 chain.

function exchangeRate() public view returns (uint256) {
    require(oracle != address(0), "Oracle not set");

    uint256 rate = IOracleAdapter(oracle).fetchExchangeRate(address(this));
    require(rate > 0, "Invalid rate");

    // Convert from 18 decimals to asset decimals
    uint8 assetDecimals = IERC20Metadata(asset()).decimals();
    if (assetDecimals < 18) {
        return rate / (10 ** (18 - assetDecimals));
    }
    return rate;
}

This design offers several advantages:

  • Eliminates the need for complex on-chain accounting

  • Enables unified exchange rates across multiple networks

  • Eliminates the need to account for each chain individually as the L1 serves as the source of truth from where exchange rate is published via oracles.

2. Unique Asset Valuation in YTokenL2

Traditional ERC4626 vs. YTokenL2 Approach

Traditional ERC4626 vaults determine asset-to-share conversions using a fundamental formula:

shares = (assets * totalSupply) / totalAssets

This approach requires the contract to track the total assets under management and maintain accurate accounting as assets flow in and out.

function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual override returns (uint256) {
    return assets.mulDiv(Constants.PINT, exchangeRate(), rounding); // Constants.PINT = 1e18
}

function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual override returns (uint256) {
    return shares.mulDiv(exchangeRate(), Constants.PINT, rounding);
}

By relying on this oracle-based approach, the preview functions (previewDeposit, previewMint, previewWithdraw, and previewRedeem) all use the exchange rate rather than asset/supply ratios to determine expected amounts. This design reduces gas costs and simplifies cross-chain yield synchronization, making it particularly well-suited for L2 environments.

For example, if the exchange rate is 1.05e6 for a USDC-based vault, it means each YToken is worth 1.05 USDC.

PreviousUSPsNextYUSD

Last updated 22 days ago

YTokenL2 takes a fundamentally different approach. Instead of relying on internal accounting of total assets and total supply, it leverages an external oracle to provide the directly.

exchangeRate()