forked from Se7en-Seas/boring-vault
-
Notifications
You must be signed in to change notification settings - Fork 1
add scripts to deploy vaults #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
maxKMyt
wants to merge
11
commits into
dev_proto
Choose a base branch
from
feat-musd-vaults
base: dev_proto
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fb56324
add scripts to deploy vaults
EvmSerhii 3957046
create config for Mantra deployment
EvmSerhii 2351747
add mantra mainnet and testnet to foundry
EvmSerhii d0e9ffa
fix config path
EvmSerhii a3e32f8
Update config with mainnet toggle
EvmSerhii 7a4a00e
Minor naming updates
maxKMyt f8eff2b
Add description on roles in config
EvmSerhii e910cdf
Update role description
maxKMyt 9b4f095
edit config and add mainnet toggle
EvmSerhii 1d16bf2
latest deployment
EvmSerhii b8f03de
update with latest deployment
EvmSerhii File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity 0.8.21; | ||
|
|
||
| import {Deployer} from "src/helper/Deployer.sol"; | ||
| import { | ||
| RolesAuthority, | ||
| Authority | ||
| } from "@solmate/auth/authorities/RolesAuthority.sol"; | ||
| import "forge-std/Script.sol"; | ||
|
|
||
| /** | ||
| * @notice Script to deploy the CREATE3 Deployer and its RolesAuthority. | ||
| * @dev Run with: forge script script/01_DeployDeployer.s.sol --rpc-url <mantra_rpc> --broadcast --verify | ||
| */ | ||
| contract DeployDeployer is Script { | ||
| uint8 public constant DEPLOYER_ROLE = 1; | ||
|
|
||
| function run() external { | ||
| uint256 deployerKey = vm.envUint("ETHERFI_LIQUID_DEPLOYER"); | ||
|
||
| address deployerAddr = vm.addr(deployerKey); | ||
|
|
||
| vm.startBroadcast(deployerKey); | ||
|
|
||
| // 1. Deploy Deployer (Owned by deployerAddr, no initial authority) | ||
| Deployer deployer = new Deployer(deployerAddr, Authority(address(0))); | ||
|
|
||
| // 2. Deploy RolesAuthority for the Deployer (Owned by deployerAddr) | ||
| RolesAuthority auth = new RolesAuthority( | ||
| deployerAddr, | ||
| Authority(address(0)) | ||
| ); | ||
|
|
||
| // 3. Link them | ||
| deployer.setAuthority(auth); | ||
|
|
||
| // 4. Grant deployerAddr permission to deploy through the factory | ||
| // We use Role 1 for Deployer Role to match the project's standard | ||
| auth.setRoleCapability( | ||
| DEPLOYER_ROLE, | ||
| address(deployer), | ||
| Deployer.deployContract.selector, | ||
| true | ||
| ); | ||
| auth.setUserRole(deployerAddr, DEPLOYER_ROLE, true); | ||
|
|
||
| vm.stopBroadcast(); | ||
|
|
||
| console.log("Deployer deployed at:", address(deployer)); | ||
| console.log("RolesAuthority deployed at:", address(auth)); | ||
| } | ||
| } | ||
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,196 @@ | ||
| // SPDX-License-Identifier: UNLICENSED | ||
| pragma solidity 0.8.21; | ||
|
|
||
| import {BoringVault} from "src/base/BoringVault.sol"; | ||
| import { | ||
| AccountantWithRateProviders | ||
| } from "src/base/Roles/AccountantWithRateProviders.sol"; | ||
| import { | ||
| TellerWithMultiAssetSupport | ||
| } from "src/base/Roles/TellerWithMultiAssetSupport.sol"; | ||
| import {DelayedWithdraw} from "src/base/Roles/DelayedWithdraw.sol"; | ||
| import { | ||
| RolesAuthority, | ||
| Authority | ||
| } from "@solmate/auth/authorities/RolesAuthority.sol"; | ||
| import {Deployer} from "src/helper/Deployer.sol"; | ||
| import {ERC20} from "@solmate/tokens/ERC20.sol"; | ||
| import "forge-std/Script.sol"; | ||
|
|
||
| /** | ||
| * @notice Script to deploy "Maxi Yield" Vault through the Deployer. | ||
| * @dev Run with: forge script script/02_DeployMaxiYieldVault.s.sol --rpc-url <mantra_rpc> --broadcast --verify | ||
| */ | ||
| contract DeployMaxiYieldVault is Script { | ||
| // Config for Mantra Testnet | ||
| address public constant mUSD = 0x4B545d0758eda6601B051259bD977125fbdA7ba2; | ||
| address public constant WETH = address(0); | ||
|
|
||
| // Deployer and Auth addresses (deployed in step 01) | ||
| address public deployerAddr = vm.envAddress("DEPLOYER_CONTRACT_ADDRESS"); | ||
| address public rolesAuthAddr = vm.envAddress("ROLES_AUTH_CONTRACT_ADDRESS"); | ||
|
|
||
| // Standard Project Roles | ||
| uint8 public constant MANAGER_ROLE = 1; | ||
| uint8 public constant MINTER_ROLE = 2; | ||
| uint8 public constant BURNER_ROLE = 3; | ||
| uint8 public constant OWNER_ROLE = 8; | ||
| uint8 public constant MULTISIG_ROLE = 9; | ||
| uint8 public constant UPDATE_EXCHANGE_RATE_ROLE = 11; | ||
|
|
||
| function run() external { | ||
| vm.createSelectFork("mantra"); | ||
| uint256 deployerKey = vm.envUint("ETHERFI_LIQUID_DEPLOYER"); | ||
| address owner = vm.addr(deployerKey); | ||
| Deployer deployer = Deployer(deployerAddr); | ||
| RolesAuthority auth = RolesAuthority(rolesAuthAddr); | ||
|
|
||
| vm.startBroadcast(deployerKey); | ||
|
|
||
| // --- 1. Deploy Core Components via Deployer --- | ||
| address vault = deployer.deployContract( | ||
| "Maxi Yield Vault V1.0", | ||
| type(BoringVault).creationCode, | ||
| abi.encode(owner, "Maxi Yield mUSD", "my-mUSD", 6), | ||
| 0 | ||
| ); | ||
|
|
||
| address accountant = deployer.deployContract( | ||
| "Maxi Yield Accountant V1.0", | ||
| type(AccountantWithRateProviders).creationCode, | ||
| abi.encode( | ||
| owner, | ||
| vault, | ||
| owner, | ||
| 1e6, | ||
| mUSD, | ||
| 1.5e4, | ||
| 0.5e4, | ||
| 20 hours, | ||
| 0, | ||
| 0 | ||
| ), | ||
| 0 | ||
|
||
| ); | ||
|
|
||
| address teller = deployer.deployContract( | ||
| "Maxi Yield Teller V1.0", | ||
| type(TellerWithMultiAssetSupport).creationCode, | ||
| abi.encode(owner, vault, accountant, WETH), | ||
| 0 | ||
| ); | ||
|
|
||
| address delayedWithdraw = deployer.deployContract( | ||
| "Maxi Yield DelayedWithdraw V1.0", | ||
| type(DelayedWithdraw).creationCode, | ||
| abi.encode(owner, vault, accountant, owner), | ||
| 0 | ||
| ); | ||
|
|
||
| // --- 2. Post-Deployment Setup --- | ||
|
|
||
| // Roles Permissions | ||
| BoringVault(payable(vault)).setAuthority(auth); | ||
| AccountantWithRateProviders(accountant).setAuthority(auth); | ||
| TellerWithMultiAssetSupport(payable(teller)).setAuthority(auth); | ||
| DelayedWithdraw(delayedWithdraw).setAuthority(auth); | ||
|
|
||
| // Minter Role (2) -> Teller can mint shares | ||
| auth.setRoleCapability( | ||
| MINTER_ROLE, | ||
| vault, | ||
| BoringVault.enter.selector, | ||
| true | ||
| ); | ||
| auth.setUserRole(teller, MINTER_ROLE, true); | ||
|
|
||
| // Burner Role (3) -> DelayedWithdraw can burn shares | ||
| auth.setRoleCapability( | ||
| BURNER_ROLE, | ||
| vault, | ||
| BoringVault.exit.selector, | ||
| true | ||
| ); | ||
| auth.setUserRole(delayedWithdraw, BURNER_ROLE, true); | ||
|
|
||
| // Update Rate Role (11) -> Owner can update accountant exchange rate | ||
| auth.setRoleCapability( | ||
| UPDATE_EXCHANGE_RATE_ROLE, | ||
| accountant, | ||
| AccountantWithRateProviders.updateExchangeRate.selector, | ||
| true | ||
| ); | ||
| auth.setUserRole(owner, UPDATE_EXCHANGE_RATE_ROLE, true); | ||
|
|
||
| // Owner Role (8) -> Broad administrative rights | ||
| auth.setRoleCapability( | ||
| OWNER_ROLE, | ||
| teller, | ||
| TellerWithMultiAssetSupport.setShareLockPeriod.selector, | ||
| true | ||
| ); | ||
| auth.setRoleCapability( | ||
| OWNER_ROLE, | ||
| teller, | ||
| TellerWithMultiAssetSupport.updateAssetData.selector, | ||
| true | ||
| ); | ||
| auth.setRoleCapability( | ||
| OWNER_ROLE, | ||
| delayedWithdraw, | ||
| DelayedWithdraw.setupWithdrawAsset.selector, | ||
| true | ||
| ); | ||
| auth.setRoleCapability( | ||
| OWNER_ROLE, | ||
| delayedWithdraw, | ||
| DelayedWithdraw.setPullFundsFromVault.selector, | ||
| true | ||
| ); | ||
| auth.setUserRole(owner, OWNER_ROLE, true); | ||
|
|
||
| // Public Roles | ||
| auth.setPublicCapability( | ||
| teller, | ||
| TellerWithMultiAssetSupport.deposit.selector, | ||
| true | ||
| ); | ||
| auth.setPublicCapability( | ||
| delayedWithdraw, | ||
| DelayedWithdraw.requestWithdraw.selector, | ||
| true | ||
| ); | ||
| auth.setPublicCapability( | ||
| delayedWithdraw, | ||
| DelayedWithdraw.completeWithdraw.selector, | ||
| true | ||
| ); | ||
|
|
||
| // Logic Config | ||
| TellerWithMultiAssetSupport(payable(teller)).setShareLockPeriod(86400); // 24h | ||
| TellerWithMultiAssetSupport(payable(teller)).updateAssetData( | ||
| ERC20(mUSD), | ||
| true, | ||
| true, | ||
| 0 | ||
| ); | ||
|
|
||
| DelayedWithdraw(delayedWithdraw).setupWithdrawAsset( | ||
| ERC20(mUSD), | ||
| 0, | ||
| 7 days, | ||
| 0, | ||
| 100 | ||
| ); | ||
| DelayedWithdraw(delayedWithdraw).setPullFundsFromVault(true); | ||
|
|
||
| BoringVault(payable(vault)).setBeforeTransferHook(teller); | ||
|
|
||
| vm.stopBroadcast(); | ||
|
|
||
| console.log("Maxi Yield Vault:", vault); | ||
| console.log("Maxi Yield Accountant:", accountant); | ||
| console.log("Maxi Yield Teller:", teller); | ||
| console.log("Maxi Yield DelayedWithdraw:", delayedWithdraw); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add configs for both: mantra, mantraDukong