### Complete Workflow Example Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Commands to start an Anvil fork and run the full test workflow: deploy, activate via MS batch, create proposal, and execute proposal. ```bash # Terminal 1: Start Anvil fork (uses mainnet RPC from foundry.toml) pnpm run anvil:fork # Terminal 2: Run full test workflow # 1. Deploy ./shell/deployV3.sh \ --account tester \ --sequence src/scripts/deploy/savedDeployments/price.json \ --chain http://localhost:8545 \ --broadcast true # 2. MS Batch to activate ./shell/safeBatchV2.sh --contract PriceDeploy --function run --chain mainnet --account tester --fork true --broadcast true # 3. Create proposal src/scripts/proposals/submitProposal.sh --file src/proposals/UpdatePrice.sol --contract UpdatePrice --account tester --chain http://localhost:8545 --broadcast true # 4. Execute proposal src/scripts/proposals/executeOnAnvilFork.sh --file src/proposals/UpdatePrice.sol --contract UpdatePrice ``` -------------------------------- ### Install Modules and Policies Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/convertible_deposits/INSTALL.md Executes the ConvertibleDepositInstall contract's install function via safeBatchV2.sh to install modules and activate the policy. ```bash ./shell/safeBatchV2.sh --contract ConvertibleDepositInstall --function install --chain sepolia --account OlympusDeployer --broadcast true ``` -------------------------------- ### Clone and Setup olympus-contracts Repository Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Commands to clone the olympus-contracts repository, checkout the sepolia branch (which has updated dependencies and Sepolia config), and install dependencies with yarn. ```bash git clone https://github.com/OlympusDAO/olympus-contracts.git cd olympus-contracts git checkout sepolia # Has updated dependencies and Sepolia config yarn ``` -------------------------------- ### Install and Enable Token Pool Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/BRIDGE_CCIP.md Install and enable the token pool. Append --broadcast to perform the actual transaction instead of a simulation. ```bash forge script src/scripts/ops/batches/CCIPTokenPool.sol --sig "install(bool)()" true --rpc-url --account < cast account > --slow -vvv --sender < account address > ``` -------------------------------- ### Install dependencies with pnpm Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Installs all project dependencies. Runs the postinstall script automatically. ```bash pnpm install ``` -------------------------------- ### Install dependencies and build with Foundry Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/README.md Changes to the bophades directory, checks out the rbs-v2 branch, installs npm modules for linting and doc generation, and compiles contracts with forge build, which also installs git submodule dependencies. ```sh cd bophades git checkout rbs-v2 pnpm run install # install npm modules for linting and doc generation forge build # installs git submodule dependencies when contracts are compiled ``` -------------------------------- ### Dummy test to ensure setUp execution Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/proposals/README.md Include this test in the proposal test file to verify that the setUp function runs correctly. It simply asserts true. ```solidity // [DO NOT DELETE] Dummy test to ensure that `setUp` is executed function testProposal() public { assertTrue(true); } ``` -------------------------------- ### Start Anvil Fork Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/proposals/README.md Starts a local Anvil fork for testing purposes. ```bash pnpm run anvil:fork ``` -------------------------------- ### Install PRICEv2 submodules Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/CONFIG.md Installs seven submodules (BalancerPoolTokenPrice, BunniPrice, ChainlinkPriceFeeds, ERC4626Price, UniswapV2PoolTokenPrice, UniswapV3Price, SimplePriceFeedStrategy) on PRICEv2 using PriceConfigV2.installSubmodule.selector. ```solidity // 6. Install submodules on PRICEv2 // - Install BalancerPoolTokenPrice submodule // - Install BunniPrice submodule // - Install ChainlinkPriceFeeds submodule // - Install ERC4626Price submodule // - Install UniswapV2PoolTokenPrice submodule // - Install UniswapV3Price submodule // - Install SimplePriceFeedStrategy submodule console2.log("Installing BalancerPoolTokenPrice submodule"); addToBatch( priceConfigV2, abi.encodeWithSelector(PriceConfigV2.installSubmodule.selector, balancerPoolTokenPrice) ); console2.log("Installing BunniPrice submodule"); addToBatch( priceConfigV2, abi.encodeWithSelector(PriceConfigV2.installSubmodule.selector, bunniPrice) ); console2.log("Installing ChainlinkPriceFeeds submodule"); addToBatch( priceConfigV2, abi.encodeWithSelector(PriceConfigV2.installSubmodule.selector, chainlinkPriceFeeds) ); console2.log("Installing ERC4626Price submodule"); addToBatch( priceConfigV2, abi.encodeWithSelector(PriceConfigV2.installSubmodule.selector, erc4626Price) ); console2.log("Installing UniswapV2PoolTokenPrice submodule"); addToBatch( priceConfigV2, abi.encodeWithSelector(PriceConfigV2.installSubmodule.selector, uniswapV2PoolTokenPrice) ); console2.log("Installing UniswapV3Price submodule"); addToBatch( priceConfigV2, abi.encodeWithSelector(PriceConfigV2.installSubmodule.selector, uniswapV3Price) ); console2.log("Installing SimplePriceFeedStrategy submodule"); addToBatch( priceConfigV2, abi.encodeWithSelector(PriceConfigV2.installSubmodule.selector, simplePriceFeedStrategy) ); ``` -------------------------------- ### Start Anvil fork Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Starts the Anvil fork using the mainnet RPC from foundry.toml. This is a prerequisite for local testing. ```bash # Start Anvil fork (uses mainnet RPC from foundry.toml) pnpm run anvil:fork ``` -------------------------------- ### Grant roles and ownership Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY_L2.md Runs the grantRoles.sh script to grant roles and ownership for initial setup. ```bash ./shell/L2/grantRoles.sh --account --env --broadcast true ``` -------------------------------- ### Start Anvil Fork of Sepolia Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Optional local testing: starts an Anvil fork of Sepolia. Scripts detect chain from block.chainid and use appropriate RPC URL. ```bash # Terminal 1: Start Anvil fork anvil --fork-url sepolia ``` -------------------------------- ### Launch Anvil fork Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/proposals/README.md Starts a local Anvil fork for testing. Requires the FORK_TEST_RPC_URL environment variable to be set. ```bash anvil --fork-url $FORK_TEST_RPC_URL --port 8545 --auto-impersonate ``` -------------------------------- ### Test assertion with decimal scale comments Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Example format for documenting mathematical working in test assertions. Shows step-by-step calculation with decimal scales and expected value derivation, including rounding down behavior. ```solidity // deposit = 5e18 (18 decimals) // ohmScale = 1e9 (9 decimals) // price = 2e18 (18 decimals) // Expected: (5e18 * 1e9) / 2e18 = 5e27 / 2e18 = 2.5e9 (9 decimals) // Rounds down to 2e9 assertEq(convertibleAmount, 2e9, "Convertible amount does not equal 2e9"); ``` -------------------------------- ### Constructor arguments hex representation Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY.md Example of how constructor arguments are decoded into hex format for verification. ```hex constructor(address,address,address,uint256,uint256[2],uint256[2])" 0x 0000000000000000000000002286d7f9639e8158fad1169e76d1fbc38247f54b # address1 00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5 # address2 0000000000000000000000006b175474e89094c44da98b954eedeac495271d0f # address3 0000000000000000000000000000000000000000000000000000000000000064 # uint256 00000000000000000000000000000000000000000000000000000000000003e8 # array1[0] 00000000000000000000000000000000000000000000000000000000000007d0 # array1[1] 00000000000000000000000000000000000000000000000000000000000003e8 # array2[0] 00000000000000000000000000000000000000000000000000000000000007d0 # array2[1] ``` -------------------------------- ### Handoff ownership to DAO multisig Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY_L2.md Transfers ownership of the installation to the DAO multisig. Run using the deployer account. ```bash ./shell/L2/handoff.sh --account MyAccount --env .env.optimism --broadcast true ``` -------------------------------- ### Setup bridge on Base to trust Optimism Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY_L2.md Configures the CrossChainBridge on Base to trust messages from the Optimism CrossChainBridge. Run using an address with the bridge_admin role on Base (likely the deployer account). ```bash ./shell/L2/setupBridge.sh --account MyAccount --localChain base --remoteChain optimism --env .env.base ``` -------------------------------- ### Setup bridge on Optimism to trust Base Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY_L2.md Configures the CrossChainBridge on Optimism to trust messages from the Base CrossChainBridge. Run using the deployer account. ```bash ./shell/L2/setupBridge.sh --account MyAccount --localChain optimism --remoteChain base --env .env.optimism ``` -------------------------------- ### RPC URL examples for --chain flag Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Shows how to pass RPC URLs with the --chain flag for Anvil fork, Tenderly VNet, and mainnet. The script automatically detects localhost URLs and applies the --legacy flag for EIP-1559 compatibility. ```bash # Anvil fork --chain http://localhost:8545 # Tenderly VNet --chain https://rpc.tenderly.co/vnet/... # Mainnet (uses foundry.toml endpoint) --chain mainnet ``` -------------------------------- ### List all linting rules with notes/warnings Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md This command filters `forge lint` output to list unique linting rule names (excluding src/test) with their notes and warnings. Useful for getting an overview of all linting rules. ```bash # List all linting rules with notes/warnings forge lint 2>&1 | grep -E "^warning\[|^note\[" | grep -v "src/test" | sed 's/^.*\[\([^]]*\)\].*/\1/' | sort | uniq | cat ``` -------------------------------- ### Retrieve Olympus module address from kernel Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/proposals/README.md Use this pattern to get module addresses from the Olympus kernel instead of importing them directly. It fetches the kernel from the address registry and then retrieves the module address by keycode, e.g., 'TRSRY'. ```solidity Kernel kernel = Kernel(addresses.getAddress("olympus-kernel")); address TRSRY = address(kernel.getModuleForKeycode(toKeycode(bytes5("TRSRY")))); ``` -------------------------------- ### GovernorBravo castVoteInternal minimum vote calculation Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/proposals/OCG.md Calculates the voter's influence by taking the minimum of their voting power at the start of the proposal and at the time of voting. ```solidity function castVoteInternal( address voter, uint256 proposalId, uint8 support ) internal returns (uint256) { // Checks... // Get the user's votes at the start of the proposal and at the time of voting. Take the minimum. uint256 originalVotes = gohm.getPriorVotes(voter, proposal.startBlock); uint256 currentVotes = gohm.getPriorVotes(voter, block.number - 1); uint256 votes = currentVotes > originalVotes ? originalVotes : currentVotes; // Effects... } ``` -------------------------------- ### Build all files with pnpm or forge Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Builds all project files. Both commands are equivalent for building the entire project. ```bash pnpm build ``` ```bash forge build ``` -------------------------------- ### Deploy Bophades on L2 Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY_L2.md Runs the deployment script for a new L2 chain. Set --broadcast to false for simulation mode (recommended). Requires a .env. file and a cast wallet account. ```bash ./shell/L2/deploy.sh --account --env --broadcast true --verify true ``` -------------------------------- ### Create oracle_args.json for oracle deployment Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/oracle_factories.md Define the token addresses and price bounds in a JSON file to be used by the deployment script. ```json { "functions": [ { "name": "deployChainlinkOracle", "args": { "baseToken": "0x...", "quoteToken": "0x...", "minPrice": "1000000000000000000", "maxPrice": "10000000000000000000" } } ] } ``` -------------------------------- ### previewMigrate Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/V1_MIGRATOR.md Preview the OHM v2 amount that will be received for a given OHM v1 amount. ```APIDOC ## previewMigrate ### Description Preview the OHM v2 amount that will be received for a given OHM v1 amount. ### Function Signature ```solidity function previewMigrate(uint256 amount_) external view returns (uint256 ohmV2Amount_); ``` ### Parameters - **amount_** (uint256) - The amount of OHM v1 to preview. ### Returns - **ohmV2Amount_** (uint256) - The corresponding OHM v2 amount. ``` -------------------------------- ### Execute deployment shell script Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY.md Run the deployment process using the specified sequence file. Optional flags include --broadcast, --verify, --resume, and --env. ```shell shell/deploy.sh --sequence src/scripts/deploy/savedDeployments/rbs_v1_3.json ``` -------------------------------- ### Run linting with pnpm Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/README.md Runs the pre-configured solhint and prettier-plugin-solidity linters. ```sh pnpm run lint ``` -------------------------------- ### Deployment Order Summary Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Text-based deployment order summary showing the sequence of steps across the olympus-contracts and Bophades repos, including the VerifyLegacyStaking usage command. ```text 1. olympus-contracts repo (0.7.5) └── Deploy sOHM → gOHM → Staking → setIndex → setgOHM → initialize → migrate └── Add addresses to env.json 2. Bophades repo - VerifyLegacyStaking (0.8.15) └── Reads from env.json → Verifies on-chain configuration └── Usage: forge script src/scripts/ops/VerifyLegacyStaking.s.sol --rpc-url sepolia 3. Bophades repo - ReplaceStaking (0.8.15) ├── Phase 1: Deactivate old policies ├── Phase 2: Upgrade DLGTE module ├── Phase 3: Deploy new policies ├── Phase 4: Activate new policies ├── Phase 5: Enable CoolerTreasuryBorrower ├── Phase 6: Test staking (mint and stake sample OHM) ├── Phase 7: Update env.json └── Phase 8: Verify deployment ``` -------------------------------- ### Deploy ConvertibleDeposits Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/convertible_deposits/INSTALL.md Deploys the ConvertibleDeposits contract on Sepolia using the deployV3.sh script with the specified sequence file and environment. ```bash ./shell/deployV3.sh --account OlympusDeployer --sequence src/scripts/deploy/savedDeployments/convertible_deposit.json --chain sepolia --env .env.sepolia --broadcast true --verify true ``` -------------------------------- ### Run Activator Script Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/convertible_deposits/INSTALL.md Executes the ConvertibleDepositInstall contract's runActivator function via safeBatchV2.sh to run the activator. ```bash ./shell/safeBatchV2.sh --contract ConvertibleDepositInstall --function runActivator --chain sepolia --account OlympusDeployer --broadcast true ``` -------------------------------- ### Set Merkle Root via safeBatchV2.sh (simulation) Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/V1_MIGRATOR.md Command to simulate setting the merkle root on the V1Migrator contract using the safeBatchV2.sh script. Recommended for DAO MS execution. ```bash ./shell/safeBatchV2.sh --chain mainnet --contract V1MigratorConfig --function setMerkleRoot --args src/scripts/ops/batches/args/V1MigratorConfig_setMerkleRoot.json ``` -------------------------------- ### Run Ethereum deployment script Source: https://github.com/olympusdao/olympus-v3/blob/develop/shell/lz-bridge/anvil-deployment/README.md Executes the mainnet deployment and activation flow for the LZ bridge. This script runs the full sequence: injecting placeholder L2 gateways, forking mainnet, deploying the bridge contracts, syncing addresses, running the pre-OCG and post-OCG steps, and printing the final state. ```bash ./run-ethereum.sh ``` -------------------------------- ### Run L2 deployment script Source: https://github.com/olympusdao/olympus-v3/blob/develop/shell/lz-bridge/anvil-deployment/README.md Executes the deployment and configuration batch for a specified L2 chain. ```bash ./run-l2.sh --chain arbitrum ``` -------------------------------- ### Run Deployment on Sepolia Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Command to run the deployment script on the Sepolia network using Hardhat. ```bash npx hardhat run scripts/deploy-staking-only.js --network sepolia ``` -------------------------------- ### Submit Proposal via Ledger Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/proposals/README.md Submits a proposal using a Ledger hardware wallet. ```bash ./src/scripts/proposals/submitProposal.sh \ --file src/proposals/ContractRegistryProposal.sol \ --contract ContractRegistryProposalScript \ --ledger 0 \ --chain mainnet \ --broadcast true \ --env .env ``` -------------------------------- ### Verify deployment Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY_L2.md Verifies the deployment using the verify.sh script. ```bash ./shell/L2/verify.sh --env .env.optimism ``` -------------------------------- ### Deploy Chainlink oracle via safeBatchV2.sh Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/oracle_factories.md Execute the batch script to deploy a Chainlink oracle using the specified arguments file. ```bash # Deploy Chainlink oracle for a token pair ./shell/safeBatchV2.sh \ --contract DeployOracles \ --function deployChainlinkOracle \ --chain mainnet \ --multisig true \ --broadcast true \ --args oracle_args.json ``` -------------------------------- ### Deploy ReplaceStaking script using Ledger Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Deploys the ReplaceStaking script on the Sepolia network using a Ledger hardware wallet. ```bash forge script src/scripts/ops/ReplaceStaking.s.sol:ReplaceStaking \ --rpc-url sepolia \ --ledger \ --mnemonic-indexes <> \ --sender 0x1A5309F208f161a393E8b5A253de8Ab894A67188 \ --broadcast \ --verify \ -vvv ``` -------------------------------- ### Rehearse with --use-deployed flag Source: https://github.com/olympusdao/olympus-v3/blob/develop/shell/lz-bridge/anvil-deployment/README.md Skips the deploy step and runs the activation flow against already-deployed contracts. The fork is taken at the latest block, so the deployed bytecode is present. Assumes the contracts are still in their pre-activation state. ```bash ./run-ethereum.sh --use-deployed # OCG proposal against the deployed mainnet contracts ``` ```bash ./run-l2.sh --chain arbitrum --use-deployed # L2 batches against the deployed Arbitrum contracts ``` -------------------------------- ### Load PRICE configuration variables from JSON Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/CONFIG.md Reads observation times and arrays for DAI, USDC, and WETH from a JSON file using vm.readFile and readUint/readUintArray. ```solidity // 0. Load variables from the JSON file // TODO final values need to be added string memory argData = vm.readFile("./src/scripts/ops/batches/RBSv2Install_3_RBS.json"); uint256 daiLastObsTime_ = argData.readUint(".daiLastObsTime"); uint256[] memory daiObs_ = argData.readUintArray(".daiObs"); // 7 days * 24 hours / 8 hours = 21 observations uint256 usdcLastObsTime_ = argData.readUint(".usdcLastObsTime"); uint256[] memory usdcObs_ = argData.readUintArray(".usdcObs"); // 7 days * 24 hours / 8 hours = 21 observations uint256 wethLastObsTime_ = argData.readUint(".wethLastObsTime"); uint256[] memory wethObs_ = argData.readUintArray(".wethObs"); // 7 days * 24 hours / 8 hours = 21 observations ``` -------------------------------- ### Configure OHM on PRICE with Uniswap V3 TWAP Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/CONFIG.md Creates a PRICEv2.Component array with a UniswapV3Price.getTokenTWAP selector and parameters, then adds the OHM price feed to PriceConfigV2 using addAssetPrice. The observation window is shorter because it is compared against reserves. ```solidity // 7. Configure OHM on PRICE // - Uses a TWAP from the Uniswap V3 pool with the configured observation window { PRICEv2.Component[] memory ohmFeeds = new PRICEv2.Component[](1); ohmFeeds[0] = PRICEv2.Component( toSubKeycode("PRICE.UNIV3"), UniswapV3Price.getTokenTWAP.selector, abi.encode( UniswapV3Price.UniswapV3Params({ pool: IUniswapV3Pool(ohmWethUniV3Pool), observationWindowSeconds: twapObservationWindow, // This is shorter, as it is compared against reserves maxDeviationBps: twapMaxDeviationBps }) ) ); console2.log("Adding OHM price feed to PRICE"); addToBatch( priceConfigV2, abi.encodeWithSelector( PriceConfigV2.addAssetPrice.selector, ohm, false, // store moving average false, // use the moving average as part of price strategy 0, // moving average 0, new uint256[](0), PRICEv2.Component(toSubKeycode(bytes20(0)), bytes4(0), abi.encode(0)), // no price strategy ohmFeeds ) ); } ``` -------------------------------- ### Create OCG proposal with Ledger Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Creates and tests an OCG proposal using a Ledger device. Pass --chain http://localhost:8545 to use the local Anvil fork. ```bash # Using a Ledger src/scripts/proposals/submitProposal.sh \ --file src/proposals/MyProposal.sol \ --contract MyProposal \ --ledger 0 \ --chain http://localhost:8545 \ --broadcast true ``` -------------------------------- ### Import deployer account as a cast wallet Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/lz-bridge-testnet/README.md Register the deployer account once as a cast wallet for use in deployment scripts. Alternatively, pass --ledger instead of --account lz-testnet. ```bash cast wallet import lz-testnet --interactive ``` -------------------------------- ### Run CodeRabbit review Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Run CodeRabbit before pushing or when explicitly requested. Verify the PR base and diff scope before trusting the result. ```bash coderabbit review --agent --base ``` -------------------------------- ### Run Deployment on Anvil Fork Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Command to run the deployment script on a local Anvil fork. Ensure Anvil is running before executing this command. ```bash # Ensure Anvil is running (see Environment Setup) npx hardhat run scripts/deploy-staking-only.js --network localhost ``` -------------------------------- ### Wrap OHM to gOHM Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY_TESTNET.md Runs the stakeToGOhm.sh script to wrap OHM to gOHM. ```bash ./shell/mint/stakeToGOhm.sh ``` -------------------------------- ### Submit proposal with Forge script Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/proposals/README.md Runs the proposal script against the local fork, simulating submission. Reverts if there are any issues. ```bash forge script src/proposals/ConvertibleDepositProposal.sol:ConvertibleDepositProposalScript --rpc-url http://localhost:8545 --account -vvv --slow ``` -------------------------------- ### Submit OCG Oracle Proposal Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/oracle_factories.md Submits the OracleProposal.sol script to enable oracle policies and deploy initial oracles via on-chain governance. ```bash src/scripts/proposals/submitProposal.sh \ --file src/proposals/OracleProposal.sol \ --contract OracleProposalScript \ --account \ --chain mainnet \ --broadcast true ``` -------------------------------- ### Configure EmissionManager Roles Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/convertible_deposits/INSTALL.md Executes the ConvertibleDepositInstall contract's configureEmissionManagerRoles function via safeBatchV2.sh to set up EmissionManager roles. ```bash ./shell/safeBatchV2.sh --contract ConvertibleDepositInstall --function configureEmissionManagerRoles --chain sepolia --account OlympusDeployer --broadcast true ``` -------------------------------- ### Batch script to upgrade PRICE module and configure policies Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/CONFIG.md Solidity batch script using addToBatch() to upgrade the PRICE module to v2, activate PriceConfigV2, deactivate PriceConfigV1, and grant roles. Requires Operator deactivation before upgrade. ```solidity // 3. Upgrade the PRICE module to v2 // Requires that Operator is deactivated console2.log("Upgrading PRICE module to v2"); addToBatch( kernel, abi.encodeWithSelector(Kernel.executeAction.selector, Actions.UpgradeModule, priceV2) ); // 4. Activate PriceConfigV2 policy console2.log("Activating PriceConfigV2 policy"); addToBatch( kernel, abi.encodeWithSelector( Kernel.executeAction.selector, Actions.ActivatePolicy, priceConfigV2 ) ); // 4a. Disable PriceConfigV1 policy (superseded by PriceConfigV2) console2.log("Deactivating PriceConfigV1 policy"); addToBatch( kernel, abi.encodeWithSelector( Kernel.executeAction.selector, Actions.DeactivatePolicy, priceConfigV1 ) ); // 5. Set roles for new policy access control // PriceConfigV2 policy // - Give DAO MS the priceconfig_admin role // - Give DAO MS the priceconfig_policy role // - Give Policy MS the priceconfig_policy role console2.log("Granting admin role for PriceConfigV2 policy"); addToBatch( rolesAdmin, abi.encodeWithSelector( RolesAdmin.grantRole.selector, bytes32("priceconfig_admin"), daoMS ) ); console2.log("Granting policy role for PriceConfigV2 policy"); addToBatch( rolesAdmin, abi.encodeWithSelector( RolesAdmin.grantRole.selector, bytes32("priceconfig_policy"), daoMS ) ); console2.log("Granting policy role for PriceConfigV2 policy"); addToBatch( rolesAdmin, abi.encodeWithSelector( RolesAdmin.grantRole.selector, bytes32("priceconfig_policy"), policyMS ) ); ``` -------------------------------- ### Configure LZ Bridge on All Three Testnets Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/lz-bridge-testnet/README.md Run after all chains are deployed. Each chain points its peers at the gateway addresses from step 1. The configure script grants bootstrap roles, sets up the LZ endpoint, peers, enforced options, rate limits, and enables the delegate, gateway, and periphery. ```bash ./shell/lz-bridge/testnet/configure.sh --chain sepolia --account lz-testnet --broadcast true ./shell/lz-bridge/testnet/configure.sh --chain base-sepolia --account lz-testnet --broadcast true ./shell/lz-bridge/testnet/configure.sh --chain arbitrum-sepolia --account lz-testnet --broadcast true ``` -------------------------------- ### Deploy ReserveWrapper Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/convertible_deposits/INSTALL.md Deploys the ReserveWrapper contract on Sepolia using the deployV3.sh script with the specified sequence file and environment. ```bash ./shell/deployV3.sh --account OlympusDeployer --sequence src/scripts/deploy/savedDeployments/reserve_wrapper.json --chain sepolia --env .env.sepolia --broadcast true --verify true ``` -------------------------------- ### Deal gOHM to Wallet Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/proposals/README.md Deals gOHM to the specified wallet address and sets up the voting checkpoint on the local Anvil fork. ```bash shell/anvil/deal_gohm.sh ``` -------------------------------- ### Deploy CCIP Bridge on Canonical Chains Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/BRIDGE_CCIP.md Use this command to simulate the deployment of the CCIP bridge on canonical chains like mainnet or sepolia. ```bash ./shell/deployV3.sh --account < cast account > --sequence src/scripts/deploy/savedDeployments/ccip_bridge_mainnet.json --chain --broadcast false --verify false ``` -------------------------------- ### Deal gOHM to a wallet Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Runs the deal_gohm.sh script to transfer 15 gOHM to the specified wallet address and set up voting checkpoints. ```bash # Deal 15 gOHM to a wallet ./shell/anvil/deal_gohm.sh 0x1234... ``` -------------------------------- ### Deploy Morpho oracle via safeBatchV2.sh Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/oracle_factories.md Execute the batch script to deploy a Morpho oracle using the specified arguments file. ```bash # Deploy Morpho oracle for a token pair ./shell/safeBatchV2.sh \ --contract DeployOracles \ --function deployMorphoOracle \ --chain mainnet \ --multisig true \ --broadcast true \ --args oracle_args.json ``` -------------------------------- ### Execute MS batch Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Activates or configures deployed contracts via multisig batch using safeBatchV2.sh. Note that --chain mainnet is still required for address lookup from env.json, but --fork true overrides the RPC to localhost:8545. ```bash ./shell/safeBatchV2.sh \ --contract MyBatchScript \ --function functionName \ --chain mainnet \ --account my_wallet \ --multisig true \ --broadcast true \ --fork true ``` -------------------------------- ### Run all tests with pnpm Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Runs the full test suite by executing the shell script ./shell/test_all.sh. ```bash pnpm run test ``` -------------------------------- ### Calculate code metrics for PRICE modules Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/README.md Runs the metrics command on the PRICE module contracts and related libraries to generate code metrics. ```shell pnpm run metrics src/modules/PRICE/**/*.sol src/libraries/Deviation.sol src/libraries/UniswapV3/BunniHelper.sol src/libraries/UniswapV3/Oracle.sol ``` -------------------------------- ### Set Merkle Root via safeBatchV2.sh (broadcast) Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/V1_MIGRATOR.md Command to execute the merkle root update after simulation by adding --broadcast true. ```bash ./shell/safeBatchV2.sh --chain mainnet --contract V1MigratorConfig --function setMerkleRoot --args src/scripts/ops/batches/args/V1MigratorConfig_setMerkleRoot.json --broadcast true ``` -------------------------------- ### Deploy Oracle Factories via shell script Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/oracle_factories.md Executes the deployment of oracle factory contracts using the specified sequence file and chain configuration. ```bash ./shell/deployV3.sh \ --account \ --sequence src/scripts/deploy/savedDeployments/oracle_factories_deploy.json \ --chain mainnet \ --broadcast true \ --verify true ``` -------------------------------- ### Test Commands Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Lists the pnpm and forge commands used to run different test suites. Fork tests require the ALCHEMY_API_KEY environment variable. ```bash pnpm run test ``` ```bash pnpm run test:unit ``` ```bash pnpm run test:invariant ``` ```bash pnpm run test:fork ``` ```bash pnpm run test:proposal ``` ```bash forge test -vvv --match-contract ``` -------------------------------- ### Check Wired State on Sepolia Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/lz-bridge-testnet/README.md Read-only command that prints whether the gateway, delegate, and periphery are enabled and whether each peer is set. ```bash ./shell/lz-bridge/testnet/status.sh --chain sepolia ``` -------------------------------- ### Clone the bophades repository Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/README.md Clones the OlympusDAO bophades repository from GitHub. ```sh git clone https://github.com/OlympusDAO/bophades ``` -------------------------------- ### Accept Admin Role for Token Pool Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/BRIDGE_CCIP.md The deployer wallet must temporarily accept the admin role to configure the pool. Append --broadcast to perform the actual transaction instead of a simulation. ```bash forge script src/scripts/ops/batches/CCIPTokenPool.sol --sig "acceptAdminRole(bool)()" false --rpc-url --account < cast account > --slow -vvv --sender < account address > ``` -------------------------------- ### Source Environment Variables Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Loads the .env file into the current shell session. ```bash source .env ``` -------------------------------- ### Deploy LZ Bridge on All Three Testnets Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/lz-bridge-testnet/README.md Run the deploy script once per chain to write addresses to deployments/.json. Use the lz-testnet account and broadcast the transactions. ```bash ./shell/lz-bridge/testnet/deploy.sh --chain sepolia --account lz-testnet --broadcast true ./shell/lz-bridge/testnet/deploy.sh --chain base-sepolia --account lz-testnet --broadcast true ./shell/lz-bridge/testnet/deploy.sh --chain arbitrum-sepolia --account lz-testnet --broadcast true ``` -------------------------------- ### Execute proposal on fork Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Executes the proposal actions via the Anvil fork using executeOnAnvilFork.sh. ```bash src/scripts/proposals/executeOnAnvilFork.sh \ --file src/proposals/MyProposal.sol \ --contract MyProposal ``` -------------------------------- ### Create OCG proposal with cast wallet Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Creates and tests an OCG proposal using a cast wallet. Pass --chain http://localhost:8545 to use the local Anvil fork. ```bash # Using a cast wallet src/scripts/proposals/submitProposal.sh \ --file src/proposals/MyProposal.sol \ --contract MyProposal \ --account my_wallet \ --chain http://localhost:8545 \ --broadcast true ``` -------------------------------- ### Configure ConvertibleDeposit Roles Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/convertible_deposits/INSTALL.md Executes the ConvertibleDepositInstall contract's grantConvertibleDepositRoles function via safeBatchV2.sh to grant kernel roles. ```bash ./shell/safeBatchV2.sh --contract ConvertibleDepositInstall --function grantConvertibleDepositRoles --chain sepolia --account OlympusDeployer --broadcast true ``` -------------------------------- ### Simulate proposal execution Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/proposals/README.md Override _run to simulate the proposal actions on the TimelockController. It uses addresses from the registry for the governor, legacy gOHM, and proposer. ```solidity // Executes the proposal actions. function _run(Addresses addresses, address) internal override { // Simulates actions on TimelockController _simulateActions( addresses.getAddress("olympus-governor"), addresses.getAddress("olympus-legacy-gohm"), addresses.getAddress("proposer") ); } ``` -------------------------------- ### Deploy ReplaceStaking script using cast wallet Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/REPLACE_STAKING.md Deploys the ReplaceStaking script on the Sepolia network using a cast wallet account. ```bash forge script src/scripts/ops/ReplaceStaking.s.sol:ReplaceStaking \ --rpc-url sepolia \ --account <> \ --sender 0x1A5309F208f161a393E8b5A253de8Ab894A67188 \ --broadcast \ --verify \ -vvv ``` -------------------------------- ### Converting between decimal scales Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Shows how to convert values between different decimal scales by dividing or multiplying by the scale factor. The first converts from 18 decimals to 9 decimals, the second from 9 to 18. ```solidity // Convert from 18 decimals to 9 decimals value9 = value18 / 1e9; // Convert from 9 decimals to 18 decimals value18 = value9 * 1e9; ``` -------------------------------- ### Configure Remote Chains for Token Pool Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/BRIDGE_CCIP.md Configure the remote chains for a token pool using the chains key. Append --broadcast to perform the actual transaction instead of a simulation. ```bash forge script src/scripts/ops/batches/CCIPTokenPool.sol --sig "configureAllRemoteChains(bool)()" false --rpc-url --account < cast account > --slow -vvv --sender < account address > ``` -------------------------------- ### Directory Structure Tree Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Shows the top-level layout of the Olympus V3 repository, including Kernel.sol, modules, policies, and supporting directories. Use this as a reference for navigating the codebase. ```ml src/ ├── Kernel.sol # Central control system ├── modules/ # Shared state storage │ ├── TRSRY/ # Treasury management │ ├── MINTR/ # Token minting │ ├── PRICE/ # Price oracles │ ├── RANGE/ # Range-bound stability │ └── ROLES/ # Access control ├── policies/ # Business logic contracts │ ├── cooler/ # Lending protocols │ ├── deposits/ # Deposit facilities │ ├── BoostedLiquidity/ # Liquidity mining │ └── bridge/ # Cross-chain functionality ├── external/ # External contract dependencies ├── interfaces/ # Standard interfaces ├── libraries/ # Utility libraries └── test/ # Test files and mocks └── scripts/ # Deployment and configuration scripts └── proposals/ # On-Chain Governance (OCG) proposals ``` -------------------------------- ### Activate Oracle Policies via multisig batch Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/oracle_factories.md Registers the deployed oracle factory policies with the Kernel module using a multisig batch script. ```bash ./shell/safeBatchV2.sh \ --contract ConfigureOracles \ --function configureOracles \ --chain mainnet \ --multisig true \ --broadcast true ``` -------------------------------- ### Execute manual Etherscan verification Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/DEPLOY.md Run the verification script with the target contract address, path, and encoded constructor arguments. ```shell shell/verify_etherscan.sh 0x0AE561226896dA978EaDA0Bec4a7d3CfAE04f506 src/policies/Operator.sol:Operator 0x0000000000000000000000002286d7f9639e8158fad1169e76d1fbc38247f54b000000000000000000000000007f7a1cb838a872515c8ebd16be4b14ef43a22200000000000000000000000073df08ce9dcc8d74d22f23282c4d49f13b4c795e00000000000000000000000064aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d50000000000000000000000006b175474e89094c44da98b954eedeac495271d0f00000000000000000000000083f20f44975d03b1b09e64809b757c47f942beea0000000000000000000000000000000000000000000000000000000000000bb8000000000000000000000000000000000000000000000000000000000003f48000000000000000000000000000000000000000000000000000000000000186a0000000000000000000000000000000000000000000000000000000000000384000000000000000000000000000000000000000000000000000000000000003e8000000000000000000000000000000000000000000000000000000000007e90000000000000000000000000000000000000000000000000000000000000000120000000000000000000000000000000000000000000000000000000000000015 ``` -------------------------------- ### Submit Proposal via Cast Wallet Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/proposals/README.md Submits a proposal using a configured cast wallet. ```bash ./src/scripts/proposals/submitProposal.sh \ --file src/proposals/ContractRegistryProposal.sol \ --contract ContractRegistryProposalScript \ --account my_wallet \ --chain mainnet \ --broadcast true \ --env .env ``` -------------------------------- ### Run OCG proposal tests Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Runs the OCG proposal tests. ```bash pnpm run test:proposal ``` -------------------------------- ### Build a specific contract with forge Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Builds only the specified contract file. Use the --contracts flag to target a single contract. ```bash forge build --contracts path/to/contract.sol ``` -------------------------------- ### Configure DAI price feed on PRICE Source: https://github.com/olympusdao/olympus-v3/blob/develop/audit/2023-11_price-v2/CONFIG.md Sets up DAI price feed using Chainlink and Uniswap V3 components with specified parameters. ```solidity // 1. Configure DAI price feed and moving average data on PRICE // - Uses the Chainlink price feed with the standard observation window // - Uses the Uniswap V3 pool TWAP with the configured observation window // - Configures PRICE to track a moving average // - The price will be the average of the above three { PRICEv2.Component[] memory daiFeeds = new PRICEv2.Component[](2); { daiFeeds[0] = PRICEv2.Component( toSubKeycode("PRICE.CHAINLINK"), ChainlinkPriceFeeds.getOneFeedPrice.selector, abi.encode( ChainlinkPriceFeeds.OneFeedParams( AggregatorV2V3Interface(daiUsdPriceFeed), DEFAULT_TWAP_OBSERVATION_WINDOW ) ) ); daiFeeds[1] = PRICEv2.Component( toSubKeycode("PRICE.UNIV3"), UniswapV3Price.getTokenTWAP.selector, abi.encode( UniswapV3Price.UniswapV3Params({ pool: IUniswapV3Pool(daiUsdcUniV3Pool), observationWindowSeconds: twapObservationWindow, // This is shorter, as it is compared against reserves maxDeviationBps: twapMaxDeviationBps }) ) ); } ``` -------------------------------- ### Single line section header Source: https://github.com/olympusdao/olympus-v3/blob/develop/CODE_STD.md Use this single-line comment to denote all other sections in Solidity source files. ```solidity // ========= HEADER ========= // ``` -------------------------------- ### Run fork tests with ALCHEMY_API_KEY Source: https://github.com/olympusdao/olympus-v3/blob/develop/AGENTS.md Runs fork tests. Requires the ALCHEMY_API_KEY environment variable to be set. ```bash pnpm run test:fork ``` -------------------------------- ### Deploy contracts to fork Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/FORK.md Deploys new or updated contracts to the Anvil fork using the deployV3.sh script. Requires a wallet account and a deployment sequence file. ```bash ./shell/deployV3.sh \ --account my_wallet \ --sequence src/scripts/deploy/savedDeployments/my_sequence.json \ --chain http://localhost:8545 \ --broadcast true ``` -------------------------------- ### SRC Directory Structure Source: https://github.com/olympusdao/olympus-v3/blob/develop/README.md Visual representation of the project's source directory layout, highlighting core modules and framework components. ```ml ├─ external - "External contracts needed for core functionality" ├─ interfaces - "Standard interfaces" ├─ libraries - "Libraries" ├─ modules - "Default framework modules" │ ├─ AUTHR │ ├─ INSTR │ ├─ MINTR │ ├─ PRICE │ ├─ RANGE │ ├─ TRSRY │ ├─ BLREG ├─ policies - "Default framework policies" ├─ test - "General test utilities and mocks/larps" ``` -------------------------------- ### Generate Ledger signature for multisig Source: https://github.com/olympusdao/olympus-v3/blob/develop/src/scripts/ops/README.md Step 1 of the Ledger workflow: run the script with --signonly true to generate signature data without broadcasting. ```bash ./shell/safeBatchV2.sh --contract YourContract --function function_name --signonly true --multisig true --ledger mnemonic_index ``` -------------------------------- ### Deploy CCIP Bridge on Non-Canonical Chains Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/BRIDGE_CCIP.md Use this command to simulate the deployment of the CCIP bridge on non-canonical chains. ```bash ./shell/deployV3.sh --account < cast account > --sequence src/scripts/deploy/savedDeployments/ccip_bridge_not_mainnet.json --chain --broadcast false --verify false ``` -------------------------------- ### Accept Ownership of Token Administrator Role Source: https://github.com/olympusdao/olympus-v3/blob/develop/documentation/BRIDGE_CCIP.md The DAO MS must accept the proposal to become the token administrator. The second argument true creates a batch to be signed by the Safe multi-sig. ```bash forge script src/scripts/ops/batches/CCIPTokenPool.sol --sig "acceptAdminRole(bool)()" true --rpc-url --account < cast account > --slow -vvv --sender < account address > ```