@@ -13,6 +13,7 @@ import {
1313} from "rxjs"
1414import { Dot , DotQueries , MultiAddress , WndAh } from "../.papi/descriptors/dist"
1515import { NominationPool , StakingSdk } from "./sdk-types"
16+ import { PERBILL } from "./types"
1617
1718export 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
87105export const getNominationPool$Fn =
88106 (
0 commit comments