You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tests: prepare for ERC4626 composability (NAV-based); remove 1:1 assumptions
- Deposit mints per previewDeposit (NAV), not 1:1
- Withdraw burns per previewWithdraw and updates only resolved vault
- Transfers do not modify per-user ledgers
- totalAssets sums across tracked vaults
- Ingesting SendEarn shares mints aggregator shares per NAV
Test plan:
- Run: bunx hardhat test test/rewards/SendEarnRewards.erc4626.spec.ts
Copy file name to clipboardExpand all lines: docs/rewards-aggregator-erc4626.md
+49-2Lines changed: 49 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,53 @@ Status: Spec only (docs-first). Implementation and tests will follow in separate
14
14
- Active vaults (wrapper-wide): first time a deposit is made into a vault, it’s added to `_activeVaults` for view-only `totalAssets()`.
15
15
- Active vaults (per-user): first time a user receives underlying shares for a vault, it’s added to that user’s active set for proportional re‑attribution on ERC20 transfers (no external calls).
16
16
17
-
## Asset and conversions
17
+
## Asset, conversions, and NAV-based accounting (v2.0)
18
+
- ERC4626 aggregator with `asset()` equal to the underlying asset used by all SendEarn vaults (e.g., USDC).
19
+
- NAV-based share pricing (standard ERC4626 math): aggregator shares represent a pro‑rata claim on the total aggregated assets held via SendEarn vault shares.
20
+
- Conversions (no 1:1 simplification):
21
+
-`totalAssets()` equals the sum, over all tracked vaults `v`, of `IERC4626(v).convertToAssets(IERC4626(v).balanceOf(address(this)))`.
22
+
-`_convertToShares(assets)` and `_convertToAssets(shares)` use standard ERC4626 formulas based on current `totalAssets()` and `totalSupply()`.
23
+
24
+
### Deposit interfaces
25
+
There are two complementary ways to contribute value:
- Redeem underlying vault shares sufficient to produce `assetsOut`, send to `receiver`
59
+
- Update per‑user ledger and burn aggregator shares using NAV
60
+
61
+
### Transfers
62
+
- ERC20 transfers of aggregator shares DO NOT modify per‑user underlying ledgers.
63
+
- Flows (CFA) are updated only on deposit/withdraw/redeem (see CFA v2.1).
18
64
- The aggregator’s `asset()` equals the underlying asset used by all routed SendEarn vaults (e.g., USDC).
19
65
- Follow standard ERC4626 math for conversions; do not assume 1:1 shares/assets. `totalAssets()` reflects the current value of all held SendEarn vault shares converted via each vault’s `convertToAssets`.
20
66
@@ -55,9 +101,10 @@ All routed targets MUST satisfy:
55
101
56
102
## Total assets (view-only)
57
103
-`totalAssets()` sums across wrapper-held positions:
0 commit comments