From c64acdbb12f303165634a3fe4222231abc06769f Mon Sep 17 00:00:00 2001 From: aazhou1 Date: Fri, 22 Nov 2024 14:40:16 -0500 Subject: [PATCH] vault deploy jobs --- .../deploy-sepolia-vault-governance.yaml | 54 +++++++++++++ .github/workflows/deploy-sepolia-vault.yaml | 34 +++++--- script/DeployGovernance.s.sol | 4 +- script/VaultGovernanceDeploy.s.sol | 34 ++++++++ script/VaultManagement.s.sol | 78 ++++++++++++------- 5 files changed, 163 insertions(+), 41 deletions(-) create mode 100644 .github/workflows/deploy-sepolia-vault-governance.yaml create mode 100644 script/VaultGovernanceDeploy.s.sol diff --git a/.github/workflows/deploy-sepolia-vault-governance.yaml b/.github/workflows/deploy-sepolia-vault-governance.yaml new file mode 100644 index 00000000..acb55f13 --- /dev/null +++ b/.github/workflows/deploy-sepolia-vault-governance.yaml @@ -0,0 +1,54 @@ +name: "[sepolia-deploy] deploy governance for vault" +on: + workflow_dispatch: + inputs: + proposer: + description: 'Proposer address' + required: true + default: '0x' + vault: + description: 'Vault Address' + required: true + default: '0x' + accountant: + description: 'Accountant Address' + required: true + default: '0x' + governorRoleAddress: + description: 'Governor role address' + required: true + default: '0x' + governorVaults: + description: 'Governor vaults as comma separated' + required: false + default: '' + +jobs: + deploy: + runs-on: ubuntu-latest + environment: + name: sepolia + url: https://term-finance.github.io/yearn-v3-term-vault/ + steps: + - uses: actions/checkout@master + with: + fetch-depth: 0 + submodules: recursive + - uses: foundry-rs/foundry-toolchain@v1 + - run: forge install + - run: forge build + - run: forge tree + - run: forge script script/VaultGovernanceDeploy.s.sol:VaultGovernanceDeploy --rpc-url $RPC_URL --broadcast --gas-price 500000000000 --verify --verbosity 4 + env: + RPC_URL: ${{ secrets.RPC_URL }} + PRIVATE_KEY: ${{ secrets.GOVERNANCE_DEPLOYER_KEY }} + ETHERSCAN_API_KEY: ${{ secrets.ETHERSCAN_API_KEY }} + PROPOSER: ${{ github.event.inputs.proposer }} + VAULT: ${{ github.event.inputs.vault }} + ACCOUNTANT: ${{ github.event.inputs.accountant }} + GOVERNOR: ${{ github.event.inputs.governorRoleAddress }} + GOVERNANCE_FACTORY: ${{ vars.GOVERNANCE_FACTORY }} + + + + \ No newline at end of file diff --git a/.github/workflows/deploy-sepolia-vault.yaml b/.github/workflows/deploy-sepolia-vault.yaml index 60211de1..8cf45e2b 100644 --- a/.github/workflows/deploy-sepolia-vault.yaml +++ b/.github/workflows/deploy-sepolia-vault.yaml @@ -18,16 +18,24 @@ on: description: 'Profit max unlock time' required: true default: '0' - roleManager: - description: 'Role Manager' + depositLimit: + description: 'Deposit limit' required: false - default: '0x' - roleNumber: - description: 'sum of roles' + default: '0' + defaultRefund: + description: 'Default refund' required: false default: '0' - depositLimit: - description: 'Deposit limit' + defaultMaxFee: + description: 'Default max fee' + required: false + default: '0' + defaultMaxGain: + description: 'Default max gain' + required: false + default: '0' + defaultMaxLoss: + description: 'Default max loss' required: false default: '0' @@ -57,12 +65,14 @@ jobs: ACCOUNTANT_FACTORY: ${{ vars.ACCOUNTANT_FACTORY }} VAULT_NAME: ${{ github.event.inputs.vaultName }} VAULT_SYMBOL: ${{ github.event.inputs.vaultSymbol }} - FEE_MANAGER: ${{ vars.FEE_MANAGER }} FEE_RECIPIENT: ${{ vars.FEE_RECIPIENT }} DEPOSIT_LIMIT: ${{ github.event.inputs.depositLimit }} - IS_TEST: true - ROLE_MANAGER: ${{ github.event.inputs.roleManager }} - ROLE_NUM: ${{ github.event.inputs.roleNumber }} + VAULT_GOVERNANCE_FACTORY: ${{ vars.VAULT_GOVERNANCE_FACTORY }} + KEEPER: ${{ vars.KEEPER }} PROFIT_MAX_UNLOCK_TIME: ${{ github.event.inputs.profitMaxUnlockTime }} - ADMIN_ADDRESS: ${{ vars.ADMIN_ADDRESS }} + DEFAULT_REFUND: ${{ github.event.inputs.defaultRefund }} + DEFAULT_MAX_FEE: ${{ github.event.inputs.defaultMaxFee }} + DEFAULT_MAX_GAIN: ${{ github.event.inputs.defaultMaxGain }} + DEFAULT_MAX_LOSS: ${{ github.event.inputs.defaultMaxLoss }} + \ No newline at end of file diff --git a/script/DeployGovernance.s.sol b/script/DeployGovernance.s.sol index 3a83580f..a87bee47 100644 --- a/script/DeployGovernance.s.sol +++ b/script/DeployGovernance.s.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.18; import "forge-std/Script.sol"; import "../src/Strategy.sol"; -interface TermVaultGovernanceFactory { +interface TermStrategyGovernanceFactory { function deploySafe( address proposer, address strategy, @@ -109,7 +109,7 @@ contract DeployGovernance is Script { vm.startBroadcast(deployerPK); - TermVaultGovernanceFactory factory = TermVaultGovernanceFactory(vm.envAddress("GOVERNANCE_FACTORY")); + TermStrategyGovernanceFactory factory = TermStrategyGovernanceFactory(vm.envAddress("GOVERNANCE_FACTORY")); address proposer = vm.envAddress("PROPOSER"); address strategy = vm.envAddress("STRATEGY"); address governor = vm.envAddress("GOVERNOR"); diff --git a/script/VaultGovernanceDeploy.s.sol b/script/VaultGovernanceDeploy.s.sol new file mode 100644 index 00000000..156af90e --- /dev/null +++ b/script/VaultGovernanceDeploy.s.sol @@ -0,0 +1,34 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.18; +import "forge-std/Script.sol"; + +interface TermVaultGovernanceFactory { + function deploySafe( + address proposer, + address vault, + address accountant, + address governor + ) external; +} + +contract VaultGovernanceDeploy is Script { + function run() external { + uint256 deployerPK = vm.envUint("PRIVATE_KEY"); + + // Set up the RPC URL (optional if you're using the default foundry config) + string memory rpcUrl = vm.envString("RPC_URL"); + + vm.startBroadcast(deployerPK); + + TermVaultGovernanceFactory factory = TermVaultGovernanceFactory(vm.envAddress("GOVERNANCE_FACTORY")); + address proposer = vm.envAddress("PROPOSER"); + address vault = vm.envAddress("VAULT"); + address accountant = vm.envAddress("ACCOUNTANT"); + address governor = vm.envAddress("GOVERNOR"); + + factory.deploySafe(proposer, vault, accountant, governor); + + vm.stopBroadcast(); + } + +} \ No newline at end of file diff --git a/script/VaultManagement.s.sol b/script/VaultManagement.s.sol index 8d242682..163e85d3 100644 --- a/script/VaultManagement.s.sol +++ b/script/VaultManagement.s.sol @@ -14,6 +14,8 @@ contract SetupVaultManagement is Script { // Set up the RPC URL (optional if you're using the default foundry config) string memory rpcUrl = vm.envString("RPC_URL"); + address deployer = vm.addr(deployerPK); + vm.startBroadcast(deployerPK); // Retrieve environment variables @@ -22,48 +24,70 @@ contract SetupVaultManagement is Script { address asset = vm.envAddress("ASSET_ADDRESS"); string memory name = vm.envString("VAULT_NAME"); string memory symbol = vm.envString("VAULT_SYMBOL"); - address roleManager = vm.envAddress("ROLE_MANAGER"); uint256 profitMaxUnlockTime = vm.envUint("PROFIT_MAX_UNLOCK_TIME"); - address feeManager = vm.envAddress("FEE_MANAGER"); - address feeRecipient = vm.envAddress("FEE_RECIPIENT"); - uint256 depositLimit = vm.envOr("DEPOSIT_LIMIT",uint256(0)); - - address admin = vm.envAddress("ADMIN_ADDRESS"); - uint256 roleNum = vm.envOr("ROLE_NUM", uint(256)); - bool isTest = vm.envBool("IS_TEST"); + address vaultGovernanceFactory = vm.envAddress("VAULT_GOVERNANCE_FACTORY"); IVaultFactory vaultFactory = IVaultFactory(vaultFactoryAddress); - address vaultAddress = vaultFactory.deploy_new_vault(asset, name, symbol, roleManager, profitMaxUnlockTime); + address vaultAddress = vaultFactory.deploy_new_vault(asset, name, symbol, deployer, profitMaxUnlockTime); IVault vault = IVault(vaultAddress); console.log("deployed vault contract to"); console.log(address(vault)); AccountantFactory accountantFactory = AccountantFactory(accountantFactoryAddress); - address accountantAddress = accountantFactory.newAccountant(feeManager, feeRecipient); + address accountantAddress = accountantFactory.newAccountant(); Accountant accountant = Accountant(accountantAddress); console.log("deployed accountant contract to"); console.log(address(accountant)); - if (isTest) { - vault.set_role(admin, roleNum); - console.log("set role for admin"); - console.log(roleNum); + _setVaultParams(vault, accountantAddress, vaultGovernanceFactory); + _setAccountantParams(accountant, vaultGovernanceFactory); - vault.set_accountant(address(accountant)); - console.log("set accountant for vault"); - console.log(address(accountant)); + vm.stopBroadcast(); + } + function _setVaultParams(IVault vault, address accountant, address vaultGovernanceFactory) internal { + uint256 depositLimit = vm.envOr("DEPOSIT_LIMIT",uint256(0)); + address keeper = vm.envAddress("KEEPER_ADDRESS"); - vault.set_deposit_limit(depositLimit); - console.log("set deposit limit"); - console.log(depositLimit); + vault.set_role(keeper, 112); + console.log("set role for keeper"); - vault.set_use_default_queue(true); - console.log("set use default queue to true"); - vault.set_auto_allocate(true); - console.log("set auto allocate to true"); - } - - vm.stopBroadcast(); + vault.set_accountant(accountant); + console.log("set accountant for vault"); + console.log(accountant); + + vault.set_deposit_limit(depositLimit); + console.log("set deposit limit"); + console.log(depositLimit); + + vault.set_use_default_queue(true); + console.log("set use default queue to true"); + vault.set_auto_allocate(true); + console.log("set auto allocate to true"); + + vault.transfer_role_manager(vaultGovernanceFactory); + vault.accept_role_manager(); + } + + function _setAccountantParams(Accountant accountant, address vaultGovernanceFactory) internal { + uint16 defaultManagement = uint16(vm.envOr("DEFAULT_MANAGEMENT", uint256(0))); + uint16 defaultPerformance = uint16(vm.envOr("DEFAULT_PERFORMANCE", uint256(0))); + uint16 defaultRefund = uint16(vm.envOr("DEFAULT_REFUND", uint256(0))); + uint16 defaultMaxFee = uint16(vm.envOr("DEFAULT_MAX_FEE", uint256(0))); + uint16 defaultMaxGain = uint16(vm.envOr("DEFAULT_MAX_GAIN", uint256(0))); + uint16 defaultMaxLoss = uint16(vm.envOr("DEFAULT_MAX_LOSS", uint256(0))); + address newFeeRecipient = vm.envAddress("FEE_RECIPIENT"); + + accountant.updateDefaultConfig(defaultManagement, defaultPerformance, defaultRefund, defaultMaxFee, defaultMaxGain, defaultMaxLoss); + console.log("set default config for accountant"); + console.log(defaultManagement); + console.log(defaultPerformance); + console.log(defaultRefund); + console.log(defaultMaxFee); + console.log(defaultMaxGain); + console.log(defaultMaxLoss); + + accountant.setFutureFeeManager(vaultGovernanceFactory); + accountant.setFeeRecipient(newFeeRecipient); } }