@subwallet/extension-base 1.1.31-1 → 1.1.31-beta.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 +111 -69
- package/background/KoniTypes.js +19 -13
- package/background/errors/TransactionError.js +9 -0
- package/cjs/background/KoniTypes.js +20 -16
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/constants/index.js +19 -4
- package/cjs/koni/api/dotsama/balance.js +464 -0
- package/cjs/koni/api/nft/config.js +33 -23
- package/cjs/koni/api/nft/index.js +14 -0
- package/cjs/koni/api/nft/nft.js +1 -22
- package/cjs/koni/api/nft/ordinal_nft/constants.js +21 -0
- package/cjs/koni/api/nft/ordinal_nft/index.js +121 -0
- package/cjs/koni/api/nft/ordinal_nft/utils.js +41 -0
- package/cjs/koni/api/staking/bonding/amplitude.js +17 -15
- package/cjs/koni/api/staking/bonding/astar.js +11 -10
- package/cjs/koni/api/staking/bonding/index.js +4 -1
- package/cjs/koni/api/staking/bonding/paraChain.js +25 -23
- package/cjs/koni/api/staking/bonding/relayChain.js +48 -45
- package/cjs/koni/api/staking/bonding/utils.js +104 -86
- package/cjs/koni/api/staking/index.js +6 -5
- package/cjs/koni/api/staking/paraChain.js +6 -5
- package/cjs/koni/api/staking/relayChain.js +3 -2
- package/cjs/koni/api/yield/helper/utils.js +46 -0
- package/cjs/koni/background/cron.js +11 -1
- package/cjs/koni/background/handlers/Extension.js +362 -69
- package/cjs/koni/background/handlers/State.js +51 -3
- package/cjs/koni/background/handlers/index.js +4 -2
- package/cjs/koni/background/subscription.js +95 -37
- package/cjs/services/campaign-service/index.js +9 -6
- package/cjs/services/chain-service/constants.js +2 -16
- package/cjs/services/chain-service/index.js +3 -2
- package/cjs/services/chain-service/utils.js +7 -1
- package/cjs/services/earning-service/constants/chains.js +29 -0
- package/cjs/services/earning-service/constants/index.js +27 -0
- package/cjs/services/earning-service/constants/step.js +18 -0
- package/cjs/services/earning-service/handlers/base.js +259 -0
- package/cjs/services/earning-service/handlers/index.js +60 -0
- package/cjs/services/earning-service/handlers/lending/base.js +20 -0
- package/cjs/services/earning-service/handlers/lending/index.js +13 -0
- package/cjs/services/earning-service/handlers/lending/interlay.js +191 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +239 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +43 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +297 -0
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +226 -0
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +395 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +384 -0
- package/cjs/services/earning-service/handlers/native-staking/astar.js +461 -0
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +146 -0
- package/cjs/services/earning-service/handlers/native-staking/base.js +159 -0
- package/cjs/services/earning-service/handlers/native-staking/index.js +34 -0
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +385 -0
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +558 -0
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +560 -0
- package/cjs/services/earning-service/handlers/special.js +503 -0
- package/cjs/services/earning-service/service.js +387 -0
- package/cjs/services/earning-service/utils/index.js +128 -0
- package/cjs/services/event-service/index.js +4 -0
- package/cjs/services/keyring-service/index.js +14 -2
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +21 -0
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +21 -0
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +17 -0
- package/cjs/services/migration-service/scripts/MigrateProvider.js +29 -0
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js +21 -0
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +21 -0
- package/cjs/services/migration-service/scripts/index.js +7 -1
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +149 -0
- package/cjs/services/mint-campaign-service/campaigns/index.js +13 -0
- package/cjs/services/mint-campaign-service/constants.js +11 -0
- package/cjs/services/mint-campaign-service/index.js +18 -0
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +51 -0
- package/cjs/services/storage-service/databases/index.js +4 -0
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +36 -0
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +65 -0
- package/cjs/services/storage-service/index.js +241 -0
- package/cjs/services/subscan-service/index.js +16 -0
- package/cjs/services/transaction-service/event-parser/index.js +58 -0
- package/cjs/services/transaction-service/helpers/index.js +3 -1
- package/cjs/services/transaction-service/index.js +231 -75
- package/cjs/services/transaction-service/utils.js +1 -0
- package/cjs/types/campaigns/index.js +16 -0
- package/cjs/types/campaigns/unlock-dot.js +1 -0
- package/cjs/types/index.js +44 -0
- package/cjs/types/ordinal.js +1 -0
- package/cjs/types/transaction.js +1 -0
- package/cjs/types/yield/actions/index.js +27 -0
- package/cjs/types/yield/actions/join/index.js +38 -0
- package/cjs/types/yield/actions/join/step.js +47 -0
- package/cjs/types/yield/actions/join/submit.js +1 -0
- package/cjs/types/yield/actions/join/validate.js +16 -0
- package/cjs/types/yield/actions/others.js +1 -0
- package/cjs/types/yield/index.js +27 -0
- package/cjs/types/yield/info/account/index.js +49 -0
- package/cjs/types/yield/info/account/info.js +1 -0
- package/cjs/types/yield/info/account/reward.js +1 -0
- package/cjs/types/yield/info/account/target.js +32 -0
- package/cjs/types/yield/info/account/unstake.js +27 -0
- package/cjs/types/yield/info/base.js +41 -0
- package/cjs/types/yield/info/chain/index.js +27 -0
- package/cjs/types/yield/info/chain/info.js +1 -0
- package/cjs/types/yield/info/chain/target.js +1 -0
- package/cjs/types/yield/info/index.js +49 -0
- package/cjs/types/yield/info/pallet.js +15 -0
- package/cjs/types.js +1 -0
- package/cjs/utils/address.js +34 -0
- package/cjs/utils/fetchStaticData.js +2 -1
- package/cjs/utils/index.js +89 -1
- package/cjs/utils/keyring.js +57 -0
- package/cjs/utils/number.js +3 -1
- package/cjs/utils/object.js +12 -0
- package/constants/index.d.ts +6 -1
- package/constants/index.js +6 -1
- package/koni/api/nft/config.js +33 -23
- package/koni/api/nft/index.js +15 -1
- package/koni/api/nft/nft.js +2 -23
- package/koni/api/nft/ordinal_nft/constants.d.ts +9 -0
- package/koni/api/nft/ordinal_nft/constants.js +12 -0
- package/koni/api/nft/ordinal_nft/index.d.ts +8 -0
- package/koni/api/nft/ordinal_nft/index.js +114 -0
- package/koni/api/nft/ordinal_nft/utils.d.ts +2 -0
- package/koni/api/nft/ordinal_nft/utils.js +33 -0
- package/koni/api/staking/bonding/amplitude.js +11 -9
- package/koni/api/staking/bonding/astar.js +9 -8
- package/koni/api/staking/bonding/index.d.ts +1 -1
- package/koni/api/staking/bonding/index.js +5 -1
- package/koni/api/staking/bonding/paraChain.js +12 -10
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +33 -30
- package/koni/api/staking/bonding/utils.d.ts +15 -38
- package/koni/api/staking/bonding/utils.js +85 -69
- package/koni/api/staking/index.js +2 -1
- package/koni/api/staking/paraChain.js +7 -6
- package/koni/api/staking/relayChain.js +4 -3
- package/koni/api/yield/helper/utils.d.ts +10 -0
- package/koni/api/yield/helper/utils.js +32 -0
- package/koni/background/cron.d.ts +1 -0
- package/koni/background/cron.js +12 -2
- package/koni/background/handlers/Extension.d.ts +17 -1
- package/koni/background/handlers/Extension.js +321 -30
- package/koni/background/handlers/State.d.ts +18 -2
- package/koni/background/handlers/State.js +50 -3
- package/koni/background/handlers/index.js +4 -2
- package/koni/background/subscription.d.ts +6 -1
- package/koni/background/subscription.js +97 -38
- package/package.json +316 -3
- package/services/campaign-service/index.js +9 -6
- package/services/chain-service/constants.d.ts +0 -11
- package/services/chain-service/constants.js +1 -14
- package/services/chain-service/index.js +3 -2
- package/services/chain-service/utils.d.ts +1 -0
- package/services/chain-service/utils.js +5 -1
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +1235 -0
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +1355 -0
- package/services/earning-service/constants/chains.d.ts +14 -0
- package/services/earning-service/constants/chains.js +21 -0
- package/services/earning-service/constants/index.d.ts +2 -0
- package/services/earning-service/constants/index.js +5 -0
- package/services/earning-service/constants/step.d.ts +3 -0
- package/services/earning-service/constants/step.js +10 -0
- package/services/earning-service/handlers/base.d.ts +112 -0
- package/services/earning-service/handlers/base.js +253 -0
- package/services/earning-service/handlers/index.d.ts +5 -0
- package/services/earning-service/handlers/index.js +8 -0
- package/services/earning-service/handlers/lending/base.d.ts +6 -0
- package/services/earning-service/handlers/lending/base.js +12 -0
- package/services/earning-service/handlers/lending/index.d.ts +1 -0
- package/services/earning-service/handlers/lending/index.js +4 -0
- package/services/earning-service/handlers/lending/interlay.d.ts +24 -0
- package/services/earning-service/handlers/lending/interlay.js +183 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +27 -0
- package/services/earning-service/handlers/liquid-staking/acala.js +231 -0
- package/services/earning-service/handlers/liquid-staking/base.d.ts +9 -0
- package/services/earning-service/handlers/liquid-staking/base.js +35 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +46 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.js +286 -0
- package/services/earning-service/handlers/liquid-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +26 -0
- package/services/earning-service/handlers/liquid-staking/parallel.js +218 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +34 -0
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +385 -0
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +22 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +375 -0
- package/services/earning-service/handlers/native-staking/astar.d.ts +19 -0
- package/services/earning-service/handlers/native-staking/astar.js +451 -0
- package/services/earning-service/handlers/native-staking/base-para.d.ts +11 -0
- package/services/earning-service/handlers/native-staking/base-para.js +138 -0
- package/services/earning-service/handlers/native-staking/base.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/base.js +150 -0
- package/services/earning-service/handlers/native-staking/index.d.ts +4 -0
- package/services/earning-service/handlers/native-staking/index.js +7 -0
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +15 -0
- package/services/earning-service/handlers/native-staking/para-chain.js +377 -0
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +21 -0
- package/services/earning-service/handlers/native-staking/relay-chain.js +549 -0
- package/services/earning-service/handlers/nomination-pool/index.d.ts +36 -0
- package/services/earning-service/handlers/nomination-pool/index.js +550 -0
- package/services/earning-service/handlers/special.d.ts +65 -0
- package/services/earning-service/handlers/special.js +495 -0
- package/services/earning-service/service.d.ts +45 -0
- package/services/earning-service/service.js +379 -0
- package/services/earning-service/utils/index.d.ts +18 -0
- package/services/earning-service/utils/index.js +112 -0
- package/services/event-service/index.d.ts +1 -0
- package/services/event-service/index.js +4 -0
- package/services/event-service/types.d.ts +8 -0
- package/services/keyring-service/index.d.ts +2 -1
- package/services/keyring-service/index.js +14 -2
- package/services/migration-service/scripts/DeleteEarningData.d.ts +4 -0
- package/services/migration-service/scripts/DeleteEarningData.js +13 -0
- package/services/migration-service/scripts/EnableEarningChains.d.ts +4 -0
- package/services/migration-service/scripts/EnableEarningChains.js +13 -0
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +13 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +13 -0
- package/services/migration-service/scripts/index.js +7 -1
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +13 -0
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +139 -0
- package/services/mint-campaign-service/campaigns/index.d.ts +1 -0
- package/services/mint-campaign-service/campaigns/index.js +4 -0
- package/services/mint-campaign-service/constants.d.ts +1 -0
- package/services/mint-campaign-service/constants.js +4 -0
- package/services/mint-campaign-service/index.d.ts +7 -0
- package/services/mint-campaign-service/index.js +11 -0
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +18 -1
- package/services/storage-service/DatabaseService.js +51 -0
- package/services/storage-service/databases/index.d.ts +3 -1
- package/services/storage-service/databases/index.js +4 -0
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +10 -0
- package/services/storage-service/db-stores/YieldPoolStore.js +28 -0
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +9 -0
- package/services/storage-service/db-stores/YieldPositionStore.js +57 -0
- package/services/subscan-service/index.d.ts +3 -2
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/services/transaction-service/event-parser/index.d.ts +3 -1
- package/services/transaction-service/event-parser/index.js +57 -1
- package/services/transaction-service/helpers/index.js +3 -1
- package/services/transaction-service/index.d.ts +4 -15
- package/services/transaction-service/index.js +229 -73
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +1 -0
- package/types/campaigns/index.d.ts +1 -0
- package/types/campaigns/index.js +4 -0
- package/types/campaigns/unlock-dot.d.ts +71 -0
- package/types/campaigns/unlock-dot.js +1 -0
- package/types/index.d.ts +5 -0
- package/types/index.js +5 -1
- package/types/ordinal.d.ts +69 -0
- package/types/ordinal.js +1 -0
- package/types/transaction.d.ts +3 -0
- package/types/transaction.js +1 -0
- package/types/yield/actions/index.d.ts +2 -0
- package/types/yield/actions/index.js +5 -0
- package/types/yield/actions/join/index.d.ts +3 -0
- package/types/yield/actions/join/index.js +6 -0
- package/types/yield/actions/join/step.d.ts +95 -0
- package/types/yield/actions/join/step.js +46 -0
- package/types/yield/actions/join/submit.d.ts +57 -0
- package/types/yield/actions/join/submit.js +1 -0
- package/types/yield/actions/join/validate.d.ts +18 -0
- package/types/yield/actions/join/validate.js +10 -0
- package/types/yield/actions/others.d.ts +85 -0
- package/types/yield/actions/others.js +1 -0
- package/types/yield/index.d.ts +2 -0
- package/types/yield/index.js +5 -0
- package/types/yield/info/account/index.d.ts +4 -0
- package/types/yield/info/account/index.js +7 -0
- package/types/yield/info/account/info.d.ts +92 -0
- package/types/yield/info/account/info.js +1 -0
- package/types/yield/info/account/reward.d.ts +45 -0
- package/types/yield/info/account/reward.js +1 -0
- package/types/yield/info/account/target.d.ts +43 -0
- package/types/yield/info/account/target.js +27 -0
- package/types/yield/info/account/unstake.d.ts +31 -0
- package/types/yield/info/account/unstake.js +22 -0
- package/types/yield/info/base.d.ts +45 -0
- package/types/yield/info/base.js +36 -0
- package/types/yield/info/chain/index.d.ts +2 -0
- package/types/yield/info/chain/index.js +5 -0
- package/types/yield/info/chain/info.d.ts +251 -0
- package/types/yield/info/chain/info.js +1 -0
- package/types/yield/info/chain/target.d.ts +37 -0
- package/types/yield/info/chain/target.js +1 -0
- package/types/yield/info/index.d.ts +4 -0
- package/types/yield/info/index.js +7 -0
- package/types/yield/info/pallet.d.ts +143 -0
- package/types/yield/info/pallet.js +9 -0
- package/utils/fetchStaticData.js +2 -1
- package/utils/index.d.ts +5 -0
- package/utils/index.js +53 -1
- package/utils/number.d.ts +1 -1
- package/utils/number.js +1 -1
- package/utils/object.d.ts +1 -0
- package/utils/object.js +6 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { APIItemState,
|
|
4
|
+
import { APIItemState, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { subscribeAmplitudeNominatorMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/amplitude';
|
|
6
6
|
import { subscribeAstarNominatorMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/astar';
|
|
7
7
|
import { subscribeParaChainNominatorMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/paraChain';
|
|
8
|
-
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
9
8
|
import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
9
|
+
import { _STAKING_CHAIN_GROUP } from '@subwallet/extension-base/services/earning-service/constants';
|
|
10
|
+
import { EarningStatus } from '@subwallet/extension-base/types';
|
|
10
11
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
11
12
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
12
13
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -35,7 +36,7 @@ function getSingleStakingAmplitude(substrateApi, address, chainInfoMap, chain, s
|
|
|
35
36
|
chain,
|
|
36
37
|
type: StakingType.NOMINATED,
|
|
37
38
|
address: owner,
|
|
38
|
-
status:
|
|
39
|
+
status: EarningStatus.NOT_STAKING,
|
|
39
40
|
activeStake: '0',
|
|
40
41
|
nominations: [],
|
|
41
42
|
unstakings: []
|
|
@@ -96,7 +97,7 @@ function getMultiStakingAmplitude(substrateApi, useAddresses, chainInfoMap, chai
|
|
|
96
97
|
chain,
|
|
97
98
|
type: StakingType.NOMINATED,
|
|
98
99
|
address: owner,
|
|
99
|
-
status:
|
|
100
|
+
status: EarningStatus.NOT_STAKING,
|
|
100
101
|
activeStake: '0',
|
|
101
102
|
nominations: [],
|
|
102
103
|
unstakings: []
|
|
@@ -214,7 +215,7 @@ export function getParaStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
214
215
|
chain,
|
|
215
216
|
type: StakingType.NOMINATED,
|
|
216
217
|
address: owner,
|
|
217
|
-
status:
|
|
218
|
+
status: EarningStatus.NOT_STAKING,
|
|
218
219
|
activeStake: '0',
|
|
219
220
|
nominations: [],
|
|
220
221
|
unstakings: []
|
|
@@ -274,7 +275,7 @@ export function getAstarStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
274
275
|
chain,
|
|
275
276
|
type: StakingType.NOMINATED,
|
|
276
277
|
address: owner,
|
|
277
|
-
status:
|
|
278
|
+
status: EarningStatus.NOT_STAKING,
|
|
278
279
|
activeStake: '0',
|
|
279
280
|
nominations: [],
|
|
280
281
|
unstakings: []
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { APIItemState,
|
|
4
|
+
import { APIItemState, StakingType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { subscribeRelayChainNominatorMetadata, subscribeRelayChainPoolMemberMetadata } from '@subwallet/extension-base/koni/api/staking/bonding/relayChain';
|
|
6
6
|
import { _getChainNativeTokenBasicInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
|
+
import { EarningStatus } from '@subwallet/extension-base/types';
|
|
7
8
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
8
9
|
import { BN } from '@polkadot/util';
|
|
9
10
|
import { isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -51,7 +52,7 @@ export function getRelayStakingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
51
52
|
nominatorStateCallback({
|
|
52
53
|
chain,
|
|
53
54
|
type: StakingType.NOMINATED,
|
|
54
|
-
status:
|
|
55
|
+
status: EarningStatus.NOT_STAKING,
|
|
55
56
|
address: owner,
|
|
56
57
|
activeStake: '0',
|
|
57
58
|
nominations: [],
|
|
@@ -113,7 +114,7 @@ export function getRelayPoolingOnChain(substrateApi, useAddresses, chainInfoMap,
|
|
|
113
114
|
chain,
|
|
114
115
|
type: StakingType.POOLED,
|
|
115
116
|
address: owner,
|
|
116
|
-
status:
|
|
117
|
+
status: EarningStatus.NOT_STAKING,
|
|
117
118
|
activeStake: '0',
|
|
118
119
|
nominations: [],
|
|
119
120
|
// can only join 1 pool at a time
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
|
+
import { RuntimeDispatchInfo, SpecialYieldPoolInfo, YieldStepDetail } from '@subwallet/extension-base/types';
|
|
4
|
+
export declare const syntheticSelectedValidators: string[];
|
|
5
|
+
export declare function calculateAlternativeFee(feeInfo: RuntimeDispatchInfo): number;
|
|
6
|
+
export declare const DEFAULT_YIELD_FIRST_STEP: YieldStepDetail;
|
|
7
|
+
export declare const YIELD_EXTRINSIC_TYPES: ExtrinsicType[];
|
|
8
|
+
export declare const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
|
|
9
|
+
export declare const YIELD_POOL_MIN_AMOUNT_PERCENT: Record<string, number>;
|
|
10
|
+
export declare function convertDerivativeToOriginToken(amount: string, poolInfo: SpecialYieldPoolInfo, derivativeTokenInfo: _ChainAsset, originTokenInfo: _ChainAsset): number;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
import { _getAssetDecimals } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
|
+
import { YieldStepType } from '@subwallet/extension-base/types';
|
|
7
|
+
export const syntheticSelectedValidators = ['15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6', '1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih', '1yGJ3h7TQuJWLYSsUVPZbM8aR8UsQXCqMvrFx5Fn1ktiAmq', '16GDRhRYxk42paoK6TfHAqWej8PdDDUwdDazjv4bAn4KGNeb', '13Ybj8CPEArUee78DxUAP9yX3ABmFNVQME1ZH4w8HVncHGzc', '14yx4vPAACZRhoDQm1dyvXD3QdRQyCRRCe5tj1zPomhhS29a', '14Vh8S1DzzycngbAB9vqEgPFR9JpSvmF1ezihTUES1EaHAV', '153YD8ZHD9dRh82U419bSCB5SzWhbdAFzjj4NtA5pMazR2yC', '1LUckyocmz9YzeQZHVpBvYYRGXb3rnSm2tvfz79h3G3JDgP', '14oRE62MB1SWR6h5RTx3GY5HK2oZipi1Gp3zdiLwVYLfEyRZ', '1cFsLn7o74nmjbRyDtMAnMpQMc5ZLsjgCSz9Np2mcejUK83', '15ZvLonEseaWZNy8LDkXXj3Y8bmAjxCjwvpy4pXWSL4nGSBs', '1NebF2xZHb4TJJpiqZZ3reeTo8dZov6LZ49qZqcHHbsmHfo', '1HmAqbBRrWvsqbLkvpiVDkdA2PcctUE5JUe3qokEh1FN455', '15tfUt4iQNjMyhZiJGBf4EpETE2KqtW1nfJwbBT1MvWjvcK9', '12RXTLiaYh59PokjZVhQvKzcfBEB5CvDnjKKUmDUotzcTH3S'];
|
|
8
|
+
export function calculateAlternativeFee(feeInfo) {
|
|
9
|
+
return feeInfo.partialFee;
|
|
10
|
+
}
|
|
11
|
+
export const DEFAULT_YIELD_FIRST_STEP = {
|
|
12
|
+
id: 0,
|
|
13
|
+
name: 'Fill information',
|
|
14
|
+
type: YieldStepType.DEFAULT
|
|
15
|
+
};
|
|
16
|
+
export const YIELD_EXTRINSIC_TYPES = [ExtrinsicType.MINT_VDOT, ExtrinsicType.MINT_LDOT, ExtrinsicType.MINT_SDOT, ExtrinsicType.MINT_QDOT, ExtrinsicType.MINT_STDOT, ExtrinsicType.REDEEM_QDOT, ExtrinsicType.REDEEM_SDOT, ExtrinsicType.REDEEM_VDOT, ExtrinsicType.REDEEM_LDOT, ExtrinsicType.REDEEM_STDOT, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.STAKING_LEAVE_POOL, ExtrinsicType.STAKING_POOL_WITHDRAW];
|
|
17
|
+
export const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
|
|
18
|
+
export const YIELD_POOL_MIN_AMOUNT_PERCENT = {
|
|
19
|
+
DOT___acala_liquid_staking: 0.98,
|
|
20
|
+
DOT___bifrost_liquid_staking: 0.99,
|
|
21
|
+
DOT___parallel_liquid_staking: 0.97,
|
|
22
|
+
default: 0.98
|
|
23
|
+
};
|
|
24
|
+
export function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, originTokenInfo) {
|
|
25
|
+
var _poolInfo$statistic, _poolInfo$statistic$a;
|
|
26
|
+
const derivativeDecimals = _getAssetDecimals(derivativeTokenInfo);
|
|
27
|
+
const originDecimals = _getAssetDecimals(originTokenInfo);
|
|
28
|
+
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;
|
|
29
|
+
const formattedAmount = parseInt(amount) / 10 ** derivativeDecimals; // TODO: decimals
|
|
30
|
+
const minAmount = formattedAmount * exchangeRate;
|
|
31
|
+
return Math.floor(minAmount * 10 ** originDecimals);
|
|
32
|
+
}
|
|
@@ -28,6 +28,7 @@ export declare class KoniCron {
|
|
|
28
28
|
resetNft: (newAddress: string) => void;
|
|
29
29
|
refreshStakingReward: (address: string) => () => void;
|
|
30
30
|
refreshStakingRewardFastInterval: (address: string) => () => void;
|
|
31
|
+
refreshEarningRewardHistoryInterval: (address: string) => () => void;
|
|
31
32
|
setStakingRewardReady: () => void;
|
|
32
33
|
checkNetworkAvailable: (serviceInfo: ServiceInfo) => boolean;
|
|
33
34
|
reloadNft(): Promise<boolean>;
|
package/koni/background/cron.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CRON_REFRESH_NFT_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
|
|
4
|
+
import { CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL, CRON_REFRESH_NFT_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
|
|
5
5
|
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
@@ -83,16 +83,20 @@ export class KoniCron {
|
|
|
83
83
|
|
|
84
84
|
// MantaPay
|
|
85
85
|
reloadMantaPay && this.removeCron('syncMantaPay');
|
|
86
|
+
commonReload && this.removeCron('refreshPoolingStakingReward');
|
|
86
87
|
|
|
87
88
|
// NFT
|
|
88
89
|
(commonReload || needUpdateNft) && this.resetNft(address);
|
|
89
90
|
(commonReload || needUpdateNft) && this.removeCron('refreshNft');
|
|
91
|
+
commonReload && this.removeCron('refreshPoolingStakingReward');
|
|
90
92
|
|
|
91
93
|
// Chains
|
|
92
94
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
93
|
-
// only add cron
|
|
95
|
+
// only add cron jobs if there's at least 1 active network
|
|
94
96
|
(commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
95
97
|
reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
98
|
+
(commonReload || chainUpdated) && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
99
|
+
(commonReload || chainUpdated) && this.addCron('refreshEarningRewardHistoryInterval', this.refreshEarningRewardHistoryInterval(currentAccountInfo.address), CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL);
|
|
96
100
|
} else {
|
|
97
101
|
this.setStakingRewardReady();
|
|
98
102
|
}
|
|
@@ -106,6 +110,7 @@ export class KoniCron {
|
|
|
106
110
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
107
111
|
// this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
108
112
|
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
113
|
+
this.addCron('refreshEarningRewardHistoryInterval', this.refreshEarningRewardHistoryInterval(currentAccountInfo.address), CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL);
|
|
109
114
|
this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
110
115
|
} else {
|
|
111
116
|
this.setStakingRewardReady();
|
|
@@ -153,6 +158,11 @@ export class KoniCron {
|
|
|
153
158
|
this.subscriptions.subscribeStakingRewardFastInterval(address).catch(this.logger.error);
|
|
154
159
|
};
|
|
155
160
|
};
|
|
161
|
+
refreshEarningRewardHistoryInterval = address => {
|
|
162
|
+
return () => {
|
|
163
|
+
this.subscriptions.subscribeEarningRewardHistoryInterval(address).catch(this.logger.error);
|
|
164
|
+
};
|
|
165
|
+
};
|
|
156
166
|
setStakingRewardReady = () => {
|
|
157
167
|
this.state.updateStakingRewardReady(true);
|
|
158
168
|
};
|
|
@@ -92,6 +92,7 @@ export default class KoniExtension {
|
|
|
92
92
|
private getBalance;
|
|
93
93
|
private subscribeBalance;
|
|
94
94
|
private getCrowdloan;
|
|
95
|
+
private getCrowdloanContributions;
|
|
95
96
|
private subscribeCrowdloan;
|
|
96
97
|
private validatePassword;
|
|
97
98
|
private validatedAccountsPassword;
|
|
@@ -162,7 +163,6 @@ export default class KoniExtension {
|
|
|
162
163
|
private getNominationPoolOptions;
|
|
163
164
|
private submitBonding;
|
|
164
165
|
private submitUnbonding;
|
|
165
|
-
private submitStakeWithdrawal;
|
|
166
166
|
private submitStakeClaimReward;
|
|
167
167
|
private submitCancelStakeWithdrawal;
|
|
168
168
|
private submitPoolBonding;
|
|
@@ -214,6 +214,22 @@ export default class KoniExtension {
|
|
|
214
214
|
private resolveAddressByDomain;
|
|
215
215
|
private addInjects;
|
|
216
216
|
private removeInjects;
|
|
217
|
+
private subscribeYieldPoolInfo;
|
|
218
|
+
private earlyValidateJoin;
|
|
219
|
+
private getOptimalYieldPath;
|
|
220
|
+
private handleYieldStep;
|
|
221
|
+
private handleYieldLeave;
|
|
222
|
+
private getYieldPoolTargets;
|
|
223
|
+
private subscribeYieldPosition;
|
|
224
|
+
private subscribeYieldReward;
|
|
225
|
+
private subscribeYieldRewardHistory;
|
|
226
|
+
private subscribeEarningMinAmountPercent;
|
|
227
|
+
private handleValidateYieldProcess;
|
|
228
|
+
private yieldSubmitWithdrawal;
|
|
229
|
+
private yieldSubmitCancelWithdrawal;
|
|
230
|
+
private yieldSubmitClaimReward;
|
|
231
|
+
private unlockDotCheckCanMint;
|
|
232
|
+
private unlockDotSubscribeMintedData;
|
|
217
233
|
private subscribeProcessingBanner;
|
|
218
234
|
private completeCampaignBanner;
|
|
219
235
|
private subscribeBuyTokens;
|