Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deploy: adding deployment scripts #10

Merged
merged 6 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ out/

# Ignores development broadcast logs
!/broadcast
/broadcast/*/31337/
/broadcast/**/dry-run/
/broadcast/*

# Docs
docs/
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[submodule "lib/pancake-v4-periphery"]
path = lib/pancake-v4-periphery
url = https://github.com/pancakeswap/pancake-v4-periphery
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/forge-gas-snapshot"]
path = lib/forge-gas-snapshot
url = https://github.com/marktoda/forge-gas-snapshot
[submodule "lib/pancake-v4-universal-router"]
path = lib/pancake-v4-universal-router
url = https://github.com/pancakeswap/pancake-v4-universal-router
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
1 change: 0 additions & 1 deletion lib/pancake-v4-periphery
Submodule pancake-v4-periphery deleted from d3ccae
1 change: 1 addition & 0 deletions lib/pancake-v4-universal-router
12 changes: 6 additions & 6 deletions remappings.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
pancake-v4-periphery/=lib/pancake-v4-periphery/
pancake-v4-core/=lib/pancake-v4-periphery/lib/pancake-v4-core/
forge-std/=lib/forge-std/src/
ds-test/=lib/forge-std/lib/ds-test/src/
forge-gas-snapshot/=lib/forge-gas-snapshot/src/
openzeppelin-contracts/=lib/pancake-v4-periphery/lib/pancake-v4-core/lib/openzeppelin-contracts/
solmate/=lib/pancake-v4-periphery/lib/pancake-v4-core/lib/solmate/
permit/=lib/pancake-v4-periphery/lib/permit/
openzeppelin-contracts/=lib/pancake-v4-universal-router/lib/pancake-v4-periphery/lib/pancake-v4-core/lib/openzeppelin-contracts/
solmate/=lib/pancake-v4-universal-router/lib/pancake-v4-periphery/lib/pancake-v4-core/lib/solmate/
pancake-v4-core/=lib/pancake-v4-universal-router/lib/pancake-v4-periphery/lib/pancake-v4-core/
pancake-v4-periphery/=lib/pancake-v4-universal-router/lib/pancake-v4-periphery/
pancake-v4-universal-router/=lib/pancake-v4-universal-router/
permit2/=lib/pancake-v4-universal-router/lib/pancake-v4-periphery/lib/permit2/
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("mockVeCake");
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("mockVeCake");
emit log_named_address("VeCake", veCake);

BinVeCakeExclusiveHook binVeCakeExclusiveHook =
new BinVeCakeExclusiveHook(IBinPoolManager(binPoolManager), address(veCake));
emit log_named_address("BinVeCakeExclusiveHook", 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;
}
}
11 changes: 11 additions & 0 deletions script/config/bsc-testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"vault": "0x08F012b8E2f3021db8bd2A896A7F422F4041F131",
"clPoolManager": "0x969D90aC74A1a5228b66440f8C8326a8dA47A5F9",
"binPoolManager": "0x437ef7C8C00d20a8535ae1786c5800c88413e7Af",
"clPositionManager": "0x89A7D45D007077485CB5aE2abFB740b1fe4FF574",
"binPositionManager": "0xfB84c0D67f217f078E949d791b8d3081FE91Bca2",
"mockVeCake": "0x86668337a40CaAd59F463E89550c6Aa59C056988",
"clVeCakeExclusiveHook": "0x7B07026C721F824ee913D65C5810884dEDf9ED50",
"binVeCakeExclusiveHook": "0x6D211114Ef77F89CD6912441CbaFfFBF71E25587"
}

8 changes: 0 additions & 8 deletions test/pool-cl/helpers/MockCLPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,6 @@ contract MockCLPositionManager is CLPositionManager, CommonBase {
this.modifyLiquidities(data, block.timestamp);

liquidityMinted = getPositionLiquidity(tokenId, config);

// Vm.Log[] memory entries = vm.getRecordedLogs();
// // find IBinFungibleToken.TransferBatch
// for (uint256 i = 0; i < entries.length; i++) {
// if (entries[i].topics[0] == keccak256("TransferBatch(address,address,address,uint256[],uint256[])")) {
// (tokenIds, liquidityMinted) = abi.decode(entries[i].data, (uint256[], uint256[]));
// }
// }
}

function decreaseLiquidity(
Expand Down