Skip to content

Commit aba57be

Browse files
authored
Merge pull request #46 from polkadot-api/vo/pool-commissions
fix(staking): pool commissions not in per one
2 parents 1e30e41 + b742edc commit aba57be

File tree

2 files changed

+42
-18
lines changed

2 files changed

+42
-18
lines changed

packages/sdk-staking/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
## Unreleased
44

5+
## 0.3.2 2025-11-01
6+
7+
### Fixed
8+
9+
- Pool commissions not in per one.
10+
511
## 0.3.1 2025-10-30
612

713
### Fixed

packages/sdk-staking/src/nominationPools.ts

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
} from "rxjs"
1414
import { Dot, DotQueries, MultiAddress, WndAh } from "../.papi/descriptors/dist"
1515
import { NominationPool, StakingSdk } from "./sdk-types"
16+
import { PERBILL } from "./types"
1617

1718
export const unbondNominationPoolFn =
1819
(api: TypedApi<Dot>): StakingSdk["unbondNominationPool"] =>
@@ -65,24 +66,41 @@ const mapPool = (
6566
address: SS58String,
6667
bond: bigint,
6768
name?: Binary,
68-
): NominationPool => ({
69-
id,
70-
name: name?.asText() ?? "",
71-
addresses: {
72-
...pool?.roles,
73-
commission: pool.commission.current?.[1],
74-
pool: address,
75-
},
76-
commission: {
77-
...pool.commission,
78-
current: pool.commission.current?.[0] ?? 0,
79-
},
80-
memberCount: pool.member_counter,
81-
nominations: nominations?.targets ?? [],
82-
points: pool.points,
83-
bond,
84-
state: pool.state.type,
85-
})
69+
): NominationPool => {
70+
const [currentCommission, commissionAddr] = pool.commission.current ?? [
71+
0,
72+
undefined,
73+
]
74+
75+
return {
76+
id,
77+
name: name?.asText() ?? "",
78+
addresses: {
79+
...pool?.roles,
80+
commission: commissionAddr,
81+
pool: address,
82+
},
83+
commission: {
84+
...pool.commission,
85+
current: currentCommission / Number(PERBILL),
86+
max: pool.commission.max
87+
? pool.commission.max / Number(PERBILL)
88+
: undefined,
89+
change_rate: pool.commission.change_rate
90+
? {
91+
max_increase:
92+
pool.commission.change_rate.max_increase / Number(PERBILL),
93+
min_delay: pool.commission.change_rate.min_delay,
94+
}
95+
: undefined,
96+
},
97+
memberCount: pool.member_counter,
98+
nominations: nominations?.targets ?? [],
99+
points: pool.points,
100+
bond,
101+
state: pool.state.type,
102+
}
103+
}
86104

87105
export const getNominationPool$Fn =
88106
(

0 commit comments

Comments
 (0)