This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
forge build # Compile contracts
forge test # Run all tests
forge test --mt test_deposit # Run specific test by name
forge test -vvv # Run tests with verbose output
forge fmt # Format code
forge lint --severity high # Lint for high-severity issuesScripts in script/ follow pattern Deploy<ContractName>.s.sol. Run with:
forge script script/DeployX.s.sol --rpc-url $MAINNET_RPC_URL --broadcastAvailable RPC endpoints: mainnet, hoodi, chiado, gnosis (configured in foundry.toml)
- Tests use mainnet fork (requires
MAINNET_RPC_URLenv variable) - Fork block numbers are specified in test files (e.g.,
forkBlockNumber = 23_117_000) - Tests often use
vm.prank(),vm.warp(), andvm.startPrank()/vm.stopPrank()for impersonation and time manipulation - Subgraph endpoints for fetching test data (vaults, allocators, leverage positions):
- Ethereum:
https://graphs.stakewise.io/mainnet/subgraphs/name/stakewise/prod - Gnosis:
https://graphs.stakewise.io/gnosis/subgraphs/name/stakewise/prod
- Ethereum:
This is the StakeWise v3 periphery contracts repository containing supplementary contracts that interact with the core v3-core protocol.
StrategiesRegistry (src/StrategiesRegistry.sol): Central registry managing strategies and their proxies. Tracks enabled strategies, proxy addresses, and strategy-specific configurations.
StrategyProxy (src/StrategyProxy.sol): Minimal proxy contract that executes transactions on behalf of leverage strategies. Each user-vault-strategy combination gets its own proxy deployed via Clones.cloneDeterministic().
LeverageStrategy (src/leverage/LeverageStrategy.sol): Abstract base for leverage strategies. Uses osToken flash loans to create leveraged positions by:
- Depositing osToken to lending protocol (e.g., Aave)
- Borrowing asset tokens (WETH/GNO)
- Depositing borrowed assets to vault and minting more osToken
- Repeating via flash loan for maximum leverage
Chain-specific implementations:
EthAaveLeverageStrategy- Ethereum mainnet with Aave V3GnoAaveLeverageStrategy- Gnosis chain with Aave V3
TokensConverter (src/converters/): Converts reward tokens to vault asset tokens via CoW Protocol swaps. Uses composable conditional orders.
Helper Contracts (src/helpers/):
BoostHelpers- Calculates boost position details and LTV ratiosStakeHelpers- Facilitates staking operationsVaultUserLtvTracker- Tracks user LTV positions across vaults
MerkleDistributor (src/MerkleDistributor.sol): Distributes incentives using merkle proofs with oracle-signed root updates.
- Strategy proxies are deterministically addressed:
keccak256(abi.encode(strategyId, vault, user)) - Flash loan pattern for leverage: borrow osToken, convert to assets, deposit to vault, mint more osToken, repay flash loan
- Strategy configs stored in StrategiesRegistry as
bytesunderkeccak256(strategyId, configName)
v3-core: StakeWise core protocol (vaults, osToken, keeper)aave-v3-origin: Aave V3 for borrowing/lendingcomposable-cow: CoW Protocol for token swapsopenzeppelin-contracts-upgradeable: Upgradeable contract patterns
Solidity 0.8.26 with Cancun EVM, optimizer enabled (200 runs), via-IR compilation.
- Single quotes for strings (
'string'not"string") - Number underscores for thousands (
1_000_000) - Multi-line function headers with params first