@subwallet/extension-base 1.1.40-1 → 1.1.42-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/background/KoniTypes.d.ts +3 -1
- package/cjs/constants/index.js +1 -1
- package/cjs/koni/api/dotsama/transfer.js +1 -1
- package/cjs/koni/api/nft/bit.country/index.js +2 -0
- package/cjs/koni/api/nft/config.js +3 -1
- package/cjs/koni/api/tokens/evm/transfer.js +4 -4
- package/cjs/koni/background/handlers/Extension.js +32 -17
- package/cjs/koni/background/handlers/State.js +42 -10
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/SubWalleEvmProvider.js +5 -9
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +58 -0
- package/cjs/services/chain-service/constants.js +11 -7
- package/cjs/services/chain-service/handler/chain-spec/goldberg.js +75 -8
- package/cjs/services/chain-service/index.js +88 -79
- package/cjs/services/chain-service/utils.js +11 -6
- package/cjs/services/earning-service/constants/chains.js +10 -5
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +9 -3
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +8 -1
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +6 -1
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +25 -17
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +4 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +6 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +144 -45
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +14 -16
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +9 -11
- package/cjs/services/earning-service/handlers/special.js +2 -0
- package/cjs/services/earning-service/service.js +51 -18
- package/cjs/services/fee-service/service.js +70 -0
- package/cjs/services/fee-service/utils/index.js +209 -0
- package/cjs/services/migration-service/scripts/DeleteChainStaking.js +23 -0
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting.js +50 -0
- package/cjs/services/migration-service/scripts/index.js +6 -1
- package/cjs/services/transaction-service/index.js +37 -37
- package/cjs/types/fee/index.js +1 -0
- package/cjs/types/index.js +11 -0
- package/cjs/utils/eth.js +2 -105
- package/cjs/utils/index.js +12 -0
- package/cjs/utils/reportError.js +31 -0
- package/constants/index.d.ts +1 -1
- package/constants/index.js +1 -1
- package/koni/api/dotsama/transfer.js +1 -1
- package/koni/api/nft/bit.country/index.js +3 -1
- package/koni/api/nft/config.d.ts +1 -0
- package/koni/api/nft/config.js +1 -0
- package/koni/api/tokens/evm/transfer.js +1 -1
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +18 -3
- package/koni/background/handlers/State.d.ts +4 -1
- package/koni/background/handlers/State.js +33 -2
- package/package.json +36 -6
- package/packageInfo.js +1 -1
- package/page/SubWalleEvmProvider.d.ts +0 -1
- package/page/SubWalleEvmProvider.js +5 -9
- package/services/balance-service/helpers/subscribe/substrate/index.js +59 -1
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +11 -7
- package/services/chain-service/handler/chain-spec/goldberg.d.ts +70 -1
- package/services/chain-service/handler/chain-spec/goldberg.js +75 -8
- package/services/chain-service/index.d.ts +8 -4
- package/services/chain-service/index.js +74 -67
- package/services/chain-service/types.d.ts +4 -0
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +10 -6
- package/services/earning-service/constants/chains.d.ts +3 -0
- package/services/earning-service/constants/chains.js +7 -4
- package/services/earning-service/handlers/liquid-staking/acala.js +9 -3
- package/services/earning-service/handlers/liquid-staking/bifrost.js +8 -1
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +1 -1
- package/services/earning-service/handlers/liquid-staking/parallel.js +6 -1
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +25 -17
- package/services/earning-service/handlers/native-staking/amplitude.js +4 -0
- package/services/earning-service/handlers/native-staking/astar.js +6 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +144 -45
- package/services/earning-service/handlers/native-staking/relay-chain.js +15 -17
- package/services/earning-service/handlers/nomination-pool/index.js +10 -12
- package/services/earning-service/handlers/special.d.ts +1 -0
- package/services/earning-service/handlers/special.js +2 -0
- package/services/earning-service/service.d.ts +4 -1
- package/services/earning-service/service.js +52 -19
- package/services/fee-service/service.d.ts +12 -0
- package/services/fee-service/service.js +63 -0
- package/services/fee-service/utils/index.d.ts +8 -0
- package/services/fee-service/utils/index.js +193 -0
- package/services/migration-service/scripts/DeleteChainStaking.d.ts +4 -0
- package/services/migration-service/scripts/DeleteChainStaking.js +15 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting.js +42 -0
- package/services/migration-service/scripts/index.js +5 -1
- package/services/transaction-service/index.js +2 -2
- package/types/fee/index.d.ts +49 -0
- package/types/fee/index.js +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/yield/info/account/unstake.d.ts +2 -0
- package/types/yield/info/pallet.d.ts +4 -0
- package/utils/eth.d.ts +0 -15
- package/utils/eth.js +0 -101
- package/utils/index.d.ts +1 -0
- package/utils/index.js +1 -0
- package/utils/reportError.d.ts +1 -0
- package/utils/reportError.js +23 -0
|
@@ -5,8 +5,8 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
5
5
|
import { BasicTxErrorType, ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { getERC20Contract } from '@subwallet/extension-base/koni/api/tokens/evm/web3';
|
|
7
7
|
import { _getAssetDecimals, _getContractAddressOfToken } from '@subwallet/extension-base/services/chain-service/utils';
|
|
8
|
+
import { calculateGasFeeParams } from '@subwallet/extension-base/services/fee-service/utils';
|
|
8
9
|
import { EarningStatus, UnstakingStatus, YieldStepType } from '@subwallet/extension-base/types';
|
|
9
|
-
import { recalculateGasPrice } from '@subwallet/extension-base/utils/eth';
|
|
10
10
|
import fetch from 'cross-fetch';
|
|
11
11
|
import { BN, BN_TEN, BN_ZERO } from '@polkadot/util';
|
|
12
12
|
import { ST_LIQUID_TOKEN_ABI } from "../../constants/index.js";
|
|
@@ -248,6 +248,7 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
248
248
|
return Promise.resolve([]);
|
|
249
249
|
}
|
|
250
250
|
async handleTokenApproveStep(data, path) {
|
|
251
|
+
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
251
252
|
const {
|
|
252
253
|
address
|
|
253
254
|
} = data;
|
|
@@ -266,14 +267,15 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
266
267
|
const gasLimit = await approveCall.estimateGas({
|
|
267
268
|
from: address
|
|
268
269
|
});
|
|
269
|
-
const
|
|
270
|
-
const gasPrice = recalculateGasPrice(_price, this.chain);
|
|
270
|
+
const priority = await calculateGasFeeParams(evmApi, this.chain);
|
|
271
271
|
const transactionObject = {
|
|
272
272
|
from: address,
|
|
273
273
|
to: _getContractAddressOfToken(inputTokenInfo),
|
|
274
274
|
data: approveEncodedCall,
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
gas: gasLimit,
|
|
276
|
+
gasPrice: priority.gasPrice,
|
|
277
|
+
maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
278
|
+
maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
277
279
|
};
|
|
278
280
|
const _data = {
|
|
279
281
|
inputTokenSlug: inputTokenSlug,
|
|
@@ -289,6 +291,7 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
289
291
|
});
|
|
290
292
|
}
|
|
291
293
|
async handleSubmitStep(data, path) {
|
|
294
|
+
var _priority$maxFeePerGa2, _priority$maxPriority2;
|
|
292
295
|
const {
|
|
293
296
|
address,
|
|
294
297
|
amount
|
|
@@ -307,14 +310,15 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
307
310
|
const gasLimit = await depositCall.estimateGas({
|
|
308
311
|
from: address
|
|
309
312
|
});
|
|
310
|
-
const
|
|
311
|
-
const gasPrice = recalculateGasPrice(_price, this.chain);
|
|
313
|
+
const priority = await calculateGasFeeParams(evmApi, this.chain);
|
|
312
314
|
const transactionObject = {
|
|
313
315
|
from: address,
|
|
314
316
|
to: _getContractAddressOfToken(derivativeTokenInfo),
|
|
315
317
|
data: depositEncodedCall,
|
|
316
|
-
|
|
317
|
-
|
|
318
|
+
gas: gasLimit,
|
|
319
|
+
gasPrice: priority.gasPrice,
|
|
320
|
+
maxFeePerGas: (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
|
|
321
|
+
maxPriorityFeePerGas: (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
|
|
318
322
|
};
|
|
319
323
|
return {
|
|
320
324
|
txChain: this.chain,
|
|
@@ -334,6 +338,7 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
334
338
|
return Promise.reject(new TransactionError(BasicTxErrorType.UNSUPPORTED));
|
|
335
339
|
}
|
|
336
340
|
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
341
|
+
var _priority$maxFeePerGa3, _priority$maxPriority3;
|
|
337
342
|
const evmApi = this.evmApi;
|
|
338
343
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
339
344
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
@@ -348,14 +353,15 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
348
353
|
const gasLimit = await redeemCall.estimateGas({
|
|
349
354
|
from: address
|
|
350
355
|
});
|
|
351
|
-
const
|
|
352
|
-
const gasPrice = recalculateGasPrice(_price, this.chain);
|
|
356
|
+
const priority = await calculateGasFeeParams(evmApi, this.chain);
|
|
353
357
|
const transaction = {
|
|
354
358
|
from: address,
|
|
355
359
|
to: _getContractAddressOfToken(derivativeTokenInfo),
|
|
356
360
|
data: redeemEncodedCall,
|
|
357
|
-
|
|
358
|
-
|
|
361
|
+
gas: gasLimit,
|
|
362
|
+
gasPrice: priority.gasPrice,
|
|
363
|
+
maxFeePerGas: (_priority$maxFeePerGa3 = priority.maxFeePerGas) === null || _priority$maxFeePerGa3 === void 0 ? void 0 : _priority$maxFeePerGa3.toString(),
|
|
364
|
+
maxPriorityFeePerGas: (_priority$maxPriority3 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority3 === void 0 ? void 0 : _priority$maxPriority3.toString()
|
|
359
365
|
};
|
|
360
366
|
return [ExtrinsicType.UNSTAKE_STDOT, transaction];
|
|
361
367
|
}
|
|
@@ -365,6 +371,7 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
365
371
|
/* Other actions */
|
|
366
372
|
|
|
367
373
|
async handleYieldWithdraw(address, unstakingInfo) {
|
|
374
|
+
var _priority$maxFeePerGa4, _priority$maxPriority4;
|
|
368
375
|
const evmApi = this.evmApi;
|
|
369
376
|
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
370
377
|
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
@@ -379,14 +386,15 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
379
386
|
const gasLimit = await withdrawCall.estimateGas({
|
|
380
387
|
from: address
|
|
381
388
|
});
|
|
382
|
-
const
|
|
383
|
-
const gasPrice = recalculateGasPrice(_price, this.chain);
|
|
389
|
+
const priority = await calculateGasFeeParams(evmApi, this.chain);
|
|
384
390
|
return {
|
|
385
391
|
from: address,
|
|
386
392
|
to: _getContractAddressOfToken(derivativeTokenInfo),
|
|
387
393
|
data: withdrawEncodedCall,
|
|
388
|
-
|
|
389
|
-
|
|
394
|
+
gas: gasLimit,
|
|
395
|
+
gasPrice: priority.gasPrice,
|
|
396
|
+
maxFeePerGas: (_priority$maxFeePerGa4 = priority.maxFeePerGas) === null || _priority$maxFeePerGa4 === void 0 ? void 0 : _priority$maxFeePerGa4.toString(),
|
|
397
|
+
maxPriorityFeePerGas: (_priority$maxPriority4 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority4 === void 0 ? void 0 : _priority$maxPriority4.toString()
|
|
390
398
|
}; // TODO: check tx history parsing
|
|
391
399
|
}
|
|
392
400
|
|
|
@@ -141,12 +141,16 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
141
141
|
const isClaimable = parseInt(unstakingBlock) - currentBlockNumber < 0;
|
|
142
142
|
const remainingBlock = parseInt(unstakingBlock) - currentBlockNumber;
|
|
143
143
|
const waitingTime = remainingBlock * blockDuration;
|
|
144
|
+
// const currentTimestampMs = Date.now();
|
|
145
|
+
// const targetTimestampMs = currentTimestampMs + waitingTime * 60 * 60 * 1000;
|
|
146
|
+
|
|
144
147
|
unstakingBalance = unstakingAmount.toString();
|
|
145
148
|
unstakingList.push({
|
|
146
149
|
chain: chainInfo.slug,
|
|
147
150
|
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
148
151
|
claimable: unstakingAmount.toString(),
|
|
149
152
|
waitingTime,
|
|
153
|
+
// targetTimestampMs: targetTimestampMs,
|
|
150
154
|
validatorAddress: undefined
|
|
151
155
|
});
|
|
152
156
|
}
|
|
@@ -18,8 +18,7 @@ export function getAstarWithdrawable(yieldPosition) {
|
|
|
18
18
|
const unstakingInfo = {
|
|
19
19
|
chain: yieldPosition.chain,
|
|
20
20
|
status: UnstakingStatus.CLAIMABLE,
|
|
21
|
-
claimable: '0'
|
|
22
|
-
waitingTime: 0
|
|
21
|
+
claimable: '0'
|
|
23
22
|
};
|
|
24
23
|
let bnWithdrawable = BN_ZERO;
|
|
25
24
|
for (const unstaking of yieldPosition.unstakings) {
|
|
@@ -200,14 +199,19 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
|
|
|
200
199
|
const isClaimable = unlockingChunk.unlockEra - parseInt(currentEra) < 0;
|
|
201
200
|
const remainingEra = unlockingChunk.unlockEra - parseInt(currentEra);
|
|
202
201
|
const waitingTime = remainingEra * _STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
202
|
+
// const currentTimestampMs = Date.now();
|
|
203
|
+
// const targetTimestampMs = currentTimestampMs + waitingTime * 60 * 60 * 1000;
|
|
204
|
+
|
|
203
205
|
unstakingList.push({
|
|
204
206
|
chain: chainInfo.slug,
|
|
205
207
|
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
206
208
|
claimable: unlockingChunk.amount.toString(),
|
|
207
209
|
waitingTime
|
|
210
|
+
// targetTimestampMs: targetTimestampMs
|
|
208
211
|
});
|
|
209
212
|
}
|
|
210
213
|
}
|
|
214
|
+
|
|
211
215
|
if (nominationList.length === 0 && unstakingList.length === 0) {
|
|
212
216
|
return {
|
|
213
217
|
balanceToken: this.nativeToken.slug,
|
|
@@ -5,11 +5,27 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
5
5
|
import { BasicTxErrorType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { getBondedValidators, getEarningStatusByNominations, getParaCurrentInflation, isUnstakeAll } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
7
|
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
|
+
import { _STAKING_CHAIN_GROUP, MANTA_MIN_DELEGATION, MANTA_VALIDATOR_POINTS_PER_BLOCK } from '@subwallet/extension-base/services/earning-service/constants';
|
|
8
9
|
import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
|
|
9
10
|
import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
|
|
10
11
|
import { balanceFormatter, formatNumber, parseRawNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
12
|
+
import BigN from 'bignumber.js';
|
|
11
13
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
12
14
|
import BaseParaNativeStakingPoolHandler from "./base-para.js";
|
|
15
|
+
function calculateMantaNominatorReturn(decimal, commission, totalActiveCollators, bnAnnualInflation, blocksPreviousRound, bnCollatorExpectedBlocksPerRound, bnCollatorTotalStaked, isCountCommission) {
|
|
16
|
+
const MIN_DELEGATION = new BigN(MANTA_MIN_DELEGATION);
|
|
17
|
+
const factor = new BigN(10).pow(decimal);
|
|
18
|
+
const annualInflation = bnAnnualInflation.dividedBy(factor);
|
|
19
|
+
const collatorTotalStaked = bnCollatorTotalStaked.dividedBy(factor);
|
|
20
|
+
const annualRewardsPerCollator = annualInflation.dividedBy(totalActiveCollators);
|
|
21
|
+
const adjustmentFactor = new BigN(blocksPreviousRound).dividedBy(bnCollatorExpectedBlocksPerRound);
|
|
22
|
+
const marginalReward = annualRewardsPerCollator.multipliedBy(MIN_DELEGATION).dividedBy(collatorTotalStaked.plus(MIN_DELEGATION));
|
|
23
|
+
let bnApy = new BigN(100).multipliedBy(adjustmentFactor).multipliedBy(marginalReward).dividedBy(MIN_DELEGATION);
|
|
24
|
+
if (isCountCommission) {
|
|
25
|
+
bnApy = new BigN((1 - commission) * 100).multipliedBy(adjustmentFactor).multipliedBy(marginalReward).dividedBy(MIN_DELEGATION);
|
|
26
|
+
}
|
|
27
|
+
return bnApy.toNumber();
|
|
28
|
+
}
|
|
13
29
|
export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingPoolHandler {
|
|
14
30
|
/* Subscribe pool info */
|
|
15
31
|
|
|
@@ -137,13 +153,18 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
137
153
|
const remainingEra = scheduledRequest.whenExecutable - currentRound;
|
|
138
154
|
const waitingTime = remainingEra * _STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
139
155
|
const claimable = Object.values(scheduledRequest.action)[0];
|
|
156
|
+
// const currentTimestampMs = Date.now();
|
|
157
|
+
// const targetTimestampMs = currentTimestampMs + waitingTime * 60 * 60 * 1000;
|
|
158
|
+
|
|
140
159
|
unstakingMap[delegation.owner] = {
|
|
141
160
|
chain: chainInfo.slug,
|
|
142
161
|
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
143
162
|
validatorAddress: delegation.owner,
|
|
144
163
|
claimable: claimable.toString(),
|
|
145
164
|
waitingTime
|
|
165
|
+
// targetTimestampMs: targetTimestampMs
|
|
146
166
|
};
|
|
167
|
+
|
|
147
168
|
hasUnstaking = true;
|
|
148
169
|
break; // only handle 1 scheduledRequest per collator
|
|
149
170
|
}
|
|
@@ -246,52 +267,130 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
246
267
|
async getPoolTargets() {
|
|
247
268
|
const apiProps = await this.substrateApi.isReady;
|
|
248
269
|
const allCollators = [];
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
const
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
270
|
+
if (_STAKING_CHAIN_GROUP.manta.includes(this.chain)) {
|
|
271
|
+
var _this$chainInfo$subst;
|
|
272
|
+
const DECIMAL = (_this$chainInfo$subst = this.chainInfo.substrateInfo) === null || _this$chainInfo$subst === void 0 ? void 0 : _this$chainInfo$subst.decimals;
|
|
273
|
+
const POINTS_PER_BLOCK = MANTA_VALIDATOR_POINTS_PER_BLOCK; // producing 1 block will get 20 points for validator
|
|
274
|
+
|
|
275
|
+
const [_allCollators, _collatorCommission, _allCollatorsPool, _selectedCollators, _round, _totalIssuance, _inflationConfig] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo.entries(), apiProps.api.query.parachainStaking.collatorCommission(), apiProps.api.query.parachainStaking.candidatePool(), apiProps.api.query.parachainStaking.selectedCandidates(), apiProps.api.query.parachainStaking.round(), apiProps.api.query.balances.totalIssuance(), apiProps.api.query.parachainStaking.inflationConfig()]);
|
|
276
|
+
|
|
277
|
+
// noted: Annual Inflation = Total Issuance * Annual Inflation Percent
|
|
278
|
+
const round = _round.toPrimitive();
|
|
279
|
+
const totalIssuance = _totalIssuance.toString();
|
|
280
|
+
const inflationConfig = _inflationConfig.toHuman();
|
|
281
|
+
const annualInflationPercent = parseFloat(inflationConfig.annual.ideal.slice(0, -1)) / 100;
|
|
282
|
+
const bnAnnualInflation = new BigN(totalIssuance).multipliedBy(annualInflationPercent);
|
|
283
|
+
|
|
284
|
+
// noted: allCollatorsPool -> all candidate collators; selectedCollators -> candidate collators selected in current round
|
|
285
|
+
const allCollatorsPoolInfo = _allCollatorsPool.toPrimitive();
|
|
286
|
+
const allCollatorsPool = allCollatorsPoolInfo.map(collator => collator.owner.toString());
|
|
287
|
+
const selectedCollators = _selectedCollators.toPrimitive();
|
|
288
|
+
const totalActiveCollators = selectedCollators.length;
|
|
289
|
+
const bnCollatorExpectedBlocksPerRound = new BigN(round.length).dividedBy(allCollatorsPool.length);
|
|
290
|
+
const maxDelegationPerCollator = apiProps.api.consts.parachainStaking.maxTopDelegationsPerCandidate.toString();
|
|
291
|
+
const rawCollatorCommission = _collatorCommission.toHuman();
|
|
292
|
+
const collatorCommission = parseFloat(rawCollatorCommission.split('%')[0]);
|
|
293
|
+
const collatorCommissionPercent = collatorCommission / 100;
|
|
294
|
+
for (const collator of _allCollators) {
|
|
295
|
+
const _collatorAddress = collator[0].toHuman();
|
|
296
|
+
const collatorAddress = _collatorAddress[0];
|
|
297
|
+
if (allCollatorsPool.includes(collatorAddress)) {
|
|
298
|
+
const collatorInfo = collator[1].toPrimitive();
|
|
299
|
+
const bnTotalStake = new BN(collatorInfo.totalCounted);
|
|
300
|
+
const bnOwnStake = new BN(collatorInfo.bond);
|
|
301
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
302
|
+
const bnMinBond = new BN(collatorInfo.lowestTopDelegationAmount);
|
|
303
|
+
allCollators.push({
|
|
304
|
+
commission: 0,
|
|
305
|
+
address: collatorAddress,
|
|
306
|
+
totalStake: bnTotalStake.toString(),
|
|
307
|
+
ownStake: bnOwnStake.toString(),
|
|
308
|
+
otherStake: bnOtherStake.toString(),
|
|
309
|
+
nominatorCount: collatorInfo.delegationCount,
|
|
310
|
+
blocked: false,
|
|
311
|
+
isVerified: false,
|
|
312
|
+
minBond: bnMinBond.toString(),
|
|
313
|
+
chain: this.chain,
|
|
314
|
+
isCrowded: parseInt(maxDelegationPerCollator) > 0
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
await Promise.all(allCollators.map(async collator => {
|
|
319
|
+
if (allCollatorsPool.includes(collator.address)) {
|
|
320
|
+
// noted: number of blocks = total points / points per block
|
|
321
|
+
const _collatorPoints = await apiProps.api.query.parachainStaking.awardedPts(parseInt(round.current) - 1, collator.address);
|
|
322
|
+
const collatorPoints = _collatorPoints.toPrimitive();
|
|
323
|
+
const blocksPreviousRound = collatorPoints / POINTS_PER_BLOCK;
|
|
324
|
+
collator.expectedReturn = calculateMantaNominatorReturn(DECIMAL, collatorCommissionPercent, totalActiveCollators, bnAnnualInflation, blocksPreviousRound, bnCollatorExpectedBlocksPerRound, new BigN(collator.totalStake), false);
|
|
325
|
+
}
|
|
326
|
+
}));
|
|
327
|
+
const extraInfoMap = {};
|
|
328
|
+
await Promise.all(allCollators.map(async collator => {
|
|
329
|
+
const [_info, [identity, isReasonable]] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo(collator.address), parseIdentity(apiProps, collator.address)]);
|
|
330
|
+
const rawInfo = _info.toHuman();
|
|
331
|
+
const active = (rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.status) === 'Active';
|
|
332
|
+
extraInfoMap[collator.address] = {
|
|
333
|
+
identity,
|
|
334
|
+
isVerified: isReasonable,
|
|
335
|
+
active
|
|
336
|
+
};
|
|
337
|
+
}));
|
|
338
|
+
for (const validator of allCollators) {
|
|
339
|
+
validator.blocked = !extraInfoMap[validator.address].active;
|
|
340
|
+
validator.identity = extraInfoMap[validator.address].identity;
|
|
341
|
+
validator.isVerified = extraInfoMap[validator.address].isVerified;
|
|
342
|
+
// @ts-ignore
|
|
343
|
+
validator.commission = collatorCommission;
|
|
344
|
+
}
|
|
345
|
+
return allCollators;
|
|
346
|
+
} else {
|
|
347
|
+
const [_allCollators, _collatorCommission] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo.entries(), apiProps.api.query.parachainStaking.collatorCommission()]);
|
|
348
|
+
const maxDelegationPerCollator = apiProps.api.consts.parachainStaking.maxTopDelegationsPerCandidate.toString();
|
|
349
|
+
const rawCollatorCommission = _collatorCommission.toHuman();
|
|
350
|
+
const collatorCommission = parseFloat(rawCollatorCommission.split('%')[0]);
|
|
351
|
+
for (const collator of _allCollators) {
|
|
352
|
+
const _collatorAddress = collator[0].toHuman();
|
|
353
|
+
const collatorAddress = _collatorAddress[0];
|
|
354
|
+
const collatorInfo = collator[1].toPrimitive();
|
|
355
|
+
const bnTotalStake = new BN(collatorInfo.totalCounted);
|
|
356
|
+
const bnOwnStake = new BN(collatorInfo.bond);
|
|
357
|
+
const bnOtherStake = bnTotalStake.sub(bnOwnStake);
|
|
358
|
+
const bnMinBond = new BN(collatorInfo.lowestTopDelegationAmount);
|
|
359
|
+
allCollators.push({
|
|
360
|
+
commission: 0,
|
|
361
|
+
expectedReturn: 0,
|
|
362
|
+
address: collatorAddress,
|
|
363
|
+
totalStake: bnTotalStake.toString(),
|
|
364
|
+
ownStake: bnOwnStake.toString(),
|
|
365
|
+
otherStake: bnOtherStake.toString(),
|
|
366
|
+
nominatorCount: collatorInfo.delegationCount,
|
|
367
|
+
blocked: false,
|
|
368
|
+
isVerified: false,
|
|
369
|
+
minBond: bnMinBond.toString(),
|
|
370
|
+
chain: this.chain,
|
|
371
|
+
isCrowded: parseInt(maxDelegationPerCollator) > 0
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
const extraInfoMap = {};
|
|
375
|
+
await Promise.all(allCollators.map(async collator => {
|
|
376
|
+
const [_info, [identity, isReasonable]] = await Promise.all([apiProps.api.query.parachainStaking.candidateInfo(collator.address), parseIdentity(apiProps, collator.address)]);
|
|
377
|
+
const rawInfo = _info.toHuman();
|
|
378
|
+
const active = (rawInfo === null || rawInfo === void 0 ? void 0 : rawInfo.status) === 'Active';
|
|
379
|
+
extraInfoMap[collator.address] = {
|
|
380
|
+
identity,
|
|
381
|
+
isVerified: isReasonable,
|
|
382
|
+
active
|
|
383
|
+
};
|
|
384
|
+
}));
|
|
385
|
+
for (const validator of allCollators) {
|
|
386
|
+
validator.blocked = !extraInfoMap[validator.address].active;
|
|
387
|
+
validator.identity = extraInfoMap[validator.address].identity;
|
|
388
|
+
validator.isVerified = extraInfoMap[validator.address].isVerified;
|
|
389
|
+
// @ts-ignore
|
|
390
|
+
validator.commission = collatorCommission;
|
|
391
|
+
}
|
|
392
|
+
return allCollators;
|
|
293
393
|
}
|
|
294
|
-
return allCollators;
|
|
295
394
|
}
|
|
296
395
|
|
|
297
396
|
/* Get pool targets */
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
5
|
import { BasicTxErrorType, ExtrinsicType, StakingTxErrorType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { calculateAlephZeroValidatorReturn, calculateChainStakedReturnV2, calculateInflation, calculateTernoaValidatorReturn, calculateValidatorStakedReturn, getAvgValidatorEraReward, getCommission, getMaxValidatorErrorMessage, getMinStakeErrorMessage, getSupportedDaysByHistoryDepth } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
9
|
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
10
10
|
import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
|
|
@@ -122,9 +122,9 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
122
122
|
/* Subscribe pool position */
|
|
123
123
|
|
|
124
124
|
async parseNominatorMetadata(chainInfo, address, substrateApi, ledger, currentEra, minStake, _deriveSessionProgress) {
|
|
125
|
-
var _substrateApi$api$que7, _substrateApi$api$que8, _substrateApi$api$que9, _substrateApi$api$que10;
|
|
125
|
+
var _substrateApi$api$que7, _substrateApi$api$que8, _substrateApi$api$que9, _substrateApi$api$que10, _substrateApi$api$que11, _substrateApi$api$que12;
|
|
126
126
|
const chain = chainInfo.slug;
|
|
127
|
-
const [_nominations, _bonded] = await Promise.all([(_substrateApi$api$que7 = substrateApi.api.query) === null || _substrateApi$api$que7 === void 0 ? void 0 : (_substrateApi$api$que8 = _substrateApi$api$que7.staking) === null || _substrateApi$api$que8 === void 0 ? void 0 : _substrateApi$api$que8.nominators(address), (_substrateApi$api$que9 = substrateApi.api.query) === null || _substrateApi$api$que9 === void 0 ? void 0 : (_substrateApi$api$que10 = _substrateApi$api$que9.staking) === null || _substrateApi$api$que10 === void 0 ? void 0 : _substrateApi$api$que10.bonded(address)]);
|
|
127
|
+
const [_nominations, _bonded, _activeEra] = await Promise.all([(_substrateApi$api$que7 = substrateApi.api.query) === null || _substrateApi$api$que7 === void 0 ? void 0 : (_substrateApi$api$que8 = _substrateApi$api$que7.staking) === null || _substrateApi$api$que8 === void 0 ? void 0 : _substrateApi$api$que8.nominators(address), (_substrateApi$api$que9 = substrateApi.api.query) === null || _substrateApi$api$que9 === void 0 ? void 0 : (_substrateApi$api$que10 = _substrateApi$api$que9.staking) === null || _substrateApi$api$que10 === void 0 ? void 0 : _substrateApi$api$que10.bonded(address), (_substrateApi$api$que11 = substrateApi.api.query) === null || _substrateApi$api$que11 === void 0 ? void 0 : (_substrateApi$api$que12 = _substrateApi$api$que11.staking) === null || _substrateApi$api$que12 === void 0 ? void 0 : _substrateApi$api$que12.activeEra()]);
|
|
128
128
|
const unlimitedNominatorRewarded = substrateApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
129
129
|
const _maxNominatorRewardedPerValidator = (substrateApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
130
130
|
const maxNominatorRewardedPerValidator = parseInt(_maxNominatorRewardedPerValidator);
|
|
@@ -181,21 +181,19 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
ledger.unlocking.forEach(unlockingChunk => {
|
|
184
|
-
|
|
185
|
-
const
|
|
186
|
-
const
|
|
187
|
-
const
|
|
188
|
-
const eraLength = _deriveSessionProgress.eraLength.toNumber();
|
|
189
|
-
const eraProgress = _deriveSessionProgress.eraProgress.toNumber();
|
|
190
|
-
const remainingSlots = eraLength - eraProgress;
|
|
191
|
-
const remainingHours = expectedBlockTime * remainingSlots / 60 / 60;
|
|
184
|
+
const activeEra = _activeEra.toPrimitive();
|
|
185
|
+
const era = parseInt(activeEra.index);
|
|
186
|
+
const startTimestampMs = parseInt(activeEra.start);
|
|
187
|
+
const remainingEra = unlockingChunk.era - era;
|
|
192
188
|
const eraTime = _STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
193
|
-
const
|
|
189
|
+
const remaningTimestampMs = remainingEra * eraTime * 60 * 60 * 1000;
|
|
190
|
+
const targetTimestampMs = startTimestampMs + remaningTimestampMs;
|
|
191
|
+
const isClaimable = targetTimestampMs - Date.now() <= 0;
|
|
194
192
|
unstakingList.push({
|
|
195
193
|
chain,
|
|
196
194
|
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
197
195
|
claimable: unlockingChunk.value.toString(),
|
|
198
|
-
|
|
196
|
+
targetTimestampMs: targetTimestampMs
|
|
199
197
|
});
|
|
200
198
|
});
|
|
201
199
|
return {
|
|
@@ -210,19 +208,19 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
210
208
|
};
|
|
211
209
|
}
|
|
212
210
|
async subscribePoolPosition(useAddresses, resultCallback) {
|
|
213
|
-
var _substrateApi$api$
|
|
211
|
+
var _substrateApi$api$que13;
|
|
214
212
|
let cancel = false;
|
|
215
213
|
const substrateApi = await this.substrateApi.isReady;
|
|
216
214
|
const defaultInfo = this.baseInfo;
|
|
217
215
|
const chainInfo = this.chainInfo;
|
|
218
|
-
const unsub = await ((_substrateApi$api$
|
|
216
|
+
const unsub = await ((_substrateApi$api$que13 = substrateApi.api.query.staking) === null || _substrateApi$api$que13 === void 0 ? void 0 : _substrateApi$api$que13.ledger.multi(useAddresses, async ledgers => {
|
|
219
217
|
if (cancel) {
|
|
220
218
|
unsub();
|
|
221
219
|
return;
|
|
222
220
|
}
|
|
223
221
|
if (ledgers) {
|
|
224
|
-
var _substrateApi$api$
|
|
225
|
-
const [_currentEra, _minimumActiveStake, _minNominatorBond, _deriveSessionProgress] = await Promise.all([(_substrateApi$api$
|
|
222
|
+
var _substrateApi$api$que14, _substrateApi$api$que15, _substrateApi$api$que16, _substrateApi$api$que17, _substrateApi$api$que18, _substrateApi$api$que19, _substrateApi$api$que20, _substrateApi$api$que21, _substrateApi$api$der, _substrateApi$api$der2;
|
|
223
|
+
const [_currentEra, _minimumActiveStake, _minNominatorBond, _deriveSessionProgress] = await Promise.all([(_substrateApi$api$que14 = substrateApi.api.query) === null || _substrateApi$api$que14 === void 0 ? void 0 : (_substrateApi$api$que15 = _substrateApi$api$que14.staking) === null || _substrateApi$api$que15 === void 0 ? void 0 : _substrateApi$api$que15.currentEra(), ((_substrateApi$api$que16 = substrateApi.api.query) === null || _substrateApi$api$que16 === void 0 ? void 0 : (_substrateApi$api$que17 = _substrateApi$api$que16.staking) === null || _substrateApi$api$que17 === void 0 ? void 0 : _substrateApi$api$que17.minimumActiveStake) && ((_substrateApi$api$que18 = substrateApi.api.query) === null || _substrateApi$api$que18 === void 0 ? void 0 : (_substrateApi$api$que19 = _substrateApi$api$que18.staking) === null || _substrateApi$api$que19 === void 0 ? void 0 : _substrateApi$api$que19.minimumActiveStake()), (_substrateApi$api$que20 = substrateApi.api.query) === null || _substrateApi$api$que20 === void 0 ? void 0 : (_substrateApi$api$que21 = _substrateApi$api$que20.staking) === null || _substrateApi$api$que21 === void 0 ? void 0 : _substrateApi$api$que21.minNominatorBond(), (_substrateApi$api$der = substrateApi.api.derive) === null || _substrateApi$api$der === void 0 ? void 0 : (_substrateApi$api$der2 = _substrateApi$api$der.session) === null || _substrateApi$api$der2 === void 0 ? void 0 : _substrateApi$api$der2.progress()]);
|
|
226
224
|
const currentEra = _currentEra.toString();
|
|
227
225
|
const minActiveStake = (_minimumActiveStake === null || _minimumActiveStake === void 0 ? void 0 : _minimumActiveStake.toString()) || '0';
|
|
228
226
|
const minNominatorBond = _minNominatorBond.toString();
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
5
|
import { APIItemState, BasicTxErrorType, ChainType, ExtrinsicType, StakingTxErrorType, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { calculateChainStakedReturnV2, calculateInflation, getAvgValidatorEraReward, getExistUnstakeErrorMessage, getMinStakeErrorMessage, getSupportedDaysByHistoryDepth, parsePoolStashAddress } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
|
-
import {
|
|
7
|
+
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { _getChainSubstrateAddressPrefix } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
9
|
import { EarningStatus, UnstakingStatus, YieldPoolType, YieldStepType } from '@subwallet/extension-base/types';
|
|
10
10
|
import { balanceFormatter, formatNumber, reformatAddress } from '@subwallet/extension-base/utils';
|
|
@@ -150,7 +150,7 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
150
150
|
const maxNominatorRewardedPerValidator = parseInt(_maxNominatorRewardedPerValidator);
|
|
151
151
|
const poolsPalletId = substrateApi.api.consts.nominationPools.palletId.toString();
|
|
152
152
|
const poolStashAccount = parsePoolStashAddress(substrateApi.api, 0, poolMemberInfo.poolId, poolsPalletId);
|
|
153
|
-
const [_nominations, _poolMetadata] = await Promise.all([substrateApi.api.query.staking.nominators(poolStashAccount), substrateApi.api.query.nominationPools.metadata(poolMemberInfo.poolId)]);
|
|
153
|
+
const [_nominations, _poolMetadata, _activeEra] = await Promise.all([substrateApi.api.query.staking.nominators(poolStashAccount), substrateApi.api.query.nominationPools.metadata(poolMemberInfo.poolId), substrateApi.api.query.staking.activeEra()]);
|
|
154
154
|
const poolMetadata = _poolMetadata.toPrimitive();
|
|
155
155
|
const nominations = _nominations.toJSON();
|
|
156
156
|
const poolName = isHex(poolMetadata) ? hexToString(poolMetadata) : poolMetadata;
|
|
@@ -184,22 +184,20 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
184
184
|
const unstakings = [];
|
|
185
185
|
let unstakingBalance = BN_ZERO;
|
|
186
186
|
Object.entries(poolMemberInfo.unbondingEras).forEach(([unlockingEra, amount]) => {
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
const
|
|
190
|
-
const
|
|
191
|
-
const eraLength = _deriveSessionProgress.eraLength.toNumber();
|
|
192
|
-
const eraProgress = _deriveSessionProgress.eraProgress.toNumber();
|
|
193
|
-
const remainingSlots = eraLength - eraProgress;
|
|
194
|
-
const remainingHours = expectedBlockTime * remainingSlots / 60 / 60;
|
|
187
|
+
const activeEra = _activeEra.toPrimitive();
|
|
188
|
+
const era = parseInt(activeEra.index);
|
|
189
|
+
const startTimestampMs = parseInt(activeEra.start);
|
|
190
|
+
const remainingEra = parseInt(unlockingEra) - era;
|
|
195
191
|
const eraTime = _STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
196
|
-
const
|
|
192
|
+
const remaningTimestampMs = remainingEra * eraTime * 60 * 60 * 1000;
|
|
193
|
+
const targetTimestampMs = startTimestampMs + remaningTimestampMs;
|
|
194
|
+
const isClaimable = targetTimestampMs - Date.now() <= 0;
|
|
197
195
|
unstakingBalance = unstakingBalance.add(new BN(amount));
|
|
198
196
|
unstakings.push({
|
|
199
197
|
chain: chainInfo.slug,
|
|
200
198
|
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
201
199
|
claimable: amount.toString(),
|
|
202
|
-
|
|
200
|
+
targetTimestampMs: targetTimestampMs
|
|
203
201
|
});
|
|
204
202
|
});
|
|
205
203
|
const bnActiveStake = new BN(poolMemberInfo.points.toString());
|
|
@@ -19,6 +19,7 @@ export default abstract class BaseSpecialStakingPoolHandler extends BasePoolHand
|
|
|
19
19
|
protected constructor(state: KoniState, chain: string);
|
|
20
20
|
get metadataInfo(): Omit<SpecialYieldPoolMetadata, 'description'>;
|
|
21
21
|
protected updateExchangeRate(rate: number): void;
|
|
22
|
+
/** Exchange rate before divine with decimals */
|
|
22
23
|
protected getExchangeRate(): Promise<number>;
|
|
23
24
|
get isPoolSupportAlternativeFee(): boolean;
|
|
24
25
|
earlyValidate(request: RequestEarlyValidateYield): Promise<ResponseEarlyValidateYield>;
|
|
@@ -41,6 +41,8 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
41
41
|
this.rate = rate;
|
|
42
42
|
this.exchangeRatePromise.resolve(true);
|
|
43
43
|
}
|
|
44
|
+
|
|
45
|
+
/** Exchange rate before divine with decimals */
|
|
44
46
|
async getExchangeRate() {
|
|
45
47
|
await this.exchangeRatePromise.promise;
|
|
46
48
|
return this.rate;
|
|
@@ -18,12 +18,15 @@ export default class EarningService implements StoppableServiceInterface, Persis
|
|
|
18
18
|
readonly yieldPositionListSubject: BehaviorSubject<YieldPositionInfo[]>;
|
|
19
19
|
private dbService;
|
|
20
20
|
private eventService;
|
|
21
|
+
private useOnlineCacheOnly;
|
|
21
22
|
constructor(state: KoniState);
|
|
23
|
+
disableOnlineCacheOnly(): void;
|
|
22
24
|
private initHandlers;
|
|
23
25
|
startPromiseHandler: PromiseHandler<void>;
|
|
24
26
|
stopPromiseHandler: PromiseHandler<void>;
|
|
25
27
|
status: ServiceStatus;
|
|
26
28
|
init(): Promise<void>;
|
|
29
|
+
private delayReloadTimeout;
|
|
27
30
|
handleActions(): void;
|
|
28
31
|
loadData(): Promise<void>;
|
|
29
32
|
persistData(): Promise<void>;
|
|
@@ -36,7 +39,7 @@ export default class EarningService implements StoppableServiceInterface, Persis
|
|
|
36
39
|
subscribeMinAmountPercent(): BehaviorSubject<Record<string, number>>;
|
|
37
40
|
getMinAmountPercent(): Record<string, number>;
|
|
38
41
|
getYieldPool(slug: string): Promise<YieldPoolInfo | undefined>;
|
|
39
|
-
subscribePoolsInfo(callback: (rs: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
42
|
+
subscribePoolsInfo(onlineData: Record<string, YieldPoolInfo>, callback: (rs: YieldPoolInfo) => void): Promise<VoidFunction>;
|
|
40
43
|
private getYieldPoolInfoFromDB;
|
|
41
44
|
subscribeYieldPoolInfo(): BehaviorSubject<Record<string, YieldPoolInfo>>;
|
|
42
45
|
getYieldPoolInfo(): Promise<YieldPoolInfo[]>;
|