Skip to content

Commit

Permalink
more deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
radar bear committed Nov 16, 2024
1 parent 61027ef commit dc7d9f3
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 5 deletions.
45 changes: 44 additions & 1 deletion script/deployBotsubaccountFactory.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
6 changes: 4 additions & 2 deletions script/deployMerkle.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -24,6 +25,7 @@ contract DeployMerkleDistributor is Script {
// timestamp
endTime
);
distributor.transferOwnership(owner);
vm.stopBroadcast();

string memory chainId = vm.envString("CHAIN_ID");
Expand Down
4 changes: 2 additions & 2 deletions script/deployOracleAdaptor.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ contract OracleAdaptorScript is Script {
vm.startBroadcast(deployerPrivateKey);
new OracleAdaptor(
// source
0xE70f2D34Fd04046aaEC26a198A35dD8F2dF5cd92,
0x64c911996D3c6aC71f9b455B1E8E7266BcbD848F,
// decimalCorrection
20,
10,
//heartbeatInterval
86_400,
86_400,
Expand Down
48 changes: 48 additions & 0 deletions script/deployVeJOJO.sol
Original file line number Diff line number Diff line change
@@ -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);
}
}
14 changes: 14 additions & 0 deletions src/subaccount/BotSubaccountFactory.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit dc7d9f3

Please sign in to comment.