Skip to content

Commit

Permalink
deployment scripts (yippiee!!!)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexhooketh committed Nov 15, 2024
1 parent e03bddb commit 031fe34
Show file tree
Hide file tree
Showing 3 changed files with 164 additions and 9 deletions.
10 changes: 1 addition & 9 deletions contracts/.env.example
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
# private key that will be used to deploy the contracts
PRIVATE_KEY=0x...
# the address that ADMIN_ROLE will be moved to
ADMIN_ADDRESS=0x...
# the address that UNLIMITED_CREATOR_ROLE will be moved to
UNLIMITED_CREATOR_ADDRESS=0x...
# the address that REGISTRAR_ROLE will be moved to
REGISTRAR_ADDRESS=0x...
# verification key for the SP1 Untron program
SP1_VKEY=0x...
PRIVATE_KEY=0x...
90 changes: 90 additions & 0 deletions contracts/script/Deploy.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// 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";

// Mock contracts for testing
contract MockUSDT is ERC20 {
constructor() ERC20("Mock USDT", "USDT") {
_mint(msg.sender, 1000000 * 10**decimals());
}
}

contract MockLiFi {
function call(bytes calldata) external returns (bool) {
return true;
}
}

contract MockSP1Verifier {
function verifyProof(bytes32, bytes calldata, bytes calldata) external pure returns (bool) {
return true;
}
}

contract DeployScript is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

// Deploy mock contracts
MockUSDT mockUSDT = new MockUSDT();
MockLiFi mockLiFi = new MockLiFi();
MockSP1Verifier mockVerifier = new MockSP1Verifier();

// Deploy implementation
UntronCore implementation = new UntronCore();

// Deploy proxy
bytes memory initData = abi.encodeWithSelector(
UntronCore.initialize.selector,
"" // empty 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(
1000000 * 1e6, // maxOrderSize: 1M USDT
1000 * 1e6, // requiredCollateral: 1000 USDT
3600 * 1000 // orderTtlMillis: 1 hour
);

// Set fees variables
untron.setFeesVariables(
1000, // relayerFee: 0.1%
10 * 1e6 // fulfillerFee: 10 USDT
);

// Set transfers variables
untron.setTransfersVariables(
address(mockUSDT),
address(mockLiFi)
);

// 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 USDT at:", address(mockUSDT));
console.log("Deployed Mock LiFi at:", address(mockLiFi));
console.log("Deployed Mock Verifier at:", address(mockVerifier));
}
}
73 changes: 73 additions & 0 deletions contracts/script/DeployMainnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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 DeployMainnetScript is Script {
function run() external {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

// Deploy mock verifier
MockSP1Verifier mockVerifier = new MockSP1Verifier();

// Deploy implementation
UntronCore implementation = new UntronCore();

// Deploy proxy
bytes memory initData = abi.encodeWithSelector(
UntronCore.initialize.selector,
"" // empty 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));
}
}

0 comments on commit 031fe34

Please sign in to comment.