EIPs Explained

ERC-5115 · Draft · ERC · 2022-05-30

ERC-5115: SY Token

Standardized Yield (SY): an ERC-20 wrapper interface for any yield-bearing position (lending, LP tokens, liquid staking, reward farms), with multi-token deposit/redeem and a single exchangeRate.

What problem does it solve?

Yield comes from many places: lending markets, AMM liquidity, liquid staking, reward farms and rebasing tokens. Each has its own interface, so a protocol that builds on top of them needs a custom adapter for every source.

ERC-4626 solved this for vaults with one underlying asset. It does not fit everything. An AMM pool's value is measured in "liquidity units" that you cannot deposit directly. Some positions earn extra reward tokens, and some wrappers want to accept several input tokens. ERC-5115, Standardized Yield (SY), is a looser interface meant to wrap almost any of these.

How it works

The spec models every yield source as a Generic Yield Generating Pool:

  • asset: the unit the pool's value is measured in (USDC for a lending market, stETH for wstETH, LP liquidity for an AMM).
  • shares: units of ownership in the pool. An SY token is the shares, as an ERC-20.
  • exchangeRate: assets per share, scaled by 1e18. It goes up as the pool earns.
  • reward tokens: optional extra tokens the pool earns, such as COMP.

On top of ERC-20 (with name, symbol and decimals required), the interface adds:

Function Purpose
deposit(receiver, tokenIn, amount, minSharesOut, depositFromInternalBalance) Convert any supported input token into SY shares
redeem(receiver, shares, tokenOut, minTokenOut, burnFromInternalBalance) Burn shares for any supported output token
exchangeRate() assetBalance = syBalance * exchangeRate / 1e18
getTokensIn() / getTokensOut() Lists of accepted input and output tokens
yieldToken() The wrapped yield-bearing token (zero address for a native SY)
previewDeposit / previewRedeem Quotes that must not exceed the actual result

deposit and redeem include slippage limits (minSharesOut and minTokenOut), emit Deposit and Redeem events, and may accept native ETH. The ...InternalBalance flags allow a Uniswap-V2-style flow, where tokens are sent to the contract first and then claimed in the same transaction.

Sample code

Depositing USDC into an SY wrapper and reading the underlying value (ethers v6):

import { Contract, Wallet, JsonRpcProvider, parseUnits } from "ethers";

const signer = new Wallet(process.env.PRIVATE_KEY!, new JsonRpcProvider(process.env.RPC_URL));
const sy = new Contract(syAddress, [
  "function getTokensIn() view returns (address[])",
  "function previewDeposit(address,uint256) view returns (uint256)",
  "function deposit(address,address,uint256,uint256,bool) payable returns (uint256)",
  "function exchangeRate() view returns (uint256)",
  "function balanceOf(address) view returns (uint256)",
], signer);
const usdc = new Contract(usdcAddress, ["function approve(address,uint256) returns (bool)"], signer);

const amount = parseUnits("1000", 6);
const quote = await sy.previewDeposit(usdcAddress, amount);
await (await usdc.approve(syAddress, amount)).wait();
await (await sy.deposit(signer.address, usdcAddress, amount, quote * 995n / 1000n, true)).wait(); // 0.5 % slippage

const shares = await sy.balanceOf(signer.address);
console.log("value in assets:", (shares * (await sy.exchangeRate())) / 10n ** 18n);

Things to know

  • Status: Draft. The interface may still change. For plain single-asset vaults, ERC-4626 is the established, Final standard and the authors expect it to stay the default.
  • The authors are from Pendle, whose protocol wraps yield sources as SY tokens. Outside that ecosystem, support is limited.
  • exchangeRate is in asset units, which are not always a token you can withdraw (for example, AMM liquidity units). Use previewRedeem to get an amount in a specific output token.
  • Reward claiming is mentioned as a possible extension but is not part of this interface.
  • Any contract can claim to be SY. Integrators should review each implementation, and yieldToken() must truthfully report what is wrapped.
  • SY tokens may implement ERC-2612 permit and may revert on transfer if they are designed to be non-transferable.

#defi #yield #erc-20 #vaults #wrappers

Details

Authors
Vu Nguyen (@mrenoon), Long Vuong (@UncleGrandpa925), Anton Buenavista (@ayobuenavista)
Status
Draft
Type
Standards Track / ERC
Created
2022-05-30
Requires

Machine-readable: Markdown · JSON