How sherlock-audit/2025-05-yearn-ybold works
Project type and purpose
• This is a DeFi on-chain protocol: a Yearn V3 ERC-4626 vault (“yBOLD”) plus companion strategies that interact with Liquity V2 Stability Pools and Auction contracts. It includes profit tracking (Accountant), staking wrapper (Staker), and off-chain keepers to call tend/harvest.
File structure
• Top level:
• yv3-liquityv2-sp-strategy/ — core Solidity code, configs, tests
• src/interfaces/ — external protocol and Yearn interface definitions
• src/periphery/ — Accountant.sol, Staker.sol and their Factories
• Strategy.sol + StrategyFactory.sol
• Staker.sol + StakerFactory.sol
• lib/ — vendored Yearn and OpenZeppelin libraries, TokenizedStrategy, VaultV3
• config files: foundry.toml, slither.config.json, .env.example, Makefile
• Factories indicate a dynamic-deployment pattern (StrategyFactory, AccountantFactory, StakerFactory).
Key architecture points from README
• yBOLD vault (VaultV3) allocates BOLD into N Strategy instances (each wraps a Liquity Stability Pool + Auction)
• Accountant.sol collects all gains from yBOLD, mints new yBOLD to itself, then distributes to st-yBOLD via Staker.sol
• Off-chain keepers call tend() (to claim collateral & start auctions) and harvest() (to report P/L)
• External integrations: Liquity StabilityPool, AuctionFactory/Auction, price oracles, TroveManager, etc.
Main components
a. On-chain contracts:
• yBOLD Vault (ERC-4626, VaultV3)
• Strategy (Strategy.sol) + StrategyFactory
• Accountant (Accountant.sol) + AccountantFactory
• Staker (Staker.sol) + StakerFactory
• External protocol contracts:
– StabilityPool
– Auction / AuctionFactory
– TroveManager, ActivePool, CollateralRegistry, SortedTroves, MultiTroveGetter
– PriceFeed / AggregatorV3Interface
b. Off-chain services:
• Keeper bots (call tend/harvest)
c. External systems:
• Price oracles (e.g., Chainlink)
• Ethereum / L2 networks (Ethereum, Arbitrum, etc.)
Relationships & data flows
• User → deposit BOLD → yBOLD Vault → issues yBOLD
• yBOLD Vault ↔ Strategy instances (deposit/withdraw BOLD; report P/L)
• Strategy ↔ StabilityPool (deposit BOLD collateral), Strategy ↔ Auction (auction collateral → BOLD)
• Strategy.report → yBOLD → Accountant
• Accountant.mint yBOLD → to itself → forward to Staker
• User → deposit yBOLD → Staker → earn yield
• Keepers monitor on-chain events → call tend()/harvest() on Strategy
Architectural patterns & design principles
• Factory pattern for dynamic contract deployments
• ERC-4626 vault standard for yBOLD & st-yBOLD
• TokenizedStrategy inheritance: reuse Yearn’s base strategy logic
• Separation of concerns: Vault (user shares), Strategy (yield logic), Accountant (fee routing), Staker (yield distribution)
• Off-chain keeper orchestration
Essential elements
• Component labels, version references (e.g., VaultV3.vy)
• Arrowheads with action labels (deposit(), tend(), harvest(), process_report())
• Blue = core on-chain contracts
• Green = external protocol contracts
• Orange = off-chain keepers