Skip to content

Commit

Permalink
Fix and deploy (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 authored Aug 9, 2024
1 parent 1ef9c4e commit 16e756a
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 86 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/DeployKoi.s.sol:DeployKoiScript --rpc-url "https://koi-rpc.darwinia.network"
deploy :; @forge script script/DeployKoi.s.sol:DeployKoiScript --rpc-url "https://koi-rpc.darwinia.network" --broadcast
dry-run:; @forge script script/Deploy.s.sol:DeployScript
deploy :; @forge script script/Deploy.s.sol:DeployScript --broadcast --verify

.PHONY: all flat clean test salt deploy
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| KTONStakingRewards | 0x000000000419683a1a03AbC21FC9da25fd2B4dD7 |
| RewardsDistribution | 0x000000000Ae5DB7BDAf8D071e680452e33d91Dd5 |
| modlda/trsry | 0x6d6f646c64612f74727372790000000000000000 |
| gKTON | 0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F |
| KtonDAO | 0xfe024E36B116bBFCb337BfD71a8C9e32330dA128 |
| Timelock | 0x80dEE0851313a46b2a8604209B1f3225E1721c9a |
| KtonDAOVault | 0xf1b4f3D438eE2B363C5ba1641A498709ff5780bA |
| gKTON | 0xa42980efF5439F97A768F0B7a00c70ff0a213977 |
| KtonDAO | 0xF3522CA27807ED1264e399FaC42e8621Db4b5Dc4 |
| Timelock | 0xb80b7Bd1001d6B5D4a9bf0d3524b85b244147C30 |
| KtonDAOVault | 0x9e5cED4C978F92591fD0609c5c781e6aDdB75ac0 |
11 changes: 9 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
src = "src"
out = "out"
libs = ["lib"]
sender = "0xb32832E2dBFa8f818db83Ec38FdBa4c08e46293f"
sender = "0xcaEaf98F2131022A62841f798f47B904cDCb7114"
force = true
ffi = true
ast = true
Expand All @@ -15,8 +15,15 @@ bytecode_hash = "ipfs"
extra_output = ["storageLayout"]
extra_output_files = ["metadata"]
fs_permissions = [{ access = "read", path = "out" }]
eth_rpc_url = "https://rpc.darwinia.network"
etherscan_api_key = "xxx"

[rpc_endpoints]
pangolin = "https://pangolin-rpc.darwinia.network"
koi = "https://koi-rpc.darwinia.network"
crab = "https://crab-rpc.darwinia.network"
darwinia = "https://rpc.darwinia.network"

[etherscan]
koi = { key = "xxx", url = "https://koi-scan.darwinia.network/api", chain = 701 }
crab = { key = "xxx", url = "https://crab-scan.darwinia.network/api", chain = 44 }
darwinia = { key = "xxx", url = "https://explorer.darwinia.network/api", chain = 46 }
56 changes: 48 additions & 8 deletions script/Deploy.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,78 @@ import {KtonTimelockController} from "../src/governance/KtonTimelockController.s
import {KtonDAOVault} from "../src/staking/KtonDAOVault.sol";

contract DeployScript is Script {
address gKTON = 0x6FB1cE2dc2043FEc15d4d8A58cAF06a47A8f025F;
address ktonDAO = 0xfe024E36B116bBFCb337BfD71a8C9e32330dA128;
address timelock = 0x80dEE0851313a46b2a8604209B1f3225E1721c9a;
address vault = 0xf1b4f3D438eE2B363C5ba1641A498709ff5780bA;
address gKTON = 0xa42980efF5439F97A768F0B7a00c70ff0a213977;
address ktonDAO = 0xF3522CA27807ED1264e399FaC42e8621Db4b5Dc4;
address timelock = 0xb80b7Bd1001d6B5D4a9bf0d3524b85b244147C30;
address vault = 0x9e5cED4C978F92591fD0609c5c781e6aDdB75ac0;

function setUp() public {}
struct Settings {
uint256 quorum;
uint256 initialProposalThreshold;
uint32 initialVotingPeriod;
uint256 timelockDeplay;
}

function getSettings(uint256 chainId) public pure returns (Settings memory) {
if (chainId == 701) {
return Settings({
quorum: 3e16,
initialProposalThreshold: 1e16,
initialVotingPeriod: 1 hours,
timelockDeplay: 0
});
} else if (chainId == 44) {
return Settings({
quorum: 4_500e18,
initialProposalThreshold: 35e18,
initialVotingPeriod: 30 days,
timelockDeplay: 3 days
});
} else if (chainId == 46) {
return Settings({
quorum: 3_000e18,
initialProposalThreshold: 20e18,
initialVotingPeriod: 30 days,
timelockDeplay: 3 days
});
}
}

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

safeconsole.log("Chain Id: ", block.chainid);
Settings memory s = getSettings(block.chainid);

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 = 3_000e18;
uint256 quorum = s.quorum;
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")
(
IVotes(gKTON),
TimelockControllerUpgradeable(payable(timelock)),
0,
s.initialVotingPeriod,
s.initialProposalThreshold,
"KtonDAO"
)
),
opts
);
safeconsole.log("KtonDAO: ", ktonDAO_PROXY);
safeconsole.log("KtonDAO_Logic: ", Upgrades.getImplementationAddress(ktonDAO_PROXY));

uint256 minDelay = 3 days;
uint256 minDelay = s.timelockDeplay;
address[] memory proposers = new address[](1);
proposers[0] = ktonDAO;
KtonTimelockController timelockController =
Expand Down
61 changes: 0 additions & 61 deletions script/DeployKoi.s.sol

This file was deleted.

2 changes: 1 addition & 1 deletion src/governance/GovernanceKTON.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ contract GovernanceKTON is
__ERC20_init("Governance KTON", "gKTON");
__ERC20Permit_init("Governance KTON");
__ERC20Votes_init();
__ERC165_init();
__ERC165_init();
}

function supportsInterface(bytes4 _interfaceId) public view virtual override returns (bool) {
Expand Down
5 changes: 0 additions & 5 deletions src/staking/StakingRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,6 @@ abstract contract StakingRewards is IStakingRewards, Initializable, ReentrancyGu
}
}

function exit() external {
_withdraw(_balances[msg.sender]);
getReward();
}

/* ========== RESTRICTED FUNCTIONS ========== */

function notifyRewardAmount() external payable onlyRewardsDistribution updateReward(address(0)) {
Expand Down
2 changes: 0 additions & 2 deletions src/staking/interfaces/IStakingRewards.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,4 @@ interface IStakingRewards {
function unlockAndWithdraw(uint256 amount) external;

function getReward() external;

function exit() external;
}
2 changes: 1 addition & 1 deletion verify/GovernanceKTON.json

Large diffs are not rendered by default.

0 comments on commit 16e756a

Please sign in to comment.