@subwallet/extension-base 1.1.31-beta.0 → 1.1.32-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 +69 -111
- package/background/KoniTypes.js +13 -19
- package/background/errors/TransactionError.js +0 -9
- package/cjs/background/KoniTypes.js +16 -20
- package/cjs/background/errors/TransactionError.js +0 -9
- package/cjs/constants/index.js +4 -19
- package/cjs/koni/api/nft/config.js +23 -33
- package/cjs/koni/api/nft/index.js +0 -14
- package/cjs/koni/api/nft/nft.js +22 -1
- package/cjs/koni/api/staking/bonding/amplitude.js +15 -17
- package/cjs/koni/api/staking/bonding/astar.js +10 -11
- package/cjs/koni/api/staking/bonding/index.js +3 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +29 -28
- package/cjs/koni/api/staking/bonding/relayChain.js +45 -48
- package/cjs/koni/api/staking/bonding/utils.js +86 -104
- package/cjs/koni/api/staking/index.js +5 -6
- package/cjs/koni/api/staking/paraChain.js +5 -6
- package/cjs/koni/api/staking/relayChain.js +2 -3
- package/cjs/koni/background/cron.js +1 -11
- package/cjs/koni/background/handlers/Extension.js +69 -362
- package/cjs/koni/background/handlers/State.js +3 -51
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +37 -95
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +18 -3
- package/cjs/services/chain-service/index.js +2 -3
- package/cjs/services/chain-service/utils.js +1 -7
- package/cjs/services/event-service/index.js +0 -4
- package/cjs/services/keyring-service/index.js +2 -14
- package/cjs/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/cjs/services/migration-service/scripts/index.js +1 -7
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -51
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/cjs/services/subscan-service/index.js +0 -16
- package/cjs/services/transaction-service/event-parser/index.js +0 -58
- package/cjs/services/transaction-service/helpers/index.js +1 -3
- package/cjs/services/transaction-service/index.js +75 -231
- package/cjs/services/transaction-service/utils.js +0 -1
- package/cjs/types/index.js +0 -44
- package/cjs/utils/fetchStaticData.js +1 -2
- package/cjs/utils/index.js +1 -89
- package/cjs/utils/number.js +1 -3
- package/constants/index.d.ts +1 -6
- package/constants/index.js +1 -6
- package/koni/api/nft/config.js +23 -33
- package/koni/api/nft/index.js +1 -15
- package/koni/api/nft/nft.js +23 -2
- package/koni/api/staking/bonding/amplitude.js +9 -11
- package/koni/api/staking/bonding/astar.js +8 -9
- package/koni/api/staking/bonding/index.d.ts +2 -1
- package/koni/api/staking/bonding/index.js +3 -5
- package/koni/api/staking/bonding/paraChain.js +16 -15
- package/koni/api/staking/bonding/relayChain.d.ts +2 -2
- package/koni/api/staking/bonding/relayChain.js +30 -33
- package/koni/api/staking/bonding/utils.d.ts +38 -15
- package/koni/api/staking/bonding/utils.js +69 -85
- package/koni/api/staking/index.js +1 -2
- package/koni/api/staking/paraChain.js +6 -7
- package/koni/api/staking/relayChain.js +3 -4
- package/koni/background/cron.d.ts +0 -1
- package/koni/background/cron.js +2 -12
- package/koni/background/handlers/Extension.d.ts +1 -17
- package/koni/background/handlers/Extension.js +30 -321
- package/koni/background/handlers/State.d.ts +2 -18
- package/koni/background/handlers/State.js +3 -50
- package/koni/background/handlers/index.js +2 -4
- package/koni/background/subscription.d.ts +1 -6
- package/koni/background/subscription.js +38 -97
- package/package.json +8 -321
- package/packageInfo.js +1 -1
- package/services/campaign-service/index.js +6 -9
- package/services/chain-service/constants.d.ts +11 -0
- package/services/chain-service/constants.js +16 -2
- package/services/chain-service/index.js +2 -3
- package/services/chain-service/utils.d.ts +0 -1
- package/services/chain-service/utils.js +1 -5
- package/services/event-service/index.d.ts +0 -1
- package/services/event-service/index.js +0 -4
- package/services/event-service/types.d.ts +0 -8
- package/services/keyring-service/index.d.ts +1 -2
- package/services/keyring-service/index.js +2 -14
- package/services/migration-service/scripts/MigrateLedgerAccount.js +1 -1
- package/services/migration-service/scripts/MigrateTransactionHistory.js +1 -1
- package/services/migration-service/scripts/index.js +1 -7
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -18
- package/services/storage-service/DatabaseService.js +0 -51
- package/services/storage-service/databases/index.d.ts +1 -3
- package/services/storage-service/databases/index.js +0 -4
- package/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- package/services/subscan-service/index.d.ts +2 -3
- package/services/subscan-service/index.js +0 -15
- package/services/subscan-service/types.d.ts +0 -20
- package/services/transaction-service/event-parser/index.d.ts +1 -3
- package/services/transaction-service/event-parser/index.js +1 -57
- package/services/transaction-service/helpers/index.js +1 -3
- package/services/transaction-service/index.d.ts +15 -4
- package/services/transaction-service/index.js +73 -229
- package/services/transaction-service/types.d.ts +0 -2
- package/services/transaction-service/utils.js +0 -1
- package/types/index.d.ts +0 -5
- package/types/index.js +1 -5
- package/utils/fetchStaticData.js +1 -2
- package/utils/index.d.ts +0 -5
- package/utils/index.js +1 -53
- package/utils/number.d.ts +1 -1
- package/utils/number.js +1 -1
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/koni/api/nft/ordinal_nft/constants.js +0 -21
- package/cjs/koni/api/nft/ordinal_nft/index.js +0 -121
- package/cjs/koni/api/nft/ordinal_nft/utils.js +0 -41
- package/cjs/koni/api/yield/helper/utils.js +0 -46
- package/cjs/services/earning-service/constants/chains.js +0 -29
- package/cjs/services/earning-service/constants/index.js +0 -27
- package/cjs/services/earning-service/constants/step.js +0 -18
- package/cjs/services/earning-service/handlers/base.js +0 -259
- package/cjs/services/earning-service/handlers/index.js +0 -60
- package/cjs/services/earning-service/handlers/lending/base.js +0 -20
- package/cjs/services/earning-service/handlers/lending/index.js +0 -13
- package/cjs/services/earning-service/handlers/lending/interlay.js +0 -191
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -239
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -43
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -297
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -226
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -395
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -384
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -461
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -146
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -159
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -385
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -558
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -560
- package/cjs/services/earning-service/handlers/special.js +0 -503
- package/cjs/services/earning-service/service.js +0 -387
- package/cjs/services/earning-service/utils/index.js +0 -128
- package/cjs/services/migration-service/scripts/DeleteEarningData.js +0 -21
- package/cjs/services/migration-service/scripts/EnableEarningChains.js +0 -21
- 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/migration-service/scripts/databases/MigrateEarningHistory.js +0 -21
- package/cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -21
- package/cjs/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -149
- package/cjs/services/mint-campaign-service/campaigns/index.js +0 -13
- package/cjs/services/mint-campaign-service/constants.js +0 -11
- package/cjs/services/mint-campaign-service/index.js +0 -18
- package/cjs/services/storage-service/db-stores/YieldPoolStore.js +0 -36
- package/cjs/services/storage-service/db-stores/YieldPositionStore.js +0 -65
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types/campaigns/index.js +0 -16
- package/cjs/types/campaigns/unlock-dot.js +0 -1
- package/cjs/types/ordinal.js +0 -1
- package/cjs/types/transaction.js +0 -1
- package/cjs/types/yield/actions/index.js +0 -27
- package/cjs/types/yield/actions/join/index.js +0 -38
- package/cjs/types/yield/actions/join/step.js +0 -47
- package/cjs/types/yield/actions/join/submit.js +0 -1
- package/cjs/types/yield/actions/join/validate.js +0 -16
- package/cjs/types/yield/actions/others.js +0 -1
- package/cjs/types/yield/index.js +0 -27
- package/cjs/types/yield/info/account/index.js +0 -49
- package/cjs/types/yield/info/account/info.js +0 -1
- package/cjs/types/yield/info/account/reward.js +0 -1
- package/cjs/types/yield/info/account/target.js +0 -32
- package/cjs/types/yield/info/account/unstake.js +0 -27
- package/cjs/types/yield/info/base.js +0 -41
- package/cjs/types/yield/info/chain/index.js +0 -27
- package/cjs/types/yield/info/chain/info.js +0 -1
- package/cjs/types/yield/info/chain/target.js +0 -1
- package/cjs/types/yield/info/index.js +0 -49
- package/cjs/types/yield/info/pallet.js +0 -15
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
- package/cjs/utils/object.js +0 -12
- package/koni/api/nft/ordinal_nft/constants.d.ts +0 -9
- package/koni/api/nft/ordinal_nft/constants.js +0 -12
- package/koni/api/nft/ordinal_nft/index.d.ts +0 -8
- package/koni/api/nft/ordinal_nft/index.js +0 -114
- package/koni/api/nft/ordinal_nft/utils.d.ts +0 -2
- package/koni/api/nft/ordinal_nft/utils.js +0 -33
- package/koni/api/yield/helper/utils.d.ts +0 -10
- package/koni/api/yield/helper/utils.js +0 -32
- package/services/earning-service/constants/abis/compound_finance_v2_abi.json +0 -1235
- package/services/earning-service/constants/abis/st_liquid_token_abi.json +0 -1355
- package/services/earning-service/constants/chains.d.ts +0 -14
- package/services/earning-service/constants/chains.js +0 -21
- package/services/earning-service/constants/index.d.ts +0 -2
- package/services/earning-service/constants/index.js +0 -5
- package/services/earning-service/constants/step.d.ts +0 -3
- package/services/earning-service/constants/step.js +0 -10
- package/services/earning-service/handlers/base.d.ts +0 -112
- package/services/earning-service/handlers/base.js +0 -253
- package/services/earning-service/handlers/index.d.ts +0 -5
- package/services/earning-service/handlers/index.js +0 -8
- package/services/earning-service/handlers/lending/base.d.ts +0 -6
- package/services/earning-service/handlers/lending/base.js +0 -12
- package/services/earning-service/handlers/lending/index.d.ts +0 -1
- package/services/earning-service/handlers/lending/index.js +0 -4
- package/services/earning-service/handlers/lending/interlay.d.ts +0 -24
- package/services/earning-service/handlers/lending/interlay.js +0 -183
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -231
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -9
- package/services/earning-service/handlers/liquid-staking/base.js +0 -35
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -46
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -286
- package/services/earning-service/handlers/liquid-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/liquid-staking/index.js +0 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +0 -26
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -218
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -34
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -385
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -375
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/astar.js +0 -451
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -138
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/base.js +0 -150
- package/services/earning-service/handlers/native-staking/index.d.ts +0 -4
- package/services/earning-service/handlers/native-staking/index.js +0 -7
- package/services/earning-service/handlers/native-staking/para-chain.d.ts +0 -15
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -377
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -549
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -36
- package/services/earning-service/handlers/nomination-pool/index.js +0 -550
- package/services/earning-service/handlers/special.d.ts +0 -65
- package/services/earning-service/handlers/special.js +0 -495
- package/services/earning-service/service.d.ts +0 -45
- package/services/earning-service/service.js +0 -379
- package/services/earning-service/utils/index.d.ts +0 -18
- package/services/earning-service/utils/index.js +0 -112
- package/services/migration-service/scripts/DeleteEarningData.d.ts +0 -4
- package/services/migration-service/scripts/DeleteEarningData.js +0 -13
- package/services/migration-service/scripts/EnableEarningChains.d.ts +0 -4
- package/services/migration-service/scripts/EnableEarningChains.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningHistory.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningHistory.js +0 -13
- package/services/migration-service/scripts/databases/MigrateEarningVersion.d.ts +0 -4
- package/services/migration-service/scripts/databases/MigrateEarningVersion.js +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.d.ts +0 -13
- package/services/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -139
- package/services/mint-campaign-service/campaigns/index.d.ts +0 -1
- package/services/mint-campaign-service/campaigns/index.js +0 -4
- package/services/mint-campaign-service/constants.d.ts +0 -1
- package/services/mint-campaign-service/constants.js +0 -4
- package/services/mint-campaign-service/index.d.ts +0 -7
- package/services/mint-campaign-service/index.js +0 -11
- package/services/storage-service/db-stores/YieldPoolStore.d.ts +0 -10
- package/services/storage-service/db-stores/YieldPoolStore.js +0 -28
- package/services/storage-service/db-stores/YieldPositionStore.d.ts +0 -9
- package/services/storage-service/db-stores/YieldPositionStore.js +0 -57
- package/types/campaigns/index.d.ts +0 -1
- package/types/campaigns/index.js +0 -4
- package/types/campaigns/unlock-dot.d.ts +0 -71
- package/types/campaigns/unlock-dot.js +0 -1
- package/types/ordinal.d.ts +0 -69
- package/types/ordinal.js +0 -1
- package/types/transaction.d.ts +0 -3
- package/types/transaction.js +0 -1
- package/types/yield/actions/index.d.ts +0 -2
- package/types/yield/actions/index.js +0 -5
- package/types/yield/actions/join/index.d.ts +0 -3
- package/types/yield/actions/join/index.js +0 -6
- package/types/yield/actions/join/step.d.ts +0 -95
- package/types/yield/actions/join/step.js +0 -46
- package/types/yield/actions/join/submit.d.ts +0 -57
- package/types/yield/actions/join/submit.js +0 -1
- package/types/yield/actions/join/validate.d.ts +0 -18
- package/types/yield/actions/join/validate.js +0 -10
- package/types/yield/actions/others.d.ts +0 -85
- package/types/yield/actions/others.js +0 -1
- package/types/yield/index.d.ts +0 -2
- package/types/yield/index.js +0 -5
- package/types/yield/info/account/index.d.ts +0 -4
- package/types/yield/info/account/index.js +0 -7
- package/types/yield/info/account/info.d.ts +0 -92
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -45
- package/types/yield/info/account/reward.js +0 -1
- package/types/yield/info/account/target.d.ts +0 -43
- package/types/yield/info/account/target.js +0 -27
- package/types/yield/info/account/unstake.d.ts +0 -31
- package/types/yield/info/account/unstake.js +0 -22
- package/types/yield/info/base.d.ts +0 -45
- package/types/yield/info/base.js +0 -36
- package/types/yield/info/chain/index.d.ts +0 -2
- package/types/yield/info/chain/index.js +0 -5
- package/types/yield/info/chain/info.d.ts +0 -251
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -37
- package/types/yield/info/chain/target.js +0 -1
- package/types/yield/info/index.d.ts +0 -4
- package/types/yield/info/index.js +0 -7
- package/types/yield/info/pallet.d.ts +0 -143
- package/types/yield/info/pallet.js +0 -9
- package/utils/object.d.ts +0 -1
- package/utils/object.js +0 -6
|
@@ -1,503 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _chainList = require("@subwallet/chain-list");
|
|
9
|
-
var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
10
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
11
|
-
var _constants = require("@subwallet/extension-base/constants");
|
|
12
|
-
var _xcm = require("@subwallet/extension-base/koni/api/xcm");
|
|
13
|
-
var _utils = require("@subwallet/extension-base/koni/api/yield/helper/utils");
|
|
14
|
-
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
15
|
-
var _types = require("@subwallet/extension-base/types");
|
|
16
|
-
var _utils3 = require("@subwallet/extension-base/utils");
|
|
17
|
-
var _i18next = require("i18next");
|
|
18
|
-
var _util = require("@polkadot/util");
|
|
19
|
-
var _base = _interopRequireDefault(require("./base"));
|
|
20
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
21
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
22
|
-
|
|
23
|
-
class BaseSpecialStakingPoolHandler extends _base.default {
|
|
24
|
-
/** Pool's type */
|
|
25
|
-
|
|
26
|
-
/** Exchange rate before divine with decimals */
|
|
27
|
-
rate = 0;
|
|
28
|
-
constructor(state, chain) {
|
|
29
|
-
super(state, chain);
|
|
30
|
-
this.exchangeRatePromise = (0, _utils3.createPromiseHandler)();
|
|
31
|
-
}
|
|
32
|
-
get metadataInfo() {
|
|
33
|
-
return {
|
|
34
|
-
altInputAssets: this.altInputAsset,
|
|
35
|
-
derivativeAssets: this.derivativeAssets,
|
|
36
|
-
inputAsset: this.inputAsset,
|
|
37
|
-
rewardAssets: this.rewardAssets,
|
|
38
|
-
feeAssets: this.feeAssets,
|
|
39
|
-
logo: this.logo,
|
|
40
|
-
shortName: this.shortName,
|
|
41
|
-
name: this.name,
|
|
42
|
-
isAvailable: true,
|
|
43
|
-
maintainAsset: this.nativeToken.slug,
|
|
44
|
-
maintainBalance: this.maintainBalance,
|
|
45
|
-
availableMethod: this.availableMethod
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
updateExchangeRate(rate) {
|
|
49
|
-
this.rate = rate;
|
|
50
|
-
this.exchangeRatePromise.resolve(true);
|
|
51
|
-
}
|
|
52
|
-
async getExchangeRate() {
|
|
53
|
-
await this.exchangeRatePromise.promise;
|
|
54
|
-
return this.rate;
|
|
55
|
-
}
|
|
56
|
-
get isPoolSupportAlternativeFee() {
|
|
57
|
-
return this.feeAssets.length > 1;
|
|
58
|
-
}
|
|
59
|
-
async earlyValidate(request) {
|
|
60
|
-
var _poolInfo$statistic;
|
|
61
|
-
const poolInfo = await this.getPoolInfo();
|
|
62
|
-
if (!poolInfo || !((_poolInfo$statistic = poolInfo.statistic) !== null && _poolInfo$statistic !== void 0 && _poolInfo$statistic.earningThreshold.join)) {
|
|
63
|
-
return {
|
|
64
|
-
passed: false,
|
|
65
|
-
errorMessage: 'There\'s a trouble fetching data, please check your internet connection and try again'
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
if (request.address === _constants.ALL_ACCOUNT_KEY) {
|
|
69
|
-
return {
|
|
70
|
-
passed: true
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
const feeAssetInfo = this.state.chainService.getAssetBySlug(this.feeAssets[0]);
|
|
74
|
-
const altInputAssetInfo = this.state.chainService.getAssetBySlug(this.altInputAsset);
|
|
75
|
-
const inputAssetInfo = this.state.chainService.getAssetBySlug(this.inputAsset);
|
|
76
|
-
const [inputAssetBalance, altInputAssetBalance, feeAssetBalance] = await Promise.all([this.state.balanceService.getTokenFreeBalance(request.address, inputAssetInfo.originChain, inputAssetInfo.slug), altInputAssetInfo ? this.state.balanceService.getTokenFreeBalance(request.address, altInputAssetInfo.originChain, altInputAssetInfo.slug) : Promise.resolve({
|
|
77
|
-
symbol: '',
|
|
78
|
-
decimals: 0,
|
|
79
|
-
value: '0'
|
|
80
|
-
}), this.state.balanceService.getTokenFreeBalance(request.address, feeAssetInfo.originChain, feeAssetInfo.slug)]);
|
|
81
|
-
const bnInputAssetBalance = new _util.BN(inputAssetBalance.value);
|
|
82
|
-
const bnAltInputAssetBalance = new _util.BN(altInputAssetBalance.value);
|
|
83
|
-
const bnMinJoinPool = new _util.BN(poolInfo.statistic.earningThreshold.join);
|
|
84
|
-
const inputTokenInfo = this.state.chainService.getAssetBySlug(this.inputAsset);
|
|
85
|
-
const altInputTokenInfo = this.state.chainService.getAssetBySlug(this.altInputAsset);
|
|
86
|
-
const minJoinDiv = _util.BN_TEN.pow(new _util.BN(inputAssetInfo.decimals || 0));
|
|
87
|
-
const parsedMinJoinPool = bnMinJoinPool.div(minJoinDiv);
|
|
88
|
-
if (bnInputAssetBalance.add(bnAltInputAssetBalance).lt(bnMinJoinPool)) {
|
|
89
|
-
const originChain = this.state.getChainInfo(inputTokenInfo.originChain);
|
|
90
|
-
const altChain = this.state.getChainInfo(altInputTokenInfo.originChain);
|
|
91
|
-
return {
|
|
92
|
-
passed: false,
|
|
93
|
-
errorMessage: `You need at least ${parsedMinJoinPool.toString()} ${inputTokenInfo.symbol} (${originChain.name}) or ${altInputTokenInfo.symbol} (${altChain.name}) to start earning`
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
if (this.feeAssets.length === 1) {
|
|
97
|
-
const bnFeeAssetBalance = new _util.BN(feeAssetBalance.value);
|
|
98
|
-
const minFeeAssetBalance = new _util.BN(this.maintainBalance || '0');
|
|
99
|
-
const feeAssetDiv = _util.BN_TEN.pow(new _util.BN(feeAssetInfo.decimals || 0));
|
|
100
|
-
const parsedMinFeeAssetBalance = minFeeAssetBalance.div(feeAssetDiv).mul(new _util.BN(12)).div(_util.BN_TEN);
|
|
101
|
-
if (bnFeeAssetBalance.lte(_util.BN_ZERO)) {
|
|
102
|
-
const feeChain = this.state.getChainInfo(feeAssetInfo.originChain);
|
|
103
|
-
return {
|
|
104
|
-
passed: false,
|
|
105
|
-
errorMessage: `You need at least ${parsedMinFeeAssetBalance.toString()} ${feeAssetInfo.symbol} (${feeChain.name}) to start earning`
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
passed: true
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
get group() {
|
|
114
|
-
const inputAsset = this.state.getAssetBySlug(this.inputAsset);
|
|
115
|
-
const groupSlug = inputAsset.multiChainAsset;
|
|
116
|
-
return groupSlug || this.inputAsset;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* Subscribe pool info */
|
|
120
|
-
|
|
121
|
-
async subscribePoolInfo(callback) {
|
|
122
|
-
let cancel = false;
|
|
123
|
-
const getStatInterval = () => {
|
|
124
|
-
if (!this.isActive) {
|
|
125
|
-
if (!cancel) {
|
|
126
|
-
const rs = {
|
|
127
|
-
...this.baseInfo,
|
|
128
|
-
type: this.type,
|
|
129
|
-
metadata: {
|
|
130
|
-
...this.metadataInfo,
|
|
131
|
-
description: this.getDescription()
|
|
132
|
-
}
|
|
133
|
-
};
|
|
134
|
-
callback(rs);
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
this.getPoolStat().then(rs => {
|
|
138
|
-
if (!cancel) {
|
|
139
|
-
callback(rs);
|
|
140
|
-
}
|
|
141
|
-
}).catch(console.error);
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
getStatInterval();
|
|
145
|
-
const interval = setInterval(() => {
|
|
146
|
-
if (cancel) {
|
|
147
|
-
clearInterval(interval);
|
|
148
|
-
} else {
|
|
149
|
-
getStatInterval();
|
|
150
|
-
}
|
|
151
|
-
}, _utils.YIELD_POOL_STAT_REFRESH_INTERVAL);
|
|
152
|
-
return new Promise(resolve => {
|
|
153
|
-
const rs = () => {
|
|
154
|
-
cancel = true;
|
|
155
|
-
clearInterval(interval);
|
|
156
|
-
};
|
|
157
|
-
resolve(rs);
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/* Subscribe pool info */
|
|
162
|
-
|
|
163
|
-
/* Get pool reward */
|
|
164
|
-
|
|
165
|
-
async getPoolReward() {
|
|
166
|
-
return new Promise(resolve => resolve(_util.noop));
|
|
167
|
-
}
|
|
168
|
-
async getPoolRewardHistory() {
|
|
169
|
-
return new Promise(resolve => resolve(_util.noop));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/* Get pool reward */
|
|
173
|
-
|
|
174
|
-
/* Get pool targets */
|
|
175
|
-
|
|
176
|
-
async getPoolTargets() {
|
|
177
|
-
return new Promise(resolve => resolve([]));
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
/* Get pool targets */
|
|
181
|
-
|
|
182
|
-
/* Join pool action */
|
|
183
|
-
|
|
184
|
-
/* Generate steps */
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @async
|
|
188
|
-
* @function getXcmStep
|
|
189
|
-
* */
|
|
190
|
-
async getXcmStep(params) {
|
|
191
|
-
const {
|
|
192
|
-
address,
|
|
193
|
-
amount
|
|
194
|
-
} = params;
|
|
195
|
-
const bnAmount = new _util.BN(amount);
|
|
196
|
-
const inputTokenSlug = this.inputAsset; // assume that the pool only has 1 input token, will update later
|
|
197
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
198
|
-
const inputTokenBalance = await this.state.balanceService.getTokenFreeBalance(address, inputTokenInfo.originChain, inputTokenSlug);
|
|
199
|
-
const bnInputTokenBalance = new _util.BN(inputTokenBalance.value);
|
|
200
|
-
if (!bnInputTokenBalance.gte(bnAmount)) {
|
|
201
|
-
if (this.altInputAsset) {
|
|
202
|
-
const altInputTokenSlug = this.altInputAsset;
|
|
203
|
-
const altInputTokenInfo = this.state.getAssetBySlug(altInputTokenSlug);
|
|
204
|
-
const altInputTokenBalance = await this.state.balanceService.getTokenFreeBalance(address, altInputTokenInfo.originChain, altInputTokenSlug);
|
|
205
|
-
const bnAltInputTokenBalance = new _util.BN(altInputTokenBalance.value || '0');
|
|
206
|
-
if (bnAltInputTokenBalance.gt(_util.BN_ZERO)) {
|
|
207
|
-
const step = {
|
|
208
|
-
metadata: {
|
|
209
|
-
sendingValue: bnAmount.toString(),
|
|
210
|
-
originTokenInfo: altInputTokenInfo,
|
|
211
|
-
destinationTokenInfo: inputTokenInfo
|
|
212
|
-
},
|
|
213
|
-
name: 'Transfer DOT from Polkadot',
|
|
214
|
-
type: _types.YieldStepType.XCM
|
|
215
|
-
};
|
|
216
|
-
const xcmOriginSubstrateApi = await this.state.getSubstrateApi(altInputTokenInfo.originChain).isReady;
|
|
217
|
-
const xcmTransfer = await (0, _xcm.createXcmExtrinsic)({
|
|
218
|
-
originTokenInfo: altInputTokenInfo,
|
|
219
|
-
destinationTokenInfo: inputTokenInfo,
|
|
220
|
-
sendingValue: bnAmount.toString(),
|
|
221
|
-
recipient: address,
|
|
222
|
-
chainInfoMap: this.state.getChainInfoMap(),
|
|
223
|
-
substrateApi: xcmOriginSubstrateApi
|
|
224
|
-
});
|
|
225
|
-
const _xcmFeeInfo = await xcmTransfer.paymentInfo(address);
|
|
226
|
-
const xcmFeeInfo = _xcmFeeInfo.toPrimitive();
|
|
227
|
-
// TODO: calculate fee for destination chain
|
|
228
|
-
|
|
229
|
-
const fee = {
|
|
230
|
-
slug: altInputTokenSlug,
|
|
231
|
-
amount: Math.round(xcmFeeInfo.partialFee * 1.2).toString() // TODO
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
return [step, fee];
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
return undefined;
|
|
239
|
-
}
|
|
240
|
-
get defaultSubmitStep() {
|
|
241
|
-
return [this.submitJoinStepInfo, {
|
|
242
|
-
slug: this.feeAssets[0],
|
|
243
|
-
amount: '0'
|
|
244
|
-
}];
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
/**
|
|
248
|
-
* @function submitJoinStepInfo
|
|
249
|
-
* @description Base info of submit step
|
|
250
|
-
* @return Fee of the submitting step
|
|
251
|
-
* */
|
|
252
|
-
|
|
253
|
-
async getSubmitStep(params) {
|
|
254
|
-
const fee = await this.getSubmitStepFee(params);
|
|
255
|
-
return [this.submitJoinStepInfo, fee];
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/* Generate steps */
|
|
259
|
-
|
|
260
|
-
/* Validate join action */
|
|
261
|
-
|
|
262
|
-
async validateTokenApproveStep(params, path) {
|
|
263
|
-
return Promise.resolve([new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED)]);
|
|
264
|
-
}
|
|
265
|
-
async validateXcmStep(params, path, bnInputTokenBalance) {
|
|
266
|
-
const processValidation = {
|
|
267
|
-
ok: true,
|
|
268
|
-
status: _types.YieldValidationStatus.OK
|
|
269
|
-
};
|
|
270
|
-
const bnAmount = new _util.BN(params.amount);
|
|
271
|
-
const altInputTokenSlug = this.altInputAsset || '';
|
|
272
|
-
const altInputTokenInfo = this.state.getAssetBySlug(altInputTokenSlug);
|
|
273
|
-
const altInputTokenBalance = await this.state.balanceService.getTokenFreeBalance(params.address, altInputTokenInfo.originChain, altInputTokenSlug);
|
|
274
|
-
const missingAmount = bnAmount.sub(bnInputTokenBalance); // TODO: what if input token is not LOCAL ??
|
|
275
|
-
const xcmFee = new _util.BN(path.totalFee[1].amount || '0');
|
|
276
|
-
const xcmAmount = missingAmount.add(xcmFee);
|
|
277
|
-
const bnAltInputTokenBalance = new _util.BN(altInputTokenBalance.value || '0');
|
|
278
|
-
const altInputTokenMinAmount = new _util.BN(altInputTokenInfo.minAmount || '0');
|
|
279
|
-
if (!bnAltInputTokenBalance.sub(xcmAmount).gte(altInputTokenMinAmount)) {
|
|
280
|
-
processValidation.failedStep = path.steps[1];
|
|
281
|
-
processValidation.ok = false;
|
|
282
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_BALANCE;
|
|
283
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_BALANCE, processValidation.message, processValidation)];
|
|
284
|
-
}
|
|
285
|
-
return [];
|
|
286
|
-
}
|
|
287
|
-
async validateJoinStep(id, params, path, bnInputTokenBalance, isXcmOk) {
|
|
288
|
-
const _poolInfo = await this.getPoolInfo();
|
|
289
|
-
if (!_poolInfo) {
|
|
290
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
291
|
-
}
|
|
292
|
-
const poolInfo = _poolInfo;
|
|
293
|
-
if (!poolInfo.statistic) {
|
|
294
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
295
|
-
}
|
|
296
|
-
const processValidation = {
|
|
297
|
-
ok: true,
|
|
298
|
-
status: _types.YieldValidationStatus.OK
|
|
299
|
-
};
|
|
300
|
-
const feeTokenSlug = path.totalFee[id].slug;
|
|
301
|
-
const feeTokenInfo = this.state.getAssetBySlug(feeTokenSlug);
|
|
302
|
-
const defaultFeeTokenSlug = this.feeAssets[0];
|
|
303
|
-
const bnAmount = new _util.BN(params.amount);
|
|
304
|
-
if (this.feeAssets.length === 1 && feeTokenSlug === defaultFeeTokenSlug) {
|
|
305
|
-
var _path$totalFee$id;
|
|
306
|
-
const bnFeeAmount = new _util.BN(((_path$totalFee$id = path.totalFee[id]) === null || _path$totalFee$id === void 0 ? void 0 : _path$totalFee$id.amount) || '0');
|
|
307
|
-
const feeTokenBalance = await this.state.balanceService.getTokenFreeBalance(params.address, feeTokenInfo.originChain, feeTokenSlug);
|
|
308
|
-
const bnFeeTokenBalance = new _util.BN(feeTokenBalance.value || '0');
|
|
309
|
-
const bnFeeTokenMinAmount = new _util.BN((feeTokenInfo === null || feeTokenInfo === void 0 ? void 0 : feeTokenInfo.minAmount) || '0');
|
|
310
|
-
if (!bnFeeTokenBalance.sub(bnFeeAmount).gte(bnFeeTokenMinAmount)) {
|
|
311
|
-
processValidation.failedStep = path.steps[id];
|
|
312
|
-
processValidation.ok = false;
|
|
313
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_FEE;
|
|
314
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_FEE, processValidation.message, processValidation)];
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
if (!bnAmount.gte(new _util.BN(poolInfo.statistic.earningThreshold.join || '0'))) {
|
|
318
|
-
processValidation.failedStep = path.steps[id];
|
|
319
|
-
processValidation.ok = false;
|
|
320
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_MIN_JOIN_POOL;
|
|
321
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_MIN_JOIN_POOL, processValidation.message, processValidation)];
|
|
322
|
-
}
|
|
323
|
-
if (!isXcmOk && bnAmount.gt(bnInputTokenBalance)) {
|
|
324
|
-
processValidation.failedStep = path.steps[id];
|
|
325
|
-
processValidation.ok = false;
|
|
326
|
-
processValidation.status = _types.YieldValidationStatus.NOT_ENOUGH_BALANCE;
|
|
327
|
-
return [new _TransactionError.TransactionError(_types.YieldValidationStatus.NOT_ENOUGH_BALANCE, processValidation.message, processValidation)];
|
|
328
|
-
}
|
|
329
|
-
return [];
|
|
330
|
-
}
|
|
331
|
-
async validateYieldJoin(params, path) {
|
|
332
|
-
const inputTokenSlug = this.inputAsset;
|
|
333
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
334
|
-
const balanceService = this.state.balanceService;
|
|
335
|
-
const inputTokenBalance = await balanceService.getTokenFreeBalance(params.address, inputTokenInfo.originChain, inputTokenSlug);
|
|
336
|
-
const bnInputTokenBalance = new _util.BN(inputTokenBalance.value || '0');
|
|
337
|
-
const bnAmount = new _util.BN(params.amount);
|
|
338
|
-
if (bnAmount.lte(_util.BN_ZERO)) {
|
|
339
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, 'Amount must be greater than 0')];
|
|
340
|
-
}
|
|
341
|
-
let isXcmOk = false;
|
|
342
|
-
for (const step of path.steps) {
|
|
343
|
-
const getErrors = async () => {
|
|
344
|
-
switch (step.type) {
|
|
345
|
-
case _types.YieldStepType.DEFAULT:
|
|
346
|
-
return Promise.resolve([]);
|
|
347
|
-
case _types.YieldStepType.XCM:
|
|
348
|
-
return this.validateXcmStep(params, path, bnInputTokenBalance);
|
|
349
|
-
case _types.YieldStepType.TOKEN_APPROVAL:
|
|
350
|
-
return this.validateTokenApproveStep(params, path);
|
|
351
|
-
default:
|
|
352
|
-
return this.validateJoinStep(step.id, params, path, bnInputTokenBalance, isXcmOk);
|
|
353
|
-
}
|
|
354
|
-
};
|
|
355
|
-
const errors = await getErrors();
|
|
356
|
-
if (errors.length) {
|
|
357
|
-
return errors;
|
|
358
|
-
} else if (step.type === _types.YieldStepType.XCM) {
|
|
359
|
-
isXcmOk = true;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return [];
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
/* Validate join action */
|
|
366
|
-
|
|
367
|
-
/* Submit join action */
|
|
368
|
-
|
|
369
|
-
async handleTokenApproveStep(data, path) {
|
|
370
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
371
|
-
}
|
|
372
|
-
async handleXcmStep(data, path, xcmFee) {
|
|
373
|
-
const {
|
|
374
|
-
address,
|
|
375
|
-
amount
|
|
376
|
-
} = data;
|
|
377
|
-
const destinationTokenSlug = this.inputAsset;
|
|
378
|
-
const originChainInfo = this.state.getChainInfo(_chainList.COMMON_CHAIN_SLUGS.POLKADOT);
|
|
379
|
-
const originTokenSlug = (0, _utils2._getChainNativeTokenSlug)(originChainInfo);
|
|
380
|
-
const originTokenInfo = this.state.getAssetBySlug(originTokenSlug);
|
|
381
|
-
const destinationTokenInfo = this.state.getAssetBySlug(destinationTokenSlug);
|
|
382
|
-
const substrateApi = this.state.getSubstrateApi(originChainInfo.slug);
|
|
383
|
-
const inputTokenBalance = await this.state.balanceService.getTokenFreeBalance(address, destinationTokenInfo.originChain, destinationTokenSlug);
|
|
384
|
-
const bnInputTokenBalance = new _util.BN(inputTokenBalance.value);
|
|
385
|
-
const bnXcmFee = new _util.BN(xcmFee);
|
|
386
|
-
const bnAmount = new _util.BN(amount);
|
|
387
|
-
const bnTotalAmount = bnAmount.sub(bnInputTokenBalance).add(bnXcmFee);
|
|
388
|
-
const extrinsic = await (0, _xcm.createXcmExtrinsic)({
|
|
389
|
-
chainInfoMap: this.state.getChainInfoMap(),
|
|
390
|
-
destinationTokenInfo,
|
|
391
|
-
originTokenInfo,
|
|
392
|
-
recipient: address,
|
|
393
|
-
sendingValue: bnTotalAmount.toString(),
|
|
394
|
-
substrateApi
|
|
395
|
-
});
|
|
396
|
-
const xcmData = {
|
|
397
|
-
originNetworkKey: originChainInfo.slug,
|
|
398
|
-
destinationNetworkKey: destinationTokenInfo.originChain,
|
|
399
|
-
from: address,
|
|
400
|
-
to: address,
|
|
401
|
-
value: bnTotalAmount.toString(),
|
|
402
|
-
tokenSlug: originTokenSlug,
|
|
403
|
-
showExtraWarning: true
|
|
404
|
-
};
|
|
405
|
-
return {
|
|
406
|
-
txChain: originChainInfo.slug,
|
|
407
|
-
extrinsicType: _KoniTypes.ExtrinsicType.TRANSFER_XCM,
|
|
408
|
-
extrinsic,
|
|
409
|
-
txData: xcmData,
|
|
410
|
-
transferNativeAmount: bnTotalAmount.toString()
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
handleYieldJoin(data, path, currentStep) {
|
|
414
|
-
const type = path.steps[currentStep].type;
|
|
415
|
-
switch (type) {
|
|
416
|
-
case _types.YieldStepType.DEFAULT:
|
|
417
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
418
|
-
case _types.YieldStepType.TOKEN_APPROVAL:
|
|
419
|
-
return this.handleTokenApproveStep(data, path);
|
|
420
|
-
case _types.YieldStepType.XCM:
|
|
421
|
-
{
|
|
422
|
-
const xcmFee = path.totalFee[currentStep].amount || '0';
|
|
423
|
-
return this.handleXcmStep(data, path, xcmFee);
|
|
424
|
-
}
|
|
425
|
-
default:
|
|
426
|
-
return this.handleSubmitStep(data, path);
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
/* Submit join action */
|
|
431
|
-
|
|
432
|
-
/* Join pool action */
|
|
433
|
-
|
|
434
|
-
/* Leave pool action */
|
|
435
|
-
|
|
436
|
-
async validateYieldLeave(amount, address, fastLeave, selectedTarget) {
|
|
437
|
-
const poolInfo = await this.getPoolInfo();
|
|
438
|
-
const poolPosition = await this.getPoolPosition(address);
|
|
439
|
-
if (!poolInfo || !poolInfo.statistic || !poolPosition) {
|
|
440
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
441
|
-
}
|
|
442
|
-
if (!this.availableMethod.defaultUnstake && !fastLeave) {
|
|
443
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
444
|
-
}
|
|
445
|
-
if (!this.availableMethod.fastUnstake && fastLeave) {
|
|
446
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
447
|
-
}
|
|
448
|
-
const errors = [];
|
|
449
|
-
const bnActiveStake = new _util.BN(poolPosition.activeStake);
|
|
450
|
-
const bnAmount = new _util.BN(amount);
|
|
451
|
-
const bnRemainingStake = bnActiveStake.sub(bnAmount);
|
|
452
|
-
const minStake = new _util.BN(poolInfo.statistic.earningThreshold.join || '0');
|
|
453
|
-
const minUnstake = new _util.BN((fastLeave ? poolInfo.statistic.earningThreshold.fastUnstake : poolInfo.statistic.earningThreshold.defaultUnstake) || '0');
|
|
454
|
-
const maxUnstakeRequest = poolInfo.statistic.maxWithdrawalRequestPerFarmer;
|
|
455
|
-
const derivativeTokenInfo = this.state.getAssetBySlug(this.derivativeAssets[0]);
|
|
456
|
-
if (bnAmount.lte(_util.BN_ZERO)) {
|
|
457
|
-
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS, (0, _i18next.t)('Amount must be greater than 0'))];
|
|
458
|
-
}
|
|
459
|
-
if (bnAmount.lt(minUnstake)) {
|
|
460
|
-
const minUnstakeStr = (0, _utils3.formatNumber)(minUnstake.toString(), derivativeTokenInfo.decimals || 0);
|
|
461
|
-
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.NOT_ENOUGH_MIN_UNSTAKE, (0, _i18next.t)('You need to unstake at least {{amount}} {{token}}', {
|
|
462
|
-
replace: {
|
|
463
|
-
amount: minUnstakeStr,
|
|
464
|
-
token: derivativeTokenInfo.symbol
|
|
465
|
-
}
|
|
466
|
-
})));
|
|
467
|
-
}
|
|
468
|
-
if (!fastLeave) {
|
|
469
|
-
if (!(bnRemainingStake.isZero() || bnRemainingStake.gte(minStake))) {
|
|
470
|
-
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.INVALID_ACTIVE_STAKE)); // TODO
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
if (poolPosition.unstakings.length > maxUnstakeRequest) {
|
|
474
|
-
errors.push(new _TransactionError.TransactionError(_KoniTypes.StakingTxErrorType.EXCEED_MAX_UNSTAKING, (0, _i18next.t)('You cannot unstake more than {{number}} times', {
|
|
475
|
-
replace: {
|
|
476
|
-
number: maxUnstakeRequest
|
|
477
|
-
}
|
|
478
|
-
})));
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
return Promise.resolve(errors);
|
|
482
|
-
}
|
|
483
|
-
handleYieldUnstake(amount, address, selectedTarget) {
|
|
484
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/* Leave pool action */
|
|
488
|
-
|
|
489
|
-
/* Other action */
|
|
490
|
-
|
|
491
|
-
handleYieldCancelUnstake() {
|
|
492
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
493
|
-
}
|
|
494
|
-
handleYieldClaimReward(address, bondReward) {
|
|
495
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
496
|
-
}
|
|
497
|
-
handleYieldWithdraw(address, unstakingInfo) {
|
|
498
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.UNSUPPORTED));
|
|
499
|
-
}
|
|
500
|
-
|
|
501
|
-
/* Other actions */
|
|
502
|
-
}
|
|
503
|
-
exports.default = BaseSpecialStakingPoolHandler;
|