@subwallet/extension-base 1.1.35-beta.1 → 1.1.35-beta.3
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 +12 -0
- package/background/KoniTypes.js +3 -0
- package/cjs/background/KoniTypes.js +3 -0
- package/cjs/koni/api/staking/bonding/utils.js +44 -0
- package/cjs/koni/api/tokens/evm/transfer.js +35 -19
- package/cjs/koni/api/yield/helper/utils.js +6 -3
- package/cjs/koni/background/handlers/Extension.js +20 -12
- package/cjs/koni/background/handlers/State.js +15 -5
- package/cjs/services/chain-service/index.js +0 -3
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +2 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +2 -1
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +2 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +10 -2
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +10 -2
- package/cjs/services/earning-service/handlers/special.js +7 -3
- package/cjs/services/earning-service/service.js +9 -2
- package/cjs/services/notification-service/NotificationService.js +7 -4
- package/cjs/services/request-service/handler/EvmRequestHandler.js +46 -29
- package/cjs/services/transaction-service/index.js +43 -14
- package/cjs/signers/web3/QrSigner.js +2 -0
- package/cjs/types/yield/actions/join/step.js +1 -0
- package/cjs/utils/environment.js +16 -14
- package/cjs/utils/eth/mergeTransactionAndSignature.js +25 -10
- package/cjs/utils/eth.js +51 -2
- package/cjs/utils/mv3.js +1 -1
- package/cjs/utils/number.js +5 -1
- package/cjs/utils/yield/index.js +3 -0
- package/koni/api/staking/bonding/utils.d.ts +5 -0
- package/koni/api/staking/bonding/utils.js +40 -0
- package/koni/api/tokens/evm/transfer.js +36 -21
- package/koni/api/yield/helper/utils.d.ts +1 -1
- package/koni/api/yield/helper/utils.js +5 -3
- package/koni/background/handlers/Extension.js +21 -13
- package/koni/background/handlers/State.js +16 -6
- package/package.json +11 -7
- package/services/chain-service/index.js +0 -3
- package/services/earning-service/handlers/liquid-staking/base.d.ts +1 -1
- package/services/earning-service/handlers/liquid-staking/base.js +2 -1
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +37 -0
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +132 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +3 -3
- package/services/earning-service/handlers/liquid-staking/bifrost.js +2 -1
- package/services/earning-service/handlers/liquid-staking/index.d.ts +1 -0
- package/services/earning-service/handlers/liquid-staking/index.js +1 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +2 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +11 -3
- package/services/earning-service/handlers/nomination-pool/index.js +11 -3
- package/services/earning-service/handlers/special.js +7 -3
- package/services/earning-service/service.d.ts +2 -1
- package/services/earning-service/service.js +10 -3
- package/services/notification-service/NotificationService.js +7 -4
- package/services/request-service/handler/EvmRequestHandler.d.ts +2 -2
- package/services/request-service/handler/EvmRequestHandler.js +46 -29
- package/services/transaction-service/index.js +44 -15
- package/services/transaction-service/types.d.ts +2 -2
- package/signers/types.d.ts +2 -0
- package/signers/web3/QrSigner.js +2 -0
- package/types/yield/actions/join/step.d.ts +1 -0
- package/types/yield/actions/join/step.js +1 -0
- package/utils/environment.js +16 -11
- package/utils/eth/mergeTransactionAndSignature.js +25 -10
- package/utils/eth.d.ts +14 -0
- package/utils/eth.js +48 -0
- package/utils/mv3.js +1 -1
- package/utils/number.d.ts +2 -0
- package/utils/number.js +2 -0
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
|
@@ -371,16 +371,19 @@ export declare enum ExtrinsicType {
|
|
|
371
371
|
MINT_SDOT = "earn.mint_sdot",
|
|
372
372
|
MINT_QDOT = "earn.mint_qdot",
|
|
373
373
|
MINT_STDOT = "earn.mint_stdot",
|
|
374
|
+
MINT_VMANTA = "earn.mint_vmanta",
|
|
374
375
|
REDEEM_QDOT = "earn.redeem_qdot",
|
|
375
376
|
REDEEM_VDOT = "earn.redeem_vdot",
|
|
376
377
|
REDEEM_LDOT = "earn.redeem_ldot",
|
|
377
378
|
REDEEM_SDOT = "earn.redeem_sdot",
|
|
378
379
|
REDEEM_STDOT = "earn.redeem_stdot",
|
|
380
|
+
REDEEM_VMANTA = "earn.redeem_vmanta",
|
|
379
381
|
UNSTAKE_QDOT = "earn.unstake_qdot",
|
|
380
382
|
UNSTAKE_VDOT = "earn.unstake_vdot",
|
|
381
383
|
UNSTAKE_LDOT = "earn.unstake_ldot",
|
|
382
384
|
UNSTAKE_SDOT = "earn.unstake_sdot",
|
|
383
385
|
UNSTAKE_STDOT = "earn.unstake_stdot",
|
|
386
|
+
UNSTAKE_VMANTA = "earn.unstake_vmanta",
|
|
384
387
|
TOKEN_APPROVE = "evm.token_approve",
|
|
385
388
|
EVM_EXECUTE = "evm.execute",
|
|
386
389
|
UNKNOWN = "unknown"
|
|
@@ -407,16 +410,19 @@ export interface ExtrinsicDataTypeMap {
|
|
|
407
410
|
[ExtrinsicType.MINT_QDOT]: SubmitYieldStepData;
|
|
408
411
|
[ExtrinsicType.MINT_STDOT]: SubmitYieldStepData;
|
|
409
412
|
[ExtrinsicType.MINT_STDOT]: SubmitYieldStepData;
|
|
413
|
+
[ExtrinsicType.MINT_VMANTA]: SubmitYieldStepData;
|
|
410
414
|
[ExtrinsicType.UNSTAKE_VDOT]: RequestYieldLeave;
|
|
411
415
|
[ExtrinsicType.UNSTAKE_QDOT]: RequestYieldLeave;
|
|
412
416
|
[ExtrinsicType.UNSTAKE_LDOT]: RequestYieldLeave;
|
|
413
417
|
[ExtrinsicType.UNSTAKE_SDOT]: RequestYieldLeave;
|
|
414
418
|
[ExtrinsicType.UNSTAKE_STDOT]: RequestYieldLeave;
|
|
419
|
+
[ExtrinsicType.UNSTAKE_VMANTA]: RequestYieldLeave;
|
|
415
420
|
[ExtrinsicType.REDEEM_VDOT]: RequestYieldLeave;
|
|
416
421
|
[ExtrinsicType.REDEEM_QDOT]: RequestYieldLeave;
|
|
417
422
|
[ExtrinsicType.REDEEM_LDOT]: RequestYieldLeave;
|
|
418
423
|
[ExtrinsicType.REDEEM_SDOT]: RequestYieldLeave;
|
|
419
424
|
[ExtrinsicType.REDEEM_STDOT]: RequestYieldLeave;
|
|
425
|
+
[ExtrinsicType.REDEEM_VMANTA]: RequestYieldLeave;
|
|
420
426
|
[ExtrinsicType.TOKEN_APPROVE]: TokenApproveData;
|
|
421
427
|
[ExtrinsicType.EVM_EXECUTE]: TransactionConfig;
|
|
422
428
|
[ExtrinsicType.CROWDLOAN]: any;
|
|
@@ -455,6 +461,9 @@ export interface BasicTokenInfo {
|
|
|
455
461
|
export interface AmountData extends BasicTokenInfo {
|
|
456
462
|
value: string;
|
|
457
463
|
}
|
|
464
|
+
export interface FeeData extends AmountData {
|
|
465
|
+
tooHigh?: boolean;
|
|
466
|
+
}
|
|
458
467
|
export interface AmountDataWithId extends AmountData {
|
|
459
468
|
id: string;
|
|
460
469
|
}
|
|
@@ -470,16 +479,19 @@ export declare type TransactionAdditionalInfo = {
|
|
|
470
479
|
[ExtrinsicType.TRANSFER_XCM]: XCMTransactionAdditionalInfo;
|
|
471
480
|
[ExtrinsicType.SEND_NFT]: NFTTransactionAdditionalInfo;
|
|
472
481
|
[ExtrinsicType.MINT_VDOT]: Pick<SubmitYieldStepData, 'derivativeTokenSlug' | 'exchangeRate' | 'slug'>;
|
|
482
|
+
[ExtrinsicType.MINT_VMANTA]: Pick<SubmitYieldStepData, 'derivativeTokenSlug' | 'exchangeRate' | 'slug'>;
|
|
473
483
|
[ExtrinsicType.MINT_QDOT]: Pick<SubmitYieldStepData, 'derivativeTokenSlug' | 'exchangeRate' | 'slug'>;
|
|
474
484
|
[ExtrinsicType.MINT_SDOT]: Pick<SubmitYieldStepData, 'derivativeTokenSlug' | 'exchangeRate' | 'slug'>;
|
|
475
485
|
[ExtrinsicType.MINT_LDOT]: Pick<SubmitYieldStepData, 'derivativeTokenSlug' | 'exchangeRate' | 'slug'>;
|
|
476
486
|
[ExtrinsicType.MINT_STDOT]: Pick<SubmitYieldStepData, 'derivativeTokenSlug' | 'exchangeRate' | 'slug'>;
|
|
477
487
|
[ExtrinsicType.REDEEM_VDOT]: LeavePoolAdditionalData;
|
|
488
|
+
[ExtrinsicType.REDEEM_VMANTA]: LeavePoolAdditionalData;
|
|
478
489
|
[ExtrinsicType.REDEEM_QDOT]: LeavePoolAdditionalData;
|
|
479
490
|
[ExtrinsicType.REDEEM_SDOT]: LeavePoolAdditionalData;
|
|
480
491
|
[ExtrinsicType.REDEEM_LDOT]: LeavePoolAdditionalData;
|
|
481
492
|
[ExtrinsicType.REDEEM_STDOT]: LeavePoolAdditionalData;
|
|
482
493
|
[ExtrinsicType.UNSTAKE_VDOT]: LeavePoolAdditionalData;
|
|
494
|
+
[ExtrinsicType.UNSTAKE_VMANTA]: LeavePoolAdditionalData;
|
|
483
495
|
[ExtrinsicType.UNSTAKE_QDOT]: LeavePoolAdditionalData;
|
|
484
496
|
[ExtrinsicType.UNSTAKE_SDOT]: LeavePoolAdditionalData;
|
|
485
497
|
[ExtrinsicType.UNSTAKE_LDOT]: LeavePoolAdditionalData;
|
package/background/KoniTypes.js
CHANGED
|
@@ -81,16 +81,19 @@ export let ExtrinsicType;
|
|
|
81
81
|
ExtrinsicType["MINT_SDOT"] = "earn.mint_sdot";
|
|
82
82
|
ExtrinsicType["MINT_QDOT"] = "earn.mint_qdot";
|
|
83
83
|
ExtrinsicType["MINT_STDOT"] = "earn.mint_stdot";
|
|
84
|
+
ExtrinsicType["MINT_VMANTA"] = "earn.mint_vmanta";
|
|
84
85
|
ExtrinsicType["REDEEM_QDOT"] = "earn.redeem_qdot";
|
|
85
86
|
ExtrinsicType["REDEEM_VDOT"] = "earn.redeem_vdot";
|
|
86
87
|
ExtrinsicType["REDEEM_LDOT"] = "earn.redeem_ldot";
|
|
87
88
|
ExtrinsicType["REDEEM_SDOT"] = "earn.redeem_sdot";
|
|
88
89
|
ExtrinsicType["REDEEM_STDOT"] = "earn.redeem_stdot";
|
|
90
|
+
ExtrinsicType["REDEEM_VMANTA"] = "earn.redeem_vmanta";
|
|
89
91
|
ExtrinsicType["UNSTAKE_QDOT"] = "earn.unstake_qdot";
|
|
90
92
|
ExtrinsicType["UNSTAKE_VDOT"] = "earn.unstake_vdot";
|
|
91
93
|
ExtrinsicType["UNSTAKE_LDOT"] = "earn.unstake_ldot";
|
|
92
94
|
ExtrinsicType["UNSTAKE_SDOT"] = "earn.unstake_sdot";
|
|
93
95
|
ExtrinsicType["UNSTAKE_STDOT"] = "earn.unstake_stdot";
|
|
96
|
+
ExtrinsicType["UNSTAKE_VMANTA"] = "earn.unstake_vmanta";
|
|
94
97
|
ExtrinsicType["TOKEN_APPROVE"] = "evm.token_approve";
|
|
95
98
|
ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
|
|
96
99
|
ExtrinsicType["UNKNOWN"] = "unknown";
|
|
@@ -95,16 +95,19 @@ exports.ExtrinsicType = ExtrinsicType;
|
|
|
95
95
|
ExtrinsicType["MINT_SDOT"] = "earn.mint_sdot";
|
|
96
96
|
ExtrinsicType["MINT_QDOT"] = "earn.mint_qdot";
|
|
97
97
|
ExtrinsicType["MINT_STDOT"] = "earn.mint_stdot";
|
|
98
|
+
ExtrinsicType["MINT_VMANTA"] = "earn.mint_vmanta";
|
|
98
99
|
ExtrinsicType["REDEEM_QDOT"] = "earn.redeem_qdot";
|
|
99
100
|
ExtrinsicType["REDEEM_VDOT"] = "earn.redeem_vdot";
|
|
100
101
|
ExtrinsicType["REDEEM_LDOT"] = "earn.redeem_ldot";
|
|
101
102
|
ExtrinsicType["REDEEM_SDOT"] = "earn.redeem_sdot";
|
|
102
103
|
ExtrinsicType["REDEEM_STDOT"] = "earn.redeem_stdot";
|
|
104
|
+
ExtrinsicType["REDEEM_VMANTA"] = "earn.redeem_vmanta";
|
|
103
105
|
ExtrinsicType["UNSTAKE_QDOT"] = "earn.unstake_qdot";
|
|
104
106
|
ExtrinsicType["UNSTAKE_VDOT"] = "earn.unstake_vdot";
|
|
105
107
|
ExtrinsicType["UNSTAKE_LDOT"] = "earn.unstake_ldot";
|
|
106
108
|
ExtrinsicType["UNSTAKE_SDOT"] = "earn.unstake_sdot";
|
|
107
109
|
ExtrinsicType["UNSTAKE_STDOT"] = "earn.unstake_stdot";
|
|
110
|
+
ExtrinsicType["UNSTAKE_VMANTA"] = "earn.unstake_vmanta";
|
|
108
111
|
ExtrinsicType["TOKEN_APPROVE"] = "evm.token_approve";
|
|
109
112
|
ExtrinsicType["EVM_EXECUTE"] = "evm.execute";
|
|
110
113
|
ExtrinsicType["UNKNOWN"] = "unknown";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -8,9 +9,11 @@ exports.calcInflationRewardCurve = calcInflationRewardCurve;
|
|
|
8
9
|
exports.calcInflationUniformEraPayout = calcInflationUniformEraPayout;
|
|
9
10
|
exports.calculateAlephZeroValidatorReturn = calculateAlephZeroValidatorReturn;
|
|
10
11
|
exports.calculateChainStakedReturn = calculateChainStakedReturn;
|
|
12
|
+
exports.calculateChainStakedReturnV2 = calculateChainStakedReturnV2;
|
|
11
13
|
exports.calculateInflation = calculateInflation;
|
|
12
14
|
exports.calculateTernoaValidatorReturn = calculateTernoaValidatorReturn;
|
|
13
15
|
exports.calculateValidatorStakedReturn = calculateValidatorStakedReturn;
|
|
16
|
+
exports.getAvgValidatorEraReward = getAvgValidatorEraReward;
|
|
14
17
|
exports.getBondedValidators = getBondedValidators;
|
|
15
18
|
exports.getCommission = getCommission;
|
|
16
19
|
exports.getEarningStatusByNominations = getEarningStatusByNominations;
|
|
@@ -20,6 +23,7 @@ exports.getMinStakeErrorMessage = exports.getMaxValidatorErrorMessage = void 0;
|
|
|
20
23
|
exports.getParaCurrentInflation = getParaCurrentInflation;
|
|
21
24
|
exports.getStakingAvailableActionsByChain = getStakingAvailableActionsByChain;
|
|
22
25
|
exports.getStakingAvailableActionsByNominator = getStakingAvailableActionsByNominator;
|
|
26
|
+
exports.getSupportedDaysByHistoryDepth = getSupportedDaysByHistoryDepth;
|
|
23
27
|
exports.getValidatorLabel = getValidatorLabel;
|
|
24
28
|
exports.getWithdrawalInfo = getWithdrawalInfo;
|
|
25
29
|
exports.getYieldAvailableActionsByPosition = getYieldAvailableActionsByPosition;
|
|
@@ -37,6 +41,7 @@ var _constants2 = require("@subwallet/extension-base/services/earning-service/co
|
|
|
37
41
|
var _types = require("@subwallet/extension-base/types");
|
|
38
42
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
39
43
|
var _number = require("@subwallet/extension-base/utils/number");
|
|
44
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
40
45
|
var _i18next = require("i18next");
|
|
41
46
|
var _util = require("@polkadot/util");
|
|
42
47
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
@@ -102,6 +107,24 @@ function calculateChainStakedReturn(inflation, totalEraStake, totalIssuance, net
|
|
|
102
107
|
|
|
103
108
|
return stakedReturn;
|
|
104
109
|
}
|
|
110
|
+
function calculateChainStakedReturnV2(chainInfo, totalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, isCompound) {
|
|
111
|
+
const DAYS_PER_YEAR = 365;
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
const DECIMAL = chainInfo.substrateInfo.decimals;
|
|
114
|
+
const lastTotalStakedUnit = new _bignumber.default(lastTotalStaked).dividedBy(new _bignumber.default(10 ** DECIMAL));
|
|
115
|
+
const totalIssuanceUnit = new _bignumber.default(totalIssuance).dividedBy(new _bignumber.default(10 ** DECIMAL));
|
|
116
|
+
const supplyStaked = lastTotalStakedUnit.dividedBy(totalIssuanceUnit);
|
|
117
|
+
const dayRewardRate = validatorEraReward.multipliedBy(erasPerDay).dividedBy(totalIssuance).multipliedBy(100);
|
|
118
|
+
let inflationToStakers = new _bignumber.default(0);
|
|
119
|
+
if (!isCompound) {
|
|
120
|
+
inflationToStakers = dayRewardRate.multipliedBy(DAYS_PER_YEAR);
|
|
121
|
+
} else {
|
|
122
|
+
const multiplier = dayRewardRate.dividedBy(100).plus(1).exponentiatedBy(365);
|
|
123
|
+
inflationToStakers = new _bignumber.default(100).multipliedBy(multiplier).minus(100);
|
|
124
|
+
}
|
|
125
|
+
const averageRewardRate = inflationToStakers.dividedBy(supplyStaked);
|
|
126
|
+
return averageRewardRate.toNumber();
|
|
127
|
+
}
|
|
105
128
|
function calculateAlephZeroValidatorReturn(chainStakedReturn, commission) {
|
|
106
129
|
return chainStakedReturn * (100 - commission) / 100;
|
|
107
130
|
}
|
|
@@ -343,6 +366,27 @@ function getValidatorLabel(chain) {
|
|
|
343
366
|
}
|
|
344
367
|
return 'Collator';
|
|
345
368
|
}
|
|
369
|
+
function getAvgValidatorEraReward(supportedDays, eraRewardHistory) {
|
|
370
|
+
let sumEraReward = new _bignumber.default(0);
|
|
371
|
+
let failEra = 0;
|
|
372
|
+
for (const _item of eraRewardHistory) {
|
|
373
|
+
const item = _item.toString();
|
|
374
|
+
if (!item) {
|
|
375
|
+
failEra += 1;
|
|
376
|
+
} else {
|
|
377
|
+
const eraReward = new _bignumber.default(item);
|
|
378
|
+
sumEraReward = sumEraReward.plus(eraReward);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
return sumEraReward.dividedBy(new _bignumber.default(supportedDays - failEra));
|
|
382
|
+
}
|
|
383
|
+
function getSupportedDaysByHistoryDepth(erasPerDay, maxSupportedEras) {
|
|
384
|
+
if (maxSupportedEras / erasPerDay > 30) {
|
|
385
|
+
return 30;
|
|
386
|
+
} else {
|
|
387
|
+
return 15;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
346
390
|
const getMinStakeErrorMessage = (chainInfo, bnMinStake) => {
|
|
347
391
|
const tokenInfo = (0, _utils._getChainNativeTokenBasicInfo)(chainInfo);
|
|
348
392
|
const number = (0, _number.formatNumber)(bnMinStake.toString(), tokenInfo.decimals || 0, _number.balanceFormatter);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -12,6 +13,7 @@ var _web = require("@subwallet/extension-base/koni/api/tokens/evm/web3");
|
|
|
12
13
|
var _constants = require("@subwallet/extension-base/services/chain-service/constants");
|
|
13
14
|
var _helper = require("@subwallet/extension-base/services/chain-service/helper");
|
|
14
15
|
var _eth = require("@subwallet/extension-base/utils/eth");
|
|
16
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
15
17
|
var _util = require("@polkadot/util");
|
|
16
18
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
17
19
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -45,20 +47,29 @@ const handleTransferBalanceResult = _ref => {
|
|
|
45
47
|
};
|
|
46
48
|
exports.handleTransferBalanceResult = handleTransferBalanceResult;
|
|
47
49
|
async function getEVMTransactionObject(chainInfo, from, to, value, transferAll, evmApiMap) {
|
|
50
|
+
var _priority$maxFeePerGa, _priority$maxPriority;
|
|
48
51
|
const networkKey = chainInfo.slug;
|
|
49
52
|
const web3Api = evmApiMap[networkKey];
|
|
50
|
-
const
|
|
51
|
-
const gasPrice = (0, _eth.recalculateGasPrice)(_price, chainInfo.slug);
|
|
53
|
+
const priority = await (0, _eth.calculateGasFeeParams)(web3Api, networkKey);
|
|
52
54
|
const transactionObject = {
|
|
53
|
-
gasPrice: gasPrice,
|
|
54
55
|
to: to,
|
|
55
56
|
value: value,
|
|
56
|
-
from: from
|
|
57
|
+
from: from,
|
|
58
|
+
gasPrice: priority.gasPrice,
|
|
59
|
+
maxFeePerGas: (_priority$maxFeePerGa = priority.maxFeePerGas) === null || _priority$maxFeePerGa === void 0 ? void 0 : _priority$maxFeePerGa.toString(),
|
|
60
|
+
maxPriorityFeePerGas: (_priority$maxPriority = priority.maxPriorityFeePerGas) === null || _priority$maxPriority === void 0 ? void 0 : _priority$maxPriority.toString()
|
|
57
61
|
};
|
|
58
62
|
const gasLimit = await web3Api.api.eth.estimateGas(transactionObject);
|
|
59
63
|
transactionObject.gas = gasLimit;
|
|
60
|
-
|
|
61
|
-
|
|
64
|
+
let estimateFee;
|
|
65
|
+
if (priority.baseGasFee) {
|
|
66
|
+
const priorityFee = priority.baseGasFee.plus(priority.maxPriorityFeePerGas);
|
|
67
|
+
const maxFee = priority.maxFeePerGas.gte(priorityFee) ? priority.maxFeePerGas : priorityFee;
|
|
68
|
+
estimateFee = maxFee.multipliedBy(gasLimit);
|
|
69
|
+
} else {
|
|
70
|
+
estimateFee = new _bignumber.default(priority.gasPrice).multipliedBy(gasLimit);
|
|
71
|
+
}
|
|
72
|
+
transactionObject.value = transferAll ? new _bignumber.default(value).minus(estimateFee).toString() : value;
|
|
62
73
|
if (_constants.EVM_REFORMAT_DECIMALS.acala.includes(networkKey)) {
|
|
63
74
|
const numberReplace = 18 - 12;
|
|
64
75
|
transactionObject.value = transactionObject.value.substring(0, transactionObject.value.length - 6) + new Array(numberReplace).fill('0').join('');
|
|
@@ -66,53 +77,58 @@ async function getEVMTransactionObject(chainInfo, from, to, value, transferAll,
|
|
|
66
77
|
return [transactionObject, transactionObject.value.toString()];
|
|
67
78
|
}
|
|
68
79
|
async function getERC20TransactionObject(assetAddress, chainInfo, from, to, value, transferAll, evmApiMap) {
|
|
80
|
+
var _priority$maxFeePerGa2, _priority$maxPriority2;
|
|
69
81
|
const networkKey = chainInfo.slug;
|
|
70
82
|
const evmApi = evmApiMap[networkKey];
|
|
71
83
|
const erc20Contract = (0, _web.getERC20Contract)(networkKey, assetAddress, evmApiMap);
|
|
72
|
-
let freeAmount = new
|
|
84
|
+
let freeAmount = new _bignumber.default(0);
|
|
73
85
|
let transferValue = value;
|
|
74
86
|
if (transferAll) {
|
|
75
87
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
76
88
|
const bal = await erc20Contract.methods.balanceOf(from).call();
|
|
77
|
-
freeAmount = new
|
|
78
|
-
transferValue = freeAmount.
|
|
89
|
+
freeAmount = new _bignumber.default(bal || '0');
|
|
90
|
+
transferValue = freeAmount.toFixed(0) || '0';
|
|
79
91
|
}
|
|
80
92
|
function generateTransferData(to, transferValue) {
|
|
81
93
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
82
94
|
return erc20Contract.methods.transfer(to, transferValue).encodeABI();
|
|
83
95
|
}
|
|
84
96
|
const transferData = generateTransferData(to, transferValue);
|
|
85
|
-
const [gasLimit,
|
|
97
|
+
const [gasLimit, priority] = await Promise.all([
|
|
86
98
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
87
99
|
erc20Contract.methods.transfer(to, transferValue).estimateGas({
|
|
88
100
|
from
|
|
89
|
-
}),
|
|
90
|
-
const gasPrice = (0, _eth.recalculateGasPrice)(_price, chainInfo.slug);
|
|
101
|
+
}), (0, _eth.calculateGasFeeParams)(evmApi, networkKey)]);
|
|
91
102
|
const transactionObject = {
|
|
92
|
-
gasPrice: gasPrice,
|
|
93
103
|
gas: gasLimit,
|
|
94
104
|
from,
|
|
105
|
+
value: '0',
|
|
95
106
|
to: assetAddress,
|
|
96
|
-
data: transferData
|
|
107
|
+
data: transferData,
|
|
108
|
+
gasPrice: priority.gasPrice,
|
|
109
|
+
maxFeePerGas: (_priority$maxFeePerGa2 = priority.maxFeePerGas) === null || _priority$maxFeePerGa2 === void 0 ? void 0 : _priority$maxFeePerGa2.toString(),
|
|
110
|
+
maxPriorityFeePerGas: (_priority$maxPriority2 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority2 === void 0 ? void 0 : _priority$maxPriority2.toString()
|
|
97
111
|
};
|
|
98
112
|
if (transferAll) {
|
|
99
|
-
transferValue =
|
|
113
|
+
transferValue = freeAmount.toFixed(0);
|
|
100
114
|
transactionObject.data = generateTransferData(to, transferValue);
|
|
101
115
|
}
|
|
102
116
|
return [transactionObject, transferValue];
|
|
103
117
|
}
|
|
104
118
|
async function getERC721Transaction(web3Api, chain, contractAddress, senderAddress, recipientAddress, tokenId) {
|
|
119
|
+
var _priority$maxFeePerGa3, _priority$maxPriority3;
|
|
105
120
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
106
121
|
const contract = new web3Api.api.eth.Contract(_helper._ERC721_ABI, contractAddress);
|
|
107
|
-
const [gasLimit,
|
|
122
|
+
const [gasLimit, priority] = await Promise.all([
|
|
108
123
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
109
124
|
contract.methods.safeTransferFrom(senderAddress, recipientAddress, tokenId).estimateGas({
|
|
110
125
|
from: senderAddress
|
|
111
|
-
}),
|
|
112
|
-
const gasPrice = (0, _eth.recalculateGasPrice)(_price, chain);
|
|
126
|
+
}), (0, _eth.calculateGasFeeParams)(web3Api, chain)]);
|
|
113
127
|
return {
|
|
114
128
|
from: senderAddress,
|
|
115
|
-
gasPrice,
|
|
129
|
+
gasPrice: priority.gasPrice,
|
|
130
|
+
maxFeePerGas: (_priority$maxFeePerGa3 = priority.maxFeePerGas) === null || _priority$maxFeePerGa3 === void 0 ? void 0 : _priority$maxFeePerGa3.toString(),
|
|
131
|
+
maxPriorityFeePerGas: (_priority$maxPriority3 = priority.maxPriorityFeePerGas) === null || _priority$maxPriority3 === void 0 ? void 0 : _priority$maxPriority3.toString(),
|
|
116
132
|
gas: gasLimit,
|
|
117
133
|
to: contractAddress,
|
|
118
134
|
value: '0x00',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -10,6 +11,8 @@ exports.syntheticSelectedValidators = void 0;
|
|
|
10
11
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
11
12
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
12
13
|
var _types = require("@subwallet/extension-base/types");
|
|
14
|
+
var _utils2 = require("@subwallet/extension-base/utils");
|
|
15
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
13
16
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
14
17
|
// SPDX-License-Identifier: Apache-2.0
|
|
15
18
|
|
|
@@ -40,7 +43,7 @@ function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, o
|
|
|
40
43
|
const derivativeDecimals = (0, _utils._getAssetDecimals)(derivativeTokenInfo);
|
|
41
44
|
const originDecimals = (0, _utils._getAssetDecimals)(originTokenInfo);
|
|
42
45
|
const exchangeRate = ((_poolInfo$statistic = poolInfo.statistic) === null || _poolInfo$statistic === void 0 ? void 0 : (_poolInfo$statistic$a = _poolInfo$statistic.assetEarning) === null || _poolInfo$statistic$a === void 0 ? void 0 : _poolInfo$statistic$a[0].exchangeRate) || 1;
|
|
43
|
-
const formattedAmount =
|
|
44
|
-
const minAmount = formattedAmount
|
|
45
|
-
return
|
|
46
|
+
const formattedAmount = new _bignumber.default(amount).dividedBy(_utils2.BN_TEN.pow(derivativeDecimals)); // TODO: decimals
|
|
47
|
+
const minAmount = formattedAmount.multipliedBy(exchangeRate);
|
|
48
|
+
return minAmount.multipliedBy(_utils2.BN_TEN.pow(originDecimals)).toFixed(0);
|
|
46
49
|
}
|
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _common =
|
|
8
|
+
var _common = require("@ethereumjs/common");
|
|
9
|
+
var _tx = require("@ethereumjs/tx");
|
|
9
10
|
var _types = require("@subwallet/chain-list/types");
|
|
10
11
|
var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
11
12
|
var _Extension = require("@subwallet/extension-base/background/handlers/Extension");
|
|
@@ -42,7 +43,6 @@ var _keyring = require("@subwallet/keyring");
|
|
|
42
43
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
43
44
|
var _utils4 = require("@walletconnect/utils");
|
|
44
45
|
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
45
|
-
var _ethereumjsTx = require("ethereumjs-tx");
|
|
46
46
|
var _i18next = require("i18next");
|
|
47
47
|
var _types4 = require("@polkadot/types");
|
|
48
48
|
var _util = require("@polkadot/util");
|
|
@@ -1938,10 +1938,15 @@ class KoniExtension {
|
|
|
1938
1938
|
// null address
|
|
1939
1939
|
from: address
|
|
1940
1940
|
};
|
|
1941
|
-
const _price = await web3.api.eth.getGasPrice();
|
|
1942
|
-
const gasPrice = (0, _eth.recalculateGasPrice)(_price, networkKey);
|
|
1943
1941
|
const gasLimit = await web3.api.eth.estimateGas(transaction);
|
|
1944
|
-
|
|
1942
|
+
const priority = await (0, _eth.calculateGasFeeParams)(web3, networkKey);
|
|
1943
|
+
if (priority.baseGasFee) {
|
|
1944
|
+
const priorityFee = priority.baseGasFee.plus(priority.maxPriorityFeePerGas);
|
|
1945
|
+
const maxFee = priority.maxFeePerGas.gte(priorityFee) ? priority.maxFeePerGas : priorityFee;
|
|
1946
|
+
estimatedFee = maxFee.multipliedBy(gasLimit).toFixed(0);
|
|
1947
|
+
} else {
|
|
1948
|
+
estimatedFee = new _bignumber.default(priority.gasPrice).multipliedBy(gasLimit).toFixed(0);
|
|
1949
|
+
}
|
|
1945
1950
|
} else {
|
|
1946
1951
|
var _paymentInfo$partialF2;
|
|
1947
1952
|
const [mockTx] = await (0, _transfer.createTransferExtrinsic)({
|
|
@@ -2480,6 +2485,7 @@ class KoniExtension {
|
|
|
2480
2485
|
}
|
|
2481
2486
|
signed = await pair.evmSigner.signMessage(data, 'personal_sign');
|
|
2482
2487
|
} else {
|
|
2488
|
+
var _signedTranaction$r, _signedTranaction$s, _signedTranaction$v;
|
|
2483
2489
|
const tx = (0, _eth.createTransactionFromRLP)(message);
|
|
2484
2490
|
if (!tx) {
|
|
2485
2491
|
throw new Error((0, _i18next.t)('Failed to decode data. Please use a valid QR code'));
|
|
@@ -2492,21 +2498,23 @@ class KoniExtension {
|
|
|
2492
2498
|
nonce: new _bignumber.default(tx.nonce).toNumber(),
|
|
2493
2499
|
gas: new _bignumber.default(tx.gas).toNumber()
|
|
2494
2500
|
};
|
|
2495
|
-
const common = _common.
|
|
2501
|
+
const common = _common.Common.custom({
|
|
2496
2502
|
name: network.name,
|
|
2497
2503
|
networkId: (0, _utils2._getEvmChainId)(network),
|
|
2498
2504
|
chainId: (0, _utils2._getEvmChainId)(network)
|
|
2499
|
-
},
|
|
2505
|
+
}, {
|
|
2506
|
+
hardfork: 'petersburg'
|
|
2507
|
+
});
|
|
2500
2508
|
|
|
2501
2509
|
// @ts-ignore
|
|
2502
|
-
const transaction = new
|
|
2510
|
+
const transaction = new _tx.LegacyTransaction(txObject, {
|
|
2503
2511
|
common
|
|
2504
2512
|
});
|
|
2505
|
-
pair.evmSigner.signTransaction(transaction);
|
|
2513
|
+
const signedTranaction = _tx.LegacyTransaction.fromSerializedTx((0, _util.hexToU8a)(pair.evmSigner.signTransaction(transaction)));
|
|
2506
2514
|
signed = (0, _eth.signatureToHex)({
|
|
2507
|
-
r: (0
|
|
2508
|
-
s: (0
|
|
2509
|
-
v: (0
|
|
2515
|
+
r: ((_signedTranaction$r = signedTranaction.r) === null || _signedTranaction$r === void 0 ? void 0 : _signedTranaction$r.toString(16)) || '',
|
|
2516
|
+
s: ((_signedTranaction$s = signedTranaction.s) === null || _signedTranaction$s === void 0 ? void 0 : _signedTranaction$s.toString(16)) || '',
|
|
2517
|
+
v: ((_signedTranaction$v = signedTranaction.v) === null || _signedTranaction$v === void 0 ? void 0 : _signedTranaction$v.toString(16)) || ''
|
|
2510
2518
|
});
|
|
2511
2519
|
}
|
|
2512
2520
|
return {
|
|
@@ -40,6 +40,7 @@ var _parseTransaction = require("@subwallet/extension-base/utils/eth/parseTransa
|
|
|
40
40
|
var _promise = require("@subwallet/extension-base/utils/promise");
|
|
41
41
|
var _decode = require("@subwallet/keyring/pair/decode");
|
|
42
42
|
var _uiKeyring = require("@subwallet/ui-keyring");
|
|
43
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
43
44
|
var _ethSimpleKeyring = _interopRequireDefault(require("eth-simple-keyring"));
|
|
44
45
|
var _i18next = require("i18next");
|
|
45
46
|
var _rxjs = require("rxjs");
|
|
@@ -1261,10 +1262,17 @@ class KoniState {
|
|
|
1261
1262
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1262
1263
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, e === null || e === void 0 ? void 0 : e.message);
|
|
1263
1264
|
}
|
|
1264
|
-
const
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1265
|
+
const priority = await (0, _eth.calculateGasFeeParams)(evmApi, networkKey);
|
|
1266
|
+
let estimateGas;
|
|
1267
|
+
if (priority.baseGasFee) {
|
|
1268
|
+
transaction.maxPriorityFeePerGas = priority.maxPriorityFeePerGas.toString();
|
|
1269
|
+
transaction.maxFeePerGas = priority.maxFeePerGas.toString();
|
|
1270
|
+
const priorityFee = priority.baseGasFee.plus(priority.maxPriorityFeePerGas);
|
|
1271
|
+
const maxFee = priority.maxFeePerGas.lte(priorityFee) ? priority.maxFeePerGas : priorityFee;
|
|
1272
|
+
estimateGas = maxFee.multipliedBy(transaction.gas).toFixed(0);
|
|
1273
|
+
} else {
|
|
1274
|
+
estimateGas = new _bignumber.default(priority.gasPrice).multipliedBy(transaction.gas).toFixed(0);
|
|
1275
|
+
}
|
|
1268
1276
|
|
|
1269
1277
|
// Address is validated in before step
|
|
1270
1278
|
const fromAddress = allowedAccounts.find(account => account.toLowerCase() === transaction.from.toLowerCase());
|
|
@@ -1282,7 +1290,7 @@ class KoniState {
|
|
|
1282
1290
|
|
|
1283
1291
|
// Validate balance
|
|
1284
1292
|
const balance = new _util.BN((await web3.eth.getBalance(fromAddress)) || 0);
|
|
1285
|
-
if (balance.lt(new _util.BN(
|
|
1293
|
+
if (balance.lt(new _util.BN(estimateGas).add(new _util.BN(autoFormatNumber(transactionParams.value) || '0')))) {
|
|
1286
1294
|
throw new _EvmProviderError.EvmProviderError(_KoniTypes.EvmProviderErrorType.INVALID_PARAMS, (0, _i18next.t)('Insufficient balance'));
|
|
1287
1295
|
}
|
|
1288
1296
|
transaction.nonce = await web3.eth.getTransactionCount(fromAddress);
|
|
@@ -1595,6 +1603,8 @@ class KoniState {
|
|
|
1595
1603
|
await this.keyringService.resetWallet(resetAll);
|
|
1596
1604
|
this.requestService.resetWallet();
|
|
1597
1605
|
this.transactionService.resetWallet();
|
|
1606
|
+
await this.handleResetBalance(_constants.ALL_ACCOUNT_KEY, true);
|
|
1607
|
+
await this.earningService.resetWallet();
|
|
1598
1608
|
await this.dbService.resetWallet(resetAll);
|
|
1599
1609
|
this.accountRefStore.set('refList', []);
|
|
1600
1610
|
if (resetAll) {
|
|
@@ -447,9 +447,6 @@ class ChainService {
|
|
|
447
447
|
checkLatestData() {
|
|
448
448
|
clearInterval(this.refreshLatestChainDataTimeOut);
|
|
449
449
|
this.handleLatestData();
|
|
450
|
-
this.handleLatestData();
|
|
451
|
-
this.handleLatestData();
|
|
452
|
-
this.handleLatestData();
|
|
453
450
|
this.refreshLatestChainDataTimeOut = setInterval(this.handleLatestData.bind(this), _constants.LATEST_CHAIN_DATA_FETCHING_INTERVAL);
|
|
454
451
|
}
|
|
455
452
|
stopCheckLatestChainData() {
|
|
@@ -10,6 +10,7 @@ var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
|
10
10
|
var _utils = require("@subwallet/extension-base/koni/api/yield/helper/utils");
|
|
11
11
|
var _types = require("@subwallet/extension-base/types");
|
|
12
12
|
var _utils2 = require("@subwallet/extension-base/utils");
|
|
13
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
13
14
|
var _i18next = require("i18next");
|
|
14
15
|
var _util = require("@polkadot/util");
|
|
15
16
|
var _special = _interopRequireDefault(require("../special"));
|
|
@@ -38,7 +39,7 @@ class BaseLiquidStakingPoolHandler extends _special.default {
|
|
|
38
39
|
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS));
|
|
39
40
|
}
|
|
40
41
|
const formattedMinAmount = (0, _utils.convertDerivativeToOriginToken)(amount, poolInfo, derivativeTokenInfo, originTokenInfo);
|
|
41
|
-
return
|
|
42
|
+
return new _bignumber.default(formattedMinAmount).multipliedBy(this.minAmountPercent).toFixed(0);
|
|
42
43
|
}
|
|
43
44
|
async validateYieldLeave(amount, address, fastLeave, selectedTarget) {
|
|
44
45
|
const poolInfo = await this.getPoolInfo();
|
|
@@ -41,7 +41,7 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
41
41
|
super(state, chain);
|
|
42
42
|
const chainInfo = this.chainInfo;
|
|
43
43
|
this.slug = `DOT___liquid_staking___${chain}`;
|
|
44
|
-
this.name = `${chainInfo.name} Liquid Staking`;
|
|
44
|
+
this.name = `${chainInfo.name} Liquid Staking DOT`;
|
|
45
45
|
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
46
46
|
}
|
|
47
47
|
getDescription() {
|
|
@@ -100,6 +100,7 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
100
100
|
unstakingPeriod: 24 * 28,
|
|
101
101
|
maxCandidatePerFarmer: 1,
|
|
102
102
|
maxWithdrawalRequestPerFarmer: 1,
|
|
103
|
+
farmerCount: vDOTStats.holders,
|
|
103
104
|
earningThreshold: {
|
|
104
105
|
join: minimumMint,
|
|
105
106
|
defaultUnstake: minimumRedeem,
|
|
@@ -16,6 +16,12 @@ Object.defineProperty(exports, "BifrostLiquidStakingPoolHandler", {
|
|
|
16
16
|
return _bifrost.default;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
Object.defineProperty(exports, "BifrostMantaLiquidStakingPoolHandler", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _bifrostManta.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
19
25
|
Object.defineProperty(exports, "ParallelLiquidStakingPoolHandler", {
|
|
20
26
|
enumerable: true,
|
|
21
27
|
get: function () {
|
|
@@ -30,5 +36,6 @@ Object.defineProperty(exports, "StellaSwapLiquidStakingPoolHandler", {
|
|
|
30
36
|
});
|
|
31
37
|
var _acala = _interopRequireDefault(require("./acala"));
|
|
32
38
|
var _bifrost = _interopRequireDefault(require("./bifrost"));
|
|
39
|
+
var _bifrostManta = _interopRequireDefault(require("./bifrost-manta"));
|
|
33
40
|
var _parallel = _interopRequireDefault(require("./parallel"));
|
|
34
41
|
var _stellaSwap = _interopRequireDefault(require("./stella-swap"));
|
|
@@ -47,9 +47,9 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
|
47
47
|
constructor(state, chain) {
|
|
48
48
|
super(state, chain);
|
|
49
49
|
this.slug = 'xcDOT___liquid_staking___stellaswap';
|
|
50
|
-
this.name = '
|
|
50
|
+
this.name = 'StellaSwap Liquid Staking';
|
|
51
51
|
this._logo = 'stellaswap';
|
|
52
|
-
this.shortName = '
|
|
52
|
+
this.shortName = 'StellaSwap';
|
|
53
53
|
}
|
|
54
54
|
getDescription() {
|
|
55
55
|
return 'Earn rewards by staking xcDOT for stDOT';
|
|
@@ -60,7 +60,15 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
60
60
|
const 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'; // TODO
|
|
61
61
|
const maxUnlockingChunks = substrateApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
62
62
|
const unlockingEras = substrateApi.api.consts.staking.bondingDuration.toString();
|
|
63
|
-
const
|
|
63
|
+
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
64
|
+
const erasPerDay = 24 / _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from epochDuration, blockTime, sessionsPerEra
|
|
65
|
+
|
|
66
|
+
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras));
|
|
67
|
+
const startEra = parseInt(currentEra) - supportedDays * erasPerDay;
|
|
68
|
+
const [_EraStakeInfo, _totalIssuance, _auctionCounter, _minNominatorBond, _counterForNominators, _minimumActiveStake, ..._eraReward] = await Promise.all([substrateApi.api.query.staking.erasTotalStake.multi([parseInt(currentEra), parseInt(currentEra) - 1]), substrateApi.api.query.balances.totalIssuance(), (_substrateApi$api$que2 = substrateApi.api.query.auctions) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.auctionCounter(), substrateApi.api.query.staking.minNominatorBond(), substrateApi.api.query.staking.counterForNominators(), ((_substrateApi$api$que3 = substrateApi.api.query) === null || _substrateApi$api$que3 === void 0 ? void 0 : (_substrateApi$api$que4 = _substrateApi$api$que3.staking) === null || _substrateApi$api$que4 === void 0 ? void 0 : _substrateApi$api$que4.minimumActiveStake) && ((_substrateApi$api$que5 = substrateApi.api.query) === null || _substrateApi$api$que5 === void 0 ? void 0 : (_substrateApi$api$que6 = _substrateApi$api$que5.staking) === null || _substrateApi$api$que6 === void 0 ? void 0 : _substrateApi$api$que6.minimumActiveStake()), substrateApi.api.query.staking.erasValidatorReward.multi([...Array(supportedDays).keys()].map(i => i + startEra))]);
|
|
69
|
+
const [_totalEraStake, _lastTotalStaked] = _EraStakeInfo;
|
|
70
|
+
const validatorEraReward = (0, _utils.getAvgValidatorEraReward)(supportedDays, _eraReward[0]);
|
|
71
|
+
const lastTotalStaked = _lastTotalStaked.toString();
|
|
64
72
|
const minActiveStake = (_minimumActiveStake === null || _minimumActiveStake === void 0 ? void 0 : _minimumActiveStake.toString()) || '0';
|
|
65
73
|
const minNominatorBond = _minNominatorBond.toString();
|
|
66
74
|
const bnMinActiveStake = new _util.BN(minActiveStake);
|
|
@@ -72,7 +80,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
72
80
|
const bnTotalEraStake = new _util.BN(rawTotalEraStake);
|
|
73
81
|
const bnTotalIssuance = new _util.BN(rawTotalIssuance);
|
|
74
82
|
const inflation = (0, _utils.calculateInflation)(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
75
|
-
const expectedReturn = (0, _utils.
|
|
83
|
+
const expectedReturn = (0, _utils.calculateChainStakedReturnV2)(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, true);
|
|
76
84
|
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
77
85
|
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
78
86
|
const farmerCount = _counterForNominators.toPrimitive();
|
|
@@ -86,7 +86,15 @@ class NominationPoolHandler extends _base.default {
|
|
|
86
86
|
const currentEra = _currentEra.toString();
|
|
87
87
|
const maxUnlockingChunks = substrateApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
88
88
|
const unlockingEras = substrateApi.api.consts.staking.bondingDuration.toString();
|
|
89
|
-
const
|
|
89
|
+
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
90
|
+
const erasPerDay = 24 / _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug]; // Can be exactly calculate from epochDuration, blockTime, sessionsPerEra
|
|
91
|
+
|
|
92
|
+
const supportedDays = (0, _utils.getSupportedDaysByHistoryDepth)(erasPerDay, parseInt(maxSupportedEras));
|
|
93
|
+
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$que2 = substrateApi.api.query.auctions) === null || _substrateApi$api$que2 === void 0 ? void 0 : _substrateApi$api$que2.auctionCounter(), (_substrateApi$api$que3 = substrateApi.api.query) === null || _substrateApi$api$que3 === void 0 ? void 0 : (_substrateApi$api$que4 = _substrateApi$api$que3.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))]);
|
|
95
|
+
const [_totalEraStake, _lastTotalStaked] = _EraStakeInfo;
|
|
96
|
+
const validatorEraReward = (0, _utils.getAvgValidatorEraReward)(supportedDays, _eraReward[0]);
|
|
97
|
+
const lastTotalStaked = _lastTotalStaked.toString();
|
|
90
98
|
const rawTotalEraStake = _totalEraStake.toString();
|
|
91
99
|
const rawTotalIssuance = _totalIssuance.toString();
|
|
92
100
|
const numAuctions = _auctionCounter ? _auctionCounter.toHuman() : 0;
|
|
@@ -94,7 +102,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
94
102
|
const bnTotalIssuance = new _util.BN(rawTotalIssuance);
|
|
95
103
|
const inflation = (0, _utils.calculateInflation)(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
96
104
|
const minPoolJoin = (_minPoolJoin === null || _minPoolJoin === void 0 ? void 0 : _minPoolJoin.toString()) || undefined;
|
|
97
|
-
const expectedReturn = (0, _utils.
|
|
105
|
+
const expectedReturn = (0, _utils.calculateChainStakedReturnV2)(chainInfo, rawTotalIssuance, erasPerDay, lastTotalStaked, validatorEraReward, true);
|
|
98
106
|
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
99
107
|
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
100
108
|
|