feat(strategy): add Compound V3 (Comet) strategy facet#18
Merged
Conversation
Adds a compound* prefixed strategy facet that supplies the vault's underlying to a Compound III base market (cUSDCv3) and reports its position via Comet's rebasing balanceOf, mirroring the aToken pattern of the Aave facet. - IComet: minimal interface (supply/withdraw/balanceOf/baseToken plus the getUtilization/getSupplyRate view rate-readers a curator uses on-chain) - CompoundV3StrategyFacet: EIP-7201 slot vaultrouter.strategy.compound; validates baseToken == asset at config time, clamps withdraws to the position so they can never tip into a borrow, tolerates Comet's present-value rounding on supply, and no-ops harvest (base interest auto-accrues into balanceOf) - MockComet + 23 unit tests (config gating, asset mismatch, supply and withdraw shortfall guards, over-request clamp, yield accrual, allocator rebalance routing/drain/skip paths, redeem boundary) - CompoundV3Strategy.fork.t.sol: 4 tests against the live Arbitrum cUSDCv3 market (RPC-gated, auto-skips without ARBITRUM_RPC_URL) - StorageNamespaces: pin the new namespace literal to its erc7201 hash
c3b585b to
75d615c
Compare
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 a
compound*-prefixed strategy facet that supplies the vault's underlying asset to a Compound III (Comet) base market (cUSDCv3) and reports its position via Comet's rebasingbalanceOf. Shape mirrorsAaveStrategyFacet: Comet'sbalanceOfis a live-accruing rebasing balance, so the position needs no receipt-token bookkeeping andharvestis a no-op.This gives the router a second deep-liquidity money market on Arbitrum (Aave ~$1.0B, Compound III among the top markets) with a different rate curve, so allocations diversify rather than duplicate Aave's risk profile.
What's included
IComet— minimal interface (supply/withdraw/balanceOf/baseToken, plus thegetUtilization/getSupplyRateview rate-readers a curator uses to price the market on-chain). Trimmed to the facet's surface, matchingIAavePool.CompoundV3StrategyFacet— EIP-7201 slotvaultrouter.strategy.compound.MockComet+ 23 unit tests (no RPC needed).CompoundV3Strategy.fork.t.sol— 4 tests against the live Arbitrum cUSDCv3 market, RPC-gated (auto-skips withoutARBITRUM_RPC_URL).StorageNamespaces— pins the new namespace literal to its erc7201 hash.Design decisions (where it diverges from the Aave facet)
comet.baseToken() == asset(the Morpho-style guard Aave lacks), so a market for the wrong asset can never be wired in.compoundWithdrawclamps the request tobalanceOfand measures the underlying actually received.SUPPLY_ROUNDING_SLACK = 2— Comet rounds principal down on supply, so a strict< amountcheck (like Aave's) would flake; a real fee-on-supply still trips the guard, and any reverting deposit becomes a per-strategy rebalance skip, not a bricked batch.harvestis a no-op — base interest auto-accrues intobalanceOf. COMP incentive rewards accrue separately viaCometRewards(a non-underlying token needing its own claim/sell/account path) and are intentionally out of scope.Testing
Live Arbitrum addresses used by the fork test: Comet cUSDCv3
0x9c4ec768c28520B50860ea7a15bd7213a9fF58bf, base USDC0xaf88d065e77c8cC2239327C5EDb3A432268e5831.Notes
main(which now contains the erc7201 slot conventions this work depends on); the diff is just the Compound facet.