@subwallet/extension-base 1.1.29-beta.0 → 1.1.29-beta.1
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 +2 -1
- package/cjs/constants/index.js +11 -2
- package/cjs/koni/background/cron.js +10 -2
- package/cjs/koni/background/handlers/Extension.js +15 -0
- package/cjs/koni/background/subscription.js +12 -24
- package/cjs/services/earning-service/handlers/base.js +5 -3
- package/cjs/services/earning-service/handlers/lending/interlay.js +8 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +16 -5
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +17 -1
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +9 -3
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +38 -11
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +4 -2
- package/cjs/services/earning-service/handlers/native-staking/astar.js +11 -6
- package/cjs/services/earning-service/handlers/native-staking/base.js +45 -5
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +14 -1
- package/cjs/services/earning-service/handlers/special.js +7 -8
- package/cjs/services/earning-service/service.js +41 -5
- package/cjs/services/subscan-service/index.js +16 -0
- package/constants/index.d.ts +4 -1
- package/constants/index.js +4 -1
- package/koni/background/cron.d.ts +1 -0
- package/koni/background/cron.js +11 -3
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +15 -0
- package/koni/background/subscription.d.ts +1 -0
- package/koni/background/subscription.js +12 -23
- package/package.json +1 -1
- package/services/earning-service/handlers/base.d.ts +5 -1
- package/services/earning-service/handlers/base.js +5 -3
- package/services/earning-service/handlers/lending/interlay.d.ts +3 -2
- package/services/earning-service/handlers/lending/interlay.js +8 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +3 -4
- package/services/earning-service/handlers/liquid-staking/acala.js +16 -5
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +4 -3
- package/services/earning-service/handlers/liquid-staking/bifrost.js +17 -1
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +3 -5
- package/services/earning-service/handlers/liquid-staking/parallel.js +9 -3
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +4 -6
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +38 -11
- package/services/earning-service/handlers/native-staking/amplitude.js +4 -2
- package/services/earning-service/handlers/native-staking/astar.d.ts +2 -2
- package/services/earning-service/handlers/native-staking/astar.js +11 -6
- package/services/earning-service/handlers/native-staking/base.d.ts +3 -2
- package/services/earning-service/handlers/native-staking/base.js +45 -5
- package/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/services/earning-service/handlers/nomination-pool/index.d.ts +3 -1
- package/services/earning-service/handlers/nomination-pool/index.js +15 -2
- package/services/earning-service/handlers/special.d.ts +1 -4
- package/services/earning-service/handlers/special.js +7 -8
- package/services/earning-service/service.d.ts +7 -2
- package/services/earning-service/service.js +41 -5
- package/services/subscan-service/index.d.ts +2 -1
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/types/yield/info/account/info.d.ts +2 -11
- package/types/yield/info/account/reward.d.ts +15 -0
- package/types/yield/info/chain/info.d.ts +29 -3
|
@@ -7,7 +7,7 @@ import { _ChainState, _EvmApi, _NetworkUpsertParams, _SubstrateApi, _ValidateCus
|
|
|
7
7
|
import { CrowdloanContributionsResponse } from '@subwallet/extension-base/services/subscan-service/types';
|
|
8
8
|
import { SWTransactionResponse, SWTransactionResult } from '@subwallet/extension-base/services/transaction-service/types';
|
|
9
9
|
import { WalletConnectNotSupportRequest, WalletConnectSessionRequest } from '@subwallet/extension-base/services/wallet-connect-service/types';
|
|
10
|
-
import { BalanceJson, BuyServiceInfo, BuyTokenInfo, EarningRewardJson, EarningStatus, HandleYieldStepParams, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, RequestEarlyValidateYield, RequestGetYieldPoolTargets, RequestStakeCancelWithdrawal, RequestStakeClaimReward, RequestUnlockDotCheckCanMint, RequestUnlockDotSubscribeMintedData, RequestYieldLeave, RequestYieldStepSubmit, RequestYieldWithdrawal, ResponseEarlyValidateYield, ResponseGetYieldPoolTargets, SubmitYieldStepData, UnlockDotTransactionNft, UnstakingStatus, ValidateYieldProcessParams, YieldPoolInfo, YieldPositionInfo, YieldValidationStatus } from '@subwallet/extension-base/types';
|
|
10
|
+
import { BalanceJson, BuyServiceInfo, BuyTokenInfo, EarningRewardHistoryItem, EarningRewardJson, EarningStatus, HandleYieldStepParams, NominationPoolInfo, OptimalYieldPath, OptimalYieldPathParams, RequestEarlyValidateYield, RequestGetYieldPoolTargets, RequestStakeCancelWithdrawal, RequestStakeClaimReward, RequestUnlockDotCheckCanMint, RequestUnlockDotSubscribeMintedData, RequestYieldLeave, RequestYieldStepSubmit, RequestYieldWithdrawal, ResponseEarlyValidateYield, ResponseGetYieldPoolTargets, SubmitYieldStepData, UnlockDotTransactionNft, UnstakingStatus, ValidateYieldProcessParams, YieldPoolInfo, YieldPositionInfo, YieldValidationStatus } from '@subwallet/extension-base/types';
|
|
11
11
|
import { InjectedAccount, InjectedAccountWithMeta, MetadataDefBase } from '@subwallet/extension-inject/types';
|
|
12
12
|
import { KeyringPair$Json, KeyringPair$Meta } from '@subwallet/keyring/types';
|
|
13
13
|
import { KeyringOptions } from '@subwallet/ui-keyring/options/types';
|
|
@@ -1714,6 +1714,7 @@ export interface KoniRequestSignatures {
|
|
|
1714
1714
|
'pri(yield.subscribePoolInfo)': [null, YieldPoolInfo[], YieldPoolInfo[]];
|
|
1715
1715
|
'pri(yield.subscribeYieldPosition)': [null, YieldPositionInfo[], YieldPositionInfo[]];
|
|
1716
1716
|
'pri(yield.subscribeYieldReward)': [null, EarningRewardJson, EarningRewardJson];
|
|
1717
|
+
'pri(yield.subscribeRewardHistory)': [null, Record<string, EarningRewardHistoryItem>, Record<string, EarningRewardHistoryItem>];
|
|
1717
1718
|
'pri(yield.getTargets)': [RequestGetYieldPoolTargets, ResponseGetYieldPoolTargets];
|
|
1718
1719
|
'pri(yield.minAmountPercent)': [null, Record<string, number>, Record<string, number>];
|
|
1719
1720
|
'pri(yield.getNativeStakingValidators)': [YieldPoolInfo, ValidatorInfo[]];
|
package/cjs/constants/index.js
CHANGED
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
var _exportNames = {
|
|
7
|
+
BASE_SECOND_INTERVAL: true,
|
|
8
|
+
BASE_MINUTE_INTERVAL: true,
|
|
7
9
|
CRON_REFRESH_PRICE_INTERVAL: true,
|
|
8
10
|
CRON_AUTO_RECOVER_DOTSAMA_INTERVAL: true,
|
|
9
11
|
CRON_AUTO_RECOVER_WEB3_INTERVAL: true,
|
|
@@ -20,6 +22,7 @@ var _exportNames = {
|
|
|
20
22
|
CRON_RECOVER_HISTORY_INTERVAL: true,
|
|
21
23
|
CRON_SYNC_MANTA_PAY: true,
|
|
22
24
|
MANTA_PAY_BALANCE_INTERVAL: true,
|
|
25
|
+
CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL: true,
|
|
23
26
|
ALL_ACCOUNT_KEY: true,
|
|
24
27
|
ALL_NETWORK_KEY: true,
|
|
25
28
|
ALL_GENESIS_HASH: true,
|
|
@@ -31,7 +34,7 @@ var _exportNames = {
|
|
|
31
34
|
ORDINAL_COLLECTION: true,
|
|
32
35
|
ORDINAL_METHODS: true
|
|
33
36
|
};
|
|
34
|
-
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.ORDINAL_METHODS = exports.ORDINAL_COLLECTION = exports.NETWORK_MULTI_GAS_FEE = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.GAS_PRICE_RATIO = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
37
|
+
exports.XCM_MIN_AMOUNT_RATIO = exports.SUB_TOKEN_REFRESH_BALANCE_INTERVAL = exports.ORDINAL_METHODS = exports.ORDINAL_COLLECTION = exports.NETWORK_MULTI_GAS_FEE = exports.MANTA_PAY_BALANCE_INTERVAL = exports.IGNORE_QR_SIGNER = exports.IGNORE_GET_SUBSTRATE_FEATURES_LIST = exports.GAS_PRICE_RATIO = exports.CRON_SYNC_MANTA_PAY = exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = exports.CRON_REFRESH_PRICE_INTERVAL = exports.CRON_REFRESH_NFT_INTERVAL = exports.CRON_REFRESH_HISTORY_INTERVAL = exports.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = exports.CRON_REFRESH_CHAIN_STAKING_METADATA = exports.CRON_REFRESH_CHAIN_NOMINATOR_METADATA = exports.CRON_RECOVER_HISTORY_INTERVAL = exports.CRON_GET_API_MAP_STATUS = exports.CRON_AUTO_RECOVER_WEB3_INTERVAL = exports.CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = exports.BASE_SECOND_INTERVAL = exports.BASE_MINUTE_INTERVAL = exports.ASTAR_REFRESH_BALANCE_INTERVAL = exports.ALL_NETWORK_KEY = exports.ALL_GENESIS_HASH = exports.ALL_ACCOUNT_KEY = exports.ACALA_REFRESH_CROWDLOAN_INTERVAL = void 0;
|
|
35
38
|
var _staking = require("./staking");
|
|
36
39
|
Object.keys(_staking).forEach(function (key) {
|
|
37
40
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -59,6 +62,10 @@ Object.keys(_storage).forEach(function (key) {
|
|
|
59
62
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
60
63
|
// SPDX-License-Identifier: Apache-2.0
|
|
61
64
|
|
|
65
|
+
const BASE_SECOND_INTERVAL = 1000;
|
|
66
|
+
exports.BASE_SECOND_INTERVAL = BASE_SECOND_INTERVAL;
|
|
67
|
+
const BASE_MINUTE_INTERVAL = 60 * BASE_SECOND_INTERVAL;
|
|
68
|
+
exports.BASE_MINUTE_INTERVAL = BASE_MINUTE_INTERVAL;
|
|
62
69
|
const CRON_REFRESH_PRICE_INTERVAL = 30000;
|
|
63
70
|
exports.CRON_REFRESH_PRICE_INTERVAL = CRON_REFRESH_PRICE_INTERVAL;
|
|
64
71
|
const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
@@ -75,7 +82,7 @@ const CRON_REFRESH_NFT_INTERVAL = 7200000;
|
|
|
75
82
|
exports.CRON_REFRESH_NFT_INTERVAL = CRON_REFRESH_NFT_INTERVAL;
|
|
76
83
|
const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
77
84
|
exports.CRON_REFRESH_STAKING_REWARD_INTERVAL = CRON_REFRESH_STAKING_REWARD_INTERVAL;
|
|
78
|
-
const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
85
|
+
const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
|
|
79
86
|
exports.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL;
|
|
80
87
|
const CRON_REFRESH_HISTORY_INTERVAL = 900000;
|
|
81
88
|
exports.CRON_REFRESH_HISTORY_INTERVAL = CRON_REFRESH_HISTORY_INTERVAL;
|
|
@@ -91,6 +98,8 @@ const CRON_SYNC_MANTA_PAY = 300000;
|
|
|
91
98
|
exports.CRON_SYNC_MANTA_PAY = CRON_SYNC_MANTA_PAY;
|
|
92
99
|
const MANTA_PAY_BALANCE_INTERVAL = 30000;
|
|
93
100
|
exports.MANTA_PAY_BALANCE_INTERVAL = MANTA_PAY_BALANCE_INTERVAL;
|
|
101
|
+
const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
|
|
102
|
+
exports.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL;
|
|
94
103
|
const ALL_ACCOUNT_KEY = 'ALL';
|
|
95
104
|
exports.ALL_ACCOUNT_KEY = ALL_ACCOUNT_KEY;
|
|
96
105
|
const ALL_NETWORK_KEY = 'all';
|
|
@@ -99,13 +99,15 @@ class KoniCron {
|
|
|
99
99
|
// NFT
|
|
100
100
|
(commonReload || needUpdateNft) && this.resetNft(address);
|
|
101
101
|
(commonReload || needUpdateNft) && this.removeCron('refreshNft');
|
|
102
|
+
commonReload && this.removeCron('refreshPoolingStakingReward');
|
|
102
103
|
|
|
103
104
|
// Chains
|
|
104
105
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
105
|
-
// only add cron
|
|
106
|
+
// only add cron jobs if there's at least 1 active network
|
|
106
107
|
(commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
107
108
|
reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
108
|
-
commonReload && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
109
|
+
(commonReload || chainUpdated) && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
110
|
+
(commonReload || chainUpdated) && this.addCron('refreshEarningRewardHistoryInterval', this.refreshEarningRewardHistoryInterval(currentAccountInfo.address), _constants.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL);
|
|
109
111
|
} else {
|
|
110
112
|
this.setStakingRewardReady();
|
|
111
113
|
}
|
|
@@ -119,6 +121,7 @@ class KoniCron {
|
|
|
119
121
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), _constants.CRON_REFRESH_NFT_INTERVAL);
|
|
120
122
|
// this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
121
123
|
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), _constants.CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
124
|
+
this.addCron('refreshEarningRewardHistoryInterval', this.refreshEarningRewardHistoryInterval(currentAccountInfo.address), _constants.CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL);
|
|
122
125
|
this.addCron('syncMantaPay', this.syncMantaPay, _constants.CRON_SYNC_MANTA_PAY);
|
|
123
126
|
} else {
|
|
124
127
|
this.setStakingRewardReady();
|
|
@@ -166,6 +169,11 @@ class KoniCron {
|
|
|
166
169
|
this.subscriptions.subscribeStakingRewardFastInterval(address).catch(this.logger.error);
|
|
167
170
|
};
|
|
168
171
|
};
|
|
172
|
+
refreshEarningRewardHistoryInterval = address => {
|
|
173
|
+
return () => {
|
|
174
|
+
this.subscriptions.subscribeEarningRewardHistoryInterval(address).catch(this.logger.error);
|
|
175
|
+
};
|
|
176
|
+
};
|
|
169
177
|
setStakingRewardReady = () => {
|
|
170
178
|
this.state.updateStakingRewardReady(true);
|
|
171
179
|
};
|
|
@@ -3761,6 +3761,19 @@ class KoniExtension {
|
|
|
3761
3761
|
});
|
|
3762
3762
|
return this.#koniState.earningService.getEarningRewards();
|
|
3763
3763
|
}
|
|
3764
|
+
subscribeYieldRewardHistory(id, port) {
|
|
3765
|
+
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3766
|
+
const rewardHistorySubscription = this.#koniState.earningService.subscribeEarningRewardHistory().subscribe({
|
|
3767
|
+
next: rs => {
|
|
3768
|
+
cb(rs);
|
|
3769
|
+
}
|
|
3770
|
+
});
|
|
3771
|
+
this.createUnsubscriptionHandle(id, rewardHistorySubscription.unsubscribe);
|
|
3772
|
+
port.onDisconnect.addListener(() => {
|
|
3773
|
+
this.cancelSubscription(id);
|
|
3774
|
+
});
|
|
3775
|
+
return this.#koniState.earningService.getEarningRewardHistory();
|
|
3776
|
+
}
|
|
3764
3777
|
subscribeEarningMinAmountPercent(id, port) {
|
|
3765
3778
|
const cb = (0, _subscriptions.createSubscription)(id, port);
|
|
3766
3779
|
const earningMinAmountPercentSubscription = this.#koniState.earningService.subscribeMinAmountPercent().subscribe({
|
|
@@ -4105,6 +4118,8 @@ class KoniExtension {
|
|
|
4105
4118
|
return this.subscribeYieldPosition(id, port);
|
|
4106
4119
|
case 'pri(yield.subscribeYieldReward)':
|
|
4107
4120
|
return this.subscribeYieldReward(id, port);
|
|
4121
|
+
case 'pri(yield.subscribeRewardHistory)':
|
|
4122
|
+
return this.subscribeYieldRewardHistory(id, port);
|
|
4108
4123
|
case 'pri(yield.minAmountPercent)':
|
|
4109
4124
|
return this.subscribeEarningMinAmountPercent(id, port);
|
|
4110
4125
|
|
|
@@ -145,7 +145,7 @@ class KoniSubscription {
|
|
|
145
145
|
}
|
|
146
146
|
initYieldPoolStatsSubscription(substrateApiMap, evmApiMap, onlyRunOnFirstTime) {
|
|
147
147
|
let cancel = false;
|
|
148
|
-
this.state.resetYieldPoolInfo(Object.keys(this.state.
|
|
148
|
+
this.state.resetYieldPoolInfo(Object.keys(this.state.getChainInfoMap()));
|
|
149
149
|
const updateYieldPoolStats = data => {
|
|
150
150
|
this.state.updateYieldPoolInfo(data);
|
|
151
151
|
};
|
|
@@ -301,33 +301,21 @@ class KoniSubscription {
|
|
|
301
301
|
if (!addresses.length) {
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
|
-
const pooledStakingItems = await this.state.getPooledPositionByAddress(addresses);
|
|
305
|
-
const pooledAddresses = [];
|
|
306
|
-
pooledStakingItems.forEach(pooledItem => {
|
|
307
|
-
if (!pooledAddresses.includes(pooledItem.address)) {
|
|
308
|
-
pooledAddresses.push(pooledItem.address);
|
|
309
|
-
}
|
|
310
|
-
});
|
|
311
|
-
const chainInfoMap = this.state.getChainInfoMap();
|
|
312
|
-
const targetChainMap = {};
|
|
313
|
-
Object.entries(chainInfoMap).forEach(_ref2 => {
|
|
314
|
-
let [key, network] = _ref2;
|
|
315
|
-
const chainState = this.state.getChainStateByKey(key);
|
|
316
|
-
if ((0, _utils._isChainEnabled)(chainState) && (0, _utils._isChainSupportSubstrateStaking)(network)) {
|
|
317
|
-
targetChainMap[key] = network;
|
|
318
|
-
}
|
|
319
|
-
});
|
|
320
|
-
const activeNetworks = [];
|
|
321
|
-
Object.keys(targetChainMap).forEach(key => {
|
|
322
|
-
activeNetworks.push(key);
|
|
323
|
-
});
|
|
324
304
|
const updateState = result => {
|
|
325
305
|
this.state.earningService.updateEarningReward(result);
|
|
326
306
|
};
|
|
327
|
-
await Promise.all([this.state.earningService.getPoolReward(addresses, updateState)
|
|
328
|
-
|
|
307
|
+
await Promise.all([this.state.earningService.getPoolReward(addresses, updateState)]);
|
|
308
|
+
}
|
|
309
|
+
async subscribeEarningRewardHistoryInterval(address) {
|
|
310
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
311
|
+
if (!addresses.length) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const updateState = result => {
|
|
315
|
+
this.state.earningService.updateEarningRewardHistory(result);
|
|
316
|
+
};
|
|
317
|
+
await Promise.all([this.state.earningService.fetchPoolRewardHistory(addresses, updateState)]);
|
|
329
318
|
}
|
|
330
|
-
|
|
331
319
|
async reloadStaking() {
|
|
332
320
|
// const currentAddress = this.state.keyringService.currentAccount?.address;
|
|
333
321
|
|
|
@@ -32,6 +32,8 @@ class BasePoolHandler {
|
|
|
32
32
|
/** Pool's transaction type */
|
|
33
33
|
transactionChainType = _KoniTypes.ChainType.SUBSTRATE;
|
|
34
34
|
|
|
35
|
+
/** Pool's available method */
|
|
36
|
+
|
|
35
37
|
/**
|
|
36
38
|
* @constructor
|
|
37
39
|
* @param {KoniState} state - Koni state
|
|
@@ -75,7 +77,7 @@ class BasePoolHandler {
|
|
|
75
77
|
const decimals = this.nativeToken.decimals || 0;
|
|
76
78
|
const defaultMaintainBalance = new _util.BN(1).mul(_util.BN_TEN.pow(new _util.BN(decimals)));
|
|
77
79
|
const ed = new _util.BN(this.nativeToken.minAmount || '0');
|
|
78
|
-
const maintainBalance = ed.
|
|
80
|
+
const maintainBalance = ed.gte(defaultMaintainBalance) ? ed.mul(new _util.BN(1.5)) : defaultMaintainBalance;
|
|
79
81
|
return maintainBalance.toString();
|
|
80
82
|
}
|
|
81
83
|
get metadataInfo() {
|
|
@@ -85,9 +87,9 @@ class BasePoolHandler {
|
|
|
85
87
|
logo: this.logo,
|
|
86
88
|
inputAsset: this.nativeToken.slug,
|
|
87
89
|
isAvailable: true,
|
|
88
|
-
allowCancelUnstaking: false,
|
|
89
90
|
maintainAsset: this.nativeToken.slug,
|
|
90
|
-
maintainBalance: this.maintainBalance
|
|
91
|
+
maintainBalance: this.maintainBalance,
|
|
92
|
+
availableMethod: this.availableMethod
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
95
|
|
|
@@ -21,6 +21,14 @@ class InterlayLendingPoolHandler extends _base.default {
|
|
|
21
21
|
inputAsset = 'interlay-LOCAL-DOT';
|
|
22
22
|
rewardAssets = ['interlay-LOCAL-DOT'];
|
|
23
23
|
feeAssets = ['interlay-NATIVE-INTR', 'interlay-LOCAL-DOT'];
|
|
24
|
+
availableMethod = {
|
|
25
|
+
join: true,
|
|
26
|
+
defaultUnstake: false,
|
|
27
|
+
fastUnstake: true,
|
|
28
|
+
cancelUnstake: false,
|
|
29
|
+
withdraw: false,
|
|
30
|
+
claimReward: false
|
|
31
|
+
};
|
|
24
32
|
constructor(state, chain) {
|
|
25
33
|
super(state, chain);
|
|
26
34
|
const chainInfo = this.chainInfo;
|
|
@@ -23,10 +23,15 @@ class AcalaLiquidStakingPoolHandler extends _base.default {
|
|
|
23
23
|
inputAsset = 'acala-LOCAL-DOT';
|
|
24
24
|
rewardAssets = ['acala-LOCAL-DOT'];
|
|
25
25
|
feeAssets = ['acala-NATIVE-ACA', 'acala-LOCAL-DOT'];
|
|
26
|
-
/** @inner */
|
|
27
26
|
minAmountPercent = 0.98;
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
availableMethod = {
|
|
28
|
+
join: true,
|
|
29
|
+
defaultUnstake: true,
|
|
30
|
+
fastUnstake: true,
|
|
31
|
+
cancelUnstake: false,
|
|
32
|
+
withdraw: true,
|
|
33
|
+
claimReward: false
|
|
34
|
+
};
|
|
30
35
|
constructor(state, chain) {
|
|
31
36
|
super(state, chain);
|
|
32
37
|
const chainInfo = this.chainInfo;
|
|
@@ -40,6 +45,7 @@ class AcalaLiquidStakingPoolHandler extends _base.default {
|
|
|
40
45
|
|
|
41
46
|
/* Subscribe pool info */
|
|
42
47
|
|
|
48
|
+
// Todo: Update with cache statistic data => Fetching periodically assetEarning, apy, exchangeRate, tvl, totalApy
|
|
43
49
|
async getPoolStat() {
|
|
44
50
|
const substrateApi = await this.substrateApi.isReady;
|
|
45
51
|
const stakingMetaPromise = new Promise(function (resolve) {
|
|
@@ -123,6 +129,7 @@ class AcalaLiquidStakingPoolHandler extends _base.default {
|
|
|
123
129
|
derivativeToken: derivativeTokenSlug,
|
|
124
130
|
isBondedBefore: bnTotalBalance.gt(_util.BN_ZERO),
|
|
125
131
|
nominations: [],
|
|
132
|
+
// TODO: add unstaking info from homa.redeemRequests
|
|
126
133
|
unstakings: []
|
|
127
134
|
};
|
|
128
135
|
resultCallback(result);
|
|
@@ -193,12 +200,16 @@ class AcalaLiquidStakingPoolHandler extends _base.default {
|
|
|
193
200
|
weightedMinAmount // should always set a min target to prevent unexpected result
|
|
194
201
|
);
|
|
195
202
|
|
|
196
|
-
return [_KoniTypes.ExtrinsicType.
|
|
203
|
+
return [_KoniTypes.ExtrinsicType.REDEEM_LDOT, extrinsic];
|
|
197
204
|
}
|
|
198
205
|
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
199
206
|
const chainApi = await this.substrateApi.isReady;
|
|
200
207
|
const extrinsic = chainApi.api.tx.homa.requestRedeem(amount, false);
|
|
201
|
-
return [_KoniTypes.ExtrinsicType.
|
|
208
|
+
return [_KoniTypes.ExtrinsicType.UNSTAKE_LDOT, extrinsic];
|
|
209
|
+
}
|
|
210
|
+
async handleYieldWithdraw(address, unstakingInfo) {
|
|
211
|
+
const chainApi = await this.substrateApi.isReady;
|
|
212
|
+
return chainApi.api.tx.homa.claimRedemption(address);
|
|
202
213
|
}
|
|
203
214
|
|
|
204
215
|
/* Leave pool action */
|
|
@@ -26,8 +26,15 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
26
26
|
inputAsset = 'bifrost_dot-LOCAL-DOT';
|
|
27
27
|
rewardAssets = ['bifrost_dot-LOCAL-DOT'];
|
|
28
28
|
feeAssets = ['bifrost_dot-NATIVE-BNC', 'bifrost_dot-LOCAL-DOT'];
|
|
29
|
-
/** @inner */
|
|
30
29
|
minAmountPercent = 0.99;
|
|
30
|
+
availableMethod = {
|
|
31
|
+
join: true,
|
|
32
|
+
defaultUnstake: true,
|
|
33
|
+
fastUnstake: true,
|
|
34
|
+
cancelUnstake: false,
|
|
35
|
+
withdraw: false,
|
|
36
|
+
claimReward: false
|
|
37
|
+
};
|
|
31
38
|
constructor(state, chain) {
|
|
32
39
|
super(state, chain);
|
|
33
40
|
const chainInfo = this.chainInfo;
|
|
@@ -140,6 +147,8 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
const unlockingMap = {};
|
|
150
|
+
|
|
151
|
+
// TODO: review unstaking info vtokenMinting.userUnlockLedger
|
|
143
152
|
const _unlockInfoList = await substrateApi.api.query.vtokenMinting.tokenUnlockLedger.multi(unlockLedgerList.map(_ref => {
|
|
144
153
|
let {
|
|
145
154
|
ledgerId
|
|
@@ -261,6 +270,13 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
261
270
|
const extrinsic = substrateApi.api.tx.stablePool.swap(0, 1, 0, amount, weightedMinAmount);
|
|
262
271
|
return [_KoniTypes.ExtrinsicType.REDEEM_VDOT, extrinsic];
|
|
263
272
|
}
|
|
273
|
+
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
274
|
+
const chainApi = await this.substrateApi.isReady;
|
|
275
|
+
const inputTokenSlug = this.inputAsset;
|
|
276
|
+
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
277
|
+
const extrinsic = chainApi.api.tx.vtokenMinting.redeem((0, _utils._getTokenOnChainInfo)(inputTokenInfo), amount);
|
|
278
|
+
return [_KoniTypes.ExtrinsicType.UNSTAKE_VDOT, extrinsic];
|
|
279
|
+
}
|
|
264
280
|
|
|
265
281
|
/* Leave pool action */
|
|
266
282
|
}
|
|
@@ -20,10 +20,15 @@ class ParallelLiquidStakingPoolHandler extends _base.default {
|
|
|
20
20
|
inputAsset = 'parallel-LOCAL-DOT';
|
|
21
21
|
rewardAssets = ['parallel-LOCAL-DOT'];
|
|
22
22
|
feeAssets = ['parallel-NATIVE-PARA'];
|
|
23
|
-
/** @inner */
|
|
24
23
|
minAmountPercent = 0.97;
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
availableMethod = {
|
|
25
|
+
join: true,
|
|
26
|
+
defaultUnstake: true,
|
|
27
|
+
fastUnstake: true,
|
|
28
|
+
cancelUnstake: false,
|
|
29
|
+
withdraw: false,
|
|
30
|
+
claimReward: false
|
|
31
|
+
};
|
|
27
32
|
constructor(state, chain) {
|
|
28
33
|
super(state, chain);
|
|
29
34
|
const chainInfo = this.chainInfo;
|
|
@@ -119,6 +124,7 @@ class ParallelLiquidStakingPoolHandler extends _base.default {
|
|
|
119
124
|
derivativeToken: derivativeTokenSlug,
|
|
120
125
|
isBondedBefore: bnTotalBalance.gt(_util.BN_ZERO),
|
|
121
126
|
nominations: [],
|
|
127
|
+
// TODO: add unstaking info from liquidStaking.unlockings
|
|
122
128
|
unstakings: []
|
|
123
129
|
};
|
|
124
130
|
resultCallback(result);
|
|
@@ -25,6 +25,7 @@ const getStellaswapLiquidStakingContract = function (networkKey, assetAddress, e
|
|
|
25
25
|
};
|
|
26
26
|
exports.getStellaswapLiquidStakingContract = getStellaswapLiquidStakingContract;
|
|
27
27
|
const APR_STATS_URL = 'https://apr-api.stellaswap.com/api/v1/stdot';
|
|
28
|
+
const SUBWALLET_REFERRAL = '0x7e6815f45E624768548d085231f2d453f16FD7DD';
|
|
28
29
|
const MAX_INT = '115792089237316195423570985008687907853269984665640564039457584007913129639935';
|
|
29
30
|
class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
30
31
|
inputAsset = 'moonbeam-LOCAL-xcDOT';
|
|
@@ -32,11 +33,15 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
|
32
33
|
derivativeAssets = ['moonbeam-ERC20-stDOT-0xbc7E02c4178a7dF7d3E564323a5c359dc96C4db4'];
|
|
33
34
|
rewardAssets = ['moonbeam-LOCAL-xcDOT'];
|
|
34
35
|
feeAssets = ['moonbeam-NATIVE-GLMR'];
|
|
35
|
-
/** @inner */
|
|
36
|
-
allowDefaultUnstake = true;
|
|
37
|
-
/** @inner */
|
|
38
|
-
allowFastUnstake = false;
|
|
39
36
|
transactionChainType = _KoniTypes.ChainType.EVM;
|
|
37
|
+
availableMethod = {
|
|
38
|
+
join: true,
|
|
39
|
+
defaultUnstake: true,
|
|
40
|
+
fastUnstake: true,
|
|
41
|
+
cancelUnstake: false,
|
|
42
|
+
withdraw: true,
|
|
43
|
+
claimReward: false
|
|
44
|
+
};
|
|
40
45
|
constructor(state, chain) {
|
|
41
46
|
super(state, chain);
|
|
42
47
|
this.slug = 'xcDOT___liquid_staking___stellaswap';
|
|
@@ -139,11 +144,9 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
|
139
144
|
unstakings.push({
|
|
140
145
|
chain: this.chain,
|
|
141
146
|
claimable: unbondedObject.waiting,
|
|
142
|
-
status: _types.UnstakingStatus.UNLOCKING
|
|
143
|
-
waitingTime: 20 // TODO: Recheck
|
|
147
|
+
status: _types.UnstakingStatus.UNLOCKING
|
|
144
148
|
});
|
|
145
149
|
}
|
|
146
|
-
|
|
147
150
|
const totalBalance = new _util.BN(balance).add(unlockBalance);
|
|
148
151
|
const result = {
|
|
149
152
|
...this.baseInfo,
|
|
@@ -189,8 +192,7 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
|
189
192
|
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
190
193
|
const inputTokenContract = (0, _web.getERC20Contract)(this.chain, (0, _utils._getContractAddressOfToken)(inputTokenInfo), this.state.getEvmApiMap());
|
|
191
194
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
192
|
-
const allowanceCall = inputTokenContract.methods.allowance(params.address, (0, _utils._getContractAddressOfToken)(derivativeTokenInfo));
|
|
193
|
-
|
|
195
|
+
const allowanceCall = inputTokenContract.methods.allowance(params.address, (0, _utils._getContractAddressOfToken)(derivativeTokenInfo));
|
|
194
196
|
const [allowance, gasPrice] = await Promise.all([
|
|
195
197
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
196
198
|
await allowanceCall.call(), evmApi.api.eth.getGasPrice()]);
|
|
@@ -299,10 +301,12 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
|
299
301
|
} = data;
|
|
300
302
|
const inputTokenSlug = this.inputAsset;
|
|
301
303
|
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
304
|
+
const derivativeTokenInfo = this.state.getAssetBySlug(this.derivativeAssets[0]);
|
|
305
|
+
const derivativeTokenContractAddress = (0, _utils._getContractAddressOfToken)(derivativeTokenInfo);
|
|
302
306
|
const inputTokenContract = (0, _web.getERC20Contract)(this.chain, (0, _utils._getContractAddressOfToken)(inputTokenInfo), this.state.getEvmApiMap());
|
|
303
307
|
|
|
304
308
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
305
|
-
const approveCall = inputTokenContract.methods.approve(
|
|
309
|
+
const approveCall = inputTokenContract.methods.approve(derivativeTokenContractAddress, MAX_INT); // TODO: need test
|
|
306
310
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
307
311
|
const approveEncodedCall = approveCall.encodeABI();
|
|
308
312
|
const transactionObject = {
|
|
@@ -331,7 +335,7 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
|
331
335
|
const stakingContract = getStellaswapLiquidStakingContract(this.chain, (0, _utils._getContractAddressOfToken)(derivativeTokenInfo), evmApi);
|
|
332
336
|
|
|
333
337
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
334
|
-
const depositCall = stakingContract.methods.deposit(amount); // TODO:
|
|
338
|
+
const depositCall = stakingContract.methods.deposit(amount, SUBWALLET_REFERRAL); // TODO: need test
|
|
335
339
|
|
|
336
340
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
337
341
|
const depositEncodedCall = depositCall.encodeABI();
|
|
@@ -378,5 +382,28 @@ class StellaSwapLiquidStakingPoolHandler extends _base.default {
|
|
|
378
382
|
}
|
|
379
383
|
|
|
380
384
|
/* Leave pool action */
|
|
385
|
+
|
|
386
|
+
/* Other actions */
|
|
387
|
+
|
|
388
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
389
|
+
async handleYieldWithdraw(address, unstakingInfo) {
|
|
390
|
+
const evmApi = this.evmApi;
|
|
391
|
+
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
392
|
+
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
393
|
+
const stakingContract = getStellaswapLiquidStakingContract(this.chain, (0, _utils._getContractAddressOfToken)(derivativeTokenInfo), evmApi);
|
|
394
|
+
|
|
395
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
396
|
+
const withdrawCall = stakingContract.methods.claimUnbonded();
|
|
397
|
+
|
|
398
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
399
|
+
const withdrawEncodedCall = withdrawCall.encodeABI();
|
|
400
|
+
return {
|
|
401
|
+
from: address,
|
|
402
|
+
to: (0, _utils._getContractAddressOfToken)(derivativeTokenInfo),
|
|
403
|
+
data: withdrawEncodedCall
|
|
404
|
+
}; // TODO: check tx history parsing
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/* Other actions */
|
|
381
408
|
}
|
|
382
409
|
exports.default = StellaSwapLiquidStakingPoolHandler;
|
|
@@ -49,10 +49,11 @@ class AmplitudeNativeStakingPoolHandler extends _basePara.default {
|
|
|
49
49
|
const round = (0, _utils3.parseRawNumber)(roundObj.current);
|
|
50
50
|
const maxDelegations = substrateApi.api.consts.parachainStaking.maxDelegationsPerRound.toString();
|
|
51
51
|
const minDelegatorStake = substrateApi.api.consts.parachainStaking.minDelegatorStake.toString();
|
|
52
|
-
const unstakingDelay = substrateApi.api.consts.parachainStaking.stakeDuration.toString();
|
|
52
|
+
const unstakingDelay = substrateApi.api.consts.parachainStaking.stakeDuration.toString(); // in blocks
|
|
53
53
|
const _blockPerRound = substrateApi.api.consts.parachainStaking.defaultBlocksPerRound.toString();
|
|
54
54
|
const blockPerRound = parseFloat(_blockPerRound);
|
|
55
|
-
const
|
|
55
|
+
const roundTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
56
|
+
const blockDuration = roundTime / blockPerRound; // in hours
|
|
56
57
|
const unstakingPeriod = blockDuration * parseInt(unstakingDelay);
|
|
57
58
|
const minToHuman = (0, _utils3.formatNumber)(minDelegatorStake, nativeToken.decimals || 0, _utils3.balanceFormatter);
|
|
58
59
|
const delegatorStorages = await substrateApi.api.query.parachainStaking.delegatorState.keys();
|
|
@@ -77,6 +78,7 @@ class AmplitudeNativeStakingPoolHandler extends _basePara.default {
|
|
|
77
78
|
farmerCount: delegatorStorages.length,
|
|
78
79
|
// One delegator (farmer) - One collator (candidate) - on storage
|
|
79
80
|
era: round,
|
|
81
|
+
eraTime: roundTime,
|
|
80
82
|
tvl: stakeInfo.delegators,
|
|
81
83
|
// TODO recheck
|
|
82
84
|
totalApy: undefined,
|
|
@@ -43,11 +43,14 @@ function getAstarWithdrawable(yieldPosition) {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
class AstarNativeStakingPoolHandler extends _basePara.default {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
46
|
+
availableMethod = {
|
|
47
|
+
join: true,
|
|
48
|
+
defaultUnstake: true,
|
|
49
|
+
fastUnstake: false,
|
|
50
|
+
cancelUnstake: false,
|
|
51
|
+
withdraw: true,
|
|
52
|
+
claimReward: true
|
|
53
|
+
};
|
|
51
54
|
|
|
52
55
|
/* Subscribe pool info */
|
|
53
56
|
|
|
@@ -102,7 +105,8 @@ class AstarNativeStakingPoolHandler extends _basePara.default {
|
|
|
102
105
|
const era = _currentEra.toString();
|
|
103
106
|
const minDelegatorStake = substrateApi.api.consts.dappsStaking.minimumStakingAmount.toString();
|
|
104
107
|
const unstakingDelay = substrateApi.api.consts.dappsStaking.unbondingPeriod.toString();
|
|
105
|
-
const
|
|
108
|
+
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
109
|
+
const unstakingPeriod = parseInt(unstakingDelay) * eraTime;
|
|
106
110
|
const minToHuman = (0, _utils2.formatNumber)(minDelegatorStake, nativeToken.decimals || 0, _utils2.balanceFormatter);
|
|
107
111
|
const data = {
|
|
108
112
|
// TODO
|
|
@@ -125,6 +129,7 @@ class AstarNativeStakingPoolHandler extends _basePara.default {
|
|
|
125
129
|
farmerCount: 0,
|
|
126
130
|
// TODO recheck
|
|
127
131
|
era: parseInt(era),
|
|
132
|
+
eraTime,
|
|
128
133
|
tvl: undefined,
|
|
129
134
|
// TODO recheck
|
|
130
135
|
totalApy: apyInfo !== null ? apyInfo : undefined,
|
|
@@ -15,6 +15,14 @@ var _base = _interopRequireDefault(require("../base"));
|
|
|
15
15
|
|
|
16
16
|
class BaseNativeStakingPoolHandler extends _base.default {
|
|
17
17
|
type = _types.YieldPoolType.NATIVE_STAKING;
|
|
18
|
+
availableMethod = {
|
|
19
|
+
join: true,
|
|
20
|
+
defaultUnstake: true,
|
|
21
|
+
fastUnstake: false,
|
|
22
|
+
cancelUnstake: true,
|
|
23
|
+
withdraw: true,
|
|
24
|
+
claimReward: false
|
|
25
|
+
};
|
|
18
26
|
constructor(state, chain) {
|
|
19
27
|
super(state, chain);
|
|
20
28
|
const _chainAsset = this.nativeToken;
|
|
@@ -30,17 +38,49 @@ class BaseNativeStakingPoolHandler extends _base.default {
|
|
|
30
38
|
const symbol = _chainAsset.symbol;
|
|
31
39
|
return `Start staking with just {{amount}} ${symbol}`.replace('{{amount}}', amount);
|
|
32
40
|
}
|
|
33
|
-
get metadataInfo() {
|
|
34
|
-
const result = super.metadataInfo;
|
|
35
|
-
result.allowCancelUnstaking = true;
|
|
36
|
-
return result;
|
|
37
|
-
}
|
|
38
41
|
|
|
39
42
|
/* Get pool reward */
|
|
40
43
|
|
|
41
44
|
async getPoolReward(useAddresses, callBack) {
|
|
42
45
|
return new Promise(resolve => resolve(_util.noop));
|
|
43
46
|
}
|
|
47
|
+
async getPoolRewardHistory(useAddresses, callBack) {
|
|
48
|
+
let cancel = false;
|
|
49
|
+
const haveSubscanService = this.state.subscanService.checkSupportedSubscanChain(this.chain);
|
|
50
|
+
if (haveSubscanService) {
|
|
51
|
+
for (const address of useAddresses) {
|
|
52
|
+
if (cancel) {
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
const rs = await this.state.subscanService.getRewardHistoryList(this.chain, address);
|
|
57
|
+
const items = rs.list;
|
|
58
|
+
if (items) {
|
|
59
|
+
for (const item of items) {
|
|
60
|
+
const now = new Date();
|
|
61
|
+
const isMillisecond = now.getTime().toString().length === item.block_timestamp.toString().length;
|
|
62
|
+
const timeStamp = isMillisecond ? item.block_timestamp : item.block_timestamp * 1000;
|
|
63
|
+
const data = {
|
|
64
|
+
slug: this.slug,
|
|
65
|
+
type: this.type,
|
|
66
|
+
chain: this.chain,
|
|
67
|
+
address: address,
|
|
68
|
+
group: this.group,
|
|
69
|
+
blockTimestamp: timeStamp,
|
|
70
|
+
amount: item.amount
|
|
71
|
+
};
|
|
72
|
+
callBack(data);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
} catch (e) {
|
|
76
|
+
console.error(e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return () => {
|
|
81
|
+
cancel = false;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
44
84
|
|
|
45
85
|
/* Get pool reward */
|
|
46
86
|
|
|
@@ -68,7 +68,8 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
68
68
|
|
|
69
69
|
const inflationConfig = _inflation.toHuman();
|
|
70
70
|
const inflation = (0, _utils.getParaCurrentInflation)((0, _utils3.parseRawNumber)(totalStake.toString()), inflationConfig);
|
|
71
|
-
const
|
|
71
|
+
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
72
|
+
const unstakingPeriod = parseInt(unstakingDelay) * eraTime;
|
|
72
73
|
const minStake = '0';
|
|
73
74
|
const minToHuman = (0, _utils3.formatNumber)(minStake.toString(), nativeToken.decimals || 0, _utils3.balanceFormatter);
|
|
74
75
|
const data = {
|
|
@@ -90,6 +91,7 @@ class ParaNativeStakingPoolHandler extends _basePara.default {
|
|
|
90
91
|
farmerCount: 0,
|
|
91
92
|
// TODO recheck
|
|
92
93
|
era: round,
|
|
94
|
+
eraTime,
|
|
93
95
|
totalApy: undefined,
|
|
94
96
|
// not have
|
|
95
97
|
tvl: totalStake.toString(),
|
|
@@ -68,7 +68,8 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
68
68
|
const bnTotalIssuance = new _util.BN(rawTotalIssuance);
|
|
69
69
|
const inflation = (0, _utils.calculateInflation)(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
70
70
|
const expectedReturn = (0, _utils.calculateChainStakedReturn)(inflation, bnTotalEraStake, bnTotalIssuance, chainInfo.slug);
|
|
71
|
-
const
|
|
71
|
+
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
72
|
+
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
72
73
|
const farmerCount = _counterForNominators.toPrimitive();
|
|
73
74
|
const minToHuman = (0, _utils4.formatNumber)(minStake.toString(), nativeToken.decimals || 0, _utils4.balanceFormatter);
|
|
74
75
|
const data = {
|
|
@@ -90,6 +91,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
90
91
|
minJoinPool: minStake.toString(),
|
|
91
92
|
farmerCount: farmerCount,
|
|
92
93
|
era: parseInt(currentEra),
|
|
94
|
+
eraTime,
|
|
93
95
|
tvl: bnTotalEraStake.toString(),
|
|
94
96
|
// TODO recheck
|
|
95
97
|
totalApy: expectedReturn,
|