@subwallet/extension-base 1.1.28-beta.1 → 1.1.30-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 +70 -93
- package/background/KoniTypes.js +14 -16
- package/background/errors/TransactionError.js +4 -9
- package/cjs/background/KoniTypes.js +17 -17
- package/cjs/background/errors/TransactionError.js +4 -9
- package/cjs/constants/index.js +3 -9
- 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 +1 -4
- package/cjs/koni/api/staking/bonding/paraChain.js +23 -25
- 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 +0 -2
- package/cjs/koni/background/handlers/Extension.js +88 -326
- package/cjs/koni/background/handlers/State.js +3 -51
- package/cjs/koni/background/handlers/index.js +2 -4
- package/cjs/koni/background/subscription.js +18 -88
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/campaign-service/index.js +6 -9
- package/cjs/services/chain-service/constants.js +16 -2
- 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 +0 -4
- package/cjs/services/notification-service/NotificationService.js +1 -1
- package/cjs/services/storage-service/DatabaseService.js +0 -47
- package/cjs/services/storage-service/databases/index.js +0 -4
- package/cjs/services/storage-service/db-stores/NominatorMetadata.js +3 -3
- 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 +74 -180
- 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/constants/index.d.ts +0 -2
- package/constants/index.js +0 -2
- 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 +1 -1
- package/koni/api/staking/bonding/index.js +1 -5
- package/koni/api/staking/bonding/paraChain.js +10 -12
- 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.js +0 -2
- package/koni/background/handlers/Extension.d.ts +1 -14
- package/koni/background/handlers/Extension.js +50 -286
- 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 -5
- package/koni/background/subscription.js +20 -90
- package/package.json +8 -311
- 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 +14 -1
- 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 +0 -4
- package/services/notification-service/NotificationService.js +1 -1
- package/services/storage-service/DatabaseService.d.ts +1 -17
- package/services/storage-service/DatabaseService.js +0 -47
- 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 -2
- 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 +72 -178
- 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/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 -202
- 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 -168
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -196
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -39
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -257
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -180
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -373
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +0 -359
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -426
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +0 -137
- package/cjs/services/earning-service/handlers/native-staking/base.js +0 -109
- package/cjs/services/earning-service/handlers/native-staking/index.js +0 -34
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -361
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +0 -512
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +0 -501
- package/cjs/services/earning-service/handlers/special.js +0 -387
- package/cjs/services/earning-service/service.js +0 -327
- package/cjs/services/earning-service/utils/index.js +0 -111
- 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/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 -37
- 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 -34
- 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 -105
- package/services/earning-service/handlers/base.js +0 -195
- 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 -22
- package/services/earning-service/handlers/lending/interlay.js +0 -160
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +0 -27
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -188
- package/services/earning-service/handlers/liquid-staking/base.d.ts +0 -8
- package/services/earning-service/handlers/liquid-staking/base.js +0 -31
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +0 -44
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -246
- 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 -27
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -172
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +0 -36
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +0 -363
- package/services/earning-service/handlers/native-staking/amplitude.d.ts +0 -22
- package/services/earning-service/handlers/native-staking/amplitude.js +0 -350
- package/services/earning-service/handlers/native-staking/astar.d.ts +0 -18
- package/services/earning-service/handlers/native-staking/astar.js +0 -416
- package/services/earning-service/handlers/native-staking/base-para.d.ts +0 -11
- package/services/earning-service/handlers/native-staking/base-para.js +0 -129
- package/services/earning-service/handlers/native-staking/base.d.ts +0 -19
- package/services/earning-service/handlers/native-staking/base.js +0 -101
- 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 -353
- package/services/earning-service/handlers/native-staking/relay-chain.d.ts +0 -21
- package/services/earning-service/handlers/native-staking/relay-chain.js +0 -503
- package/services/earning-service/handlers/nomination-pool/index.d.ts +0 -33
- package/services/earning-service/handlers/nomination-pool/index.js +0 -492
- package/services/earning-service/handlers/special.d.ts +0 -56
- package/services/earning-service/handlers/special.js +0 -379
- package/services/earning-service/service.d.ts +0 -36
- package/services/earning-service/service.js +0 -320
- package/services/earning-service/utils/index.d.ts +0 -14
- package/services/earning-service/utils/index.js +0 -100
- 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/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 -75
- package/types/yield/actions/join/step.js +0 -34
- package/types/yield/actions/join/submit.d.ts +0 -53
- 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 -60
- 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 -112
- package/types/yield/info/account/info.js +0 -1
- package/types/yield/info/account/reward.d.ts +0 -41
- 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 -28
- package/types/yield/info/base.js +0 -28
- 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 -190
- package/types/yield/info/chain/info.js +0 -1
- package/types/yield/info/chain/target.d.ts +0 -33
- 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,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.YIELD_POOL_STAT_REFRESH_INTERVAL = exports.YIELD_POOL_MIN_AMOUNT_PERCENT = exports.YIELD_EXTRINSIC_TYPES = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
|
|
7
|
-
exports.calculateAlternativeFee = calculateAlternativeFee;
|
|
8
|
-
exports.convertDerivativeToOriginToken = convertDerivativeToOriginToken;
|
|
9
|
-
exports.syntheticSelectedValidators = void 0;
|
|
10
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
11
|
-
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
12
|
-
var _types = require("@subwallet/extension-base/types");
|
|
13
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
14
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
15
|
-
|
|
16
|
-
const syntheticSelectedValidators = ['15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6', '1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih', '1yGJ3h7TQuJWLYSsUVPZbM8aR8UsQXCqMvrFx5Fn1ktiAmq', '16GDRhRYxk42paoK6TfHAqWej8PdDDUwdDazjv4bAn4KGNeb', '13Ybj8CPEArUee78DxUAP9yX3ABmFNVQME1ZH4w8HVncHGzc', '14yx4vPAACZRhoDQm1dyvXD3QdRQyCRRCe5tj1zPomhhS29a', '14Vh8S1DzzycngbAB9vqEgPFR9JpSvmF1ezihTUES1EaHAV', '153YD8ZHD9dRh82U419bSCB5SzWhbdAFzjj4NtA5pMazR2yC', '1LUckyocmz9YzeQZHVpBvYYRGXb3rnSm2tvfz79h3G3JDgP', '14oRE62MB1SWR6h5RTx3GY5HK2oZipi1Gp3zdiLwVYLfEyRZ', '1cFsLn7o74nmjbRyDtMAnMpQMc5ZLsjgCSz9Np2mcejUK83', '15ZvLonEseaWZNy8LDkXXj3Y8bmAjxCjwvpy4pXWSL4nGSBs', '1NebF2xZHb4TJJpiqZZ3reeTo8dZov6LZ49qZqcHHbsmHfo', '1HmAqbBRrWvsqbLkvpiVDkdA2PcctUE5JUe3qokEh1FN455', '15tfUt4iQNjMyhZiJGBf4EpETE2KqtW1nfJwbBT1MvWjvcK9', '12RXTLiaYh59PokjZVhQvKzcfBEB5CvDnjKKUmDUotzcTH3S'];
|
|
17
|
-
exports.syntheticSelectedValidators = syntheticSelectedValidators;
|
|
18
|
-
function calculateAlternativeFee(feeInfo) {
|
|
19
|
-
return feeInfo.partialFee;
|
|
20
|
-
}
|
|
21
|
-
const DEFAULT_YIELD_FIRST_STEP = {
|
|
22
|
-
id: 0,
|
|
23
|
-
name: 'Fill information',
|
|
24
|
-
type: _types.YieldStepType.DEFAULT
|
|
25
|
-
};
|
|
26
|
-
exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
|
|
27
|
-
const YIELD_EXTRINSIC_TYPES = [_KoniTypes.ExtrinsicType.MINT_VDOT, _KoniTypes.ExtrinsicType.MINT_LDOT, _KoniTypes.ExtrinsicType.MINT_SDOT, _KoniTypes.ExtrinsicType.MINT_QDOT, _KoniTypes.ExtrinsicType.MINT_STDOT, _KoniTypes.ExtrinsicType.REDEEM_QDOT, _KoniTypes.ExtrinsicType.REDEEM_SDOT, _KoniTypes.ExtrinsicType.REDEEM_VDOT, _KoniTypes.ExtrinsicType.REDEEM_LDOT, _KoniTypes.ExtrinsicType.REDEEM_STDOT, _KoniTypes.ExtrinsicType.STAKING_JOIN_POOL, _KoniTypes.ExtrinsicType.STAKING_CLAIM_REWARD, _KoniTypes.ExtrinsicType.STAKING_LEAVE_POOL, _KoniTypes.ExtrinsicType.STAKING_POOL_WITHDRAW];
|
|
28
|
-
exports.YIELD_EXTRINSIC_TYPES = YIELD_EXTRINSIC_TYPES;
|
|
29
|
-
const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
|
|
30
|
-
exports.YIELD_POOL_STAT_REFRESH_INTERVAL = YIELD_POOL_STAT_REFRESH_INTERVAL;
|
|
31
|
-
const YIELD_POOL_MIN_AMOUNT_PERCENT = {
|
|
32
|
-
DOT___acala_liquid_staking: 0.98,
|
|
33
|
-
DOT___bifrost_liquid_staking: 0.99,
|
|
34
|
-
DOT___parallel_liquid_staking: 0.97,
|
|
35
|
-
default: 0.98
|
|
36
|
-
};
|
|
37
|
-
exports.YIELD_POOL_MIN_AMOUNT_PERCENT = YIELD_POOL_MIN_AMOUNT_PERCENT;
|
|
38
|
-
function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, originTokenInfo) {
|
|
39
|
-
var _poolInfo$metadata$as;
|
|
40
|
-
const derivativeDecimals = (0, _utils._getAssetDecimals)(derivativeTokenInfo);
|
|
41
|
-
const originDecimals = (0, _utils._getAssetDecimals)(originTokenInfo);
|
|
42
|
-
const exchangeRate = ((_poolInfo$metadata$as = poolInfo.metadata.assetEarning) === null || _poolInfo$metadata$as === void 0 ? void 0 : _poolInfo$metadata$as[0].exchangeRate) || 1;
|
|
43
|
-
const formattedAmount = parseInt(amount) / 10 ** derivativeDecimals; // TODO: decimals
|
|
44
|
-
const minAmount = formattedAmount * exchangeRate;
|
|
45
|
-
return Math.floor(minAmount * 10 ** originDecimals);
|
|
46
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports._STAKING_CHAIN_GROUP = exports.ST_LIQUID_TOKEN_ABI = void 0;
|
|
7
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
|
|
10
|
-
const _STAKING_CHAIN_GROUP = {
|
|
11
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network'],
|
|
12
|
-
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
13
|
-
astar: ['astar', 'shiden', 'shibuya'],
|
|
14
|
-
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
15
|
-
// amplitude and kilt only share some common logic
|
|
16
|
-
kilt: ['kilt', 'kilt_peregrine'],
|
|
17
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network'],
|
|
18
|
-
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
19
|
-
aleph: ['aleph', 'alephTest'],
|
|
20
|
-
// A0 has distinct tokenomics
|
|
21
|
-
ternoa: ['ternoa', 'ternoa_alphanet'],
|
|
22
|
-
liquidStaking: ['bifrost_dot', 'acala', 'parallel', 'moonbeam'],
|
|
23
|
-
lending: ['interlay']
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
27
|
-
exports._STAKING_CHAIN_GROUP = _STAKING_CHAIN_GROUP;
|
|
28
|
-
const ST_LIQUID_TOKEN_ABI = require('./abis/st_liquid_token_abi.json');
|
|
29
|
-
exports.ST_LIQUID_TOKEN_ABI = ST_LIQUID_TOKEN_ABI;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
var _chains = require("./chains");
|
|
7
|
-
Object.keys(_chains).forEach(function (key) {
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _chains[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function () {
|
|
13
|
-
return _chains[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
var _step = require("./step");
|
|
18
|
-
Object.keys(_step).forEach(function (key) {
|
|
19
|
-
if (key === "default" || key === "__esModule") return;
|
|
20
|
-
if (key in exports && exports[key] === _step[key]) return;
|
|
21
|
-
Object.defineProperty(exports, key, {
|
|
22
|
-
enumerable: true,
|
|
23
|
-
get: function () {
|
|
24
|
-
return _step[key];
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.fakeAddress = exports.DEFAULT_YIELD_FIRST_STEP = void 0;
|
|
7
|
-
var _types = require("@subwallet/extension-base/types");
|
|
8
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
9
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
10
|
-
|
|
11
|
-
const DEFAULT_YIELD_FIRST_STEP = {
|
|
12
|
-
id: 0,
|
|
13
|
-
name: 'Fill information',
|
|
14
|
-
type: _types.YieldStepType.DEFAULT
|
|
15
|
-
};
|
|
16
|
-
exports.DEFAULT_YIELD_FIRST_STEP = DEFAULT_YIELD_FIRST_STEP;
|
|
17
|
-
const fakeAddress = '15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6';
|
|
18
|
-
exports.fakeAddress = fakeAddress;
|
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
8
|
-
var _constants = require("@subwallet/extension-base/services/earning-service/constants");
|
|
9
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
10
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* @class BasePoolHandler
|
|
14
|
-
* @description Base pool handler
|
|
15
|
-
* */
|
|
16
|
-
class BasePoolHandler {
|
|
17
|
-
/** Koni state */
|
|
18
|
-
|
|
19
|
-
/** Pool's chain */
|
|
20
|
-
|
|
21
|
-
/** Pool's logo */
|
|
22
|
-
|
|
23
|
-
/** Pool's slug */
|
|
24
|
-
|
|
25
|
-
/** Pool's type */
|
|
26
|
-
|
|
27
|
-
/** Pool's name */
|
|
28
|
-
|
|
29
|
-
/** Pool's short name */
|
|
30
|
-
|
|
31
|
-
/** Pool's description */
|
|
32
|
-
|
|
33
|
-
/** Pool's transaction type */
|
|
34
|
-
transactionChainType = _KoniTypes.ChainType.SUBSTRATE;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @constructor
|
|
38
|
-
* @param {KoniState} state - Koni state
|
|
39
|
-
* @param {string} chain - Pool's chain
|
|
40
|
-
* */
|
|
41
|
-
constructor(state, chain) {
|
|
42
|
-
this.state = state;
|
|
43
|
-
this.chain = chain;
|
|
44
|
-
this._logo = chain;
|
|
45
|
-
}
|
|
46
|
-
get logo() {
|
|
47
|
-
return this._logo;
|
|
48
|
-
}
|
|
49
|
-
get group() {
|
|
50
|
-
const groupSlug = this.nativeToken.multiChainAsset;
|
|
51
|
-
return groupSlug || this.nativeToken.slug;
|
|
52
|
-
}
|
|
53
|
-
get substrateApi() {
|
|
54
|
-
return this.state.getSubstrateApi(this.chain);
|
|
55
|
-
}
|
|
56
|
-
get evmApi() {
|
|
57
|
-
return this.state.getEvmApi(this.chain);
|
|
58
|
-
}
|
|
59
|
-
get chainInfo() {
|
|
60
|
-
return this.state.getChainInfo(this.chain);
|
|
61
|
-
}
|
|
62
|
-
get nativeToken() {
|
|
63
|
-
return this.state.getNativeTokenInfo(this.chain);
|
|
64
|
-
}
|
|
65
|
-
get defaultInfo() {
|
|
66
|
-
return {
|
|
67
|
-
name: this.name,
|
|
68
|
-
shortName: this.shortName,
|
|
69
|
-
group: this.group,
|
|
70
|
-
logo: this.logo,
|
|
71
|
-
chain: this.chain,
|
|
72
|
-
slug: this.slug
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** Can mint when haven't enough native token (use input token for fee) */
|
|
77
|
-
get isPoolSupportAlternativeFee() {
|
|
78
|
-
return false;
|
|
79
|
-
}
|
|
80
|
-
async getPoolInfo() {
|
|
81
|
-
return this.state.dbService.getYieldPool(this.slug);
|
|
82
|
-
}
|
|
83
|
-
async getPoolPosition(address) {
|
|
84
|
-
return this.state.dbService.getYieldPositionByAddressAndSlug(address, this.slug);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/* Subscribe data */
|
|
88
|
-
|
|
89
|
-
/** Subscribe pool info */
|
|
90
|
-
|
|
91
|
-
/* Subscribe data */
|
|
92
|
-
|
|
93
|
-
/* Join action */
|
|
94
|
-
|
|
95
|
-
/* Generate steps */
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* @function firstStepFee
|
|
99
|
-
* */
|
|
100
|
-
get firstStepFee() {
|
|
101
|
-
return {
|
|
102
|
-
slug: ''
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* @function defaultSubmitStep
|
|
108
|
-
* @description Default submit step data
|
|
109
|
-
* */
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* @async
|
|
113
|
-
* @function getTokenApproveStep
|
|
114
|
-
* @param {OptimalYieldPathParams} params - base param to join pool
|
|
115
|
-
* @description Generate token approve step data
|
|
116
|
-
* */
|
|
117
|
-
async getTokenApproveStep(params) {
|
|
118
|
-
return Promise.resolve(undefined);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* @async
|
|
123
|
-
* @function getXcmStep
|
|
124
|
-
* @param {OptimalYieldPathParams} params - base param to join pool
|
|
125
|
-
* @description Generate token approve step data
|
|
126
|
-
* */
|
|
127
|
-
async getXcmStep(params) {
|
|
128
|
-
return Promise.resolve(undefined);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @async
|
|
133
|
-
* @function getSubmitStep
|
|
134
|
-
* @param {OptimalYieldPathParams} params - base param to join pool
|
|
135
|
-
* @description Generate token approve step data
|
|
136
|
-
* */
|
|
137
|
-
|
|
138
|
-
/** Generate the optimal steps to join pool */
|
|
139
|
-
async generateOptimalPath(params) {
|
|
140
|
-
const result = {
|
|
141
|
-
totalFee: [this.firstStepFee],
|
|
142
|
-
steps: [_constants.DEFAULT_YIELD_FIRST_STEP]
|
|
143
|
-
};
|
|
144
|
-
try {
|
|
145
|
-
const stepFunctions = [this.getTokenApproveStep, this.getXcmStep, this.getSubmitStep];
|
|
146
|
-
for (const stepFunction of stepFunctions) {
|
|
147
|
-
const step = await stepFunction(params);
|
|
148
|
-
if (step) {
|
|
149
|
-
const [info, fee] = step;
|
|
150
|
-
result.steps.push({
|
|
151
|
-
id: result.steps.length,
|
|
152
|
-
...info
|
|
153
|
-
});
|
|
154
|
-
result.totalFee.push(fee);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
return result;
|
|
158
|
-
} catch (e) {
|
|
159
|
-
const errorMessage = e.message;
|
|
160
|
-
if (errorMessage.includes('network')) {
|
|
161
|
-
result.connectionError = errorMessage.split(' ')[0];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/* Submit step */
|
|
165
|
-
|
|
166
|
-
const [step, fee] = this.defaultSubmitStep;
|
|
167
|
-
result.steps.push({
|
|
168
|
-
id: result.steps.length,
|
|
169
|
-
...step
|
|
170
|
-
});
|
|
171
|
-
result.totalFee.push(fee);
|
|
172
|
-
|
|
173
|
-
/* Submit step */
|
|
174
|
-
|
|
175
|
-
return result;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
/* Generate steps */
|
|
180
|
-
|
|
181
|
-
/* Validate */
|
|
182
|
-
|
|
183
|
-
/** Validate param to join the pool */
|
|
184
|
-
|
|
185
|
-
/** Create `transaction` to leave the pool */
|
|
186
|
-
async handleYieldLeave(fastLeave, amount, address, selectedTarget) {
|
|
187
|
-
if (fastLeave) {
|
|
188
|
-
return this.handleYieldRedeem(amount, address, selectedTarget);
|
|
189
|
-
} else {
|
|
190
|
-
return this.handleYieldUnstake(amount, address, selectedTarget);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/* Leave action */
|
|
195
|
-
|
|
196
|
-
/* Other actions */
|
|
197
|
-
|
|
198
|
-
/** Create `transaction` to withdraw unstaked amount */
|
|
199
|
-
|
|
200
|
-
/* Other actions */
|
|
201
|
-
}
|
|
202
|
-
exports.default = BasePoolHandler;
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
var _exportNames = {
|
|
8
|
-
BasePoolHandler: true,
|
|
9
|
-
NominationPoolHandler: true
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "BasePoolHandler", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () {
|
|
14
|
-
return _base.default;
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
Object.defineProperty(exports, "NominationPoolHandler", {
|
|
18
|
-
enumerable: true,
|
|
19
|
-
get: function () {
|
|
20
|
-
return _nominationPool.default;
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
var _base = _interopRequireDefault(require("./base"));
|
|
24
|
-
var _nominationPool = _interopRequireDefault(require("./nomination-pool"));
|
|
25
|
-
var _lending = require("./lending");
|
|
26
|
-
Object.keys(_lending).forEach(function (key) {
|
|
27
|
-
if (key === "default" || key === "__esModule") return;
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
29
|
-
if (key in exports && exports[key] === _lending[key]) return;
|
|
30
|
-
Object.defineProperty(exports, key, {
|
|
31
|
-
enumerable: true,
|
|
32
|
-
get: function () {
|
|
33
|
-
return _lending[key];
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
var _liquidStaking = require("./liquid-staking");
|
|
38
|
-
Object.keys(_liquidStaking).forEach(function (key) {
|
|
39
|
-
if (key === "default" || key === "__esModule") return;
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
41
|
-
if (key in exports && exports[key] === _liquidStaking[key]) return;
|
|
42
|
-
Object.defineProperty(exports, key, {
|
|
43
|
-
enumerable: true,
|
|
44
|
-
get: function () {
|
|
45
|
-
return _liquidStaking[key];
|
|
46
|
-
}
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
var _nativeStaking = require("./native-staking");
|
|
50
|
-
Object.keys(_nativeStaking).forEach(function (key) {
|
|
51
|
-
if (key === "default" || key === "__esModule") return;
|
|
52
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
53
|
-
if (key in exports && exports[key] === _nativeStaking[key]) return;
|
|
54
|
-
Object.defineProperty(exports, key, {
|
|
55
|
-
enumerable: true,
|
|
56
|
-
get: function () {
|
|
57
|
-
return _nativeStaking[key];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,20 +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 _types = require("@subwallet/extension-base/types");
|
|
9
|
-
var _special = _interopRequireDefault(require("../special"));
|
|
10
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
11
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
-
|
|
13
|
-
class BaseLendingPoolHandler extends _special.default {
|
|
14
|
-
type = _types.YieldPoolType.LENDING;
|
|
15
|
-
|
|
16
|
-
/* Subscribe pool info */
|
|
17
|
-
|
|
18
|
-
/* Subscribe pool info */
|
|
19
|
-
}
|
|
20
|
-
exports.default = BaseLendingPoolHandler;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
Object.defineProperty(exports, "InterlayLendingPoolHandler", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () {
|
|
10
|
-
return _interlay.default;
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
var _interlay = _interopRequireDefault(require("./interlay"));
|
|
@@ -1,168 +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 _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
9
|
-
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
10
|
-
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
11
|
-
var _types = require("@subwallet/extension-base/types");
|
|
12
|
-
var _bn = _interopRequireDefault(require("bn.js"));
|
|
13
|
-
var _util = require("@polkadot/util");
|
|
14
|
-
var _constants = require("../../constants");
|
|
15
|
-
var _base = _interopRequireDefault(require("./base"));
|
|
16
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
17
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
18
|
-
|
|
19
|
-
class InterlayLendingPoolHandler extends _base.default {
|
|
20
|
-
altInputAsset = 'polkadot-NATIVE-DOT';
|
|
21
|
-
derivativeAssets = ['interlay-LOCAL-qDOT'];
|
|
22
|
-
inputAsset = 'interlay-LOCAL-DOT';
|
|
23
|
-
rewardAssets = ['interlay-LOCAL-DOT'];
|
|
24
|
-
feeAssets = ['interlay-NATIVE-INTR', 'interlay-LOCAL-DOT'];
|
|
25
|
-
constructor(state, chain) {
|
|
26
|
-
super(state, chain);
|
|
27
|
-
const chainInfo = this.chainInfo;
|
|
28
|
-
this.slug = `DOT___lending___${chain}`;
|
|
29
|
-
this.name = `${chainInfo.name} Lending`;
|
|
30
|
-
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
31
|
-
this.description = 'Earn rewards by lending DOT';
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/* Subscribe pool info */
|
|
35
|
-
|
|
36
|
-
async getPoolStat() {
|
|
37
|
-
const substrateApi = await this.substrateApi.isReady;
|
|
38
|
-
const inputTokenSlug = this.inputAsset;
|
|
39
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
40
|
-
const _exchangeRate = await substrateApi.api.query.loans.exchangeRate((0, _utils._getTokenOnChainInfo)(inputTokenInfo));
|
|
41
|
-
const exchangeRate = _exchangeRate.toPrimitive();
|
|
42
|
-
const decimals = 10 ** 18;
|
|
43
|
-
return {
|
|
44
|
-
...this.defaultInfo,
|
|
45
|
-
description: this.description,
|
|
46
|
-
type: this.type,
|
|
47
|
-
metadata: {
|
|
48
|
-
...this.baseMetadata,
|
|
49
|
-
isAvailable: true,
|
|
50
|
-
allowCancelUnstaking: false,
|
|
51
|
-
assetEarning: [{
|
|
52
|
-
slug: this.rewardAssets[0],
|
|
53
|
-
apr: 1.29,
|
|
54
|
-
exchangeRate: exchangeRate / decimals
|
|
55
|
-
}],
|
|
56
|
-
maxCandidatePerFarmer: 1,
|
|
57
|
-
maxWithdrawalRequestPerFarmer: 1,
|
|
58
|
-
minJoinPool: '10000000000',
|
|
59
|
-
minWithdrawal: '0',
|
|
60
|
-
totalApr: 1.29,
|
|
61
|
-
tvl: '291890000000000'
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/* Subscribe pool info */
|
|
67
|
-
|
|
68
|
-
/* Subscribe pool position */
|
|
69
|
-
|
|
70
|
-
async subscribePoolPosition(useAddresses, resultCallback) {
|
|
71
|
-
let cancel = false;
|
|
72
|
-
const substrateApi = this.substrateApi;
|
|
73
|
-
await substrateApi.isReady;
|
|
74
|
-
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
75
|
-
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
76
|
-
const unsub = await substrateApi.api.query.tokens.accounts.multi(useAddresses.map(address => [address, (0, _utils._getTokenOnChainInfo)(derivativeTokenInfo)]), _balances => {
|
|
77
|
-
if (cancel) {
|
|
78
|
-
unsub();
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const balances = _balances;
|
|
82
|
-
for (let i = 0; i < balances.length; i++) {
|
|
83
|
-
const balanceItem = balances[i];
|
|
84
|
-
const address = useAddresses[i];
|
|
85
|
-
const bnTotalBalance = balanceItem.free || _util.BN_ZERO;
|
|
86
|
-
const totalBalance = bnTotalBalance.toString();
|
|
87
|
-
const result = {
|
|
88
|
-
...this.defaultInfo,
|
|
89
|
-
type: this.type,
|
|
90
|
-
address,
|
|
91
|
-
balanceToken: this.inputAsset,
|
|
92
|
-
totalStake: totalBalance,
|
|
93
|
-
activeStake: totalBalance,
|
|
94
|
-
unstakeBalance: '0',
|
|
95
|
-
status: _types.EarningStatus.EARNING_REWARD,
|
|
96
|
-
derivativeToken: derivativeTokenSlug,
|
|
97
|
-
isBondedBefore: bnTotalBalance.gt(_util.BN_ZERO),
|
|
98
|
-
nominations: [],
|
|
99
|
-
unstakings: []
|
|
100
|
-
};
|
|
101
|
-
resultCallback(result);
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
return () => {
|
|
105
|
-
cancel = true;
|
|
106
|
-
unsub();
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/* Subscribe pool position */
|
|
111
|
-
|
|
112
|
-
/* Join pool action */
|
|
113
|
-
|
|
114
|
-
get submitJoinStepInfo() {
|
|
115
|
-
return {
|
|
116
|
-
name: 'Mint qDOT',
|
|
117
|
-
type: _types.YieldStepType.MINT_QDOT
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
async getSubmitStepFee(params) {
|
|
121
|
-
const poolOriginSubstrateApi = await this.substrateApi.isReady;
|
|
122
|
-
const inputTokenSlug = this.inputAsset;
|
|
123
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
124
|
-
const defaultFeeTokenSlug = this.feeAssets[0];
|
|
125
|
-
const _mintFeeInfo = await poolOriginSubstrateApi.api.tx.loans.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), params.amount).paymentInfo(_constants.fakeAddress);
|
|
126
|
-
const mintFeeInfo = _mintFeeInfo.toPrimitive();
|
|
127
|
-
return {
|
|
128
|
-
amount: mintFeeInfo.partialFee.toString(),
|
|
129
|
-
slug: defaultFeeTokenSlug
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
async handleSubmitStep(data, path) {
|
|
133
|
-
const substrateApi = await this.substrateApi.isReady;
|
|
134
|
-
const inputTokenSlug = this.inputAsset;
|
|
135
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
136
|
-
const extrinsic = substrateApi.api.tx.loans.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), data.amount);
|
|
137
|
-
return {
|
|
138
|
-
txChain: this.chain,
|
|
139
|
-
extrinsicType: _KoniTypes.ExtrinsicType.MINT_QDOT,
|
|
140
|
-
extrinsic,
|
|
141
|
-
txData: data,
|
|
142
|
-
transferNativeAmount: '0'
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/* Join pool action */
|
|
147
|
-
|
|
148
|
-
/* Leave pool action */
|
|
149
|
-
|
|
150
|
-
async handleYieldRedeem(amount, address, selectedTarget) {
|
|
151
|
-
const substrateApi = await this.substrateApi.isReady;
|
|
152
|
-
// @ts-ignore
|
|
153
|
-
const inputTokenSlug = this.inputAsset;
|
|
154
|
-
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
155
|
-
const yieldPositionInfo = await this.getPoolPosition(address);
|
|
156
|
-
if (!yieldPositionInfo) {
|
|
157
|
-
return Promise.reject(new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INVALID_PARAMS));
|
|
158
|
-
}
|
|
159
|
-
const bnAmount = new _bn.default(amount);
|
|
160
|
-
const bnActiveBalance = new _bn.default(yieldPositionInfo.activeStake);
|
|
161
|
-
const redeemAll = bnAmount.eq(bnActiveBalance);
|
|
162
|
-
const extrinsic = !redeemAll ? substrateApi.api.tx.loans.redeem((0, _utils._getTokenOnChainInfo)(inputTokenInfo), amount) : substrateApi.api.tx.loans.redeemAll((0, _utils._getTokenOnChainInfo)(inputTokenInfo));
|
|
163
|
-
return [_KoniTypes.ExtrinsicType.REDEEM_QDOT, extrinsic];
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/* Leave pool action */
|
|
167
|
-
}
|
|
168
|
-
exports.default = InterlayLendingPoolHandler;
|