-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Rayerleier <1045643889@qq.com>
- Loading branch information
Showing
15 changed files
with
1,437 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
@openzeppelin/contracts/=lib/openzeppelin-contracts-upgradeable/lib/openzeppelin-contracts/contracts/ | ||
@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/ | ||
@symbiotic/=lib/core/src/ | ||
@symbiotic-burners/=lib/burners/src/ |
This file contains 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,27 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.25; | ||
|
||
import {Script, console2} from "forge-std/Script.sol"; | ||
import {DelegatorFactory} from "@symbiotic/contracts/DelegatorFactory.sol"; | ||
import {SlasherFactory} from "@symbiotic/contracts/SlasherFactory.sol"; | ||
import {VaultFactory} from "@symbiotic/contracts/VaultFactory.sol"; | ||
|
||
contract DeployFactories is Script { | ||
address constant OWNER = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; | ||
|
||
function run() external { | ||
uint256 deployerPrivateKey = uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
DelegatorFactory delegatorFactory = new DelegatorFactory(OWNER); | ||
console2.log("DelegatorFactory deployed at:", address(delegatorFactory)); | ||
|
||
SlasherFactory slasherFactory = new SlasherFactory(OWNER); | ||
console2.log("SlasherFactory deployed at:", address(slasherFactory)); | ||
|
||
VaultFactory vaultFactory = new VaultFactory(OWNER); | ||
console2.log("VaultFactory deployed at:", address(vaultFactory)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains 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,180 @@ | ||
pragma solidity ^0.8.25; | ||
|
||
import {Script, console2} from "forge-std/Script.sol"; | ||
import {VaultFactory} from "@symbiotic/contracts/VaultFactory.sol"; | ||
import {DelegatorFactory} from "@symbiotic/contracts/DelegatorFactory.sol"; | ||
import {SlasherFactory} from "@symbiotic/contracts/SlasherFactory.sol"; | ||
import {IMigratablesFactory} from "@symbiotic/interfaces/common/IMigratablesFactory.sol"; | ||
import {IVault} from "@symbiotic/interfaces/vault/IVault.sol"; | ||
import {IVaultConfigurator} from "@symbiotic/interfaces/IVaultConfigurator.sol"; | ||
import {IBaseDelegator} from "@symbiotic/interfaces/delegator/IBaseDelegator.sol"; | ||
import {INetworkRestakeDelegator} from "@symbiotic/interfaces/delegator/INetworkRestakeDelegator.sol"; | ||
import {IFullRestakeDelegator} from "@symbiotic/interfaces/delegator/IFullRestakeDelegator.sol"; | ||
import {IOperatorSpecificDelegator} from "@symbiotic/interfaces/delegator/IOperatorSpecificDelegator.sol"; | ||
import {IBaseSlasher} from "@symbiotic/interfaces/slasher/IBaseSlasher.sol"; | ||
import {ISlasher} from "@symbiotic/interfaces/slasher/ISlasher.sol"; | ||
import {IVetoSlasher} from "@symbiotic/interfaces/slasher/IVetoSlasher.sol"; | ||
|
||
import {iBTC_Treasury} from "../src/iBTC_Treasury.sol"; | ||
import {iBTC_Burner} from "../src/iBTC_Burner.sol"; | ||
import {VaultConfigurator} from "../src/iBTC_VaultConfigurator.sol"; | ||
import {iBTC_Vault} from "../src/iBTC_Vault.sol"; | ||
|
||
contract DeployAll is Script { | ||
// Define deployment parameters | ||
address constant COLLATERAL_ADDRESS = 0xeb762Ed11a09E4A394C9c8101f8aeeaf5382ED74; // eth sepolia | ||
uint256 constant MAX_WITHDRAW_AMOUNT = 1e9; // 10 iBTC | ||
uint256 constant MIN_WITHDRAW_AMOUNT = 1e4; | ||
uint256 deployerPrivateKey = uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); //NOTE | ||
|
||
// Replace with the correct checksummed addresses | ||
address constant VAULT_FACTORY = 0x407A039D94948484D356eFB765b3c74382A050B4; // Replace with deployed VaultFactory address | ||
address constant DELEGATOR_FACTORY = 0x890CA3f95E0f40a79885B7400926544B2214B03f; // Replace with deployed DelegatorFactory address | ||
address constant SLASHER_FACTORY = 0xbf34bf75bb779c383267736c53a4ae86ac7bB299; // Replace with deployed SlasherFactory address | ||
|
||
function run() external { | ||
address[] memory whitelistedDepositors; | ||
address owner = 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266; //NOTE | ||
address collateral = 0xeb762Ed11a09E4A394C9c8101f8aeeaf5382ED74; | ||
uint48 epochDuration = 604_800; // 7days | ||
uint256 depositLimit = 1e9; // 10iBTC | ||
uint64 delegatorIndex = 0; // NetworkRestakeDelegator | ||
address hook = 0x0000000000000000000000000000000000000000; | ||
bool withSlasher = true; | ||
uint64 slasherIndex = 1; // vetoSlasher | ||
uint48 vetoDuration = 86_400; // 1 day | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
// Deploy the iBTC_Treasury contract | ||
iBTC_Treasury treasury = new iBTC_Treasury(COLLATERAL_ADDRESS, MAX_WITHDRAW_AMOUNT, MIN_WITHDRAW_AMOUNT); | ||
|
||
// Deploy the iBTC_Burner contract | ||
iBTC_Burner burner = new iBTC_Burner(COLLATERAL_ADDRESS, address(treasury)); | ||
|
||
VaultConfigurator vaultConfigurator = new VaultConfigurator(VAULT_FACTORY, DELEGATOR_FACTORY, SLASHER_FACTORY); | ||
|
||
// Log the deployed address | ||
console2.log("VaultConfigurator deployed at:", address(vaultConfigurator)); | ||
(,, address deployer) = vm.readCallers(); | ||
|
||
bool depositWhitelist = whitelistedDepositors.length != 0; | ||
|
||
bytes memory vaultParams = abi.encode( | ||
IVault.InitParams({ | ||
collateral: collateral, | ||
burner: address(burner), | ||
epochDuration: epochDuration, | ||
depositWhitelist: depositWhitelist, | ||
isDepositLimit: depositLimit != 0, | ||
depositLimit: depositLimit, | ||
defaultAdminRoleHolder: depositWhitelist ? deployer : owner, | ||
depositWhitelistSetRoleHolder: owner, | ||
depositorWhitelistRoleHolder: owner, | ||
isDepositLimitSetRoleHolder: owner, | ||
depositLimitSetRoleHolder: owner | ||
}) | ||
); | ||
|
||
uint256 roleHolders = 1; | ||
if (hook != address(0) && hook != owner) { | ||
roleHolders = 2; | ||
} | ||
address[] memory networkLimitSetRoleHolders = new address[](roleHolders); | ||
address[] memory operatorNetworkLimitSetRoleHolders = new address[](roleHolders); | ||
address[] memory operatorNetworkSharesSetRoleHolders = new address[](roleHolders); | ||
networkLimitSetRoleHolders[0] = owner; | ||
operatorNetworkLimitSetRoleHolders[0] = owner; | ||
operatorNetworkSharesSetRoleHolders[0] = owner; | ||
if (roleHolders > 1) { | ||
networkLimitSetRoleHolders[1] = hook; | ||
operatorNetworkLimitSetRoleHolders[1] = hook; | ||
operatorNetworkSharesSetRoleHolders[1] = hook; | ||
} | ||
|
||
bytes memory delegatorParams; | ||
if (delegatorIndex == 0) { | ||
delegatorParams = abi.encode( | ||
INetworkRestakeDelegator.InitParams({ | ||
baseParams: IBaseDelegator.BaseParams({ | ||
defaultAdminRoleHolder: owner, | ||
hook: hook, | ||
hookSetRoleHolder: owner | ||
}), | ||
networkLimitSetRoleHolders: networkLimitSetRoleHolders, | ||
operatorNetworkSharesSetRoleHolders: operatorNetworkSharesSetRoleHolders | ||
}) | ||
); | ||
} else if (delegatorIndex == 1) { | ||
delegatorParams = abi.encode( | ||
IFullRestakeDelegator.InitParams({ | ||
baseParams: IBaseDelegator.BaseParams({ | ||
defaultAdminRoleHolder: owner, | ||
hook: hook, | ||
hookSetRoleHolder: owner | ||
}), | ||
networkLimitSetRoleHolders: networkLimitSetRoleHolders, | ||
operatorNetworkLimitSetRoleHolders: operatorNetworkLimitSetRoleHolders | ||
}) | ||
); | ||
} else if (delegatorIndex == 2) { | ||
delegatorParams = abi.encode( | ||
IOperatorSpecificDelegator.InitParams({ | ||
baseParams: IBaseDelegator.BaseParams({ | ||
defaultAdminRoleHolder: owner, | ||
hook: hook, | ||
hookSetRoleHolder: owner | ||
}), | ||
networkLimitSetRoleHolders: networkLimitSetRoleHolders, | ||
operator: owner | ||
}) | ||
); | ||
} | ||
|
||
bytes memory slasherParams; | ||
if (slasherIndex == 0) { | ||
slasherParams = abi.encode( | ||
ISlasher.InitParams({baseParams: IBaseSlasher.BaseParams({isBurnerHook: address(burner) != address(0)})}) | ||
); | ||
} else if (slasherIndex == 1) { | ||
slasherParams = abi.encode( | ||
IVetoSlasher.InitParams({ | ||
baseParams: IBaseSlasher.BaseParams({isBurnerHook: address(burner) != address(0)}), | ||
vetoDuration: vetoDuration, | ||
resolverSetEpochsDelay: 3 | ||
}) | ||
); | ||
} | ||
|
||
(address vault_, address delegator_, address slasher_) = IVaultConfigurator(vaultConfigurator).create( | ||
IVaultConfigurator.InitParams({ | ||
version: 1, | ||
owner: owner, | ||
vaultParams: vaultParams, | ||
delegatorIndex: delegatorIndex, | ||
delegatorParams: delegatorParams, | ||
withSlasher: withSlasher, | ||
slasherIndex: slasherIndex, | ||
slasherParams: slasherParams | ||
}) | ||
); | ||
|
||
if (depositWhitelist) { | ||
iBTC_Vault(vault_).grantRole(iBTC_Vault(vault_).DEFAULT_ADMIN_ROLE(), owner); | ||
iBTC_Vault(vault_).grantRole(iBTC_Vault(vault_).DEPOSITOR_WHITELIST_ROLE(), deployer); | ||
|
||
for (uint256 i; i < whitelistedDepositors.length; ++i) { | ||
iBTC_Vault(vault_).setDepositorWhitelistStatus(whitelistedDepositors[i], true); | ||
} | ||
|
||
iBTC_Vault(vault_).renounceRole(iBTC_Vault(vault_).DEPOSITOR_WHITELIST_ROLE(), deployer); | ||
iBTC_Vault(vault_).renounceRole(iBTC_Vault(vault_).DEFAULT_ADMIN_ROLE(), deployer); | ||
} | ||
|
||
console2.log("Vault: ", vault_); | ||
console2.log("Delegator: ", delegator_); | ||
console2.log("Slasher: ", slasher_); | ||
|
||
// Stop broadcasting transactions | ||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains 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,30 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.25; | ||
|
||
import {Script} from "forge-std/Script.sol"; | ||
import {iBTC_Treasury} from "../src/iBTC_Treasury.sol"; | ||
import {iBTC_Burner} from "../src/iBTC_Burner.sol"; | ||
|
||
contract DeployiBTC_Burner is Script { | ||
// Define deployment parameters | ||
address constant COLLATERAL_ADDRESS = 0xeb762Ed11a09E4A394C9c8101f8aeeaf5382ED74; // eth sepolia | ||
uint256 constant MAX_WITHDRAW_AMOUNT = 1e9; // 10 iBTC | ||
uint256 constant MIN_WITHDRAW_AMOUNT = 1e4; | ||
|
||
function run() external { | ||
// Fetch the private key to deploy contracts | ||
uint256 deployerPrivateKey = uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); | ||
|
||
// Start broadcasting transactions from the deployer account | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
// Deploy the iBTC_Treasury contract | ||
iBTC_Treasury treasury = new iBTC_Treasury(COLLATERAL_ADDRESS, MAX_WITHDRAW_AMOUNT, MIN_WITHDRAW_AMOUNT); | ||
|
||
// Deploy the iBTC_Burner contract | ||
iBTC_Burner burner = new iBTC_Burner(COLLATERAL_ADDRESS, address(treasury)); | ||
|
||
// Stop broadcasting transactions | ||
vm.stopBroadcast(); | ||
} | ||
} |
This file contains 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,28 @@ | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
pragma solidity 0.8.25; | ||
|
||
import {Script, console2} from "forge-std/Script.sol"; | ||
import {VaultConfigurator} from "../src/iBTC_VaultConfigurator.sol"; | ||
import {VaultFactory} from "@symbiotic/contracts/VaultFactory.sol"; | ||
import {DelegatorFactory} from "@symbiotic/contracts/DelegatorFactory.sol"; | ||
import {SlasherFactory} from "@symbiotic/contracts/SlasherFactory.sol"; | ||
|
||
contract DeployVaultConfigurator is Script { | ||
// Replace with the correct checksummed addresses | ||
address constant VAULT_FACTORY = 0x407A039D94948484D356eFB765b3c74382A050B4; // Replace with deployed VaultFactory address | ||
address constant DELEGATOR_FACTORY = 0x890CA3f95E0f40a79885B7400926544B2214B03f; // Replace with deployed DelegatorFactory address | ||
address constant SLASHER_FACTORY = 0xbf34bf75bb779c383267736c53a4ae86ac7bB299; // Replace with deployed SlasherFactory address | ||
|
||
function run() external { | ||
uint256 deployerPrivateKey = uint256(0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80); // Load the private key from the environment | ||
vm.startBroadcast(deployerPrivateKey); | ||
|
||
// Deploy the VaultConfigurator contract | ||
VaultConfigurator vaultConfigurator = new VaultConfigurator(VAULT_FACTORY, DELEGATOR_FACTORY, SLASHER_FACTORY); | ||
|
||
// Log the deployed address | ||
console2.log("VaultConfigurator deployed at:", address(vaultConfigurator)); | ||
|
||
vm.stopBroadcast(); | ||
} | ||
} |
Oops, something went wrong.