-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_example_omnibus.spec.ts
217 lines (190 loc) · 7.68 KB
/
_example_omnibus.spec.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
import { before, describe, it } from "mocha";
import { BigNumberish, formatEther, JsonRpcProvider } from "ethers";
import { enactOmnibus } from "../src/omnibuses/tools/test";
import networks from "../src/networks";
import lido from "../src/lido";
import { Receipt } from "web3-types";
import { StakingModule } from "../src/lido/lido";
import omnibus from "./_example_omnibus";
import checks from "../src/omnibuses/checks";
const { stakingRouter, tokens, easyTrack, events } = checks.mainnet;
const url = networks.localRpcUrl("eth");
console.log(url);
const provider = new JsonRpcProvider(url);
const contracts = lido.eth[omnibus.network](provider);
// Testing values
const expectedTargetShare = 400n;
const expectedTreasuryFee = 200n;
const expectedStakingModuleFee = 800n;
const tokenTransfers = [
{
recipient: "0x17F6b2C738a63a8D3A113a228cfd0b373244633D",
amount: 180_000n * 10n ** 18n,
},
{
recipient: "0x0000000000000000000000000000000000000777",
amount: 10_000n * 10n ** 18n,
},
{
recipient: "0x9B1cebF7616f2BC73b47D226f90b01a7c9F86956",
amount: 110_000n * 10n ** 18n,
},
];
const newNopCount = 7;
const newOperators = [
{
name: "A41",
rewardAddress: "0x2A64944eBFaFF8b6A0d07B222D3d83ac29c241a7",
},
{
name: "Develp GmbH",
rewardAddress: "0x0a6a0b60fFeF196113b3530781df6e747DdC565e",
},
{
name: "Ebunker",
rewardAddress: "0x2A2245d1f47430b9f60adCFC63D158021E80A728",
},
{
name: "Gateway.fm AS",
rewardAddress: "0x78CEE97C23560279909c0215e084dB293F036774",
},
{
name: "Numic",
rewardAddress: "0x0209a89b6d9F707c14eB6cD4C3Fb519280a7E1AC",
},
{
name: "ParaFi Technologies LLC",
rewardAddress: "0x5Ee590eFfdf9456d5666002fBa05fbA8C3752CB7",
},
{
name: "RockawayX Infra",
rewardAddress: "0xcA6817DAb36850D58375A10c78703CE49d41D25a",
},
];
const addFactoryValues = {
name: "reWARDS stETH",
factories: {
topUp: "0x85d703B2A4BaD713b596c647badac9A1e95bB03d" as `0x${string}`,
addRecipient: "0x1dCFc37719A99d73a0ce25CeEcbeFbF39938cF2C" as `0x${string}`,
removeRecipient: "0x00BB68a12180a8f7E20D8422ba9F81c07A19A79E" as `0x${string}`,
},
token: "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84" as `0x${string}`, // stETH
registry: "0xAa47c268e6b2D4ac7d7f7Ffb28A39484f5212c2A" as `0x${string}`,
trustedCaller: "0x87D93d9B2C672bf9c9642d853a8682546a5012B5" as `0x${string}`,
};
const removeFactoryValues = {
name: "reWARDS LDO",
factories: {
topUp: "0x200dA0b6a9905A377CF8D469664C65dB267009d1" as `0x${string}`,
addRecipient: "0x48c135Ff690C2Aa7F5B11C539104B5855A4f9252" as `0x${string}`,
removeRecipient: "0x7E8eFfAb3083fB26aCE6832bFcA4C377905F97d7" as `0x${string}`,
},
};
describe("Testing _demo_omnibus", () => {
let enactReceipt: Receipt;
let snapshotId: string;
before(async () => {
snapshotId = await provider.send("evm_snapshot", []);
});
after(async () => {
await provider.send("evm_revert", [snapshotId]);
});
describe("Check network state before voting...", () => {
it("Simple DVT module state is as expected", async () => {
await stakingRouter.checkStakingModule(StakingModule.SimpleDVT, {
targetShare: 400n,
treasuryFee: 200n,
stakingModuleFee: 800n,
});
});
});
describe("Enact omnibus and check network state after voting...", () => {
let agentLDOBalanceBefore: any;
let balancesBefore: BigNumberish[];
let nodeOperatorsCountBefore: any;
before(async () => {
agentLDOBalanceBefore = await contracts.ldo.balanceOf(contracts.agent.address);
balancesBefore = await Promise.all(tokenTransfers.map(({ recipient }) => contracts.ldo.balanceOf(recipient)));
nodeOperatorsCountBefore = await contracts.curatedStakingModule.getNodeOperatorsCount();
// Start and enact omnibus. Keep receipt to check events later.
enactReceipt = await enactOmnibus(omnibus, provider);
console.log(" Omnibus enacted successfully. Running checks...");
});
describe("Check that all assets were transferred correctly", () => {
for (let i = 0; i < tokenTransfers.length; i++) {
const { recipient, amount } = tokenTransfers[i];
it(`${formatEther(amount)} LDO were transferred to ${recipient}`, async () => {
const expectedBalance = BigInt(balancesBefore[i]) + BigInt(amount);
await tokens.checkLDOBalance(recipient, expectedBalance);
});
}
it("LDO budget was decreased by the total amount of transfers", async () => {
const totalSum = tokenTransfers.reduce((acc, { amount }) => acc + amount, 0n);
await tokens.checkLDOBalance(contracts.agent.address, agentLDOBalanceBefore - totalSum);
});
});
describe("Check staking module update...", () => {
it(`Simple DVT module was correctly updated`, async () => {
await stakingRouter.checkStakingModule(StakingModule.SimpleDVT, {
targetShare: expectedTargetShare,
treasuryFee: expectedTreasuryFee,
stakingModuleFee: expectedStakingModuleFee,
});
});
});
describe("Check adding new node operators...", () => {
it(`node operators count was increased by ${newNopCount}`, async () => {
const expectedNodeOperatorsCount = nodeOperatorsCountBefore + BigInt(newNopCount);
await stakingRouter.checkNodeOperatorsCount(expectedNodeOperatorsCount);
});
for (let i = 0; i < newOperators.length; i++) {
const operator = newOperators[i];
it(`operator ${operator.name} was successfully added`, async () => {
const operatorIndex = nodeOperatorsCountBefore + BigInt(i);
await stakingRouter.checkNodeOperator(operatorIndex, operator.name, operator.rewardAddress as `0x${string}`);
});
}
});
describe("Check easy track changes...", () => {
it(`New top up factory ${addFactoryValues.name} can make payments`, async () => {
await easyTrack.checkFactoryExists(addFactoryValues.factories.topUp);
await easyTrack.checkTopUpFactory(
addFactoryValues.token,
addFactoryValues.factories.topUp,
addFactoryValues.registry,
addFactoryValues.trustedCaller,
);
});
it(`New add recipient factory ${addFactoryValues.name} works as expected`, async () => {
await easyTrack.checkFactoryExists(addFactoryValues.factories.addRecipient);
await easyTrack.checkAddRecipientFactory(
addFactoryValues.factories.addRecipient,
addFactoryValues.registry,
addFactoryValues.trustedCaller,
);
});
it(`New remove recipient factory ${addFactoryValues.name} works as expected`, async () => {
await easyTrack.checkFactoryExists(addFactoryValues.factories.removeRecipient);
await easyTrack.checkRemoveRecipientFactory(
addFactoryValues.factories.removeRecipient,
addFactoryValues.registry,
addFactoryValues.trustedCaller,
);
});
it(`Top Up factory ${removeFactoryValues.factories.topUp} was removed`, async () => {
await easyTrack.checkFactoryNotExists(removeFactoryValues.factories.topUp);
});
it(`Add recipient factory ${removeFactoryValues.factories.addRecipient} was removed`, async () => {
await easyTrack.checkFactoryNotExists(removeFactoryValues.factories.addRecipient);
});
it(`Remove recipient factory ${removeFactoryValues.factories.removeRecipient} was removed`, async () => {
await easyTrack.checkFactoryNotExists(removeFactoryValues.factories.removeRecipient);
});
});
});
describe("Check fired events by action...", () => {
it("All expected events were fired", () => {
events.checkOmnibusEvents(omnibus.items, enactReceipt);
});
});
});