From 940edb76a62d94853a03fa86d8d8fbaff886fa79 Mon Sep 17 00:00:00 2001 From: jordan <41rjordan@proton.me> Date: Sat, 16 Nov 2024 01:45:15 +0700 Subject: [PATCH] sfsdfdsf --- contracts/.env.example | 8 +++- contracts/script/DeployMainnet.s.sol | 5 +- contracts/script/DeployProxy.s.sol | 72 ++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 contracts/script/DeployProxy.s.sol diff --git a/contracts/.env.example b/contracts/.env.example index 90459f1..79f5f8f 100644 --- a/contracts/.env.example +++ b/contracts/.env.example @@ -1,2 +1,8 @@ # private key that will be used to deploy the contracts -PRIVATE_KEY=0x... \ No newline at end of file +PRIVATE_KEY=0x... + +# implementation address +IMPLEMENTATION=0x... + +# genesis state +GENESIS_STATE=0x... \ No newline at end of file diff --git a/contracts/script/DeployMainnet.s.sol b/contracts/script/DeployMainnet.s.sol index d9f98c6..d98e7e4 100644 --- a/contracts/script/DeployMainnet.s.sol +++ b/contracts/script/DeployMainnet.s.sol @@ -15,6 +15,7 @@ contract MockSP1Verifier { contract DeployMainnetScript is Script { function run() external { uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + bytes memory state = vm.envBytes("GENESIS_STATE"); vm.startBroadcast(deployerPrivateKey); // Deploy mock verifier @@ -26,9 +27,9 @@ contract DeployMainnetScript is Script { // Deploy proxy bytes memory initData = abi.encodeWithSelector( UntronCore.initialize.selector, - "" // empty genesis state + state // genesis state ); - + UntronCoreProxy proxy = new UntronCoreProxy( address(implementation), vm.addr(deployerPrivateKey), // admin diff --git a/contracts/script/DeployProxy.s.sol b/contracts/script/DeployProxy.s.sol new file mode 100644 index 0000000..5b97e5b --- /dev/null +++ b/contracts/script/DeployProxy.s.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.20; + +import "forge-std/Script.sol"; +import "../src/UntronCore.sol"; +import "../src/UntronCoreProxy.sol"; +import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; + +contract MockSP1Verifier { + function verifyProof(bytes32, bytes calldata, bytes calldata) external pure returns (bool) { + return true; + } +} + +contract DeployProxyScript is Script { + function run() external { + uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY"); + address implementation = vm.envAddress("IMPLEMENTATION"); + bytes memory state = vm.envBytes("GENESIS_STATE"); + vm.startBroadcast(deployerPrivateKey); + + // Deploy mock verifier + MockSP1Verifier mockVerifier = new MockSP1Verifier(); + + // Deploy proxy + bytes memory initData = abi.encodeWithSelector( + UntronCore.initialize.selector, + state // genesis state + ); + + UntronCoreProxy proxy = new UntronCoreProxy( + address(implementation), + vm.addr(deployerPrivateKey), // admin + initData + ); + + // Configure the proxy + UntronCore untron = UntronCore(address(proxy)); + + // Set core variables + untron.setCoreVariables( + 10000 * 1e6, // maxOrderSize: 10K USDT + 0 * 1e6, // requiredCollateral: 0 USDT + 300 * 1000 // orderTtlMillis: 5 minutes + ); + + // Set fees variables + untron.setFeesVariables( + 0, // relayerFee: 0% + 0.05 * 1e6 // fulfillerFee: 0.05 USDT + ); + + // Set transfers variables + untron.setTransfersVariables( + 0x493257fD37EDB34451f62EDf8D2a0C418852bA4C, // USDT + 0x341e94069f53234fE6DabeF707aD424830525715 // LiFi + ); + + // Set ZK variables + untron.setZKVariables( + vm.addr(deployerPrivateKey), // trusted relayer + address(mockVerifier), + bytes32(0) // empty vkey + ); + + vm.stopBroadcast(); + + console.log("Deployed UntronCore implementation at:", address(implementation)); + console.log("Deployed UntronCore proxy at:", address(proxy)); + console.log("Deployed Mock Verifier at:", address(mockVerifier)); + } +} \ No newline at end of file