Skip to content

Commit

Permalink
script: deploy core & periphery
Browse files Browse the repository at this point in the history
  • Loading branch information
thaixuandang committed Jul 23, 2024
1 parent 698368a commit 29f9b03
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 3 deletions.
7 changes: 7 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
deploy-testnet:
op run --env-file="./.env" -- \
forge script DeployKatanaV3Testnet -f ronin-testnet

deploy-testnet-broadcast:
op run --env-file="./.env" -- \
forge script DeployKatanaV3Testnet -f ronin-testnet --verify --verifier sourcify --verifier-url https://sourcify.roninchain.com/server/ --legacy --broadcast
4 changes: 1 addition & 3 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ src = "src"
out = "out"
script = "script"
libs = ["lib"]
ffi = true

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options

solc = '0.7.6'
optimizer_runs = 900
evm_version = 'istanbul'
use_literal_content = true
extra_output = ["devdoc", "userdoc", "storagelayout"]
fs_permissions = [{ access = "read-write", path = "./" }]

[fmt]
tab_width = 2
Expand Down
29 changes: 29 additions & 0 deletions script/DeployKatanaV3Core.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.6;

import { Script, console } from "forge-std/Script.sol";
import { KatanaV3Factory } from "@katana/v3-contracts/core/KatanaV3Factory.sol";

abstract contract DeployKatanaV3Core is Script {
address owner;
address treasury;

address factory;

function setUp() public virtual {
require(owner != address(0));
require(treasury != address(0));
logParams();
}

function run() public virtual {
vm.broadcast();
factory = address(new KatanaV3Factory(owner, treasury));
console.log("KatanaV3Factory deployed:", factory);
}

function logParams() internal virtual {
console.log("owner:", owner);
console.log("treasury:", treasury);
}
}
50 changes: 50 additions & 0 deletions script/DeployKatanaV3Periphery.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.6;

import { Script, console } from "forge-std/Script.sol";
import { NonfungibleTokenPositionDescriptor } from
"@katana/v3-contracts/periphery/NonfungibleTokenPositionDescriptor.sol";
import { NonfungiblePositionManager } from "@katana/v3-contracts/periphery/NonfungiblePositionManager.sol";
import { V3Migrator } from "@katana/v3-contracts/periphery/V3Migrator.sol";
import { TickLens } from "@katana/v3-contracts/periphery/lens/TickLens.sol";
import { KatanaInterfaceMulticall } from "@katana/v3-contracts/periphery/lens/KatanaInterfaceMulticall.sol";
import { DeployKatanaV3Core } from "./DeployKatanaV3Core.s.sol";

abstract contract DeployKatanaV3Periphery is DeployKatanaV3Core {
address wron;

address tokenDescriptor;
address nonfungiblePositionManager;
address v3migrator;
address tickLens;
address katanaInterfaceMulticall;

function setUp() public virtual override {
require(wron != address(0));

super.setUp();
}

function run() public virtual override {
super.run();

vm.startBroadcast();
tokenDescriptor = address(new NonfungibleTokenPositionDescriptor(wron, "RON"));
console.log("NonfungibleTokenPositionDescriptor deployed:", tokenDescriptor);
nonfungiblePositionManager = address(new NonfungiblePositionManager(factory, wron, tokenDescriptor));
console.log("NonfungiblePositionManager deployed:", nonfungiblePositionManager);
v3migrator = address(new V3Migrator(factory, wron, nonfungiblePositionManager));
console.log("V3Migrator deployed:", v3migrator);
tickLens = address(new TickLens());
console.log("TickLens deployed:", tickLens);
katanaInterfaceMulticall = address(new KatanaInterfaceMulticall());
console.log("KatanaInterfaceMulticall deployed:", katanaInterfaceMulticall);
vm.stopBroadcast();
}

function logParams() internal virtual override {
super.logParams();

console.log("WRON:", wron);
}
}
15 changes: 15 additions & 0 deletions script/ronin-testnet/DeployFactory.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.6;

import { Script } from "forge-std/Script.sol";
import { console } from "forge-std/console.sol";
import { KatanaV3Factory } from "@katana/v3-contracts/core/KatanaV3Factory.sol";

contract DeployFactory is Script {
function run() public {
vm.rememberKey(vm.envUint("TESTNET_PK"));
vm.broadcast();
address factory = address(new KatanaV3Factory(address(0), address(0)));
console.log("KatanaV3Factory deployed:", factory);
}
}
18 changes: 18 additions & 0 deletions script/ronin-testnet/DeployKatanaV3Testnet.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.7.6;

import { Script } from "forge-std/Script.sol";
import { console } from "forge-std/console.sol";
import { DeployKatanaV3Periphery } from "../DeployKatanaV3Periphery.s.sol";

contract DeployKatanaV3Testnet is DeployKatanaV3Periphery {
function setUp() public override {
owner = 0x247F12836A421CDC5e22B93Bf5A9AAa0f521f986;
treasury = 0x968D0Cd7343f711216817E617d3f92a23dC91c07;
wron = 0xA959726154953bAe111746E265E6d754F48570E6;

vm.rememberKey(vm.envUint("TESTNET_PK"));

super.setUp();
}
}

0 comments on commit 29f9b03

Please sign in to comment.