Skip to content

Commit

Permalink
deploy: redeploy all the contracts (#231)
Browse files Browse the repository at this point in the history
  • Loading branch information
chefburger authored Feb 5, 2025
1 parent dbf7ccb commit 8c8c34a
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 118 deletions.
20 changes: 16 additions & 4 deletions script/01_DeployVault.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {Create3Factory} from "pancake-create3-factory/src/Create3Factory.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/**
*
* Step 1: Deploy
* forge script script/01_DeployVault.s.sol:DeployVaultScript -vvv \
* --rpc-url $RPC_URL \
Expand All @@ -17,22 +18,24 @@ import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
* Step 2: Verify there is no need for --constructor-args as there are no constructor arguments for Vault
* forge verify-contract <address> Vault --watch --chain <chain_id>
*
* Step 3: Proceed to deploy contract and call vault.acceptOwnership
* Step 3: Proceed to poolOwner contract and call vault.acceptOwnership
*/
contract DeployVaultScript is BaseScript {
function getDeploymentSalt() public pure override returns (bytes32) {
return keccak256("INFINITY-CORE/VAULT/0.90");
return keccak256("INFINITY-CORE/VAULT/0.97");
}

function run() public {
Create3Factory factory = Create3Factory(getAddressFromConfig("create3Factory"));

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);

vm.startBroadcast(deployerPrivateKey);

/// @dev prepare the payload to transfer ownership from deployer to real owner
/// @dev prepare the payload to transfer ownership from deployment contract to real deployer address
bytes memory afterDeploymentExecutionPayload =
abi.encodeWithSelector(Ownable.transferOwnership.selector, getAddressFromConfig("poolOwner"));
abi.encodeWithSelector(Ownable.transferOwnership.selector, deployer);

address vault = factory.deploy(
getDeploymentSalt(),
Expand All @@ -43,6 +46,15 @@ contract DeployVaultScript is BaseScript {
0
);

/// @notice accept ownership so that in the following steps,
/// the deployer address has right to register apps onto the vault
Vault(vault).acceptOwnership();

/// @notice transfer ownership to the pool owner,
/// in 2-step process this won't take effect until new owner accepts the ownership
/// Hence, this won't block the deployment process
Ownable(vault).transferOwnership(getAddressFromConfig("poolOwner"));

console.log("Vault contract deployed at ", vault);

vm.stopBroadcast();
Expand Down
16 changes: 8 additions & 8 deletions script/02_DeployCLPoolManager.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ import {Create3Factory} from "pancake-create3-factory/src/Create3Factory.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/**
*
* Step 1: Deploy
* forge script script/02_DeployCLPoolManager.s.sol:DeployCLPoolManagerScript -vvv \
* --rpc-url $RPC_URL \
* --broadcast \
* --slow
*
* Step 2: Get the ABI-encoded form of the constructor arguments
* cast abi-encode "Constructor(address)" <vault_addr>
*
* Step 3: Verify
* Step 2: Verify
* forge verify-contract <address> CLPoolManager --watch --chain <chain_id> \
* --constructor-args <constructor_args_from_step2>
* --constructor-args `cast abi-encode "Constructor(address)" <vault_addr>`
*
*/
contract DeployCLPoolManagerScript is BaseScript {
function getDeploymentSalt() public pure override returns (bytes32) {
return keccak256("INFINITY-CORE/CLPoolManager/0.90");
return keccak256("INFINITY-CORE/CLPoolManager/0.97");
}

function run() public {
Create3Factory factory = Create3Factory(getAddressFromConfig("create3Factory"));

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
vm.startBroadcast(deployerPrivateKey);

address vault = getAddressFromConfig("vault");
Expand All @@ -39,9 +39,9 @@ contract DeployCLPoolManagerScript is BaseScript {
/// @dev append the vault address to the creationCode
bytes memory creationCode = abi.encodePacked(type(CLPoolManager).creationCode, abi.encode(vault));

/// @dev prepare the payload to transfer ownership from deployer to real owner
/// @dev prepare the payload to transfer ownership from deployment contract to real deployer address
bytes memory afterDeploymentExecutionPayload =
abi.encodeWithSelector(Ownable.transferOwnership.selector, getAddressFromConfig("poolOwner"));
abi.encodeWithSelector(Ownable.transferOwnership.selector, deployer);

address clPoolManager = factory.deploy(
getDeploymentSalt(), creationCode, keccak256(creationCode), 0, afterDeploymentExecutionPayload, 0
Expand Down
14 changes: 7 additions & 7 deletions script/03_DeployBinPoolManager.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,28 @@ import {Create3Factory} from "pancake-create3-factory/src/Create3Factory.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/**
*
* Step 1: Deploy
* forge script script/03_DeployBinPoolManager.s.sol:DeployBinPoolManagerScript -vvv \
* --rpc-url $RPC_URL \
* --broadcast \
* --slow
*
* Step 2: Get the ABI-encoded form of the constructor arguments
* cast abi-encode "Constructor(address)" <vault_addr>
*
* Step 3: Verify
* Step 2: Verify
* forge verify-contract <address> BinPoolManager --watch --chain <chain_id> \
* --constructor-args <constructor_args_from_step2>
* --constructor-args `cast abi-encode "Constructor(address)" <vault_addr>`
*
*/
contract DeployBinPoolManagerScript is BaseScript {
function getDeploymentSalt() public pure override returns (bytes32) {
return keccak256("INFINITY-CORE/BinPoolManager/0.90");
return keccak256("INFINITY-CORE/BinPoolManager/0.97");
}

function run() public {
Create3Factory factory = Create3Factory(getAddressFromConfig("create3Factory"));

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address deployer = vm.addr(deployerPrivateKey);
vm.startBroadcast(deployerPrivateKey);

address vault = getAddressFromConfig("vault");
Expand All @@ -41,7 +41,7 @@ contract DeployBinPoolManagerScript is BaseScript {

/// @dev prepare the payload to transfer ownership from deployer to real owner
bytes memory afterDeploymentExecutionPayload =
abi.encodeWithSelector(Ownable.transferOwnership.selector, getAddressFromConfig("poolOwner"));
abi.encodeWithSelector(Ownable.transferOwnership.selector, deployer);

address binPoolManager = factory.deploy(
getDeploymentSalt(), creationCode, keccak256(creationCode), 0, afterDeploymentExecutionPayload, 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ import {BaseScript} from "./BaseScript.sol";
import {ProtocolFeeController} from "../src/ProtocolFeeController.sol";
import {Create3Factory} from "pancake-create3-factory/src/Create3Factory.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IProtocolFees} from "../src/interfaces/IProtocolFees.sol";

/**
* Step 1: Deploy
* forge script script/04a_DeployCLProtocolFeeController.s.sol:DeployCLProtocolFeeControllerScript -vvv \
* forge script script/04_DeployCLProtocolFeeController.s.sol:DeployCLProtocolFeeControllerScript -vvv \
* --rpc-url $RPC_URL \
* --broadcast \
* --slow
*
* Step 2: Get the ABI-encoded form of the constructor arguments
* cast abi-encode "Constructor(address)" <clPoolManager_addr>
*
* Step 3: Verify
* Step 2: Verify
* forge verify-contract <address> ProtocolFeeController --watch --chain <chain_id> \
* --constructor-args <constructor_args_from_step2>
* --constructor-args `cast abi-encode "Constructor(address)" <clPoolManager_addr>`
*
* Step 4: Proceed to deploy contract and call protocolFeeController.acceptOwnership
* Step 3: Proceed to poolOwner contract and call protocolFeeController.acceptOwnership
*/
contract DeployCLProtocolFeeControllerScript is BaseScript {
function getDeploymentSalt() public pure override returns (bytes32) {
return keccak256("INFINITY-CORE/CLProtocolFeeController/0.91");
return keccak256("INFINITY-CORE/CLProtocolFeeController/0.97");
}

function run() public {
Expand All @@ -52,6 +50,11 @@ contract DeployCLProtocolFeeControllerScript is BaseScript {

console.log("CLProtocolFeeController contract deployed at ", clProtocolFeeController);

/// @notice set the protocol fee controller for the clPoolManager
IProtocolFees(clPoolManager).setProtocolFeeController(
ProtocolFeeController(getAddressFromConfig("clProtocolFeeController"))
);

vm.stopBroadcast();
}
}
39 changes: 0 additions & 39 deletions script/04b_SetProtocolFeeControllerForCLPool.s.sol

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,24 @@ import {BaseScript} from "./BaseScript.sol";
import {ProtocolFeeController} from "../src/ProtocolFeeController.sol";
import {Create3Factory} from "pancake-create3-factory/src/Create3Factory.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {IProtocolFees} from "../src/interfaces/IProtocolFees.sol";

/**
* Step 1: Deploy
* forge script script/05a_DeployBinProtocolFeeController.s.sol:DeployBinProtocolFeeControllerScript -vvv \
* forge script script/05_DeployBinProtocolFeeController.s.sol:DeployBinProtocolFeeControllerScript -vvv \
* --rpc-url $RPC_URL \
* --broadcast \
* --slow
*
* Step 2: Get the ABI-encoded form of the constructor arguments
* cast abi-encode "Constructor(address)" <binPoolManager_addr>
*
* Step 3: Verify
* Step 2: Verify
* forge verify-contract <address> ProtocolFeeController --watch --chain <chain_id> \
* --constructor-args <constructor_args_from_step2>
* --constructor-args `cast abi-encode "Constructor(address)" <binPoolManager_addr>`
*
* Step 4: Proceed to deploy contract and call protocolFeeController.acceptOwnership
* Step 3: Proceed to poolOwner contract and call protocolFeeController.acceptOwnership
*/
contract DeployBinProtocolFeeControllerScript is BaseScript {
function getDeploymentSalt() public pure override returns (bytes32) {
return keccak256("INFINITY-CORE-CORE/BinProtocolFeeController/0.91");
return keccak256("INFINITY-CORE-CORE/BinProtocolFeeController/0.97");
}

function run() public {
Expand All @@ -52,6 +50,11 @@ contract DeployBinProtocolFeeControllerScript is BaseScript {

console.log("BinProtocolFeeController contract deployed at ", binProtocolFeeController);

/// @notice set the protocol fee controller for the clPoolManager
IProtocolFees(binPoolManager).setProtocolFeeController(
ProtocolFeeController(getAddressFromConfig("binProtocolFeeController"))
);

vm.stopBroadcast();
}
}
39 changes: 0 additions & 39 deletions script/05b_SetProtocolFeeControllerForBinPool.s.sol

This file was deleted.

33 changes: 33 additions & 0 deletions script/06_TransferPoolManagerOwner.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import "forge-std/Script.sol";
import {BaseScript} from "./BaseScript.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";

/**
*
* forge script script/06_TransferPoolManagerOwner.s.sol:TransferPoolManagerOwner -vvv \
* --rpc-url $RPC_URL \
* --broadcast \
* --slow
*
*/
contract TransferPoolManagerOwner is BaseScript {
function run() public {
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
vm.startBroadcast(deployerPrivateKey);

address clPoolManager = getAddressFromConfig("clPoolManager");
address binPoolManager = getAddressFromConfig("binPoolManager");
address poolOwner = getAddressFromConfig("poolOwner");

Ownable(clPoolManager).transferOwnership(poolOwner);
console.log("clPoolManager Ownership transferred to ", address(poolOwner));

Ownable(binPoolManager).transferOwnership(poolOwner);
console.log("binPoolManager Ownership transferred to ", address(poolOwner));

vm.stopBroadcast();
}
}
10 changes: 5 additions & 5 deletions script/config/bsc-testnet.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"create3Factory": "0x38Ab3f2CE00973A51d3A2A04d634C9bcbf20e4e1",
"poolOwner": "0x42571B8414c68B63A2729146CE93F23639d25399",
"vault": "0xd557753bde3f0EaF32626F8681Ac6d8c1EBA2BBa",
"clPoolManager": "0x70890E308DCE727180ac1B9550928fED342dea52",
"binPoolManager": "0x68554d088F3640Bd2A7B38b43AE70FDcc16ef197",
"vault": "0x2CdB3EC82EE13d341Dc6E73637BE0Eab79cb79dD",
"clPoolManager": "0x36A12c70c9Cf64f24E89ee132BF93Df2DCD199d4",
"binPoolManager": "0xe71d2e0230cE0765be53A8A1ee05bdACF30F296B",
"protocolFeeControllerOwner": "0x42571B8414c68B63A2729146CE93F23639d25399",
"clProtocolFeeController": "0xa3b9Af6E83B5161AC008cafb76712857bE54536D",
"binProtocolFeeController": "0x4eE90A76f4C0b32bce3C941b6Fa409E6c4DCE98A"
"clProtocolFeeController": "0x5ab6c844F3c0e818b92932e55b9942B2c8a2D205",
"binProtocolFeeController": "0xB91451e44f5D1D8048F8b5c093b705D61C7893F8"
}

0 comments on commit 8c8c34a

Please sign in to comment.