Skip to content

Commit

Permalink
Merge pull request #11 from darwinia-network/echo/migrate
Browse files Browse the repository at this point in the history
Deploy on Koi
  • Loading branch information
hujw77 authored Jul 11, 2024
2 parents 2de2067 + e5c1155 commit 045b5b5
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ clean :; @forge clean
test :; @forge test
fmt :; @forge fmt

dry-run:; @forge script script/Deploy.s.sol:DeployScript --rpc-url "https://koi-rpc.darwinia.network"
deploy :; @forge script script/Deploy.s.sol:DeployScript --rpc-url "https://koi-rpc.darwinia.network" --broadcast
dry-run:; @forge script script/DeployKoi.s.sol:DeployKoiScript --rpc-url "https://crab-rpc.darwinia.network"
deploy :; @forge script script/DeployKoi.s.sol:DeployKoiScript --rpc-url "https://koi-rpc.darwinia.network" --broadcast

.PHONY: all flat clean test salt deploy
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ Staking pool for KTON.
| KTONStakingRewards | 0x000000000419683a1a03AbC21FC9da25fd2B4dD7 |
| RewardsDistribution | 0x000000000Ae5DB7BDAf8D071e680452e33d91Dd5 |
| modlda/trsry | 0x6d6f646c64612f74727372790000000000000000 |
| gKTON | 0x01840055063E8d56C957b79C964D7fc50a825752 |
| KtonDAO | 0x34D4519c574047c9D7F9E79b2bc718aef159129B |
| Timelock | 0xCA435c493Ee55AB27e8C8b1b1a89706c5a2761b5 |
| KtonDAOVault | 0x0DBFbb1Ab6e42F89661B4f98d5d0acdBE21d1ffC |

### API

Expand Down
6 changes: 5 additions & 1 deletion script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ contract DeployScript is Script {
safeconsole.log("gKTON: ", gKTON_PROXY);
safeconsole.log("gKTON_Logic: ", Upgrades.getImplementationAddress(gKTON_PROXY));

Options memory opts;
uint256 quorum = 3_000e18;
opts.constructorData = abi.encode(quorum);
address ktonDAO_PROXY = Upgrades.deployTransparentProxy(
"KtonDAO.sol:KtonDAO",
timelock,
abi.encodeCall(
KtonDAO.initialize,
(IVotes(gKTON), TimelockControllerUpgradeable(payable(timelock)), 1 days, 30 days, 20e18, "KtonDAO")
)
),
opts
);
safeconsole.log("KtonDAO: ", ktonDAO_PROXY);
safeconsole.log("KtonDAO_Logic: ", Upgrades.getImplementationAddress(ktonDAO_PROXY));
Expand Down
61 changes: 61 additions & 0 deletions script/DeployKoi.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {Script} from "forge-std/Script.sol";
import {safeconsole} from "forge-std/safeconsole.sol";
import {Upgrades} from "openzeppelin-foundry-upgrades/Upgrades.sol";
import {Options} from "openzeppelin-foundry-upgrades/Options.sol";

import {GovernanceKton} from "../src/governance/GovernanceKton.sol";
import {KtonDAO, IVotes, TimelockControllerUpgradeable} from "../src/governance/KtonDAO.sol";
import {KtonTimelockController} from "../src/governance/KtonTimelockController.sol";
import {KtonDAOVault} from "../src/staking/KtonDAOVault.sol";

contract DeployKoiScript is Script {
address gKTON = 0x01840055063E8d56C957b79C964D7fc50a825752;
address ktonDAO = 0x34D4519c574047c9D7F9E79b2bc718aef159129B;
address timelock = 0xCA435c493Ee55AB27e8C8b1b1a89706c5a2761b5;
address vault = 0x0DBFbb1Ab6e42F89661B4f98d5d0acdBE21d1ffC;

function setUp() public {}

function run() public {
vm.startBroadcast();

address gKTON_PROXY = Upgrades.deployTransparentProxy(
"GovernanceKton.sol:GovernanceKton", timelock, abi.encodeCall(GovernanceKton.initialize, (vault))
);
safeconsole.log("gKTON: ", gKTON_PROXY);
safeconsole.log("gKTON_Logic: ", Upgrades.getImplementationAddress(gKTON_PROXY));

Options memory opts;
uint256 quorum = 3e16;
opts.constructorData = abi.encode(quorum);
address ktonDAO_PROXY = Upgrades.deployTransparentProxy(
"KtonDAO.sol:KtonDAO",
timelock,
abi.encodeCall(
KtonDAO.initialize,
(IVotes(gKTON), TimelockControllerUpgradeable(payable(timelock)), 0, 1 hours, 1e16, "KtonDAO")
),
opts
);
safeconsole.log("KtonDAO: ", ktonDAO_PROXY);
safeconsole.log("KtonDAO_Logic: ", Upgrades.getImplementationAddress(ktonDAO_PROXY));

uint256 minDelay = 0;
address[] memory proposers = new address[](1);
proposers[0] = ktonDAO;
KtonTimelockController timelockController =
new KtonTimelockController(minDelay, proposers, new address[](0), address(0));
safeconsole.log("Timelock: ", address(timelockController));

address KtonDAOVault_PROXY = Upgrades.deployTransparentProxy(
"KtonDAOVault.sol:KtonDAOVault", timelock, abi.encodeCall(KtonDAOVault.initialize, (timelock, gKTON))
);
safeconsole.log("KtonDAOVault: ", KtonDAOVault_PROXY);
safeconsole.log("KtonDAOVault_Logic: ", Upgrades.getImplementationAddress(KtonDAOVault_PROXY));

vm.stopBroadcast();
}
}
11 changes: 7 additions & 4 deletions src/governance/KtonDAO.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ contract KtonDAO is
GovernorVotesUpgradeable,
GovernorTimelockControlUpgradeable
{
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
uint256 public immutable QUORUM;

/// @custom:oz-upgrades-unsafe-allow constructor
constructor() {
_disableInitializers();
constructor(uint256 quorum_) {
QUORUM = quorum_;
}

function initialize(
Expand All @@ -36,8 +39,8 @@ contract KtonDAO is
__GovernorTimelockControl_init(_timelock);
}

function quorum(uint256) public pure override returns (uint256) {
return 3_000e18;
function quorum(uint256) public view override returns (uint256) {
return QUORUM;
}

// The following functions are overrides required by Solidity.
Expand Down
4 changes: 4 additions & 0 deletions src/staking/KtonDAOVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ contract KtonDAOVault is Initializable, Ownable2StepUpgradeable {

receive() external payable {}

function acceptOwnershipFromOldDistribution() external onlySystem {
IOldStakingRewards(OLD_KTON_REWARDS_DISTRIBUTION).acceptOwnership();
}

/// Runtime migration Step:
/// 1. Migrate OLD_KTON_REWARDS_DISTRIBUTION's owner to this contracts address.
/// 2. distributeRewards to this contract address.
Expand Down
2 changes: 2 additions & 0 deletions src/staking/interfaces/IOldStakingRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ interface IOldStakingRewards {
function getReward() external;

function exit() external;

function acceptOwnership() external;
}

0 comments on commit 045b5b5

Please sign in to comment.