Skip to content

Commit a92cc89

Browse files
authored
Merge pull request #117 from AstarNetwork/feat/staking-max-thresholds
Feat/staking max thresholds
2 parents ea7784a + 5ac1639 commit a92cc89

File tree

3 files changed

+1673
-1892
lines changed

3 files changed

+1673
-1892
lines changed

package.json

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,28 @@
1616
"dependencies": {
1717
"@acala-network/chopsticks": "^1.0",
1818
"@acala-network/chopsticks-testing": "^1.0",
19-
"@polkadot/api": "^15.0",
20-
"@swc/core": "^1.10.0",
21-
"axios": "^1.7.9",
22-
"dotenv": "^16.4.7",
19+
"@polkadot/api": "^15.9",
20+
"@swc/core": "^1.11.22",
21+
"axios": "^1.9.0",
22+
"dotenv": "^16.5.0",
2323
"lodash": "^4.17.21",
24-
"typescript": "5.7.2",
25-
"unplugin-swc": "^1.5.1",
26-
"vitest": "^3.0"
24+
"reflect-metadata": "^0.2.2",
25+
"typescript": "5.8.3",
26+
"unplugin-swc": "^1.5.2",
27+
"vitest": "^3.1"
2728
},
2829
"devDependencies": {
29-
"@eslint/js": "^9.16.0",
30+
"@eslint/js": "^9.25.1",
3031
"@types/eslint__js": "^8.42.3",
31-
"@types/lodash": "^4.17.13",
32-
"@types/node": "^22.10.1",
33-
"@vitest/ui": "^3.0",
34-
"eslint": "^9.16.0",
32+
"@types/lodash": "^4.17.16",
33+
"@types/node": "^22.15.2",
34+
"@vitest/ui": "^3.1",
35+
"eslint": "^9.25.1",
3536
"husky": "^9.1.7",
36-
"lint-staged": "^15.2.10",
37-
"prettier": "^3.4.2",
38-
"tsx": "^4.19.2",
39-
"typescript-eslint": "8.17.0"
37+
"lint-staged": "^15.5.1",
38+
"prettier": "^3.5.3",
39+
"tsx": "^4.19.3",
40+
"typescript-eslint": "8.31.0"
4041
},
4142
"prettier": {
4243
"tabWidth": 2,

tests/staking/tier-threshold.test.ts

Lines changed: 70 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,42 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
4444
450000, // 45%
4545
],
4646
// Perbill percentages
47-
// percentages below are calulated based on total issuance at the time when dApp staking v3 was launched (8.4B)
47+
// percentages below are calculated based on total issuance at the time when dApp staking v3 was launched (8.4B)
4848
tierThresholds: [
4949
{
5050
DynamicPercentage: {
5151
percentage: 35_700_000, // 3.57%
5252
minimumRequiredPercentage: 23_800_000, // 2.38%
53+
// new parameter on version 10
54+
...(palletVersion >= 10
55+
? {
56+
maximumPossiblePercentage: 35_700_000, // 3.57%
57+
}
58+
: {}),
5359
},
5460
},
5561
{
5662
DynamicPercentage: {
5763
percentage: 8_900_000, // 0.89%
5864
minimumRequiredPercentage: 6_000_000, // 0.6%
65+
// new parameter on version 10
66+
...(palletVersion >= 10
67+
? {
68+
maximumPossiblePercentage: 8_900_000, // 0.89%
69+
}
70+
: {}),
5971
},
6072
},
6173
{
6274
DynamicPercentage: {
6375
percentage: 2_380_000, // 0.238%
6476
minimumRequiredPercentage: 1_790_000, // 0.179%
77+
// new parameter on version 10
78+
...(palletVersion >= 10
79+
? {
80+
maximumPossiblePercentage: 2_380_000, // 0.238%
81+
}
82+
: {}),
6583
},
6684
},
6785
{
@@ -70,8 +88,7 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
7088
},
7189
},
7290
],
73-
// new parameter on version 9
74-
...(palletVersion >= 9 ? { slotNumberArgs: [1000, 50] } : {}),
91+
slotNumberArgs: [1000, 50],
7592
},
7693
},
7794
priceAggregator: {
@@ -154,13 +171,13 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
154171
}
155172
`)
156173

157-
// set price to $0.05
174+
// set price to $0.01
158175
await astar.dev.setStorage({
159176
priceAggregator: {
160177
valuesCircularBuffer: {
161178
head: 1,
162179
buffer: [
163-
50_000_000_000_000_000n, // $0.05
180+
10_000_000_000_000_000n, // $0.01
164181
],
165182
},
166183
},
@@ -171,27 +188,52 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
171188
config = await astar.api.query.dappStaking.tierConfig<TiersConfigurationV8>()
172189
numberOfSlots = calculateNumberOfSlots(config.slotsPerTier)
173190

174-
expect(numberOfSlots).toEqual(100)
175-
expect(config.toHuman()).toMatchInlineSnapshot(`
176-
{
177-
"rewardPortion": [
178-
"25.00%",
179-
"47.00%",
180-
"25.00%",
181-
"3.00%",
182-
],
183-
"slotsPerTier": [
184-
"5",
185-
"20",
186-
"30",
187-
"45",
188-
],
189-
"tierThresholds": [
190-
"299,880,001,946,038,151,514,954,140",
191-
"74,760,000,485,146,766,063,952,153",
192-
"19,992,000,129,735,876,767,663,609",
193-
"1,680,000,010,902,174,518,291,060",
194-
],
195-
}
196-
`)
191+
expect(numberOfSlots).toEqual(60)
192+
if (palletVersion >= 10) {
193+
expect(config.toHuman()).toMatchInlineSnapshot(`
194+
{
195+
"rewardPortion": [
196+
"25.00%",
197+
"47.00%",
198+
"25.00%",
199+
"3.00%",
200+
],
201+
"slotsPerTier": [
202+
"3",
203+
"12",
204+
"18",
205+
"27",
206+
],
207+
"tierThresholds": [
208+
"299,880,001,946,038,151,514,954,140",
209+
"74,760,000,485,146,766,063,952,153",
210+
"19,992,000,129,735,876,767,663,609",
211+
"1,680,000,010,902,174,518,291,060",
212+
],
213+
}
214+
`)
215+
} else {
216+
expect(config.toHuman()).toMatchInlineSnapshot(`
217+
{
218+
"rewardPortion": [
219+
"25.00%",
220+
"47.00%",
221+
"25.00%",
222+
"3.00%",
223+
],
224+
"slotsPerTier": [
225+
"3",
226+
"12",
227+
"18",
228+
"27",
229+
],
230+
"tierThresholds": [
231+
"499,800,003,243,396,919,291,550,233",
232+
"124,600,000,808,577,943,464,840,255",
233+
"33,320,000,216,226,461,286,103,348",
234+
"1,680,000,010,902,174,518,291,060",
235+
],
236+
}
237+
`)
238+
}
197239
})

0 commit comments

Comments
 (0)