Skip to content

X-O1/sayv

Repository files navigation

SAYV v1

SAYV is a savings account that earns yield on digital dollars (stablecoins) via Aave and offers users optional cash advances against their future yield. It plugs directly into YieldWield's Yield Advance for yield advance logic and TokenRegistry for token permissions.


What It Does

SAYV handles the vault logic for:

  • Accepting stablecoin deposits from users
  • Supplying those funds to Aave v3 to earn yield
  • Tracking user balances using Aave’s liquidity index and share math
  • Allowing users to take advances against future yield via YieldWield's Yield Advance
  • Managing an allowlist of tokens via TokenRegistry
  • Claiming protocol revenue automatically from Yield Advance fees

Installation (Forge)

To install SAYV into your Foundry project:

forge install X-O1/sayv

Then add your remappings to foundry.toml:

[profile.default]
src = 'contracts'
out = 'out'
libs = ['lib']

remappings = [
  '@sayv/=lib/sayv/contracts/',
  '@yield-advance/=lib/yield-advance/contracts/',
  '@token-registry/=lib/token-registry/src/'
]

Deploying SAYV

new Sayv(
  addressProviderAddress,      // Aave PoolAddressesProvider
  yieldAdvanceAddress,         // YieldWield's Yield Advance contract
  tokenRegistryAddress         // TokenRegistry contract
);

Make sure Aave and token registry contracts are deployed before initializing SAYV.


How It Works

1. Deposit

sayv.depositToVault(token, amount);

User deposits stablecoins → SAYV supplies to Aave → mints yield shares for the user.

2. Withdraw

sayv.withdrawFromVault(token, amount);

User burns yield shares → SAYV withdraws from Aave → sends stablecoins to user.

3. Take Advance

sayv.getYieldAdvance(token, collateralAmount, requestedAdvance);

User redeems part of their shares → YieldAdvance calculates advance + fee → SAYV withdraws and sends advance.

4. Repay Advance

sayv.repayYieldAdvanceWithDeposit(token, amount);

User sends stablecoins to repay their debt → SAYV re-supplies to Aave.

5. Unlock Collateral

sayv.withdrawYieldAdvanceCollateral(token);

Once debt is repaid → user gets collateral back → shares are re-minted.


Share Model

SAYV uses share-based accounting to represent user balances:

  • s_yieldShares — user’s share balance
  • s_totalYieldShares — total protocol shares
  • Shares convert to real token value via Aave’s liquidityIndex
  • Revenue shares are claimed from YieldWield's Yield Advance and added to s_totalRevenueShares

Token Management (Owner Only)

sayv.managePermittedTokens(token, true);  // Add
sayv.managePermittedTokens(token, false); // Remove
  • Automatically approves token for Aave supply
  • TokenRegistry is used for permissioning

Run Tests

forge test

License

MIT

About

High yield savings account that offers users optional cash advances on their future yield

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published