Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 17 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,28 @@
"dependencies": {
"@acala-network/chopsticks": "^1.0",
"@acala-network/chopsticks-testing": "^1.0",
"@polkadot/api": "^15.0",
"@swc/core": "^1.10.0",
"axios": "^1.7.9",
"dotenv": "^16.4.7",
"@polkadot/api": "^15.9",
"@swc/core": "^1.11.22",
"axios": "^1.9.0",
"dotenv": "^16.5.0",
"lodash": "^4.17.21",
"typescript": "5.7.2",
"unplugin-swc": "^1.5.1",
"vitest": "^3.0"
"reflect-metadata": "^0.2.2",
"typescript": "5.8.3",
"unplugin-swc": "^1.5.2",
"vitest": "^3.1"
},
"devDependencies": {
"@eslint/js": "^9.16.0",
"@eslint/js": "^9.25.1",
"@types/eslint__js": "^8.42.3",
"@types/lodash": "^4.17.13",
"@types/node": "^22.10.1",
"@vitest/ui": "^3.0",
"eslint": "^9.16.0",
"@types/lodash": "^4.17.16",
"@types/node": "^22.15.2",
"@vitest/ui": "^3.1",
"eslint": "^9.25.1",
"husky": "^9.1.7",
"lint-staged": "^15.2.10",
"prettier": "^3.4.2",
"tsx": "^4.19.2",
"typescript-eslint": "8.17.0"
"lint-staged": "^15.5.1",
"prettier": "^3.5.3",
"tsx": "^4.19.3",
"typescript-eslint": "8.31.0"
},
"prettier": {
"tabWidth": 2,
Expand Down
98 changes: 70 additions & 28 deletions tests/staking/tier-threshold.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,42 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
450000, // 45%
],
// Perbill percentages
// percentages below are calulated based on total issuance at the time when dApp staking v3 was launched (8.4B)
// percentages below are calculated based on total issuance at the time when dApp staking v3 was launched (8.4B)
tierThresholds: [
{
DynamicPercentage: {
percentage: 35_700_000, // 3.57%
minimumRequiredPercentage: 23_800_000, // 2.38%
// new parameter on version 10
...(palletVersion >= 10
? {
maximumPossiblePercentage: 35_700_000, // 3.57%
}
: {}),
},
},
{
DynamicPercentage: {
percentage: 8_900_000, // 0.89%
minimumRequiredPercentage: 6_000_000, // 0.6%
// new parameter on version 10
...(palletVersion >= 10
? {
maximumPossiblePercentage: 8_900_000, // 0.89%
}
: {}),
},
},
{
DynamicPercentage: {
percentage: 2_380_000, // 0.238%
minimumRequiredPercentage: 1_790_000, // 0.179%
// new parameter on version 10
...(palletVersion >= 10
? {
maximumPossiblePercentage: 2_380_000, // 0.238%
}
: {}),
},
},
{
Expand All @@ -70,8 +88,7 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
},
},
],
// new parameter on version 9
...(palletVersion >= 9 ? { slotNumberArgs: [1000, 50] } : {}),
slotNumberArgs: [1000, 50],
},
},
priceAggregator: {
Expand Down Expand Up @@ -154,13 +171,13 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
}
`)

// set price to $0.05
// set price to $0.01
await astar.dev.setStorage({
priceAggregator: {
valuesCircularBuffer: {
head: 1,
buffer: [
50_000_000_000_000_000n, // $0.05
10_000_000_000_000_000n, // $0.01
],
},
},
Expand All @@ -171,27 +188,52 @@ given('astar')('Number of slots adjusted based on price', async ({ networks: { a
config = await astar.api.query.dappStaking.tierConfig<TiersConfigurationV8>()
numberOfSlots = calculateNumberOfSlots(config.slotsPerTier)

expect(numberOfSlots).toEqual(100)
expect(config.toHuman()).toMatchInlineSnapshot(`
{
"rewardPortion": [
"25.00%",
"47.00%",
"25.00%",
"3.00%",
],
"slotsPerTier": [
"5",
"20",
"30",
"45",
],
"tierThresholds": [
"299,880,001,946,038,151,514,954,140",
"74,760,000,485,146,766,063,952,153",
"19,992,000,129,735,876,767,663,609",
"1,680,000,010,902,174,518,291,060",
],
}
`)
expect(numberOfSlots).toEqual(60)
if (palletVersion >= 10) {
expect(config.toHuman()).toMatchInlineSnapshot(`
{
"rewardPortion": [
"25.00%",
"47.00%",
"25.00%",
"3.00%",
],
"slotsPerTier": [
"3",
"12",
"18",
"27",
],
"tierThresholds": [
"299,880,001,946,038,151,514,954,140",
"74,760,000,485,146,766,063,952,153",
"19,992,000,129,735,876,767,663,609",
"1,680,000,010,902,174,518,291,060",
],
}
`)
} else {
expect(config.toHuman()).toMatchInlineSnapshot(`
{
"rewardPortion": [
"25.00%",
"47.00%",
"25.00%",
"3.00%",
],
"slotsPerTier": [
"3",
"12",
"18",
"27",
],
"tierThresholds": [
"499,800,003,243,396,919,291,550,233",
"124,600,000,808,577,943,464,840,255",
"33,320,000,216,226,461,286,103,348",
"1,680,000,010,902,174,518,291,060",
],
}
`)
}
})
Loading