From 667b84def8d45feb70d344357138e5dde0a76656 Mon Sep 17 00:00:00 2001 From: mihailo-maksa Date: Fri, 14 Feb 2025 20:32:14 +0100 Subject: [PATCH 1/7] linea deployment config --- foundry.toml | 2 +- script/Deploy.s.sol | 98 ++++++++++++++++++++++++++-------------- src/ProgressiveCurve.sol | 2 +- 3 files changed, 67 insertions(+), 35 deletions(-) diff --git a/foundry.toml b/foundry.toml index 87e83794..e7103f51 100644 --- a/foundry.toml +++ b/foundry.toml @@ -6,7 +6,7 @@ ffi = true ast = true build_info = true extra_output = ["storageLayout"] -evm_version = "Cancun" +evm_version = "Paris" auto_detect_remappings = false fs_permissions = [{ access = "read-write", path = "./out" }] # optimizer = true diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol index afa1ba45..8fb2516c 100644 --- a/script/Deploy.s.sol +++ b/script/Deploy.s.sol @@ -19,28 +19,30 @@ import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; import {LinearCurve} from "src/LinearCurve.sol"; contract DeployEthMultiVault is Script { - address deployer; + address public lineaTestnetAdmin = 0xB8e3452E62B45e654a300a296061597E3Cf3e039; + address public lineaMainnetAdmin = 0x323e9506B929C21AE602D64d3807721AA49b4884; // Multisig addresses for key roles in the protocol - address admin = 0xa28d4AAcA48bE54824dA53a19b05121DE71Ef480; - address protocolMultisig = 0xC03F0dE5b34339e1B968e4f317Cd7e7FBd421FD1; - address atomWarden = 0xC35DFCFE50da58d957fc47C7063f56135aFF61B8; + address public admin = lineaMainnetAdmin; + address public protocolMultisig = lineaMainnetAdmin; + address public atomWarden = lineaMainnetAdmin; - // Constants from Base - IPermit2 permit2 = IPermit2(address(0x000000000022D473030F116dDEE9F6B43aC78BA3)); // Permit2 on Base - address entryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; // EntryPoint on Base + // Constants from Linea + IPermit2 public permit2 = IPermit2(address(0x000000000022D473030F116dDEE9F6B43aC78BA3)); // Permit2 on Linea + address public entryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; // EntryPoint on Linea // Contracts to be deployed - AtomWallet atomWallet; - UpgradeableBeacon atomWalletBeacon; - EthMultiVault ethMultiVault; - TransparentUpgradeableProxy ethMultiVaultProxy; - TimelockController timelock; + AtomWallet public atomWallet; + UpgradeableBeacon public atomWalletBeacon; + EthMultiVault public ethMultiVault; + TransparentUpgradeableProxy public ethMultiVaultProxy; + TimelockController public timelock; // Bonding Curves - BondingCurveRegistry bondingCurveRegistry; - LinearCurve linearCurve; // <-- Not used in this edition of EthMultiVault - ProgressiveCurve progressiveCurve; + BondingCurveRegistry public bondingCurveRegistry; + TransparentUpgradeableProxy public bondingCurveRegistryProxy; + LinearCurve public linearCurve; // <-- Not used in this edition of EthMultiVault + ProgressiveCurve public progressiveCurve; function run() external { // Begin sending tx's to network @@ -52,16 +54,18 @@ contract DeployEthMultiVault is Script { address[] memory executors = new address[](1); proposers[0] = admin; - executors[0] = admin; + executors[0] = address(0); // deploy TimelockController timelock = new TimelockController( minDelay, // minimum delay for timelock transactions - proposers, // proposers (can schedule transactions) - executors, // executors - address(0) // no default admin that can change things without going through the timelock process (self-administered) + proposers, // proposers (can schedule and cancel transactions) + executors, // executors (can execute transactions; address(0) means it's an open role, i.e. anyone can execute the scheduled transactions) + address(0) // no optional admin that can change things without going through the timelock process ); console.logString("deployed TimelockController."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(minDelay, proposers, executors, address(0))); // deploy AtomWallet implementation contract atomWallet = new AtomWallet(); @@ -70,12 +74,14 @@ contract DeployEthMultiVault is Script { // deploy AtomWalletBeacon pointing to the AtomWallet implementation contract atomWalletBeacon = new UpgradeableBeacon(address(atomWallet), address(timelock)); console.logString("deployed UpgradeableBeacon."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(address(atomWallet), address(timelock))); IEthMultiVault.GeneralConfig memory generalConfig = IEthMultiVault.GeneralConfig({ admin: admin, // Admin address for the EthMultiVault contract protocolMultisig: protocolMultisig, // Protocol multisig address feeDenominator: 10000, // Common denominator for fee calculations - minDeposit: 0.00042 ether, // Minimum deposit amount in wei + minDeposit: 0.000025 ether, // Minimum deposit amount in wei minShare: 1e6, // Minimum share amount (e.g., for vault initialization) atomUriMaxLength: 250, // Maximum length of the atom URI data that can be passed when creating atom vaults decimalPrecision: 1e18, // decimal precision used for calculating share prices @@ -83,19 +89,19 @@ contract DeployEthMultiVault is Script { }); IEthMultiVault.AtomConfig memory atomConfig = IEthMultiVault.AtomConfig({ - atomWalletInitialDepositAmount: 0.00003 ether, // Fee charged for purchasing vault shares for the atom wallet upon creation - atomCreationProtocolFee: 0.0003 ether // Fee charged for creating an atom + atomWalletInitialDepositAmount: 0.000003 ether, // Fee charged for purchasing vault shares for the atom wallet upon creation + atomCreationProtocolFee: 0.000003 ether // Fee charged for creating an atom }); IEthMultiVault.TripleConfig memory tripleConfig = IEthMultiVault.TripleConfig({ - tripleCreationProtocolFee: 0.0003 ether, // Fee for creating a triple - atomDepositFractionOnTripleCreation: 0.00003 ether, // Static fee going towards increasing the amount of assets in the underlying atom vaults - atomDepositFractionForTriple: 900 // Fee for equity in atoms when creating a triple + tripleCreationProtocolFee: 0.000003 ether, // Fee for creating a triple + atomDepositFractionOnTripleCreation: 0.000003 ether, // Static fee going towards increasing the amount of assets in the underlying atom vaults + atomDepositFractionForTriple: 300 // Fee for equity in atoms when creating a triple }); IEthMultiVault.WalletConfig memory walletConfig = IEthMultiVault.WalletConfig({ - permit2: IPermit2(address(permit2)), // Permit2 on Base - entryPoint: entryPoint, // EntryPoint address on Base + permit2: IPermit2(address(permit2)), // Permit2 on Linea + entryPoint: entryPoint, // EntryPoint address on Linea atomWarden: atomWarden, // atomWarden address atomWalletBeacon: address(atomWalletBeacon) // Address of the AtomWalletBeacon contract }); @@ -103,29 +109,48 @@ contract DeployEthMultiVault is Script { IEthMultiVault.VaultFees memory vaultFees = IEthMultiVault.VaultFees({ entryFee: 500, // Entry fee for vault 0 exitFee: 500, // Exit fee for vault 0 - protocolFee: 250 // Protocol fee for vault 0 + protocolFee: 100 // Protocol fee for vault 0 }); // ------------------------------- Bonding Curves---------------------------------------- // Deploy BondingCurveRegistry and take temporary ownership to add the curves bondingCurveRegistry = new BondingCurveRegistry(); - console.logString("deployed BondingCurveRegistry."); - bondingCurveRegistry.initialize(msg.sender); + console.logString("deployed BondingCurveRegistry implementation."); + + bytes memory bondingCurveRegistryInitData = + abi.encodeWithSelector(BondingCurveRegistry.initialize.selector, msg.sender); + + // Deploy BondingCurveRegistry proxy + bondingCurveRegistryProxy = new TransparentUpgradeableProxy( + address(bondingCurveRegistry), // BondingCurveRegistry logic contract address + address(timelock), // Timelock controller address, which will be the owner of the ProxyAdmin contract for the proxy + bondingCurveRegistryInitData // Initialization data to call the `initialize` function in BondingCurveRegistry + ); + console.logString("deployed BondingCurveRegistry proxy."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(address(bondingCurveRegistry), address(timelock), bondingCurveRegistryInitData)); // Deploy LinearCurve linearCurve = new LinearCurve("Linear Curve"); console.logString("deployed LinearCurve."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode("Linear Curve")); // Deploy ProgressiveCurve progressiveCurve = new ProgressiveCurve("Progressive Curve", 0.00007054e18); - console.logString("deployed ProgressiveCurve."); + console.log("deployed ProgressiveCurve."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode("Progressive Curve", 0.00007054e18)); + + // Reference to the BondingCurveRegistry proxy contract + bondingCurveRegistry = BondingCurveRegistry(address(bondingCurveRegistryProxy)); // Add curves to BondingCurveRegistry bondingCurveRegistry.addBondingCurve(address(linearCurve)); bondingCurveRegistry.addBondingCurve(address(progressiveCurve)); - // Transfer ownership of BondingCurveRegistry to admin + // Transfer ownership of BondingCurveRegistry to multisig bondingCurveRegistry.setAdmin(admin); IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault.BondingCurveConfig({ @@ -157,6 +182,11 @@ contract DeployEthMultiVault is Script { initData // Initialization data to call the `init` function in EthMultiVault ); console.logString("deployed TransparentUpgradeableProxy."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(address(ethMultiVault), address(timelock), initData)); + + console.log("encoded constructor args for the ProxyAdmin: "); + console.logBytes(abi.encode(address(timelock))); // stop sending tx's vm.stopBroadcast(); @@ -167,9 +197,11 @@ contract DeployEthMultiVault is Script { console.log("UpgradeableBeacon address:", address(atomWalletBeacon)); console.log("EthMultiVault implementation address:", address(ethMultiVault)); console.log("EthMultiVault proxy address:", address(ethMultiVaultProxy)); + console.log("LinearCurve address:", address(linearCurve)); + console.log("ProgressiveCurve address:", address(progressiveCurve)); console.log("BondingCurveRegistry address:", address(bondingCurveRegistry)); console.log( - "To find the address of the ProxyAdmin contract for the EthMultiVault proxy, inspect the creation transaction of the EthMultiVault proxy contract on Basescan, in particular the AdminChanged event. Same applies to the CustomMulticall3 proxy contract." + "To find the address of the ProxyAdmin contract for the EthMultiVault proxy, inspect the creation transaction of the EthMultiVault proxy contract on Lineascan, in particular the AdminChanged event. Same applies to the BondingCurveRegistry proxy contract" ); } } diff --git a/src/ProgressiveCurve.sol b/src/ProgressiveCurve.sol index 7e44b631..e8fb2a59 100644 --- a/src/ProgressiveCurve.sol +++ b/src/ProgressiveCurve.sol @@ -7,7 +7,7 @@ import {UD60x18, ud60x18} from "@prb/math/UD60x18.sol"; /** * @title ProgressiveCurve * @author 0xIntuition - * @notice A bonding curve implementation that uses a progressive pricing model where + * @notice A bonding curve implementation that uses a progressive pricing model where * each new share costs more than the last. * * The price follows the formula: From 260eafa44d2d596a949817b9fdf0e4680d15d15a Mon Sep 17 00:00:00 2001 From: mihailo-maksa Date: Fri, 14 Feb 2025 21:10:22 +0100 Subject: [PATCH 2/7] add depoyment scripts for implementation contracts, add chainId checks --- foundry.toml | 2 +- script/DeployToBase.s.sol | 213 ++++++++++++++++++ script/{Deploy.s.sol => DeployToLinea.s.sol} | 32 ++- .../DeployAtomWalletImplementation.s.sol | 24 ++ ...oyBondingCurveRegistryImplementation.s.sol | 24 ++ .../DeployEthMultiVaultImplementation.s.sol | 24 ++ 6 files changed, 307 insertions(+), 12 deletions(-) create mode 100644 script/DeployToBase.s.sol rename script/{Deploy.s.sol => DeployToLinea.s.sol} (92%) create mode 100644 script/implementations/DeployAtomWalletImplementation.s.sol create mode 100644 script/implementations/DeployBondingCurveRegistryImplementation.s.sol create mode 100644 script/implementations/DeployEthMultiVaultImplementation.s.sol diff --git a/foundry.toml b/foundry.toml index e7103f51..87e83794 100644 --- a/foundry.toml +++ b/foundry.toml @@ -6,7 +6,7 @@ ffi = true ast = true build_info = true extra_output = ["storageLayout"] -evm_version = "Paris" +evm_version = "Cancun" auto_detect_remappings = false fs_permissions = [{ access = "read-write", path = "./out" }] # optimizer = true diff --git a/script/DeployToBase.s.sol b/script/DeployToBase.s.sol new file mode 100644 index 00000000..7f224609 --- /dev/null +++ b/script/DeployToBase.s.sol @@ -0,0 +1,213 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.21; + +import {Script, console} from "forge-std/Script.sol"; +import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; +import { + TransparentUpgradeableProxy, + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; + +import {AtomWallet} from "src/AtomWallet.sol"; +import {EthMultiVault} from "src/EthMultiVault.sol"; +import {IEthMultiVault} from "src/interfaces/IEthMultiVault.sol"; +import {IPermit2} from "src/interfaces/IPermit2.sol"; + +import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; +import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; +import {LinearCurve} from "src/LinearCurve.sol"; + +contract DeployToBase is Script { + // Multisig addresses for key roles in the protocol + address public admin = 0xa28d4AAcA48bE54824dA53a19b05121DE71Ef480; + address public protocolMultisig = 0xC03F0dE5b34339e1B968e4f317Cd7e7FBd421FD1; + address public atomWarden = 0xC35DFCFE50da58d957fc47C7063f56135aFF61B8; + + // Constants from Base + IPermit2 public permit2 = IPermit2(address(0x000000000022D473030F116dDEE9F6B43aC78BA3)); // Permit2 on Base + address public entryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; // EntryPoint on Base + + // Contracts to be deployed + AtomWallet public atomWallet; + UpgradeableBeacon public atomWalletBeacon; + EthMultiVault public ethMultiVault; + TransparentUpgradeableProxy public ethMultiVaultProxy; + TimelockController public timelock; + + // Bonding Curves + BondingCurveRegistry public bondingCurveRegistry; + TransparentUpgradeableProxy public bondingCurveRegistryProxy; + LinearCurve public linearCurve; // <-- Not used in this edition of EthMultiVault + ProgressiveCurve public progressiveCurve; + + error UnsupportedChainId(); + + function run() external { + // Begin sending tx's to network + vm.startBroadcast(); + + // Check if the script is running on the correct network + uint256 chainId = block.chainid; + if (chainId != 8453) revert UnsupportedChainId(); + + // TimelockController parameters + uint256 minDelay = 3 days; + address[] memory proposers = new address[](1); + address[] memory executors = new address[](1); + + proposers[0] = admin; + executors[0] = address(0); + + // deploy TimelockController + timelock = new TimelockController( + minDelay, // minimum delay for timelock transactions + proposers, // proposers (can schedule and cancel transactions) + executors, // executors (can execute transactions; address(0) means it's an open role, i.e. anyone can execute the scheduled transactions) + address(0) // no optional admin that can change things without going through the timelock process + ); + console.logString("deployed TimelockController."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(minDelay, proposers, executors, address(0))); + + // deploy AtomWallet implementation contract + atomWallet = new AtomWallet(); + console.logString("deployed AtomWallet."); + + // deploy AtomWalletBeacon pointing to the AtomWallet implementation contract + atomWalletBeacon = new UpgradeableBeacon(address(atomWallet), address(timelock)); + console.logString("deployed UpgradeableBeacon."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(address(atomWallet), address(timelock))); + + IEthMultiVault.GeneralConfig memory generalConfig = IEthMultiVault.GeneralConfig({ + admin: admin, // Admin address for the EthMultiVault contract + protocolMultisig: protocolMultisig, // Protocol multisig address + feeDenominator: 10000, // Common denominator for fee calculations + minDeposit: 0.000025 ether, // Minimum deposit amount in wei + minShare: 1e6, // Minimum share amount (e.g., for vault initialization) + atomUriMaxLength: 250, // Maximum length of the atom URI data that can be passed when creating atom vaults + decimalPrecision: 1e18, // decimal precision used for calculating share prices + minDelay: 1 days // minimum delay for timelocked transactions + }); + + IEthMultiVault.AtomConfig memory atomConfig = IEthMultiVault.AtomConfig({ + atomWalletInitialDepositAmount: 0.000003 ether, // Fee charged for purchasing vault shares for the atom wallet upon creation + atomCreationProtocolFee: 0.000003 ether // Fee charged for creating an atom + }); + + IEthMultiVault.TripleConfig memory tripleConfig = IEthMultiVault.TripleConfig({ + tripleCreationProtocolFee: 0.000003 ether, // Fee for creating a triple + atomDepositFractionOnTripleCreation: 0.000003 ether, // Static fee going towards increasing the amount of assets in the underlying atom vaults + atomDepositFractionForTriple: 300 // Fee for equity in atoms when creating a triple + }); + + IEthMultiVault.WalletConfig memory walletConfig = IEthMultiVault.WalletConfig({ + permit2: IPermit2(address(permit2)), // Permit2 on Linea + entryPoint: entryPoint, // EntryPoint address on Linea + atomWarden: atomWarden, // atomWarden address + atomWalletBeacon: address(atomWalletBeacon) // Address of the AtomWalletBeacon contract + }); + + IEthMultiVault.VaultFees memory vaultFees = IEthMultiVault.VaultFees({ + entryFee: 500, // Entry fee for vault 0 + exitFee: 500, // Exit fee for vault 0 + protocolFee: 100 // Protocol fee for vault 0 + }); + + IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault.BondingCurveConfig({ + registry: address(bondingCurveRegistry), + defaultCurveId: 1 // Unused in this edition of EthMultiVault + }); + + // ------------------------------- Bonding Curves---------------------------------------- + + // Deploy BondingCurveRegistry and take temporary ownership to add the curves + bondingCurveRegistry = new BondingCurveRegistry(); + console.logString("deployed BondingCurveRegistry implementation."); + + address bondingCurveRegistryImplementation = address(bondingCurveRegistry); + + bytes memory bondingCurveRegistryInitData = + abi.encodeWithSelector(BondingCurveRegistry.initialize.selector, msg.sender); + + // Deploy BondingCurveRegistry proxy + bondingCurveRegistryProxy = new TransparentUpgradeableProxy( + address(bondingCurveRegistry), // BondingCurveRegistry logic contract address + address(timelock), // Timelock controller address, which will be the owner of the ProxyAdmin contract for the proxy + bondingCurveRegistryInitData // Initialization data to call the `initialize` function in BondingCurveRegistry + ); + console.logString("deployed BondingCurveRegistry proxy."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(address(bondingCurveRegistry), address(timelock), bondingCurveRegistryInitData)); + + // Deploy LinearCurve + linearCurve = new LinearCurve("Linear Curve"); + console.logString("deployed LinearCurve."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode("Linear Curve")); + + // Deploy ProgressiveCurve + progressiveCurve = new ProgressiveCurve("Progressive Curve", 0.00007054e18); + console.log("deployed ProgressiveCurve."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode("Progressive Curve", 0.00007054e18)); + + // Reference to the BondingCurveRegistry proxy contract + bondingCurveRegistry = BondingCurveRegistry(address(bondingCurveRegistryProxy)); + + // Add curves to BondingCurveRegistry + bondingCurveRegistry.addBondingCurve(address(linearCurve)); + bondingCurveRegistry.addBondingCurve(address(progressiveCurve)); + + // Transfer ownership of BondingCurveRegistry to multisig + bondingCurveRegistry.setAdmin(admin); + + // ------------------------------------------------------------------------------------- + + // Prepare data for initializer function + bytes memory initData = abi.encodeWithSelector( + EthMultiVault.init.selector, + generalConfig, + atomConfig, + tripleConfig, + walletConfig, + vaultFees, + bondingCurveConfig + ); + + // Deploy EthMultiVault implementation contract + ethMultiVault = new EthMultiVault(); + console.logString("deployed EthMultiVault."); + + // Deploy TransparentUpgradeableProxy with EthMultiVault logic contract + ethMultiVaultProxy = new TransparentUpgradeableProxy( + address(ethMultiVault), // EthMultiVault logic contract address + address(timelock), // Timelock controller address, which will be the owner of the ProxyAdmin contract for the proxy + initData // Initialization data to call the `init` function in EthMultiVault + ); + console.logString("deployed TransparentUpgradeableProxy."); + console.logString("encoded constructor args: "); + console.logBytes(abi.encode(address(ethMultiVault), address(timelock), initData)); + + console.log("encoded constructor args for the ProxyAdmin: "); + console.logBytes(abi.encode(address(timelock))); + + // stop sending tx's + vm.stopBroadcast(); + + console.log("All contracts deployed successfully!"); + console.log("TimelockController address:", address(timelock)); + console.log("AtomWallet implementation address:", address(atomWallet)); + console.log("UpgradeableBeacon address:", address(atomWalletBeacon)); + console.log("EthMultiVault implementation address:", address(ethMultiVault)); + console.log("EthMultiVault proxy address:", address(ethMultiVaultProxy)); + console.log("BondingCurveRegistry implementation address:", bondingCurveRegistryImplementation); + console.log("BondingCurveRegistry proxy address:", address(bondingCurveRegistryProxy)); + console.log("LinearCurve address:", address(linearCurve)); + console.log("ProgressiveCurve address:", address(progressiveCurve)); + console.log( + "To find the address of the ProxyAdmin contract for the EthMultiVault proxy, inspect the creation transaction of the EthMultiVault proxy contract on Basescan, in particular the AdminChanged event. Same applies to the BondingCurveRegistry proxy contract." + ); + } +} diff --git a/script/Deploy.s.sol b/script/DeployToLinea.s.sol similarity index 92% rename from script/Deploy.s.sol rename to script/DeployToLinea.s.sol index 8fb2516c..bd9b2ebb 100644 --- a/script/Deploy.s.sol +++ b/script/DeployToLinea.s.sol @@ -18,9 +18,10 @@ import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; import {LinearCurve} from "src/LinearCurve.sol"; -contract DeployEthMultiVault is Script { - address public lineaTestnetAdmin = 0xB8e3452E62B45e654a300a296061597E3Cf3e039; - address public lineaMainnetAdmin = 0x323e9506B929C21AE602D64d3807721AA49b4884; +/// @notice If you wish to deploy the contracts on the Linea mainnet or Linea Sepolia, make sure to set evm_version = "Paris" in foundry.toml before compiling the contracts. +contract DeployToLinea is Script { + address public lineaTestnetAdmin = 0xB8e3452E62B45e654a300a296061597E3Cf3e039; // EOA + address public lineaMainnetAdmin = 0x323e9506B929C21AE602D64d3807721AA49b4884; // multisig // Multisig addresses for key roles in the protocol address public admin = lineaMainnetAdmin; @@ -44,10 +45,16 @@ contract DeployEthMultiVault is Script { LinearCurve public linearCurve; // <-- Not used in this edition of EthMultiVault ProgressiveCurve public progressiveCurve; + error UnsupportedChainId(); + function run() external { // Begin sending tx's to network vm.startBroadcast(); + // Check if the script is running on the correct network + uint256 chainId = block.chainid; + if (chainId != 59_144) revert UnsupportedChainId(); + // TimelockController parameters uint256 minDelay = 3 days; address[] memory proposers = new address[](1); @@ -112,12 +119,19 @@ contract DeployEthMultiVault is Script { protocolFee: 100 // Protocol fee for vault 0 }); + IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault.BondingCurveConfig({ + registry: address(bondingCurveRegistry), + defaultCurveId: 1 // Unused in this edition of EthMultiVault + }); + // ------------------------------- Bonding Curves---------------------------------------- // Deploy BondingCurveRegistry and take temporary ownership to add the curves bondingCurveRegistry = new BondingCurveRegistry(); console.logString("deployed BondingCurveRegistry implementation."); + address bondingCurveRegistryImplementation = address(bondingCurveRegistry); + bytes memory bondingCurveRegistryInitData = abi.encodeWithSelector(BondingCurveRegistry.initialize.selector, msg.sender); @@ -153,11 +167,6 @@ contract DeployEthMultiVault is Script { // Transfer ownership of BondingCurveRegistry to multisig bondingCurveRegistry.setAdmin(admin); - IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault.BondingCurveConfig({ - registry: address(bondingCurveRegistry), - defaultCurveId: 1 // Unused in this edition of EthMultiVault - }); - // ------------------------------------------------------------------------------------- // Prepare data for initializer function @@ -191,17 +200,18 @@ contract DeployEthMultiVault is Script { // stop sending tx's vm.stopBroadcast(); - console.log("All contracts deployed successfully:"); + console.log("All contracts deployed successfully!"); console.log("TimelockController address:", address(timelock)); console.log("AtomWallet implementation address:", address(atomWallet)); console.log("UpgradeableBeacon address:", address(atomWalletBeacon)); console.log("EthMultiVault implementation address:", address(ethMultiVault)); console.log("EthMultiVault proxy address:", address(ethMultiVaultProxy)); + console.log("BondingCurveRegistry implementation address:", bondingCurveRegistryImplementation); + console.log("BondingCurveRegistry proxy address:", address(bondingCurveRegistryProxy)); console.log("LinearCurve address:", address(linearCurve)); console.log("ProgressiveCurve address:", address(progressiveCurve)); - console.log("BondingCurveRegistry address:", address(bondingCurveRegistry)); console.log( - "To find the address of the ProxyAdmin contract for the EthMultiVault proxy, inspect the creation transaction of the EthMultiVault proxy contract on Lineascan, in particular the AdminChanged event. Same applies to the BondingCurveRegistry proxy contract" + "To find the address of the ProxyAdmin contract for the EthMultiVault proxy, inspect the creation transaction of the EthMultiVault proxy contract on Lineascan, in particular the AdminChanged event. Same applies to the BondingCurveRegistry proxy contract." ); } } diff --git a/script/implementations/DeployAtomWalletImplementation.s.sol b/script/implementations/DeployAtomWalletImplementation.s.sol new file mode 100644 index 00000000..000a0350 --- /dev/null +++ b/script/implementations/DeployAtomWalletImplementation.s.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.21; + +import {Script, console} from "forge-std/Script.sol"; + +import {AtomWallet} from "src/AtomWallet.sol"; + +contract DeployAtomWalletImplementation is Script { + error UnsupportedChainId(); + + function run() external { + vm.startBroadcast(); + + // Check if the script is running on the correct network + if (block.chainid != 8453) revert UnsupportedChainId(); + + // Deploy the AtomWallet implementation contract + AtomWallet atomWallet = new AtomWallet(); + + console.log("AtomWallet implementation deployed at: %s", address(atomWallet)); + + vm.stopBroadcast(); + } +} diff --git a/script/implementations/DeployBondingCurveRegistryImplementation.s.sol b/script/implementations/DeployBondingCurveRegistryImplementation.s.sol new file mode 100644 index 00000000..02a7ad29 --- /dev/null +++ b/script/implementations/DeployBondingCurveRegistryImplementation.s.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.21; + +import {Script, console} from "forge-std/Script.sol"; + +import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; + +contract DeployBondingCurveRegistryImplementation is Script { + error UnsupportedChainId(); + + function run() external { + vm.startBroadcast(); + + // Check if the script is running on the correct network + if (block.chainid != 8453) revert UnsupportedChainId(); + + // Deploy the BondingCurveRegistry implementation contract + BondingCurveRegistry bondingCurveRegistry = new BondingCurveRegistry(); + + console.log("BondingCurveRegistry implementation deployed at: %s", address(bondingCurveRegistry)); + + vm.stopBroadcast(); + } +} diff --git a/script/implementations/DeployEthMultiVaultImplementation.s.sol b/script/implementations/DeployEthMultiVaultImplementation.s.sol new file mode 100644 index 00000000..1787b9bc --- /dev/null +++ b/script/implementations/DeployEthMultiVaultImplementation.s.sol @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.21; + +import {Script, console} from "forge-std/Script.sol"; + +import {EthMultiVault} from "src/EthMultiVault.sol"; + +contract DeployEthMultiVaultImplementation is Script { + error UnsupportedChainId(); + + function run() external { + vm.startBroadcast(); + + // Check if the script is running on the correct network + if (block.chainid != 8453) revert UnsupportedChainId(); + + // Deploy the EthMultiVault implementation contract + EthMultiVault ethMultiVault = new EthMultiVault(); + + console.log("EthMultiVault implementation deployed at: %s", address(ethMultiVault)); + + vm.stopBroadcast(); + } +} From b17e63f111e76b02cc972844f38157b14584a68a Mon Sep 17 00:00:00 2001 From: mihailo-maksa Date: Fri, 14 Feb 2025 21:21:05 +0100 Subject: [PATCH 3/7] linea script NatSpec note --- script/DeployToLinea.s.sol | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/script/DeployToLinea.s.sol b/script/DeployToLinea.s.sol index bd9b2ebb..84b826b1 100644 --- a/script/DeployToLinea.s.sol +++ b/script/DeployToLinea.s.sol @@ -18,7 +18,11 @@ import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; import {LinearCurve} from "src/LinearCurve.sol"; -/// @notice If you wish to deploy the contracts on the Linea mainnet or Linea Sepolia, make sure to set evm_version = "Paris" in foundry.toml before compiling the contracts. +/** + * @notice If you wish to deploy the contracts on the Linea mainnet or Linea Sepolia, make sure to delete the existing `cache`, + * `cache_forge`, `out` and `broadcast` autogenerated folders from foundry, set the `evm_version = "Paris"` option in + * `foundry.toml`, and then compile the contracts again before running the deployment script. + */ contract DeployToLinea is Script { address public lineaTestnetAdmin = 0xB8e3452E62B45e654a300a296061597E3Cf3e039; // EOA address public lineaMainnetAdmin = 0x323e9506B929C21AE602D64d3807721AA49b4884; // multisig From e28c7d1a053d708f769ff031bb3dfa33f1c82a76 Mon Sep 17 00:00:00 2001 From: mihailo-maksa Date: Mon, 7 Apr 2025 15:05:24 +0200 Subject: [PATCH 4/7] re-add Deploy.s.sol --- script/Deploy.s.sol | 174 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 script/Deploy.s.sol diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol new file mode 100644 index 00000000..886c8c4f --- /dev/null +++ b/script/Deploy.s.sol @@ -0,0 +1,174 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.21; + +import {Script, console} from "forge-std/Script.sol"; +import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; +import { + TransparentUpgradeableProxy, + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; + +import {AtomWallet} from "src/AtomWallet.sol"; +import {EthMultiVault} from "src/EthMultiVault.sol"; +import {IEthMultiVault} from "src/interfaces/IEthMultiVault.sol"; +import {IPermit2} from "src/interfaces/IPermit2.sol"; + +import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; +import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; +import {LinearCurve} from "src/LinearCurve.sol"; + +contract DeployEthMultiVault is Script { + // Multisig addresses for key roles in the protocol + address public admin = 0xa28d4AAcA48bE54824dA53a19b05121DE71Ef480; + address public protocolMultisig = 0xC03F0dE5b34339e1B968e4f317Cd7e7FBd421FD1; + address public atomWarden = 0xC35DFCFE50da58d957fc47C7063f56135aFF61B8; + + // Constants from Base + IPermit2 public permit2 = IPermit2(address(0x000000000022D473030F116dDEE9F6B43aC78BA3)); // Permit2 on Base + address public entryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; // EntryPoint on Base + + // Contracts to be deployed + AtomWallet public atomWallet; + UpgradeableBeacon public atomWalletBeacon; + EthMultiVault public ethMultiVault; + TransparentUpgradeableProxy public ethMultiVaultProxy; + TimelockController public timelock; + + // Bonding Curves + TransparentUpgradeableProxy public bondingCurveRegistryProxy; + BondingCurveRegistry public bondingCurveRegistry; + LinearCurve public linearCurve; // <-- Not used in this edition of EthMultiVault + ProgressiveCurve public progressiveCurve; + + function run() external { + // Begin sending tx's to network + vm.startBroadcast(); + + // TimelockController parameters + uint256 minDelay = 1 minutes; // 1 minute during the setup stage; should be updated to 7 days later on + address[] memory proposers = new address[](1); + address[] memory executors = new address[](1); + + proposers[0] = admin; + executors[0] = address(0); + + // deploy TimelockController + timelock = new TimelockController( + minDelay, // minimum delay for timelock transactions + proposers, // proposers (can schedule transactions) + executors, // executors (can execute transactions) - open role + address(0) // no default admin that can change things without going through the timelock process (self-administered) + ); + console.logString("deployed TimelockController."); + + // deploy AtomWallet implementation contract + atomWallet = new AtomWallet(); + console.logString("deployed AtomWallet."); + + // deploy AtomWalletBeacon pointing to the AtomWallet implementation contract + atomWalletBeacon = new UpgradeableBeacon(address(atomWallet), address(timelock)); + console.logString("deployed UpgradeableBeacon."); + + IEthMultiVault.GeneralConfig memory generalConfig = IEthMultiVault.GeneralConfig({ + admin: admin, // Admin address for the EthMultiVault contract + protocolMultisig: protocolMultisig, // Protocol multisig address + feeDenominator: 10000, // Common denominator for fee calculations + minDeposit: 0.00042 ether, // Minimum deposit amount in wei + minShare: 1e6, // Minimum share amount (e.g., for vault initialization) + atomUriMaxLength: 250, // Maximum length of the atom URI data that can be passed when creating atom vaults + decimalPrecision: 1e18, // decimal precision used for calculating share prices + minDelay: 3 days // minimum delay for timelocked transactions + }); + + IEthMultiVault.AtomConfig memory atomConfig = IEthMultiVault.AtomConfig({ + atomWalletInitialDepositAmount: 0.00003 ether, // Fee charged for purchasing vault shares for the atom wallet upon creation + atomCreationProtocolFee: 0.0003 ether // Fee charged for creating an atom + }); + + IEthMultiVault.TripleConfig memory tripleConfig = IEthMultiVault.TripleConfig({ + tripleCreationProtocolFee: 0.0003 ether, // Fee for creating a triple + totalAtomDepositsOnTripleCreation: 0.00003 ether, // Static fee going towards increasing the amount of assets in the underlying atom vaults + atomDepositFractionForTriple: 900 // Fee for equity in atoms when creating a triple + }); + + IEthMultiVault.WalletConfig memory walletConfig = IEthMultiVault.WalletConfig({ + permit2: IPermit2(address(permit2)), // Permit2 on Base + entryPoint: entryPoint, // EntryPoint address on Base + atomWarden: atomWarden, // atomWarden address + atomWalletBeacon: address(atomWalletBeacon) // Address of the AtomWalletBeacon contract + }); + + IEthMultiVault.VaultFees memory vaultFees = IEthMultiVault.VaultFees({ + entryFee: 500, // Entry fee for vault 0 + exitFee: 500, // Exit fee for vault 0 + protocolFee: 250 // Protocol fee for vault 0 + }); + + // ------------------------------- Bonding Curves---------------------------------------- + + // Deploy BondingCurveRegistry and take temporary ownership to add the curves + bondingCurveRegistry = new BondingCurveRegistry(msg.sender); + console.logString("deployed BondingCurveRegistry."); + + // Deploy LinearCurve + linearCurve = new LinearCurve("Linear Curve"); + console.logString("deployed LinearCurve."); + + // Deploy ProgressiveCurve + progressiveCurve = new ProgressiveCurve("Progressive Curve", 2); + console.logString("deployed ProgressiveCurve."); + + // Add curves to BondingCurveRegistry + bondingCurveRegistry.addBondingCurve(address(linearCurve)); + bondingCurveRegistry.addBondingCurve(address(progressiveCurve)); + + // Transfer ownership of BondingCurveRegistry to the timelock + bondingCurveRegistry.transferOwnership(address(timelock)); + // NOTE: TimelockController needs to accept the ownership of the BondingCurveRegistry in order to become a new owner + + IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault.BondingCurveConfig({ + registry: address(bondingCurveRegistry), + defaultCurveId: 1 // Unused in this edition of EthMultiVault + }); + + // ------------------------------------------------------------------------------------- + + // Prepare data for initializer function of EthMultiVault + bytes memory initData = abi.encodeWithSelector( + EthMultiVault.init.selector, + generalConfig, + atomConfig, + tripleConfig, + walletConfig, + vaultFees, + bondingCurveConfig + ); + + // Deploy EthMultiVault implementation contract + ethMultiVault = new EthMultiVault(); + console.logString("deployed EthMultiVault implementation."); + + // Deploy TransparentUpgradeableProxy with EthMultiVault logic contract + ethMultiVaultProxy = new TransparentUpgradeableProxy( + address(ethMultiVault), // EthMultiVault logic contract address + address(timelock), // Timelock controller address, which will be the owner of the ProxyAdmin contract for the proxy + initData // Initialization data to call the `init` function in EthMultiVault + ); + console.logString("deployed EthMultiVault proxy."); + + // stop sending tx's + vm.stopBroadcast(); + + console.log("All contracts deployed successfully:"); + console.log("TimelockController address:", address(timelock)); + console.log("AtomWallet implementation address:", address(atomWallet)); + console.log("UpgradeableBeacon address:", address(atomWalletBeacon)); + console.log("EthMultiVault implementation address:", address(ethMultiVault)); + console.log("EthMultiVault proxy address:", address(ethMultiVaultProxy)); + console.log("BondingCurveRegistry address:", address(bondingCurveRegistry)); + console.log( + "To find the address of the ProxyAdmin contract for the EthMultiVault proxy, inspect the creation transaction of the EthMultiVault proxy contract on Basescan, in particular the AdminChanged event. Same applies to the CustomMulticall3 proxy contract." + ); + } +} \ No newline at end of file From 611cba072e36574f83e731a053038743e63d058c Mon Sep 17 00:00:00 2001 From: mihailo-maksa Date: Mon, 7 Apr 2025 15:06:18 +0200 Subject: [PATCH 5/7] remove Deploy.s.sol --- script/Deploy.s.sol | 174 -------------------------------------------- 1 file changed, 174 deletions(-) delete mode 100644 script/Deploy.s.sol diff --git a/script/Deploy.s.sol b/script/Deploy.s.sol deleted file mode 100644 index 886c8c4f..00000000 --- a/script/Deploy.s.sol +++ /dev/null @@ -1,174 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.21; - -import {Script, console} from "forge-std/Script.sol"; -import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; -import { - TransparentUpgradeableProxy, - ITransparentUpgradeableProxy -} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; - -import {AtomWallet} from "src/AtomWallet.sol"; -import {EthMultiVault} from "src/EthMultiVault.sol"; -import {IEthMultiVault} from "src/interfaces/IEthMultiVault.sol"; -import {IPermit2} from "src/interfaces/IPermit2.sol"; - -import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; -import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; -import {LinearCurve} from "src/LinearCurve.sol"; - -contract DeployEthMultiVault is Script { - // Multisig addresses for key roles in the protocol - address public admin = 0xa28d4AAcA48bE54824dA53a19b05121DE71Ef480; - address public protocolMultisig = 0xC03F0dE5b34339e1B968e4f317Cd7e7FBd421FD1; - address public atomWarden = 0xC35DFCFE50da58d957fc47C7063f56135aFF61B8; - - // Constants from Base - IPermit2 public permit2 = IPermit2(address(0x000000000022D473030F116dDEE9F6B43aC78BA3)); // Permit2 on Base - address public entryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789; // EntryPoint on Base - - // Contracts to be deployed - AtomWallet public atomWallet; - UpgradeableBeacon public atomWalletBeacon; - EthMultiVault public ethMultiVault; - TransparentUpgradeableProxy public ethMultiVaultProxy; - TimelockController public timelock; - - // Bonding Curves - TransparentUpgradeableProxy public bondingCurveRegistryProxy; - BondingCurveRegistry public bondingCurveRegistry; - LinearCurve public linearCurve; // <-- Not used in this edition of EthMultiVault - ProgressiveCurve public progressiveCurve; - - function run() external { - // Begin sending tx's to network - vm.startBroadcast(); - - // TimelockController parameters - uint256 minDelay = 1 minutes; // 1 minute during the setup stage; should be updated to 7 days later on - address[] memory proposers = new address[](1); - address[] memory executors = new address[](1); - - proposers[0] = admin; - executors[0] = address(0); - - // deploy TimelockController - timelock = new TimelockController( - minDelay, // minimum delay for timelock transactions - proposers, // proposers (can schedule transactions) - executors, // executors (can execute transactions) - open role - address(0) // no default admin that can change things without going through the timelock process (self-administered) - ); - console.logString("deployed TimelockController."); - - // deploy AtomWallet implementation contract - atomWallet = new AtomWallet(); - console.logString("deployed AtomWallet."); - - // deploy AtomWalletBeacon pointing to the AtomWallet implementation contract - atomWalletBeacon = new UpgradeableBeacon(address(atomWallet), address(timelock)); - console.logString("deployed UpgradeableBeacon."); - - IEthMultiVault.GeneralConfig memory generalConfig = IEthMultiVault.GeneralConfig({ - admin: admin, // Admin address for the EthMultiVault contract - protocolMultisig: protocolMultisig, // Protocol multisig address - feeDenominator: 10000, // Common denominator for fee calculations - minDeposit: 0.00042 ether, // Minimum deposit amount in wei - minShare: 1e6, // Minimum share amount (e.g., for vault initialization) - atomUriMaxLength: 250, // Maximum length of the atom URI data that can be passed when creating atom vaults - decimalPrecision: 1e18, // decimal precision used for calculating share prices - minDelay: 3 days // minimum delay for timelocked transactions - }); - - IEthMultiVault.AtomConfig memory atomConfig = IEthMultiVault.AtomConfig({ - atomWalletInitialDepositAmount: 0.00003 ether, // Fee charged for purchasing vault shares for the atom wallet upon creation - atomCreationProtocolFee: 0.0003 ether // Fee charged for creating an atom - }); - - IEthMultiVault.TripleConfig memory tripleConfig = IEthMultiVault.TripleConfig({ - tripleCreationProtocolFee: 0.0003 ether, // Fee for creating a triple - totalAtomDepositsOnTripleCreation: 0.00003 ether, // Static fee going towards increasing the amount of assets in the underlying atom vaults - atomDepositFractionForTriple: 900 // Fee for equity in atoms when creating a triple - }); - - IEthMultiVault.WalletConfig memory walletConfig = IEthMultiVault.WalletConfig({ - permit2: IPermit2(address(permit2)), // Permit2 on Base - entryPoint: entryPoint, // EntryPoint address on Base - atomWarden: atomWarden, // atomWarden address - atomWalletBeacon: address(atomWalletBeacon) // Address of the AtomWalletBeacon contract - }); - - IEthMultiVault.VaultFees memory vaultFees = IEthMultiVault.VaultFees({ - entryFee: 500, // Entry fee for vault 0 - exitFee: 500, // Exit fee for vault 0 - protocolFee: 250 // Protocol fee for vault 0 - }); - - // ------------------------------- Bonding Curves---------------------------------------- - - // Deploy BondingCurveRegistry and take temporary ownership to add the curves - bondingCurveRegistry = new BondingCurveRegistry(msg.sender); - console.logString("deployed BondingCurveRegistry."); - - // Deploy LinearCurve - linearCurve = new LinearCurve("Linear Curve"); - console.logString("deployed LinearCurve."); - - // Deploy ProgressiveCurve - progressiveCurve = new ProgressiveCurve("Progressive Curve", 2); - console.logString("deployed ProgressiveCurve."); - - // Add curves to BondingCurveRegistry - bondingCurveRegistry.addBondingCurve(address(linearCurve)); - bondingCurveRegistry.addBondingCurve(address(progressiveCurve)); - - // Transfer ownership of BondingCurveRegistry to the timelock - bondingCurveRegistry.transferOwnership(address(timelock)); - // NOTE: TimelockController needs to accept the ownership of the BondingCurveRegistry in order to become a new owner - - IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault.BondingCurveConfig({ - registry: address(bondingCurveRegistry), - defaultCurveId: 1 // Unused in this edition of EthMultiVault - }); - - // ------------------------------------------------------------------------------------- - - // Prepare data for initializer function of EthMultiVault - bytes memory initData = abi.encodeWithSelector( - EthMultiVault.init.selector, - generalConfig, - atomConfig, - tripleConfig, - walletConfig, - vaultFees, - bondingCurveConfig - ); - - // Deploy EthMultiVault implementation contract - ethMultiVault = new EthMultiVault(); - console.logString("deployed EthMultiVault implementation."); - - // Deploy TransparentUpgradeableProxy with EthMultiVault logic contract - ethMultiVaultProxy = new TransparentUpgradeableProxy( - address(ethMultiVault), // EthMultiVault logic contract address - address(timelock), // Timelock controller address, which will be the owner of the ProxyAdmin contract for the proxy - initData // Initialization data to call the `init` function in EthMultiVault - ); - console.logString("deployed EthMultiVault proxy."); - - // stop sending tx's - vm.stopBroadcast(); - - console.log("All contracts deployed successfully:"); - console.log("TimelockController address:", address(timelock)); - console.log("AtomWallet implementation address:", address(atomWallet)); - console.log("UpgradeableBeacon address:", address(atomWalletBeacon)); - console.log("EthMultiVault implementation address:", address(ethMultiVault)); - console.log("EthMultiVault proxy address:", address(ethMultiVaultProxy)); - console.log("BondingCurveRegistry address:", address(bondingCurveRegistry)); - console.log( - "To find the address of the ProxyAdmin contract for the EthMultiVault proxy, inspect the creation transaction of the EthMultiVault proxy contract on Basescan, in particular the AdminChanged event. Same applies to the CustomMulticall3 proxy contract." - ); - } -} \ No newline at end of file From 8f04e66d531a4f3371261b5317ae2733bab5c0b9 Mon Sep 17 00:00:00 2001 From: mihailo-maksa Date: Mon, 7 Apr 2025 15:07:37 +0200 Subject: [PATCH 6/7] run forge fmt --- script/CreateAndStake.s.sol | 9 +-- script/DeployToBase.s.sol | 57 ++++++++----------- src/EthMultiVault.sol | 16 +++++- src/interfaces/IEthMultiVault.sol | 19 ++++--- test/EthMultiVaultBase.sol | 1 + test/unit/EthMultiVault/CurveComparison.t.sol | 29 +++++++--- .../EthMultiVault/DepositTripleCurve.t.sol | 1 + test/unit/UD60x18.t.sol | 2 +- 8 files changed, 77 insertions(+), 57 deletions(-) diff --git a/script/CreateAndStake.s.sol b/script/CreateAndStake.s.sol index 8a13652c..38d39520 100644 --- a/script/CreateAndStake.s.sol +++ b/script/CreateAndStake.s.sol @@ -15,13 +15,8 @@ contract CreateAndStake is Script { // Address of the EthMultiVault contract address payable public constant ETH_MULTI_VAULT = payable(0x63B90A9c109fF8f137916026876171ffeEdEe714); - bytes[] public ATOM_URIS = [ - bytes("intuition.systems"), - bytes("is"), - bytes("bullish"), - bytes("cat"), - bytes("internet") - ]; + bytes[] public ATOM_URIS = + [bytes("intuition.systems"), bytes("is"), bytes("bullish"), bytes("cat"), bytes("internet")]; uint256[] public ATOM_IDS; diff --git a/script/DeployToBase.s.sol b/script/DeployToBase.s.sol index 968fd0b6..7f224609 100644 --- a/script/DeployToBase.s.sol +++ b/script/DeployToBase.s.sol @@ -1,19 +1,22 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.21; -import { Script, console } from "forge-std/Script.sol"; -import { TimelockController } from "@openzeppelin/contracts/governance/TimelockController.sol"; -import { TransparentUpgradeableProxy, ITransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; -import { UpgradeableBeacon } from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; - -import { AtomWallet } from "src/AtomWallet.sol"; -import { EthMultiVault } from "src/EthMultiVault.sol"; -import { IEthMultiVault } from "src/interfaces/IEthMultiVault.sol"; -import { IPermit2 } from "src/interfaces/IPermit2.sol"; - -import { BondingCurveRegistry } from "src/BondingCurveRegistry.sol"; -import { ProgressiveCurve } from "src/ProgressiveCurve.sol"; -import { LinearCurve } from "src/LinearCurve.sol"; +import {Script, console} from "forge-std/Script.sol"; +import {TimelockController} from "@openzeppelin/contracts/governance/TimelockController.sol"; +import { + TransparentUpgradeableProxy, + ITransparentUpgradeableProxy +} from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import {UpgradeableBeacon} from "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol"; + +import {AtomWallet} from "src/AtomWallet.sol"; +import {EthMultiVault} from "src/EthMultiVault.sol"; +import {IEthMultiVault} from "src/interfaces/IEthMultiVault.sol"; +import {IPermit2} from "src/interfaces/IPermit2.sol"; + +import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; +import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; +import {LinearCurve} from "src/LinearCurve.sol"; contract DeployToBase is Script { // Multisig addresses for key roles in the protocol @@ -112,11 +115,10 @@ contract DeployToBase is Script { protocolFee: 100 // Protocol fee for vault 0 }); - IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault - .BondingCurveConfig({ - registry: address(bondingCurveRegistry), - defaultCurveId: 1 // Unused in this edition of EthMultiVault - }); + IEthMultiVault.BondingCurveConfig memory bondingCurveConfig = IEthMultiVault.BondingCurveConfig({ + registry: address(bondingCurveRegistry), + defaultCurveId: 1 // Unused in this edition of EthMultiVault + }); // ------------------------------- Bonding Curves---------------------------------------- @@ -126,10 +128,8 @@ contract DeployToBase is Script { address bondingCurveRegistryImplementation = address(bondingCurveRegistry); - bytes memory bondingCurveRegistryInitData = abi.encodeWithSelector( - BondingCurveRegistry.initialize.selector, - msg.sender - ); + bytes memory bondingCurveRegistryInitData = + abi.encodeWithSelector(BondingCurveRegistry.initialize.selector, msg.sender); // Deploy BondingCurveRegistry proxy bondingCurveRegistryProxy = new TransparentUpgradeableProxy( @@ -139,13 +139,7 @@ contract DeployToBase is Script { ); console.logString("deployed BondingCurveRegistry proxy."); console.logString("encoded constructor args: "); - console.logBytes( - abi.encode( - address(bondingCurveRegistry), - address(timelock), - bondingCurveRegistryInitData - ) - ); + console.logBytes(abi.encode(address(bondingCurveRegistry), address(timelock), bondingCurveRegistryInitData)); // Deploy LinearCurve linearCurve = new LinearCurve("Linear Curve"); @@ -208,10 +202,7 @@ contract DeployToBase is Script { console.log("UpgradeableBeacon address:", address(atomWalletBeacon)); console.log("EthMultiVault implementation address:", address(ethMultiVault)); console.log("EthMultiVault proxy address:", address(ethMultiVaultProxy)); - console.log( - "BondingCurveRegistry implementation address:", - bondingCurveRegistryImplementation - ); + console.log("BondingCurveRegistry implementation address:", bondingCurveRegistryImplementation); console.log("BondingCurveRegistry proxy address:", address(bondingCurveRegistryProxy)); console.log("LinearCurve address:", address(linearCurve)); console.log("ProgressiveCurve address:", address(progressiveCurve)); diff --git a/src/EthMultiVault.sol b/src/EthMultiVault.sol index 3dfc4231..ee324560 100644 --- a/src/EthMultiVault.sol +++ b/src/EthMultiVault.sol @@ -1776,7 +1776,13 @@ contract EthMultiVault is IEthMultiVault, Initializable, ReentrancyGuardUpgradea bondingCurveVaults[id][curveId].totalAssets += assetsDelta; bondingCurveVaults[id][curveId].totalShares += sharesDelta; uint256 newSharePrice = currentSharePriceCurve(id, curveId); - emit SharePriceChangedCurve(id, curveId, newSharePrice, bondingCurveVaults[id][curveId].totalAssets, bondingCurveVaults[id][curveId].totalShares); + emit SharePriceChangedCurve( + id, + curveId, + newSharePrice, + bondingCurveVaults[id][curveId].totalAssets, + bondingCurveVaults[id][curveId].totalShares + ); } /// @dev decrease the total assets and shares for a given bonding curve vault @@ -1793,7 +1799,13 @@ contract EthMultiVault is IEthMultiVault, Initializable, ReentrancyGuardUpgradea bondingCurveVaults[id][curveId].totalAssets -= assetsDelta; bondingCurveVaults[id][curveId].totalShares -= sharesDelta; uint256 newSharePrice = currentSharePriceCurve(id, curveId); - emit SharePriceChangedCurve(id, curveId, newSharePrice, bondingCurveVaults[id][curveId].totalAssets, bondingCurveVaults[id][curveId].totalShares); + emit SharePriceChangedCurve( + id, + curveId, + newSharePrice, + bondingCurveVaults[id][curveId].totalAssets, + bondingCurveVaults[id][curveId].totalShares + ); } /// @dev internal method for vault creation diff --git a/src/interfaces/IEthMultiVault.sol b/src/interfaces/IEthMultiVault.sol index 8def3c6d..2dac05c9 100644 --- a/src/interfaces/IEthMultiVault.sol +++ b/src/interfaces/IEthMultiVault.sol @@ -7,7 +7,6 @@ import {IPermit2} from "src/interfaces/IPermit2.sol"; /// @author 0xIntuition /// @notice Interface for managing many ERC4626 style vaults in a single contract interface IEthMultiVault { - /* =================================================== */ /* CONFIGS STRUCTS */ /* =================================================== */ @@ -111,10 +110,11 @@ interface IEthMultiVault { /* =================================================== */ enum ApprovalTypes { - NONE, // 0b00 - DEPOSIT, // 0b01 - REDEMPTION, // 0b10 - BOTH // 0b11 + NONE, // 0b00 + DEPOSIT, // 0b01 + REDEMPTION, // 0b10 + BOTH // 0b11 + } /* =================================================== */ @@ -301,7 +301,9 @@ interface IEthMultiVault { /// /// @param newAtomDepositFractionForTriple new atom deposit fraction for triples /// @param oldAtomDepositFractionForTriple old atom deposit fraction for triples - event AtomDepositFractionForTripleSet(uint256 newAtomDepositFractionForTriple, uint256 oldAtomDepositFractionForTriple); + event AtomDepositFractionForTripleSet( + uint256 newAtomDepositFractionForTriple, uint256 oldAtomDepositFractionForTriple + ); /// @notice emitted upon changing the entry fee /// @@ -879,7 +881,10 @@ interface IEthMultiVault { /// @param receiver address of the receiver /// /// @return shares number of shares user has in the vault - function getVaultStateForUserCurve(uint256 vaultId, uint256 curveId, address receiver) external view returns (uint256, uint256); + function getVaultStateForUserCurve(uint256 vaultId, uint256 curveId, address receiver) + external + view + returns (uint256, uint256); /// @notice returns the shares for recipient and other important values when depositing 'assets' into a bonding curve vault /// diff --git a/test/EthMultiVaultBase.sol b/test/EthMultiVaultBase.sol index 413a36d9..94d83849 100644 --- a/test/EthMultiVaultBase.sol +++ b/test/EthMultiVaultBase.sol @@ -15,6 +15,7 @@ import {BondingCurveRegistry} from "src/BondingCurveRegistry.sol"; import {ProgressiveCurve} from "src/ProgressiveCurve.sol"; import {LinearCurve} from "src/LinearCurve.sol"; import {OffsetProgressiveCurve} from "src/OffsetProgressiveCurve.sol"; + contract EthMultiVaultBase is Test { // msg.value - atomCreationProtocolFee - protocolFee diff --git a/test/unit/EthMultiVault/CurveComparison.t.sol b/test/unit/EthMultiVault/CurveComparison.t.sol index c888865f..b289ef7d 100644 --- a/test/unit/EthMultiVault/CurveComparison.t.sol +++ b/test/unit/EthMultiVault/CurveComparison.t.sol @@ -28,10 +28,16 @@ contract CurveComparisonTest is EthMultiVaultBase, EthMultiVaultHelpers { (address registry,) = ethMultiVault.bondingCurveConfig(); address progressiveCurve = BondingCurveRegistry(registry).curveAddresses(PROGRESSIVE_CURVE_ID); address offsetProgressiveCurve = BondingCurveRegistry(registry).curveAddresses(OFFSET_PROGRESSIVE_CURVE_ID); - + console2.log("Progressive Curve slope: ", ProgressiveCurve(progressiveCurve).SLOPE().unwrap().toString()); - console2.log("Offset Progressive Curve slope: ", OffsetProgressiveCurve(offsetProgressiveCurve).SLOPE().unwrap().toString()); - console2.log("Offset Progressive Curve offset: ", OffsetProgressiveCurve(offsetProgressiveCurve).OFFSET().unwrap().toString()); + console2.log( + "Offset Progressive Curve slope: ", + OffsetProgressiveCurve(offsetProgressiveCurve).SLOPE().unwrap().toString() + ); + console2.log( + "Offset Progressive Curve offset: ", + OffsetProgressiveCurve(offsetProgressiveCurve).OFFSET().unwrap().toString() + ); // Alice creates an atom vm.startPrank(alice, alice); @@ -51,7 +57,11 @@ contract CurveComparisonTest is EthMultiVaultBase, EthMultiVaultHelpers { vm.startPrank(bob, bob); try ethMultiVault.depositAtomCurve{value: depositAmount}(bob, atomId, PROGRESSIVE_CURVE_ID) { (progressiveShares,) = ethMultiVault.getVaultStateForUserCurve(atomId, PROGRESSIVE_CURVE_ID, bob); - console2.log("%s Assets into Progressive Curve yields %s shares", depositAmount.toString(), progressiveShares.toString()); + console2.log( + "%s Assets into Progressive Curve yields %s shares", + depositAmount.toString(), + progressiveShares.toString() + ); } catch Error(string memory reason) { console2.log("Failed to deposit into progressive curve: ", reason); revert(reason); @@ -61,8 +71,13 @@ contract CurveComparisonTest is EthMultiVaultBase, EthMultiVaultHelpers { // Deposit into Curve 3 (Offset Progressive) vm.startPrank(charlie, charlie); try ethMultiVault.depositAtomCurve{value: depositAmount}(charlie, atomId, OFFSET_PROGRESSIVE_CURVE_ID) { - (offsetProgressiveShares,) = ethMultiVault.getVaultStateForUserCurve(atomId, OFFSET_PROGRESSIVE_CURVE_ID, charlie); - console2.log("%s Assets into Offset Progressive Curve yields %s shares", depositAmount.toString(), offsetProgressiveShares.toString()); + (offsetProgressiveShares,) = + ethMultiVault.getVaultStateForUserCurve(atomId, OFFSET_PROGRESSIVE_CURVE_ID, charlie); + console2.log( + "%s Assets into Offset Progressive Curve yields %s shares", + depositAmount.toString(), + offsetProgressiveShares.toString() + ); } catch Error(string memory reason) { console2.log("Failed to deposit into offset curve: ", reason); revert(reason); @@ -105,4 +120,4 @@ contract CurveComparisonTest is EthMultiVaultBase, EthMultiVaultHelpers { function testCompareCurvesMicroAmount() external { testCompareCurves(0.03 ether); } -} \ No newline at end of file +} diff --git a/test/unit/EthMultiVault/DepositTripleCurve.t.sol b/test/unit/EthMultiVault/DepositTripleCurve.t.sol index a2a8b077..fcb49651 100644 --- a/test/unit/EthMultiVault/DepositTripleCurve.t.sol +++ b/test/unit/EthMultiVault/DepositTripleCurve.t.sol @@ -7,6 +7,7 @@ import {Errors} from "src/libraries/Errors.sol"; import {EthMultiVaultBase} from "test/EthMultiVaultBase.sol"; import {EthMultiVaultHelpers} from "test/helpers/EthMultiVaultHelpers.sol"; import {IEthMultiVault} from "src/interfaces/IEthMultiVault.sol"; + contract DepositTripleCurveTest is EthMultiVaultBase, EthMultiVaultHelpers { uint256 constant CURVE_ID = 2; diff --git a/test/unit/UD60x18.t.sol b/test/unit/UD60x18.t.sol index 57285ff5..054a1397 100644 --- a/test/unit/UD60x18.t.sol +++ b/test/unit/UD60x18.t.sol @@ -40,7 +40,7 @@ contract UD60x18Test is Test { assertEq(z, 35); } - function testDecimal() public pure{ + function testDecimal() public pure { uint256 x = 10; uint256 y = 3; uint256 z = convert(convert(x).div(convert(y))); From c11886f2f08c6f3ef8bcffe0ecbc9db3379a4feb Mon Sep 17 00:00:00 2001 From: mihailo-maksa Date: Mon, 7 Apr 2025 15:19:40 +0200 Subject: [PATCH 7/7] correct function name --- script/DeployToBase.s.sol | 2 +- script/DeployToLinea.s.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/script/DeployToBase.s.sol b/script/DeployToBase.s.sol index 7f224609..cf7bf8a0 100644 --- a/script/DeployToBase.s.sol +++ b/script/DeployToBase.s.sol @@ -161,7 +161,7 @@ contract DeployToBase is Script { bondingCurveRegistry.addBondingCurve(address(progressiveCurve)); // Transfer ownership of BondingCurveRegistry to multisig - bondingCurveRegistry.setAdmin(admin); + bondingCurveRegistry.transferOwnership(admin); // ------------------------------------------------------------------------------------- diff --git a/script/DeployToLinea.s.sol b/script/DeployToLinea.s.sol index 84b826b1..b42710ec 100644 --- a/script/DeployToLinea.s.sol +++ b/script/DeployToLinea.s.sol @@ -169,7 +169,7 @@ contract DeployToLinea is Script { bondingCurveRegistry.addBondingCurve(address(progressiveCurve)); // Transfer ownership of BondingCurveRegistry to multisig - bondingCurveRegistry.setAdmin(admin); + bondingCurveRegistry.transferOwnership(admin); // -------------------------------------------------------------------------------------