[sdk]: introduce ERC-4626 vault#965
Merged
Merged
Conversation
f9d6825 to
4e43ec9
Compare
4e43ec9 to
9f6df87
Compare
Wizdave97
approved these changes
Jun 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
StreamingYieldVault— a standalone ERC-4626 vault to@hyperbridge/corewhere yield is supplied by the owner via periodic transfers (addYield) and recognized linearly over a fixed window rather than instantly. Built on OpenZeppelin's auditedERC4626,Ownable, andPausable.Motivating use case: a stablecoin issuer (e.g. cNGN) that today distributes yield to holders manually. With this vault, distribution becomes a single periodic transfer, holders get a composable yield-bearing share token, and yield is paid in the asset itself.
Design
totalAssets() = balanceOf(this) - lockedYield, where the current tranche unlocks linearly overVEST(23h, tuned for a ~24h add cadence). This defeats yield sniping: because recognition is keyed onblock.timestamp, a same-block deposit→withdraw sees an unchanged share price and captures nothing.addYieldisonlyOwnerand reverts (YieldStillVesting) until the previous tranche has fully vested, so tranches never overlap and no yield is left permanently locked.pause()to freeze all share movement — transfers, deposits, and withdrawals — via a single_updatechokepoint, for emergencies. Yield can still be added while paused; it simply can't be withdrawn until unpaused._decimalsOffset()(OZ virtual shares/assets); seed-and-burn recommended at deploy.addYieldpulls funds before marking them locked, so a first tranche larger than current backing can't underflowtotalAssets.transfer/transferFrom; OZ orders effects before interactions. Assumes a standard, non-rebasing, non-fee-on-transfer, non-hooked ERC-20 (documented as an invariant).Tests
test/StreamingYieldVault.t.sol— 29 tests (incl. 2 fuzz), covering the known vuln classes:VEST, monotonic (fuzz).addYieldguard — reverts while vesting, allowed atvestedAt(), no backlog across cycles.pause/unpauseare owner-only;addYieldstill works while paused._updatechokepoint — every path into_updateis gated (mint, withdraw-by-assets,transferFrom), the gate sits at_updateitself (even a zero-value transfer reverts while paused),paused()tracks state across re-pause cycles, and all paths flow as a no-op when unpaused.onlyOwner, zero-amount.preview*matches realized, decimals offset applied.Notes
contracts/vaults/StreamingYieldVault.sol,test/StreamingYieldVault.t.sol, plus aforge-stdremapping. No existing contracts touched.@hyperbridge/coreas a reusable Solidity primitive.Docs
Adds a developer guide at
docs/content/developers/evm/streaming-yield-vault.mdx(registered in the EVM section nav) covering how streaming/vesting works, deployment with seed-and-burn, deposit/withdraw,addYield, pausing, a reference table, and security considerations.pnpm types:checkpasses.