Skip to content

Commit

Permalink
deploy: adding deployment scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
chefburger committed Aug 21, 2024
1 parent 1d49ff8 commit 2c630a3
Show file tree
Hide file tree
Showing 6 changed files with 144 additions and 1 deletion.
5 changes: 4 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ optimizer_runs = 1000
via_ir = true
evm_version = 'cancun'
ffi = true
fs_permissions = [{ access = "read-write", path = ".forge-snapshots/" }]
fs_permissions = [
{ access = "read-write", path = ".forge-snapshots/" },
{ access = "read", path = "./script/config" },
]

[profile.default.fuzz]
runs = 1000
Expand Down
26 changes: 26 additions & 0 deletions script/01_DeployMockVeToken.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import "forge-std/Script.sol";
import {BaseScript} from "./BaseScript.sol";

import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol";

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

MockERC20 VeCake = new MockERC20("MockVeCake", "VeCake", 18);
emit log_named_address("MockVeCake", address(VeCake));

vm.stopBroadcast();
}
}
34 changes: 34 additions & 0 deletions script/02_DeployCLVeCakeExclusiveHook.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import "forge-std/Script.sol";
import {BaseScript} from "./BaseScript.sol";

import {CLVeCakeExclusiveHook} from "../src/pool-cl/vecake-exclusive/CLVeCakeExclusiveHook.sol";
import {ICLPoolManager} from "pancake-v4-core/src/pool-cl/interfaces/ICLPoolManager.sol";

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

address clPoolManager = getAddressFromConfig("clPoolManager");
emit log_named_address("CLPoolManager", clPoolManager);

address veCake = getAddressFromConfig("veCake");
emit log_named_address("VeCake", veCake);

CLVeCakeExclusiveHook clVeCakeExclusiveHook =
new CLVeCakeExclusiveHook(ICLPoolManager(clPoolManager), address(veCake));
emit log_named_address("CLVeCakeExclusiveHook", address(clVeCakeExclusiveHook));

vm.stopBroadcast();
}
}
34 changes: 34 additions & 0 deletions script/03_DeployBinVeCakeExclusiveHook.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import "forge-std/Script.sol";
import {BaseScript} from "./BaseScript.sol";

import {BinVeCakeExclusiveHook} from "../src/pool-bin/vecake-exclusive/BinVeCakeExclusiveHook.sol";
import {IBinPoolManager} from "pancake-v4-core/src/pool-bin/interfaces/IBinPoolManager.sol";

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

address binPoolManager = getAddressFromConfig("binPoolManager");
emit log_named_address("BinPoolManager", binPoolManager);

address veCake = getAddressFromConfig("veCake");
emit log_named_address("VeCake", veCake);

BinVeCakeExclusiveHook binVeCakeExclusiveHook =
new BinVeCakeExclusiveHook(IBinPoolManager(binPoolManager), address(veCake));
emit log_named_address("CLVeCakeExclusiveHook", address(binVeCakeExclusiveHook));

vm.stopBroadcast();
}
}
29 changes: 29 additions & 0 deletions script/BaseScript.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import {Test} from "forge-std/Test.sol";

abstract contract BaseScript is Test {
string path;

function setUp() public virtual {
string memory scriptConfig = vm.envString("SCRIPT_CONFIG");
emit log(string.concat("[BaseScript] SCRIPT_CONFIG: ", scriptConfig));

string memory root = vm.projectRoot();
path = string.concat(root, "/script/config/", scriptConfig, ".json");
emit log(string.concat("[BaseScript] Reading config from: ", path));
}

// reference: https://github.com/foundry-rs/foundry/blob/master/testdata/default/cheats/Json.t.sol
function getAddressFromConfig(string memory key) public view returns (address) {
string memory json = vm.readFile(path);
bytes memory data = vm.parseJson(json, string.concat(".", key));

// seems like foundry decode as 0x20 when address is not set or as "0x"
address decodedData = abi.decode(data, (address));
require(decodedData != address(0x20), "Address not set");

return decodedData;
}
}
17 changes: 17 additions & 0 deletions script/config/bsc-testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"permit2": "0x31c2F6fcFf4F8759b3Bd5Bf0e1084A055615c768",
"weth": "0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd",
"vault": "0x79D5A618c43eCAda2BaaC65A9979cF120128f6Fa",
"clPoolManager": "0x40a081A39E9638fa6e2463B92A4eff4Bdf877179",
"binPoolManager": "0xc51DE4C65d6e3fb612050E383495e9457840d2c9",
"clPositionManager": "0xF254D17B9Ccae6BC3a40c8caDF3B8Ef563362C2D",
"binPositionManager": "0x45caADA89A3E257EA17fA3B56c3E09b63CD241B1",
"clQuoter:": "0x1E51cB768587C7A22AEBdCe787fb68A0953ec113",
"binQuoter": "0x76A1DFf6c0c64CE0906269228e89256b20A1fa2f",
"clMigrator": "0xF4a2f2A173ef10dF3733bb501d9DFFaD024567FC",
"binMigrator": "0x7a6689073890AFAa6d592B840d2fA73b2D52B820",
"veCake": "0x6B1fdFc5dFB10DC5735bB242D014B4d4F1fb2c7A",
"clVeCakeExclusiveHook": "0x470a9995c3bf588eE90A7F8e1b5372da1643Bca1",
"binVeCakeExclusiveHook": "0xb8848825d56D32679A1B451CE581ba665c4786B3"
}

0 comments on commit 2c630a3

Please sign in to comment.