@subwallet/extension-base 1.1.61-0 → 1.1.62-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/constants/staking.js +9 -1
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +6 -3
- package/cjs/services/chain-service/handler/SubstrateApi.js +3 -5
- package/cjs/services/chain-service/index.js +8 -0
- package/cjs/services/chain-service/utils/index.js +4 -0
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +5 -3
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +91 -51
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +119 -106
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +22 -15
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +11 -6
- package/cjs/services/earning-service/service.js +1 -1
- package/cjs/services/earning-service/utils/index.js +10 -2
- package/cjs/services/price-service/index.js +14 -6
- package/constants/staking.d.ts +1 -0
- package/constants/staking.js +7 -0
- package/package.json +7 -12
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.js +6 -3
- package/services/chain-service/handler/SubstrateApi.js +4 -5
- package/services/chain-service/index.js +8 -0
- package/services/chain-service/utils/index.js +4 -0
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +3 -2
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +2 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +91 -51
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +2 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +119 -106
- package/services/earning-service/handlers/native-staking/relay-chain.js +23 -16
- package/services/earning-service/handlers/nomination-pool/index.js +11 -6
- package/services/earning-service/service.js +1 -1
- package/services/earning-service/utils/index.js +10 -2
- package/services/price-service/index.js +14 -6
- package/types/yield/info/chain/info.d.ts +2 -0
- package/types/yield/info/chain/target.d.ts +1 -0
- package/types/yield/info/pallet.d.ts +6 -0
- package/utils/staticData/currencySymbol.json +9 -9
- package/cjs/services/chain-service/handler/chain-spec/goldberg.js +0 -190
- package/services/chain-service/handler/chain-spec/goldberg.d.ts +0 -184
- package/services/chain-service/handler/chain-spec/goldberg.js +0 -183
|
@@ -51,20 +51,22 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
51
51
|
await defaultCallback();
|
|
52
52
|
await substrateApi.isReady;
|
|
53
53
|
const unsub = await ((_substrateApi$api$que = substrateApi.api.query.staking) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.currentEra(async _currentEra => {
|
|
54
|
-
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$cal, _substrateApi$api$que2, _substrateApi$api$que3, _substrateApi$api$que4, _substrateApi$api$que5, _substrateApi$api$que6;
|
|
54
|
+
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$con3, _substrateApi$api$cal, _substrateApi$api$que2, _substrateApi$api$que3, _substrateApi$api$que4, _substrateApi$api$que5, _substrateApi$api$que6;
|
|
55
55
|
if (cancel) {
|
|
56
56
|
unsub();
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
let maxNominations = ((_substrateApi$api$con = substrateApi.api.consts.staking) === null || _substrateApi$api$con === void 0 ? void 0 : (_substrateApi$api$con2 = _substrateApi$api$con.maxNominations) === null || _substrateApi$api$con2 === void 0 ? void 0 : _substrateApi$api$con2.toString()) || '16';
|
|
60
|
+
const unlimitedNominatorRewarded = substrateApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
61
|
+
const maxNominatorRewarded = (_substrateApi$api$con3 = substrateApi.api.consts.staking.maxNominatorRewardedPerValidator) === null || _substrateApi$api$con3 === void 0 ? void 0 : _substrateApi$api$con3.toString();
|
|
60
62
|
const _maxNominationsByNominationQuota = await ((_substrateApi$api$cal = substrateApi.api.call.stakingApi) === null || _substrateApi$api$cal === void 0 ? void 0 : _substrateApi$api$cal.nominationsQuota(0)); // todo: review param. Currently return constant for all param.
|
|
61
63
|
const maxNominationsByNominationQuota = _maxNominationsByNominationQuota === null || _maxNominationsByNominationQuota === void 0 ? void 0 : _maxNominationsByNominationQuota.toString();
|
|
62
64
|
maxNominations = maxNominationsByNominationQuota !== null && maxNominationsByNominationQuota !== void 0 ? maxNominationsByNominationQuota : maxNominations;
|
|
63
65
|
const currentEra = _currentEra.toString();
|
|
64
66
|
const maxUnlockingChunks = substrateApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
65
67
|
const unlockingEras = substrateApi.api.consts.staking.bondingDuration.toString();
|
|
66
|
-
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
67
|
-
const erasPerDay = 24 / _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from babe.epochDuration * blockTime * staking.sessionsPerEra
|
|
68
|
+
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString(); // todo: handle case historyDepth undefined
|
|
69
|
+
const erasPerDay = 24 / _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _constants._STAKING_ERA_LENGTH_MAP.default; // Can be exactly calculate from babe.epochDuration * blockTime * staking.sessionsPerEra
|
|
68
70
|
|
|
69
71
|
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras), parseInt(currentEra) / erasPerDay);
|
|
70
72
|
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
@@ -117,7 +119,8 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
117
119
|
// TODO recheck
|
|
118
120
|
unstakingPeriod: unlockingPeriod,
|
|
119
121
|
inflation: inflation
|
|
120
|
-
}
|
|
122
|
+
},
|
|
123
|
+
maxPoolMembers: unlimitedNominatorRewarded ? undefined : maxNominatorRewarded ? parseInt(maxNominatorRewarded) : undefined
|
|
121
124
|
};
|
|
122
125
|
callback(data);
|
|
123
126
|
}));
|
|
@@ -151,7 +154,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
151
154
|
let nominationStatus = _types.EarningStatus.NOT_EARNING;
|
|
152
155
|
let eraStakerOtherList = [];
|
|
153
156
|
let identity;
|
|
154
|
-
if (
|
|
157
|
+
if (_constants2._UPDATED_RUNTIME_STAKING_GROUP.includes(this.chain)) {
|
|
155
158
|
// todo: review all relaychains later
|
|
156
159
|
const [[_identity], _eraStaker] = await Promise.all([(0, _utils3.parseIdentity)(substrateApi, validatorAddress), substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress)]);
|
|
157
160
|
identity = _identity;
|
|
@@ -303,9 +306,9 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
303
306
|
const validatorInfoList = [];
|
|
304
307
|
const maxEraRewardPointsEras = _constants2.MaxEraRewardPointsEras;
|
|
305
308
|
const endEraForPoints = parseInt(activeEra) - 1;
|
|
306
|
-
let startEraForPoints = endEraForPoints - maxEraRewardPointsEras + 1;
|
|
309
|
+
let startEraForPoints = Math.max(endEraForPoints - maxEraRewardPointsEras + 1, 0);
|
|
307
310
|
let _eraStakersPromise;
|
|
308
|
-
if (
|
|
311
|
+
if (_constants2._UPDATED_RUNTIME_STAKING_GROUP.includes(this.chain)) {
|
|
309
312
|
// todo: review all relaychains later
|
|
310
313
|
_eraStakersPromise = chainApi.api.query.staking.erasStakersOverview.entries(parseInt(currentEra));
|
|
311
314
|
} else {
|
|
@@ -346,7 +349,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
346
349
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
347
350
|
const rawValidatorInfo = item[0].toHuman();
|
|
348
351
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
349
|
-
const rawValidatorStat = item[1].
|
|
352
|
+
const rawValidatorStat = item[1].toPrimitive();
|
|
350
353
|
const validatorAddress = rawValidatorInfo[1];
|
|
351
354
|
if (!blockValidatorList.includes(validatorAddress)) {
|
|
352
355
|
var _validatorPointsMap$v;
|
|
@@ -354,16 +357,20 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
354
357
|
if (topValidatorList.includes(validatorAddress)) {
|
|
355
358
|
isTopQuartile = true;
|
|
356
359
|
}
|
|
357
|
-
const
|
|
358
|
-
const
|
|
359
|
-
const bnTotalStake = new _util.BN(rawTotalStake.replaceAll(',', ''));
|
|
360
|
-
const bnOwnStake = new _util.BN(rawOwnStake.replaceAll(',', ''));
|
|
360
|
+
const bnTotalStake = new _util.BN(rawValidatorStat.total);
|
|
361
|
+
const bnOwnStake = new _util.BN(rawValidatorStat.own);
|
|
361
362
|
const otherStake = bnTotalStake.sub(bnOwnStake);
|
|
362
363
|
totalStakeMap[validatorAddress] = bnTotalStake;
|
|
363
364
|
let nominatorCount = 0;
|
|
364
|
-
if (
|
|
365
|
-
|
|
366
|
-
|
|
365
|
+
if (_constants2._UPDATED_RUNTIME_STAKING_GROUP.includes(this.chain)) {
|
|
366
|
+
nominatorCount = rawValidatorStat.nominatorCount;
|
|
367
|
+
} else {
|
|
368
|
+
if ('others' in rawValidatorStat) {
|
|
369
|
+
// todo: handle interfaces and types better
|
|
370
|
+
// @ts-ignore
|
|
371
|
+
const others = rawValidatorStat.others;
|
|
372
|
+
nominatorCount = others.length;
|
|
373
|
+
}
|
|
367
374
|
}
|
|
368
375
|
allValidators.push(validatorAddress);
|
|
369
376
|
validatorInfoList.push({
|
|
@@ -10,6 +10,7 @@ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
|
10
10
|
var _utils = require("@subwallet/extension-base/koni/api/staking/bonding/utils");
|
|
11
11
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
12
12
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
13
|
+
var _constants2 = require("@subwallet/extension-base/services/earning-service/constants");
|
|
13
14
|
var _types = require("@subwallet/extension-base/types");
|
|
14
15
|
var _utils3 = require("@subwallet/extension-base/utils");
|
|
15
16
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
@@ -91,7 +92,8 @@ class NominationPoolHandler extends _base.default {
|
|
|
91
92
|
|
|
92
93
|
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras), parseInt(currentEra) / erasPerDay);
|
|
93
94
|
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
94
|
-
const [_EraStakeInfo, _totalIssuance, _auctionCounter, _minPoolJoin, ..._eraReward] = await Promise.all([substrateApi.api.query.staking.erasTotalStake.multi([parseInt(currentEra), parseInt(currentEra) - 1]), substrateApi.api.query.balances.totalIssuance(), (_substrateApi$api$
|
|
95
|
+
const [_maxPoolMember, _EraStakeInfo, _totalIssuance, _auctionCounter, _minPoolJoin, ..._eraReward] = await Promise.all([(_substrateApi$api$que2 = substrateApi.api.query.nominationPools) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.maxPoolMembersPerPool(), substrateApi.api.query.staking.erasTotalStake.multi([parseInt(currentEra), parseInt(currentEra) - 1]), substrateApi.api.query.balances.totalIssuance(), (_substrateApi$api$que3 = substrateApi.api.query.auctions) === null || _substrateApi$api$que3 === void 0 ? void 0 : _substrateApi$api$que3.auctionCounter(), (_substrateApi$api$que4 = substrateApi.api.query.nominationPools) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.minJoinBond(), substrateApi.api.query.staking.erasValidatorReward.multi([...Array(supportedDays).keys()].map(i => i + startEra))]);
|
|
96
|
+
const maxPoolMembers = _maxPoolMember ? parseInt(_maxPoolMember.toString()) : undefined;
|
|
95
97
|
const [_totalEraStake, _lastTotalStaked] = _EraStakeInfo;
|
|
96
98
|
const validatorEraReward = (0, _utils.getAvgValidatorEraReward)(supportedDays, _eraReward[0]);
|
|
97
99
|
const lastTotalStaked = _lastTotalStaked.toString();
|
|
@@ -137,7 +139,8 @@ class NominationPoolHandler extends _base.default {
|
|
|
137
139
|
// TODO recheck
|
|
138
140
|
unstakingPeriod: unlockingPeriod,
|
|
139
141
|
inflation: inflation
|
|
140
|
-
}
|
|
142
|
+
},
|
|
143
|
+
maxPoolMembers: maxPoolMembers || undefined
|
|
141
144
|
};
|
|
142
145
|
callback(data);
|
|
143
146
|
}));
|
|
@@ -167,7 +170,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
167
170
|
const validatorList = nominations.targets;
|
|
168
171
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
169
172
|
let eraStakerOtherList = [];
|
|
170
|
-
if (
|
|
173
|
+
if (_constants2._UPDATED_RUNTIME_STAKING_GROUP.includes(this.chain)) {
|
|
171
174
|
// todo: review all relaychains later
|
|
172
175
|
const _eraStaker = await substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress);
|
|
173
176
|
eraStakerOtherList = _eraStaker.flatMap(paged => paged[1].toPrimitive().others);
|
|
@@ -327,13 +330,13 @@ class NominationPoolHandler extends _base.default {
|
|
|
327
330
|
const nominationPools = [];
|
|
328
331
|
const _allPoolsInfo = await substrateApi.api.query.nominationPools.reversePoolIdLookup.entries();
|
|
329
332
|
await Promise.all(_allPoolsInfo.map(async _poolInfo => {
|
|
330
|
-
var _bondedPool$points;
|
|
333
|
+
var _substrateApi$api$que7, _bondedPool$points;
|
|
331
334
|
const poolAddressList = _poolInfo[0].toHuman();
|
|
332
335
|
const poolAddress = poolAddressList[0];
|
|
333
336
|
const poolId = _poolInfo[1].toPrimitive();
|
|
334
337
|
const poolsPalletId = substrateApi.api.consts.nominationPools.palletId.toString();
|
|
335
338
|
const poolStashAccount = (0, _utils.parsePoolStashAddress)(substrateApi.api, 0, poolId, poolsPalletId);
|
|
336
|
-
const [_nominations, _bondedPool, _metadata, _minimumActiveStake] = await Promise.all([substrateApi.api.query.staking.nominators(poolStashAccount), substrateApi.api.query.nominationPools.bondedPools(poolId), substrateApi.api.query.nominationPools.metadata(poolId), substrateApi.api.query.staking.minimumActiveStake()]);
|
|
339
|
+
const [_nominations, _bondedPool, _metadata, _minimumActiveStake, _maxPoolMembers] = await Promise.all([substrateApi.api.query.staking.nominators(poolStashAccount), substrateApi.api.query.nominationPools.bondedPools(poolId), substrateApi.api.query.nominationPools.metadata(poolId), substrateApi.api.query.staking.minimumActiveStake(), (_substrateApi$api$que7 = substrateApi.api.query.nominationPools) === null || _substrateApi$api$que7 === void 0 ? void 0 : _substrateApi$api$que7.maxPoolMembersPerPool()]);
|
|
337
340
|
const minimumActiveStake = _minimumActiveStake.toPrimitive();
|
|
338
341
|
const nominations = _nominations.toJSON();
|
|
339
342
|
const poolMetadata = _metadata.toPrimitive();
|
|
@@ -342,6 +345,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
342
345
|
const isPoolOpen = bondedPool.state === 'Open';
|
|
343
346
|
const isPoolNominating = !!nominations && nominations.targets.length > 0;
|
|
344
347
|
const isPoolEarningReward = bondedPool.points > minimumActiveStake;
|
|
348
|
+
const maxPoolMembers = _maxPoolMembers ? parseInt(_maxPoolMembers.toString()) : undefined;
|
|
345
349
|
nominationPools.push({
|
|
346
350
|
id: poolId,
|
|
347
351
|
address: poolAddress,
|
|
@@ -350,7 +354,8 @@ class NominationPoolHandler extends _base.default {
|
|
|
350
354
|
roles: bondedPool.roles,
|
|
351
355
|
memberCounter: bondedPool.memberCounter,
|
|
352
356
|
state: bondedPool.state,
|
|
353
|
-
isProfitable: isPoolOpen && isPoolNominating && isPoolEarningReward
|
|
357
|
+
isProfitable: isPoolOpen && isPoolNominating && isPoolEarningReward,
|
|
358
|
+
isCrowded: maxPoolMembers ? bondedPool.memberCounter >= maxPoolMembers : false
|
|
354
359
|
});
|
|
355
360
|
}));
|
|
356
361
|
return nominationPools;
|
|
@@ -40,7 +40,7 @@ class EarningService {
|
|
|
40
40
|
yieldPositionSubject = new _rxjs.BehaviorSubject({});
|
|
41
41
|
yieldPositionListSubject = new _rxjs.BehaviorSubject([]); // virtual list of yieldPositionSubject with filter values
|
|
42
42
|
|
|
43
|
-
useOnlineCacheOnly =
|
|
43
|
+
useOnlineCacheOnly = false;
|
|
44
44
|
constructor(state) {
|
|
45
45
|
this.state = state;
|
|
46
46
|
this.dbService = state.dbService;
|
|
@@ -65,7 +65,7 @@ async function parseIdentity(substrateApi, address, children) {
|
|
|
65
65
|
if (substrateApi.api.query.identity) {
|
|
66
66
|
let identity;
|
|
67
67
|
const _parent = await substrateApi.api.query.identity.superOf(address);
|
|
68
|
-
const parentInfo = _parent.toHuman();
|
|
68
|
+
const parentInfo = _parent === null || _parent === void 0 ? void 0 : _parent.toHuman();
|
|
69
69
|
if (parentInfo) {
|
|
70
70
|
const [parentAddress, {
|
|
71
71
|
Raw: data
|
|
@@ -78,8 +78,16 @@ async function parseIdentity(substrateApi, address, children) {
|
|
|
78
78
|
return [compactResult(rs), isReasonable];
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
+
let identityInfo;
|
|
81
82
|
const _identity = await substrateApi.api.query.identity.identityOf(address);
|
|
82
|
-
const
|
|
83
|
+
const identityOfMetadata = substrateApi.api.query.identity.identityOf.creator.meta;
|
|
84
|
+
const identityOfReturnType = substrateApi.api.registry.lookup.getName(identityOfMetadata.type.asMap.value);
|
|
85
|
+
if (identityOfReturnType === 'PalletIdentityRegistration') {
|
|
86
|
+
identityInfo = _identity.toHuman();
|
|
87
|
+
} else {
|
|
88
|
+
const _identityInfo = _identity === null || _identity === void 0 ? void 0 : _identity.toHuman();
|
|
89
|
+
identityInfo = _identityInfo ? _identityInfo[0] : undefined;
|
|
90
|
+
}
|
|
83
91
|
if (identityInfo) {
|
|
84
92
|
var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t, _identityInfo$judgeme;
|
|
85
93
|
const displayName = (_identityInfo$info = identityInfo.info) === null || _identityInfo$info === void 0 ? void 0 : (_identityInfo$info$di = _identityInfo$info.display) === null || _identityInfo$info$di === void 0 ? void 0 : _identityInfo$info$di.Raw;
|
|
@@ -68,17 +68,25 @@ class PriceService {
|
|
|
68
68
|
})();
|
|
69
69
|
}
|
|
70
70
|
async calculatePriceMap() {
|
|
71
|
-
const
|
|
71
|
+
const {
|
|
72
|
+
price24hMap,
|
|
73
|
+
priceMap
|
|
74
|
+
} = this.rawPriceSubject.value;
|
|
72
75
|
const exchangeRateData = this.rawExchangeRateMap.value;
|
|
73
76
|
const currencyKey = this.currency.value;
|
|
74
|
-
if (Object.keys(
|
|
77
|
+
if (Object.keys(this.rawPriceSubject.value).length === 0) {
|
|
75
78
|
return;
|
|
76
79
|
}
|
|
77
80
|
if (Object.keys(exchangeRateData).length === 0) {
|
|
78
81
|
return;
|
|
79
82
|
}
|
|
80
83
|
const finalPriceMap = {
|
|
81
|
-
|
|
84
|
+
priceMap: {
|
|
85
|
+
...priceMap
|
|
86
|
+
},
|
|
87
|
+
price24hMap: {
|
|
88
|
+
...price24hMap
|
|
89
|
+
},
|
|
82
90
|
currency: currencyKey,
|
|
83
91
|
exchangeRateMap: exchangeRateData,
|
|
84
92
|
currencyData: _staticData.staticData[_staticData.StaticKey.CURRENCY_SYMBOL][currencyKey || DEFAULT_CURRENCY]
|
|
@@ -87,8 +95,8 @@ class PriceService {
|
|
|
87
95
|
return finalPriceMap;
|
|
88
96
|
}
|
|
89
97
|
Object.keys(finalPriceMap.price24hMap).forEach(key => {
|
|
90
|
-
finalPriceMap.price24hMap[key]
|
|
91
|
-
finalPriceMap.priceMap[key]
|
|
98
|
+
finalPriceMap.price24hMap[key] *= exchangeRateData[currencyKey].exchange;
|
|
99
|
+
finalPriceMap.priceMap[key] *= exchangeRateData[currencyKey].exchange;
|
|
92
100
|
});
|
|
93
101
|
await this.dbService.updatePriceStore(finalPriceMap);
|
|
94
102
|
return finalPriceMap;
|
|
@@ -119,7 +127,7 @@ class PriceService {
|
|
|
119
127
|
this.priceIds = priceIds || this.getPriceIds();
|
|
120
128
|
|
|
121
129
|
// Update for tokens price
|
|
122
|
-
this.getTokenPrice(this.priceIds,
|
|
130
|
+
this.getTokenPrice(this.priceIds, DEFAULT_CURRENCY).then(() => {
|
|
123
131
|
this.refreshPriceMapByAction();
|
|
124
132
|
}).catch(e => {
|
|
125
133
|
console.error(e);
|
package/constants/staking.d.ts
CHANGED
package/constants/staking.js
CHANGED
|
@@ -8,4 +8,11 @@ export const PREDEFINED_STAKING_POOL = {
|
|
|
8
8
|
aleph: 82,
|
|
9
9
|
availTuringTest: 11
|
|
10
10
|
};
|
|
11
|
+
export const PREDEFINED_EARNING_POOL = {
|
|
12
|
+
polkadot: [39],
|
|
13
|
+
kusama: [80],
|
|
14
|
+
vara_network: [62, 29, 50],
|
|
15
|
+
aleph: [82],
|
|
16
|
+
availTuringTest: [11]
|
|
17
|
+
};
|
|
11
18
|
export const MAX_NOMINATIONS = '16';
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.62-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -625,11 +625,6 @@
|
|
|
625
625
|
"require": "./cjs/services/chain-service/handler/AbstractChainHandler.js",
|
|
626
626
|
"default": "./services/chain-service/handler/AbstractChainHandler.js"
|
|
627
627
|
},
|
|
628
|
-
"./services/chain-service/handler/chain-spec/goldberg": {
|
|
629
|
-
"types": "./services/chain-service/handler/chain-spec/goldberg.d.ts",
|
|
630
|
-
"require": "./cjs/services/chain-service/handler/chain-spec/goldberg.js",
|
|
631
|
-
"default": "./services/chain-service/handler/chain-spec/goldberg.js"
|
|
632
|
-
},
|
|
633
628
|
"./services/chain-service/handler/EvmApi": {
|
|
634
629
|
"types": "./services/chain-service/handler/EvmApi.d.ts",
|
|
635
630
|
"require": "./cjs/services/chain-service/handler/EvmApi.js",
|
|
@@ -1874,17 +1869,17 @@
|
|
|
1874
1869
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1875
1870
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1876
1871
|
"@substrate/connect": "^0.8.9",
|
|
1877
|
-
"@subwallet/chain-list": "0.2.
|
|
1878
|
-
"@subwallet/extension-base": "^1.1.
|
|
1879
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1880
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1881
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1872
|
+
"@subwallet/chain-list": "0.2.59",
|
|
1873
|
+
"@subwallet/extension-base": "^1.1.62-0",
|
|
1874
|
+
"@subwallet/extension-chains": "^1.1.62-0",
|
|
1875
|
+
"@subwallet/extension-dapp": "^1.1.62-0",
|
|
1876
|
+
"@subwallet/extension-inject": "^1.1.62-0",
|
|
1882
1877
|
"@subwallet/keyring": "^0.1.5",
|
|
1883
1878
|
"@subwallet/ui-keyring": "^0.1.5",
|
|
1884
1879
|
"@walletconnect/sign-client": "^2.8.4",
|
|
1885
1880
|
"@walletconnect/types": "^2.8.4",
|
|
1886
1881
|
"@walletconnect/utils": "^2.8.4",
|
|
1887
|
-
"avail-js-sdk": "^0.2.
|
|
1882
|
+
"avail-js-sdk": "^0.2.12",
|
|
1888
1883
|
"axios": "^1.6.2",
|
|
1889
1884
|
"bignumber.js": "^9.1.1",
|
|
1890
1885
|
"bn.js": "^5.2.1",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.1.
|
|
10
|
+
version: '1.1.62-0'
|
|
11
11
|
};
|
|
@@ -10,7 +10,7 @@ export const API_MAX_RETRY = 2;
|
|
|
10
10
|
export const _API_OPTIONS_CHAIN_GROUP = {
|
|
11
11
|
acala: ['acala', 'karura', 'origintrail', 'kintsugi'],
|
|
12
12
|
turing: ['turingStaging', 'turing'],
|
|
13
|
-
avail: ['kate', 'availTuringTest'],
|
|
13
|
+
avail: ['kate', 'availTuringTest', 'avail_mainnet'],
|
|
14
14
|
goldberg: ['goldberg_testnet']
|
|
15
15
|
};
|
|
16
16
|
export const _PREDEFINED_SINGLE_MODES = {
|
|
@@ -91,7 +91,9 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
91
91
|
krest_network: 4,
|
|
92
92
|
polimec: 6,
|
|
93
93
|
enjin_relaychain: 24,
|
|
94
|
-
availTuringTest: 24
|
|
94
|
+
availTuringTest: 24,
|
|
95
|
+
polkadex: 24,
|
|
96
|
+
avail_mainnet: 24
|
|
95
97
|
};
|
|
96
98
|
export const _EXPECTED_BLOCK_TIME = {
|
|
97
99
|
// in seconds
|
|
@@ -121,7 +123,8 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
121
123
|
calamari_test: 12,
|
|
122
124
|
manta_network: 12,
|
|
123
125
|
enjin_relaychain: 6,
|
|
124
|
-
availTuringTest: 20
|
|
126
|
+
availTuringTest: 20,
|
|
127
|
+
avail_mainnet: 20
|
|
125
128
|
};
|
|
126
129
|
export const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
127
130
|
moonbeam: {
|
|
@@ -9,14 +9,13 @@ import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/
|
|
|
9
9
|
import { DEFAULT_AUX } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
10
10
|
import { _ChainConnectionStatus } from '@subwallet/extension-base/services/chain-service/types';
|
|
11
11
|
import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
12
|
-
import { spec as availSpec } from 'avail-js-sdk';
|
|
12
|
+
import { goldbergRpc, goldbergTypes, spec as availSpec } from 'avail-js-sdk';
|
|
13
13
|
import { BehaviorSubject } from 'rxjs';
|
|
14
14
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
15
15
|
import { typesBundle } from '@polkadot/apps-config/api';
|
|
16
16
|
import { TypeRegistry } from '@polkadot/types/create';
|
|
17
17
|
import { formatBalance } from '@polkadot/util';
|
|
18
18
|
import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
|
|
19
|
-
import goldbergSpec from "./chain-spec/goldberg.js";
|
|
20
19
|
export class SubstrateApi {
|
|
21
20
|
useLightClient = false;
|
|
22
21
|
isApiReady = false;
|
|
@@ -93,9 +92,9 @@ export class SubstrateApi {
|
|
|
93
92
|
} else if (_API_OPTIONS_CHAIN_GROUP.goldberg.includes(this.chainSlug)) {
|
|
94
93
|
api = new ApiPromise({
|
|
95
94
|
provider,
|
|
96
|
-
rpc:
|
|
97
|
-
types:
|
|
98
|
-
signedExtensions:
|
|
95
|
+
rpc: goldbergRpc,
|
|
96
|
+
types: goldbergTypes,
|
|
97
|
+
signedExtensions: availSpec.signedExtensions,
|
|
99
98
|
noInitWarn: true
|
|
100
99
|
});
|
|
101
100
|
} else {
|
|
@@ -623,6 +623,14 @@ export class ChainService {
|
|
|
623
623
|
endpoint,
|
|
624
624
|
providerName
|
|
625
625
|
} = this.getChainCurrentProviderByKey(chainInfo.slug);
|
|
626
|
+
|
|
627
|
+
/**
|
|
628
|
+
* Disable chain if not found provider
|
|
629
|
+
* */
|
|
630
|
+
if (!endpoint && !providerName) {
|
|
631
|
+
this.disableChain(chainInfo.slug);
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
626
634
|
const onUpdateStatus = status => {
|
|
627
635
|
const slug = chainInfo.slug;
|
|
628
636
|
this.updateChainConnectionStatus(slug, status);
|
|
@@ -455,6 +455,10 @@ export function updateLatestChainInfo(currentDataMap, latestChainInfoList) {
|
|
|
455
455
|
if (currentChainInfo) {
|
|
456
456
|
needUpdate = true;
|
|
457
457
|
currentChainInfo.extraInfo = latestChainInfo.extraInfo;
|
|
458
|
+
currentChainInfo.chainStatus = latestChainInfo.chainStatus;
|
|
459
|
+
if (Object.keys(currentChainInfo.providers).length === 0) {
|
|
460
|
+
currentChainInfo.chainStatus = _ChainStatus.INACTIVE;
|
|
461
|
+
}
|
|
458
462
|
}
|
|
459
463
|
if (needUpdate) {
|
|
460
464
|
storedChainInfoList.push({
|
|
@@ -5,7 +5,7 @@ import fetch from 'cross-fetch';
|
|
|
5
5
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
6
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
7
7
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
8
|
-
const ChainListVersion = '0.2.
|
|
8
|
+
const ChainListVersion = '0.2.59';
|
|
9
9
|
export async function fetchPatchData(slug) {
|
|
10
10
|
try {
|
|
11
11
|
const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
|
|
@@ -13,6 +13,7 @@ export declare const _STAKING_CHAIN_GROUP: {
|
|
|
13
13
|
krest_network: string[];
|
|
14
14
|
manta: string[];
|
|
15
15
|
};
|
|
16
|
+
export declare const _UPDATED_RUNTIME_STAKING_GROUP: string[];
|
|
16
17
|
export declare const MaxEraRewardPointsEras = 14;
|
|
17
18
|
export declare const ST_LIQUID_TOKEN_ABI: Record<string, any>;
|
|
18
19
|
export declare const MANTA_VALIDATOR_POINTS_PER_BLOCK = 20;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export const _STAKING_CHAIN_GROUP = {
|
|
5
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet', 'availTuringTest'],
|
|
5
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet', 'availTuringTest', 'avail_mainnet'],
|
|
6
6
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari', 'manta_network', 'polimec'],
|
|
7
7
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
8
8
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum', 'krest_network'],
|
|
9
9
|
// amplitude and kilt only share some common logic
|
|
10
10
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
11
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet', 'availTuringTest'],
|
|
11
|
+
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet', 'availTuringTest', 'avail_mainnet'],
|
|
12
12
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
13
13
|
aleph: ['aleph', 'alephTest'],
|
|
14
14
|
// A0 has distinct tokenomics
|
|
@@ -18,6 +18,7 @@ export const _STAKING_CHAIN_GROUP = {
|
|
|
18
18
|
krest_network: ['krest_network'],
|
|
19
19
|
manta: ['manta_network']
|
|
20
20
|
};
|
|
21
|
+
export const _UPDATED_RUNTIME_STAKING_GROUP = ['kusama', 'polkadot', 'westend', 'availTuringTest', 'avail_mainnet'];
|
|
21
22
|
export const MaxEraRewardPointsEras = 14;
|
|
22
23
|
|
|
23
24
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
@@ -9,6 +9,8 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
9
9
|
parseNominatorMetadata(chainInfo: _ChainInfo, address: string, substrateApi: _SubstrateApi, delegatorState: ParachainStakingStakeOption[], unstakingInfo: Record<string, number>): Promise<Omit<YieldPositionInfo, keyof BaseYieldPositionInfo>>;
|
|
10
10
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
11
11
|
getPoolReward(useAddresses: string[], callBack: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
|
|
12
|
+
getKrestPoolTargets(chainApi: _SubstrateApi): Promise<ValidatorInfo[]>;
|
|
13
|
+
getOtherPoolTargets(chainApi: _SubstrateApi): Promise<ValidatorInfo[]>;
|
|
12
14
|
getPoolTargets(): Promise<ValidatorInfo[]>;
|
|
13
15
|
get defaultSubmitStep(): YieldStepBaseInfo;
|
|
14
16
|
createJoinExtrinsic(data: SubmitJoinNativeStaking, positionInfo?: YieldPositionInfo, bondDest?: string): Promise<[TransactionData, YieldTokenBaseInfo]>;
|
|
@@ -38,6 +38,7 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
38
38
|
await defaultCallback();
|
|
39
39
|
const substrateApi = await this.substrateApi.isReady;
|
|
40
40
|
const unsub = await substrateApi.api.query.parachainStaking.round(async _round => {
|
|
41
|
+
var _substrateApi$api$con;
|
|
41
42
|
if (cancel) {
|
|
42
43
|
unsub();
|
|
43
44
|
return;
|
|
@@ -49,6 +50,7 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
49
50
|
const unstakingDelay = substrateApi.api.consts.parachainStaking.stakeDuration.toString(); // in blocks
|
|
50
51
|
const _blockPerRound = substrateApi.api.consts.parachainStaking.defaultBlocksPerRound.toString();
|
|
51
52
|
const maxUnstakeRequests = substrateApi.api.consts.parachainStaking.maxUnstakeRequests.toPrimitive();
|
|
53
|
+
const maxDelegatorsPerCollator = (_substrateApi$api$con = substrateApi.api.consts.parachainStaking.maxDelegatorsPerCollator) === null || _substrateApi$api$con === void 0 ? void 0 : _substrateApi$api$con.toString();
|
|
52
54
|
const blockPerRound = parseFloat(_blockPerRound);
|
|
53
55
|
const roundTime = _STAKING_ERA_LENGTH_MAP[this.chain] || _STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
54
56
|
const blockDuration = roundTime / blockPerRound; // in hours
|
|
@@ -85,7 +87,8 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
85
87
|
totalApy: undefined,
|
|
86
88
|
// TODO recheck
|
|
87
89
|
unstakingPeriod
|
|
88
|
-
}
|
|
90
|
+
},
|
|
91
|
+
maxPoolMembers: maxDelegatorsPerCollator ? parseInt(maxDelegatorsPerCollator) : undefined
|
|
89
92
|
};
|
|
90
93
|
callback(data);
|
|
91
94
|
});
|
|
@@ -259,60 +262,97 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
259
262
|
|
|
260
263
|
/* Get pool targets */
|
|
261
264
|
|
|
265
|
+
async getKrestPoolTargets(chainApi) {
|
|
266
|
+
var _chainApi$api$consts$;
|
|
267
|
+
const _allCollators = await chainApi.api.query.parachainStaking.candidatePool.entries();
|
|
268
|
+
const minDelegatorStake = chainApi.api.consts.parachainStaking.minDelegatorStake.toString();
|
|
269
|
+
const maxDelegatorsPerCollator = (_chainApi$api$consts$ = chainApi.api.consts.parachainStaking.maxDelegatorsPerCollator) === null || _chainApi$api$consts$ === void 0 ? void 0 : _chainApi$api$consts$.toString();
|
|
270
|
+
const identityPromises = _allCollators.map(collator => {
|
|
271
|
+
const collatorInfo = collator[1].toPrimitive();
|
|
272
|
+
const address = collatorInfo.id;
|
|
273
|
+
return parseIdentity(chainApi, address);
|
|
274
|
+
});
|
|
275
|
+
const identities = await Promise.all(identityPromises);
|
|
276
|
+
return _allCollators.map((_collator, i) => {
|
|
277
|
+
const [identity] = identities[i];
|
|
278
|
+
const collatorInfo = _collator[1].toPrimitive();
|
|
279
|
+
const bnTotalStake = new BN(collatorInfo.total);
|
|
280
|
+
const bnOwnStake = new BN(collatorInfo.stake);
|
|
281
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
282
|
+
const isFullDelegatorsSet = collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator);
|
|
283
|
+
let minDelegate = new BN(minDelegatorStake);
|
|
284
|
+
if (isFullDelegatorsSet) {
|
|
285
|
+
const delegatorAmounts = collatorInfo.delegators.map(delegator => new BN(delegator.amount));
|
|
286
|
+
const sortedAmounts = delegatorAmounts.sort((a, b) => a.cmp(b));
|
|
287
|
+
const minDelegateInSet = sortedAmounts[0];
|
|
288
|
+
minDelegate = minDelegate.lt(minDelegateInSet) ? minDelegateInSet : minDelegate;
|
|
289
|
+
}
|
|
290
|
+
return {
|
|
291
|
+
address: collatorInfo.id,
|
|
292
|
+
totalStake: bnTotalStake.toString(),
|
|
293
|
+
ownStake: bnOwnStake.toString(),
|
|
294
|
+
otherStake: bnOtherStake.toString(),
|
|
295
|
+
nominatorCount: collatorInfo.delegators.length,
|
|
296
|
+
commission: 0,
|
|
297
|
+
blocked: false,
|
|
298
|
+
isVerified: false,
|
|
299
|
+
minBond: minDelegate.toString(),
|
|
300
|
+
chain: this.chain,
|
|
301
|
+
isCrowded: isFullDelegatorsSet,
|
|
302
|
+
identity
|
|
303
|
+
};
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
async getOtherPoolTargets(chainApi) {
|
|
307
|
+
const [_allCollators, _inflationConfig] = await Promise.all([chainApi.api.query.parachainStaking.candidatePool.entries(), chainApi.api.query.parachainStaking.inflationConfig()]);
|
|
308
|
+
const minDelegatorStake = chainApi.api.consts.parachainStaking.minDelegatorStake.toString();
|
|
309
|
+
const maxDelegatorsPerCollator = chainApi.api.consts.parachainStaking.maxDelegatorsPerCollator.toString();
|
|
310
|
+
const inflationConfig = _inflationConfig.toHuman();
|
|
311
|
+
const rawDelegatorReturn = inflationConfig.delegator.rewardRate.annual;
|
|
312
|
+
const delegatorReturn = parseFloat(rawDelegatorReturn.split('%')[0]);
|
|
313
|
+
const identityPromises = _allCollators.map(collator => {
|
|
314
|
+
const collatorInfo = collator[1].toPrimitive();
|
|
315
|
+
const address = collatorInfo.id;
|
|
316
|
+
return parseIdentity(chainApi, address);
|
|
317
|
+
});
|
|
318
|
+
const identities = await Promise.all(identityPromises);
|
|
319
|
+
return _allCollators.map((_collator, i) => {
|
|
320
|
+
const [identity] = identities[i];
|
|
321
|
+
const collatorInfo = _collator[1].toPrimitive();
|
|
322
|
+
const bnTotalStake = new BN(collatorInfo.total);
|
|
323
|
+
const bnOwnStake = new BN(collatorInfo.stake);
|
|
324
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
325
|
+
const isFullDelegatorsSet = collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator);
|
|
326
|
+
let minDelegate = new BN(minDelegatorStake);
|
|
327
|
+
if (isFullDelegatorsSet) {
|
|
328
|
+
const delegatorAmounts = collatorInfo.delegators.map(delegator => new BN(delegator.amount));
|
|
329
|
+
const sortedAmounts = delegatorAmounts.sort((a, b) => a.cmp(b));
|
|
330
|
+
const minDelegateInSet = sortedAmounts[0];
|
|
331
|
+
minDelegate = minDelegate.lt(minDelegateInSet) ? minDelegateInSet : minDelegate;
|
|
332
|
+
}
|
|
333
|
+
return {
|
|
334
|
+
address: collatorInfo.id,
|
|
335
|
+
totalStake: bnTotalStake.toString(),
|
|
336
|
+
ownStake: bnOwnStake.toString(),
|
|
337
|
+
otherStake: bnOtherStake.toString(),
|
|
338
|
+
nominatorCount: collatorInfo.delegators.length,
|
|
339
|
+
commission: 0,
|
|
340
|
+
expectedReturn: delegatorReturn,
|
|
341
|
+
blocked: false,
|
|
342
|
+
isVerified: false,
|
|
343
|
+
minBond: minDelegate.toString(),
|
|
344
|
+
chain: this.chain,
|
|
345
|
+
isCrowded: isFullDelegatorsSet,
|
|
346
|
+
identity
|
|
347
|
+
};
|
|
348
|
+
});
|
|
349
|
+
}
|
|
262
350
|
async getPoolTargets() {
|
|
263
351
|
const chainApi = await this.substrateApi.isReady;
|
|
264
352
|
if (_STAKING_CHAIN_GROUP.krest_network.includes(this.chain)) {
|
|
265
|
-
|
|
266
|
-
const maxDelegatorsPerCollator = chainApi.api.consts.parachainStaking.maxDelegatorsPerCollator.toString();
|
|
267
|
-
const allCollators = [];
|
|
268
|
-
for (const _collator of _allCollators) {
|
|
269
|
-
const collatorInfo = _collator[1].toPrimitive();
|
|
270
|
-
const bnTotalStake = new BN(collatorInfo.total);
|
|
271
|
-
const bnOwnStake = new BN(collatorInfo.stake);
|
|
272
|
-
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
273
|
-
allCollators.push({
|
|
274
|
-
address: collatorInfo.id,
|
|
275
|
-
totalStake: bnTotalStake.toString(),
|
|
276
|
-
ownStake: bnOwnStake.toString(),
|
|
277
|
-
otherStake: bnOtherStake.toString(),
|
|
278
|
-
nominatorCount: collatorInfo.delegators.length,
|
|
279
|
-
commission: 0,
|
|
280
|
-
blocked: false,
|
|
281
|
-
isVerified: false,
|
|
282
|
-
minBond: '0',
|
|
283
|
-
chain: this.chain,
|
|
284
|
-
isCrowded: collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator)
|
|
285
|
-
});
|
|
286
|
-
}
|
|
287
|
-
return allCollators;
|
|
353
|
+
return this.getKrestPoolTargets(chainApi);
|
|
288
354
|
} else {
|
|
289
|
-
|
|
290
|
-
const maxDelegatorsPerCollator = chainApi.api.consts.parachainStaking.maxDelegatorsPerCollator.toString();
|
|
291
|
-
const inflationConfig = _inflationConfig.toHuman();
|
|
292
|
-
const rawDelegatorReturn = inflationConfig.delegator.rewardRate.annual;
|
|
293
|
-
const delegatorReturn = parseFloat(rawDelegatorReturn.split('%')[0]);
|
|
294
|
-
const allCollators = [];
|
|
295
|
-
for (const _collator of _allCollators) {
|
|
296
|
-
const collatorInfo = _collator[1].toPrimitive();
|
|
297
|
-
const bnTotalStake = new BN(collatorInfo.total);
|
|
298
|
-
const bnOwnStake = new BN(collatorInfo.stake);
|
|
299
|
-
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
300
|
-
allCollators.push({
|
|
301
|
-
address: collatorInfo.id,
|
|
302
|
-
totalStake: bnTotalStake.toString(),
|
|
303
|
-
ownStake: bnOwnStake.toString(),
|
|
304
|
-
otherStake: bnOtherStake.toString(),
|
|
305
|
-
nominatorCount: collatorInfo.delegators.length,
|
|
306
|
-
commission: 0,
|
|
307
|
-
expectedReturn: delegatorReturn,
|
|
308
|
-
blocked: false,
|
|
309
|
-
isVerified: false,
|
|
310
|
-
minBond: '0',
|
|
311
|
-
chain: this.chain,
|
|
312
|
-
isCrowded: collatorInfo.delegators.length >= parseInt(maxDelegatorsPerCollator)
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
return allCollators;
|
|
355
|
+
return this.getOtherPoolTargets(chainApi);
|
|
316
356
|
}
|
|
317
357
|
}
|
|
318
358
|
|