diff --git a/script/deployBotsubaccountFactory.s.sol b/script/deployBotsubaccountFactory.s.sol index 8475fef..3b2dd83 100644 --- a/script/deployBotsubaccountFactory.s.sol +++ b/script/deployBotsubaccountFactory.s.sol @@ -4,6 +4,7 @@ pragma solidity ^0.8.19; import "../lib/forge-std/src/Script.sol"; import "../src/subaccount/BotSubaccountFactory.sol"; +import "./utils.s.sol"; contract BotSubaccountFactoryScript is Script { // add this to be excluded from coverage report @@ -12,7 +13,49 @@ contract BotSubaccountFactoryScript is Script { function run() external { uint256 deployerPrivateKey = vm.envUint("JOJO_DEPLOYER_PK"); vm.startBroadcast(deployerPrivateKey); - new BotSubaccountFactory(0xFfD3B82971dAbccb3219d16b6EB2DB134bf55300, 0xF1D7Ac5Fd1b806d24bCd2764C7c29A9fAd51698B); + address _dealer = 0x2f7c3cF9D9280B165981311B822BecC4E05Fe635; + address _operator = 0xf7deBaF84774B0E4DA659eDe243c8A84A2aFcD14; + address botSubaccountFactory = address(new BotSubaccountFactory(_dealer, _operator)); vm.stopBroadcast(); + + string memory chainId = vm.envString("CHAIN_ID"); + bytes memory arguments = abi.encode(_dealer, _operator); + string[] memory inputs = new string[](8); + inputs[0] = "forge"; + inputs[1] = "verify-contract"; + inputs[2] = Utils.addressToString(botSubaccountFactory); + inputs[3] = "src/subaccount/BotSubaccountFactory.sol:BotSubaccountFactory"; + inputs[4] = "--chain-id"; + inputs[5] = chainId; + inputs[6] = "--constructor-args"; + inputs[7] = Utils.bytesToStringWithout0x(arguments); + Utils.logInputs(inputs); } } + +contract BotSubaccountFactoryScriptTest is Script { + // add this to be excluded from coverage report + function test() public { } + + function run() external { + uint256 deployerPrivateKey = vm.envUint("JOJO_DEPLOYER_PK"); + vm.startBroadcast(deployerPrivateKey); + address _dealer = 0x65bE09345311aCc72d9358Ea7d7B13A91DFF51B6; + address _operator = 0xF1D7Ac5Fd1b806d24bCd2764C7c29A9fAd51698B; + address botSubaccountFactory = address(new BotSubaccountFactory(_dealer, _operator)); + vm.stopBroadcast(); + + string memory chainId = vm.envString("CHAIN_ID"); + bytes memory arguments = abi.encode(_dealer, _operator); + string[] memory inputs = new string[](8); + inputs[0] = "forge"; + inputs[1] = "verify-contract"; + inputs[2] = Utils.addressToString(botSubaccountFactory); + inputs[3] = "src/subaccount/BotSubaccountFactory.sol:BotSubaccountFactory"; + inputs[4] = "--chain-id"; + inputs[5] = chainId; + inputs[6] = "--constructor-args"; + inputs[7] = Utils.bytesToStringWithout0x(arguments); + Utils.logInputs(inputs); + } +} \ No newline at end of file diff --git a/script/deployMerkle.sol b/script/deployMerkle.sol index 22714cb..5f0303a 100644 --- a/script/deployMerkle.sol +++ b/script/deployMerkle.sol @@ -13,9 +13,10 @@ contract DeployMerkleDistributor is Script { function run() external { uint256 deployerPrivateKey = vm.envUint("JOJO_DEPLOYER_PK"); vm.startBroadcast(deployerPrivateKey); + address owner = 0xD0cFCf1899A749bf0398fc885DB7ee0479C05eFC; address token = 0x0645bC5cDff2376089323Ac20Df4119e48e4BCc4; - bytes32 root = 0x915135dccd7288b4da16541980aa0cb78e5166f48b22029dcf8104dd84c0419a; - uint256 endTime = 1727740800; + bytes32 root = 0x86a94d64a9d8c155e59669d37e614a788e7d304cb96c943d3b46cfd2cb8a89f7; + uint256 endTime = 1734188400; MerkleDistributorWithDeadline distributor = new MerkleDistributorWithDeadline( // token token, @@ -24,6 +25,7 @@ contract DeployMerkleDistributor is Script { // timestamp endTime ); + distributor.transferOwnership(owner); vm.stopBroadcast(); string memory chainId = vm.envString("CHAIN_ID"); diff --git a/script/deployOracleAdaptor.s.sol b/script/deployOracleAdaptor.s.sol index 4a543e9..eddfb2a 100644 --- a/script/deployOracleAdaptor.s.sol +++ b/script/deployOracleAdaptor.s.sol @@ -14,9 +14,9 @@ contract OracleAdaptorScript is Script { vm.startBroadcast(deployerPrivateKey); new OracleAdaptor( // source - 0xE70f2D34Fd04046aaEC26a198A35dD8F2dF5cd92, + 0x64c911996D3c6aC71f9b455B1E8E7266BcbD848F, // decimalCorrection - 20, + 10, //heartbeatInterval 86_400, 86_400, diff --git a/script/deployVeJOJO.sol b/script/deployVeJOJO.sol new file mode 100644 index 0000000..3b3cf23 --- /dev/null +++ b/script/deployVeJOJO.sol @@ -0,0 +1,48 @@ +// SPDX-License-Identifier: GPL-2.0-or-later + +pragma solidity ^0.8.19; + +import "../lib/forge-std/src/Script.sol"; +import "../src/token/veJOJO.sol"; +import "./utils.s.sol"; + +contract DeployVeJOJOTest is Script { + // add this to be excluded from coverage report + function test() public {} + + function run() external { + uint256 deployerPrivateKey = vm.envUint("JOJO_DEPLOYER_PK"); + vm.startBroadcast(deployerPrivateKey); + + // 部署 veJOJO + address jojoToken = 0xA42589C591f8AE08B0e2C2C18439d72628a66c3E; // JOJO token 地址 + address usdc = 0x7107B28375Fa4cc1deaAad58F2f0B5F1d921f3DE; // usdc token 地址 + address owner = 0xF1D7Ac5Fd1b806d24bCd2764C7c29A9fAd51698B; // owner 地址 + + veJOJO v = new veJOJO( + jojoToken, // JOJO token + usdc + ); + + v.transferOwnership(owner); + vm.stopBroadcast(); + + // 验证合约 + string memory chainId = vm.envString("CHAIN_ID"); + bytes memory arguments = abi.encode( + jojoToken, + usdc + ); + + string[] memory inputs = new string[](8); + inputs[0] = "forge"; + inputs[1] = "verify-contract"; + inputs[2] = Utils.addressToString(address(v)); + inputs[3] = "src/token/veJOJO.sol:veJOJO"; + inputs[4] = "--chain-id"; + inputs[5] = chainId; + inputs[6] = "--constructor-args"; + inputs[7] = Utils.bytesToStringWithout0x(arguments); + Utils.logInputs(inputs); + } +} \ No newline at end of file diff --git a/src/subaccount/BotSubaccountFactory.sol b/src/subaccount/BotSubaccountFactory.sol index d95fc49..eb18d8c 100644 --- a/src/subaccount/BotSubaccountFactory.sol +++ b/src/subaccount/BotSubaccountFactory.sol @@ -50,6 +50,20 @@ contract BotSubaccountFactory { emit NewBotSubaccount(owner, operator, botSubaccountRegistry[owner].length - 1, botSubaccount); } + function batchNewSubaccounts(address owner, address operator, uint256 count) external returns (address[] memory botSubaccounts) { + require(count > 0, "Count must be greater than zero"); + require(count <= 100, "Cannot create more than 100 subaccounts at once"); // Prevent potential gas limit issues + + botSubaccounts = new address[](count); + for (uint256 i = 0; i < count; i++) { + address botSubaccount = Clones.clone(template); + BotSubaccount(botSubaccount).init(owner, operator, dealer, globalOperator); + botSubaccountRegistry[owner].push(botSubaccount); + botSubaccounts[i] = botSubaccount; + emit NewBotSubaccount(owner, operator, botSubaccountRegistry[owner].length - 1, botSubaccount); + } + } + function getBotSubaccounts(address master) external view returns (address[] memory) { return botSubaccountRegistry[master]; }