-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy path04-klerosliquid-to-v2-gnosis.ts
147 lines (129 loc) · 4.68 KB
/
04-klerosliquid-to-v2-gnosis.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { parseUnits, parseEther } from "ethers/lib/utils";
import { HardhatRuntimeEnvironment } from "hardhat/types";
import { DeployFunction } from "hardhat-deploy/types";
import disputeTemplate from "../config/DisputeTemplate.simple.json";
enum ForeignChains {
GNOSIS_MAINNET = 100,
GNOSIS_CHIADO = 10200,
HARDHAT = 31337,
}
const wrappedPNKByChain = new Map<ForeignChains, string>([
[ForeignChains.GNOSIS_MAINNET, "0xcb3231aBA3b451343e0Fddfc45883c842f223846"],
]);
const ONE_GWEI = parseUnits("1", "gwei");
const deployKlerosLiquid: DeployFunction = async (hre: HardhatRuntimeEnvironment) => {
const { ethers, deployments, getNamedAccounts, getChainId } = hre;
const { deploy, execute } = deployments;
// fallback to hardhat node signers on local network
const deployer = (await getNamedAccounts()).deployer ?? (await hre.ethers.getSigners())[0].address;
const chainId = Number(await getChainId());
console.log("Deploying to chainId %s with deployer %s", chainId, deployer);
if (!wrappedPNKByChain.get(chainId)) {
const wPnk = await deploy("WrappedPinakionV2", {
from: deployer,
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
});
wrappedPNKByChain.set(ForeignChains[ForeignChains[chainId]], wPnk.address);
await deploy("WPNKFaucet", {
from: deployer,
contract: "Faucet",
args: [wPnk.address],
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
});
}
const wPnkAddress = wrappedPNKByChain.get(ForeignChains[ForeignChains[chainId]]);
const rng = ethers.constants.AddressZero;
const minStakingTime = 99999999;
const maxFreezingTime = 0;
const minStake = parseEther("9999999");
const alpha = 10000;
const feeForJuror = 0;
const jurorsForCourtJump = 9999999;
const sortitionSumTreeK = 3;
const foreignGateway = await deployments.get("ForeignGatewayOnGnosis");
const extraData =
"0x00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000003"; // General court, 3 jurors
const weth = await deployments.get("WETH");
console.log("Using: \nwPNK at %s, \nForeignGateway at %s", wPnkAddress, foreignGateway.address, weth.address);
const sortitionSumTreeLibrary = await deploy("SortitionSumTreeFactory", {
from: deployer,
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
});
const xKlerosLiquidV2 = await deploy("xKlerosLiquidV2", {
from: deployer,
log: true,
libraries: {
SortitionSumTreeFactory: sortitionSumTreeLibrary.address,
},
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
});
await execute(
"xKlerosLiquidV2",
{
from: deployer,
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
},
"initialize",
deployer,
wPnkAddress,
rng,
minStakingTime,
maxFreezingTime,
false,
[minStake, alpha, feeForJuror, jurorsForCourtJump], // minStake, alpha, feeForJuror, jurorsForCourtJump
[0, 0, 0, 0], // evidencePeriod, commitPeriod, votePeriod, appealPeriod
sortitionSumTreeK,
foreignGateway.address
);
// const xKlerosLiquidV2 = await deployments.get("xKlerosLiquidV2");
await deploy("ArbitrableExample", {
from: deployer,
args: [xKlerosLiquidV2.address, 0, disputeTemplate, extraData, weth.address],
log: true,
maxFeePerGas: ONE_GWEI,
maxPriorityFeePerGas: ONE_GWEI,
});
};
// TODO: mock deployment on the hardhat network
// const xPinakionByChain = new Map<ForeignChains, string>([
// [ForeignChains.GNOSIS_MAINNET, "0x37b60f4E9A31A64cCc0024dce7D0fD07eAA0F7B3"],
// [ForeignChains.GNOSIS_CHIADO, "0x00"],
// ]);
// const tokenBridgeByChain = new Map<ForeignChains, string>([
// [ForeignChains.GNOSIS_MAINNET, "0xf6A78083ca3e2a662D6dd1703c939c8aCE2e268d"],
// [ForeignChains.GNOSIS_CHIADO, "0xbb3c86f9918C3C1d83668fA84e79E876d147fFf2"],
// ]);
// const hardhatDeployer = () => {
// // TODO: deploy mocks for xPinakion and tokenBridge for Hardhat network
// // const xPnk = await deployments.get("WPNK");
// const xPnk = xPinakionByChain[chainId];
// const tokenBridge = tokenBridgeByChain[chainId];
// const wPnk = await deploy("WrappedPinakionV2", {
// from: deployer,
// log: true,
// });
// await execute(
// "WrappedPinakionV2",
// { from: deployer, log: true },
// "initialize",
// "Staking PNK on xDai",
// "stPNK",
// xPnk,
// tokenBridge
// );
// };
deployKlerosLiquid.tags = ["KlerosLiquidOnGnosis"];
deployKlerosLiquid.skip = async ({ getChainId }) => {
const chainId = Number(await getChainId());
return !ForeignChains[chainId];
};
export default deployKlerosLiquid;