@subwallet/extension-base 1.1.28-beta.1 → 1.1.28-beta.2
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 +9 -7
- package/cjs/koni/api/yield/helper/utils.js +2 -2
- package/cjs/koni/background/handlers/Extension.js +25 -1
- package/cjs/services/earning-service/constants/chains.js +2 -2
- package/cjs/services/earning-service/handlers/base.js +24 -6
- package/cjs/services/earning-service/handlers/lending/interlay.js +9 -7
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +9 -7
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +5 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +9 -7
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +9 -7
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +9 -7
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +23 -9
- package/cjs/services/earning-service/handlers/native-staking/astar.js +28 -8
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +5 -5
- package/cjs/services/earning-service/handlers/native-staking/base.js +11 -1
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +21 -7
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +35 -18
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +34 -14
- package/cjs/services/earning-service/handlers/special.js +32 -8
- package/cjs/services/earning-service/service.js +41 -17
- package/cjs/services/earning-service/utils/index.js +18 -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 +3 -1
- package/cjs/services/storage-service/DatabaseService.js +4 -0
- package/cjs/services/transaction-service/index.js +3 -3
- package/cjs/types/yield/actions/join/step.js +10 -0
- package/cjs/types/yield/info/base.js +7 -0
- package/cjs/utils/yield/index.js +3 -0
- package/koni/api/yield/helper/utils.js +2 -2
- package/koni/background/handlers/Extension.d.ts +2 -0
- package/koni/background/handlers/Extension.js +25 -1
- package/package.json +11 -1
- package/services/earning-service/constants/chains.js +2 -2
- package/services/earning-service/handlers/base.d.ts +6 -4
- package/services/earning-service/handlers/base.js +24 -6
- package/services/earning-service/handlers/lending/interlay.d.ts +1 -1
- package/services/earning-service/handlers/lending/interlay.js +9 -7
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +2 -2
- package/services/earning-service/handlers/liquid-staking/acala.js +9 -7
- package/services/earning-service/handlers/liquid-staking/base.d.ts +2 -1
- package/services/earning-service/handlers/liquid-staking/base.js +5 -1
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +2 -2
- package/services/earning-service/handlers/liquid-staking/bifrost.js +9 -7
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +2 -2
- package/services/earning-service/handlers/liquid-staking/parallel.js +9 -7
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +1 -1
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +9 -7
- package/services/earning-service/handlers/native-staking/amplitude.js +23 -9
- package/services/earning-service/handlers/native-staking/astar.d.ts +2 -1
- package/services/earning-service/handlers/native-staking/astar.js +28 -8
- package/services/earning-service/handlers/native-staking/base-para.js +5 -5
- package/services/earning-service/handlers/native-staking/base.d.ts +3 -2
- package/services/earning-service/handlers/native-staking/base.js +10 -1
- package/services/earning-service/handlers/native-staking/para-chain.js +21 -7
- package/services/earning-service/handlers/native-staking/relay-chain.js +35 -18
- package/services/earning-service/handlers/nomination-pool/index.d.ts +1 -1
- package/services/earning-service/handlers/nomination-pool/index.js +33 -14
- package/services/earning-service/handlers/special.d.ts +4 -2
- package/services/earning-service/handlers/special.js +32 -8
- package/services/earning-service/service.d.ts +6 -2
- package/services/earning-service/service.js +40 -17
- package/services/earning-service/utils/index.d.ts +5 -1
- package/services/earning-service/utils/index.js +13 -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 +3 -1
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +4 -0
- package/services/transaction-service/index.js +3 -3
- package/types/yield/actions/join/step.d.ts +19 -0
- package/types/yield/actions/join/step.js +12 -0
- package/types/yield/actions/others.d.ts +4 -1
- package/types/yield/info/account/info.d.ts +3 -14
- package/types/yield/info/account/reward.d.ts +3 -14
- package/types/yield/info/base.d.ts +17 -0
- package/types/yield/info/base.js +8 -0
- package/types/yield/info/chain/info.d.ts +81 -63
- package/types/yield/info/chain/target.d.ts +4 -0
- package/cjs/koni/api/dotsama/balance.js +0 -464
- package/cjs/services/migration-service/scripts/MigrateEthProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigratePioneerProvider.js +0 -17
- package/cjs/services/migration-service/scripts/MigrateProvider.js +0 -29
- package/cjs/services/storage-service/index.js +0 -241
- package/cjs/types.js +0 -1
- package/cjs/utils/address.js +0 -34
- package/cjs/utils/keyring.js +0 -57
|
@@ -6,6 +6,16 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.YieldStepType = void 0;
|
|
7
7
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
8
|
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
/**
|
|
10
|
+
* @interface RequestEarlyValidateYield
|
|
11
|
+
* @description Params to early validate join pool
|
|
12
|
+
* @prop {string} slug - Pool's slug
|
|
13
|
+
* @prop {string} address - Account's address
|
|
14
|
+
* */
|
|
15
|
+
/**
|
|
16
|
+
* @interface ResponseEarlyValidateYield
|
|
17
|
+
* @prop {boolean} passed - Passed validate
|
|
18
|
+
* */
|
|
9
19
|
/**
|
|
10
20
|
* @interface OptimalYieldPathParams
|
|
11
21
|
* @description Params to generate steps
|
|
@@ -25,6 +25,13 @@ exports.YieldPoolType = YieldPoolType;
|
|
|
25
25
|
YieldPoolType["PARACHAIN_STAKING"] = "PARACHAIN_STAKING";
|
|
26
26
|
})(YieldPoolType || (exports.YieldPoolType = YieldPoolType = {}));
|
|
27
27
|
let YieldCompoundingPeriod;
|
|
28
|
+
/**
|
|
29
|
+
* @interface BasePoolInfo
|
|
30
|
+
* @prop {string} slug - Pool's slug
|
|
31
|
+
* @prop {string} chain - Pool's chain
|
|
32
|
+
* @prop {string} type - Pool's type
|
|
33
|
+
* @prop {string} group - Pool's group (by token)
|
|
34
|
+
* */
|
|
28
35
|
exports.YieldCompoundingPeriod = YieldCompoundingPeriod;
|
|
29
36
|
(function (YieldCompoundingPeriod) {
|
|
30
37
|
YieldCompoundingPeriod[YieldCompoundingPeriod["DAILY"] = 1] = "DAILY";
|
|
@@ -22,10 +22,10 @@ export const YIELD_POOL_MIN_AMOUNT_PERCENT = {
|
|
|
22
22
|
default: 0.98
|
|
23
23
|
};
|
|
24
24
|
export function convertDerivativeToOriginToken(amount, poolInfo, derivativeTokenInfo, originTokenInfo) {
|
|
25
|
-
var _poolInfo$
|
|
25
|
+
var _poolInfo$statistic, _poolInfo$statistic$a;
|
|
26
26
|
const derivativeDecimals = _getAssetDecimals(derivativeTokenInfo);
|
|
27
27
|
const originDecimals = _getAssetDecimals(originTokenInfo);
|
|
28
|
-
const exchangeRate = ((_poolInfo$
|
|
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
29
|
const formattedAmount = parseInt(amount) / 10 ** derivativeDecimals; // TODO: decimals
|
|
30
30
|
const minAmount = formattedAmount * exchangeRate;
|
|
31
31
|
return Math.floor(minAmount * 10 ** originDecimals);
|
|
@@ -215,12 +215,14 @@ export default class KoniExtension {
|
|
|
215
215
|
private addInjects;
|
|
216
216
|
private removeInjects;
|
|
217
217
|
private subscribeYieldPoolInfo;
|
|
218
|
+
private earlyValidateJoin;
|
|
218
219
|
private getOptimalYieldPath;
|
|
219
220
|
private handleYieldStep;
|
|
220
221
|
private handleYieldLeave;
|
|
221
222
|
private getYieldPoolTargets;
|
|
222
223
|
private subscribeYieldPosition;
|
|
223
224
|
private subscribeYieldReward;
|
|
225
|
+
private subscribeEarningMinAmountPercent;
|
|
224
226
|
private handleValidateYieldProcess;
|
|
225
227
|
private yieldSubmitWithdrawal;
|
|
226
228
|
private yieldSubmitCancelWithdrawal;
|
|
@@ -3551,6 +3551,9 @@ export default class KoniExtension {
|
|
|
3551
3551
|
});
|
|
3552
3552
|
return this.#koniState.getYieldPoolInfo();
|
|
3553
3553
|
}
|
|
3554
|
+
async earlyValidateJoin(request) {
|
|
3555
|
+
return await this.#koniState.earningService.earlyValidateJoin(request);
|
|
3556
|
+
}
|
|
3554
3557
|
async getOptimalYieldPath(request) {
|
|
3555
3558
|
return await this.#koniState.earningService.generateOptimalSteps(request);
|
|
3556
3559
|
}
|
|
@@ -3625,7 +3628,11 @@ export default class KoniExtension {
|
|
|
3625
3628
|
const {
|
|
3626
3629
|
slug
|
|
3627
3630
|
} = request;
|
|
3628
|
-
|
|
3631
|
+
const targets = await this.#koniState.earningService.getPoolTargets(slug);
|
|
3632
|
+
return {
|
|
3633
|
+
slug,
|
|
3634
|
+
targets
|
|
3635
|
+
};
|
|
3629
3636
|
}
|
|
3630
3637
|
async subscribeYieldPosition(id, port) {
|
|
3631
3638
|
const cb = createSubscription(id, port);
|
|
@@ -3653,6 +3660,19 @@ export default class KoniExtension {
|
|
|
3653
3660
|
});
|
|
3654
3661
|
return this.#koniState.earningService.getEarningRewards();
|
|
3655
3662
|
}
|
|
3663
|
+
subscribeEarningMinAmountPercent(id, port) {
|
|
3664
|
+
const cb = createSubscription(id, port);
|
|
3665
|
+
const earningMinAmountPercentSubscription = this.#koniState.earningService.subscribeMinAmountPercent().subscribe({
|
|
3666
|
+
next: rs => {
|
|
3667
|
+
cb(rs);
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3670
|
+
this.createUnsubscriptionHandle(id, earningMinAmountPercentSubscription.unsubscribe);
|
|
3671
|
+
port.onDisconnect.addListener(() => {
|
|
3672
|
+
this.cancelSubscription(id);
|
|
3673
|
+
});
|
|
3674
|
+
return this.#koniState.earningService.getMinAmountPercent();
|
|
3675
|
+
}
|
|
3656
3676
|
handleValidateYieldProcess(inputData) {
|
|
3657
3677
|
return this.#koniState.earningService.validateYieldJoin(inputData);
|
|
3658
3678
|
}
|
|
@@ -3981,6 +4001,8 @@ export default class KoniExtension {
|
|
|
3981
4001
|
return this.subscribeYieldPosition(id, port);
|
|
3982
4002
|
case 'pri(yield.subscribeYieldReward)':
|
|
3983
4003
|
return this.subscribeYieldReward(id, port);
|
|
4004
|
+
case 'pri(yield.minAmountPercent)':
|
|
4005
|
+
return this.subscribeEarningMinAmountPercent(id, port);
|
|
3984
4006
|
|
|
3985
4007
|
/* Info */
|
|
3986
4008
|
|
|
@@ -3988,6 +4010,8 @@ export default class KoniExtension {
|
|
|
3988
4010
|
|
|
3989
4011
|
/* Join */
|
|
3990
4012
|
|
|
4013
|
+
case 'pri(yield.join.earlyValidate)':
|
|
4014
|
+
return await this.earlyValidateJoin(request);
|
|
3991
4015
|
case 'pri(yield.join.getOptimalPath)':
|
|
3992
4016
|
return await this.getOptimalYieldPath(request);
|
|
3993
4017
|
case 'pri(yield.join.handleStep)':
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.28-beta.
|
|
20
|
+
"version": "1.1.28-beta.2",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -895,6 +895,16 @@
|
|
|
895
895
|
"require": "./cjs/services/migration-service/scripts/ClearOldStorage.js",
|
|
896
896
|
"default": "./services/migration-service/scripts/ClearOldStorage.js"
|
|
897
897
|
},
|
|
898
|
+
"./services/migration-service/scripts/databases/MigrateEarningHistory": {
|
|
899
|
+
"types": "./services/migration-service/scripts/databases/MigrateEarningHistory.d.ts",
|
|
900
|
+
"require": "./cjs/services/migration-service/scripts/databases/MigrateEarningHistory.js",
|
|
901
|
+
"default": "./services/migration-service/scripts/databases/MigrateEarningHistory.js"
|
|
902
|
+
},
|
|
903
|
+
"./services/migration-service/scripts/databases/MigrateEarningVersion": {
|
|
904
|
+
"types": "./services/migration-service/scripts/databases/MigrateEarningVersion.d.ts",
|
|
905
|
+
"require": "./cjs/services/migration-service/scripts/databases/MigrateEarningVersion.js",
|
|
906
|
+
"default": "./services/migration-service/scripts/databases/MigrateEarningVersion.js"
|
|
907
|
+
},
|
|
898
908
|
"./services/migration-service/scripts/DeleteChain": {
|
|
899
909
|
"types": "./services/migration-service/scripts/DeleteChain.d.ts",
|
|
900
910
|
"require": "./cjs/services/migration-service/scripts/DeleteChain.js",
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
export const _STAKING_CHAIN_GROUP = {
|
|
5
|
-
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network'],
|
|
5
|
+
relay: ['polkadot', 'kusama', 'aleph', 'polkadex', 'ternoa', 'ternoa_alphanet', 'alephTest', 'polkadexTest', 'westend', 'kate', 'edgeware', 'creditcoin', 'vara_network', 'goldberg_testnet'],
|
|
6
6
|
para: ['moonbeam', 'moonriver', 'moonbase', 'turing', 'turingStaging', 'bifrost', 'bifrost_testnet', 'calamari_test', 'calamari'],
|
|
7
7
|
astar: ['astar', 'shiden', 'shibuya'],
|
|
8
8
|
amplitude: ['amplitude', 'amplitude_test', 'kilt', 'kilt_peregrine', 'pendulum'],
|
|
9
9
|
// amplitude and kilt only share some common logic
|
|
10
10
|
kilt: ['kilt', 'kilt_peregrine'],
|
|
11
|
-
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network'],
|
|
11
|
+
nominationPool: ['polkadot', 'kusama', 'westend', 'alephTest', 'aleph', 'kate', 'vara_network', 'goldberg_testnet'],
|
|
12
12
|
bifrost: ['bifrost', 'bifrost_testnet'],
|
|
13
13
|
aleph: ['aleph', 'alephTest'],
|
|
14
14
|
// A0 has distinct tokenomics
|
|
@@ -3,7 +3,7 @@ import { TransactionError } from '@subwallet/extension-base/background/errors/Tr
|
|
|
3
3
|
import { ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
4
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
5
5
|
import { _EvmApi, _SubstrateApi } from '@subwallet/extension-base/services/chain-service/types';
|
|
6
|
-
import { EarningRewardItem, HandleYieldStepData, OptimalYieldPath, OptimalYieldPathParams, StakeCancelWithdrawalParams, SubmitYieldJoinData, TransactionData, UnstakingInfo, YieldPoolInfo, YieldPoolTarget, YieldPoolType, YieldPositionInfo, YieldStepBaseInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
6
|
+
import { BasePoolInfo, BaseYieldPoolMetadata, EarningRewardItem, HandleYieldStepData, OptimalYieldPath, OptimalYieldPathParams, RequestEarlyValidateYield, ResponseEarlyValidateYield, StakeCancelWithdrawalParams, SubmitYieldJoinData, TransactionData, UnstakingInfo, YieldPoolInfo, YieldPoolTarget, YieldPoolType, YieldPositionInfo, YieldStepBaseInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
7
7
|
/**
|
|
8
8
|
* @class BasePoolHandler
|
|
9
9
|
* @description Base pool handler
|
|
@@ -23,8 +23,6 @@ export default abstract class BasePoolHandler {
|
|
|
23
23
|
protected abstract name: string;
|
|
24
24
|
/** Pool's short name */
|
|
25
25
|
protected abstract shortName: string;
|
|
26
|
-
/** Pool's description */
|
|
27
|
-
protected abstract description: string;
|
|
28
26
|
/** Pool's transaction type */
|
|
29
27
|
readonly transactionChainType: ChainType;
|
|
30
28
|
/**
|
|
@@ -35,11 +33,14 @@ export default abstract class BasePoolHandler {
|
|
|
35
33
|
protected constructor(state: KoniState, chain: string);
|
|
36
34
|
get logo(): string;
|
|
37
35
|
get group(): string;
|
|
36
|
+
get isActive(): boolean;
|
|
38
37
|
protected get substrateApi(): _SubstrateApi;
|
|
39
38
|
protected get evmApi(): _EvmApi;
|
|
40
39
|
get chainInfo(): _ChainInfo;
|
|
41
40
|
protected get nativeToken(): _ChainAsset;
|
|
42
|
-
protected get
|
|
41
|
+
protected get baseInfo(): Omit<BasePoolInfo, 'type'>;
|
|
42
|
+
protected abstract getDescription(amount?: string): string;
|
|
43
|
+
protected get metadataInfo(): Omit<BaseYieldPoolMetadata, 'description'>;
|
|
43
44
|
/** Can mint when haven't enough native token (use input token for fee) */
|
|
44
45
|
get isPoolSupportAlternativeFee(): boolean;
|
|
45
46
|
getPoolInfo(): Promise<YieldPoolInfo | undefined>;
|
|
@@ -52,6 +53,7 @@ export default abstract class BasePoolHandler {
|
|
|
52
53
|
abstract getPoolReward(useAddresses: string[], callback: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
|
|
53
54
|
/** Get pool target */
|
|
54
55
|
abstract getPoolTargets(): Promise<YieldPoolTarget[]>;
|
|
56
|
+
earlyValidate(request: RequestEarlyValidateYield): Promise<ResponseEarlyValidateYield>;
|
|
55
57
|
/**
|
|
56
58
|
* @function firstStepFee
|
|
57
59
|
* */
|
|
@@ -22,8 +22,6 @@ export default class BasePoolHandler {
|
|
|
22
22
|
|
|
23
23
|
/** Pool's short name */
|
|
24
24
|
|
|
25
|
-
/** Pool's description */
|
|
26
|
-
|
|
27
25
|
/** Pool's transaction type */
|
|
28
26
|
transactionChainType = ChainType.SUBSTRATE;
|
|
29
27
|
|
|
@@ -44,6 +42,9 @@ export default class BasePoolHandler {
|
|
|
44
42
|
const groupSlug = this.nativeToken.multiChainAsset;
|
|
45
43
|
return groupSlug || this.nativeToken.slug;
|
|
46
44
|
}
|
|
45
|
+
get isActive() {
|
|
46
|
+
return this.state.activeChainSlugs.includes(this.chain);
|
|
47
|
+
}
|
|
47
48
|
get substrateApi() {
|
|
48
49
|
return this.state.getSubstrateApi(this.chain);
|
|
49
50
|
}
|
|
@@ -56,16 +57,23 @@ export default class BasePoolHandler {
|
|
|
56
57
|
get nativeToken() {
|
|
57
58
|
return this.state.getNativeTokenInfo(this.chain);
|
|
58
59
|
}
|
|
59
|
-
get
|
|
60
|
+
get baseInfo() {
|
|
60
61
|
return {
|
|
61
|
-
name: this.name,
|
|
62
|
-
shortName: this.shortName,
|
|
63
62
|
group: this.group,
|
|
64
|
-
logo: this.logo,
|
|
65
63
|
chain: this.chain,
|
|
66
64
|
slug: this.slug
|
|
67
65
|
};
|
|
68
66
|
}
|
|
67
|
+
get metadataInfo() {
|
|
68
|
+
return {
|
|
69
|
+
name: this.name,
|
|
70
|
+
shortName: this.shortName,
|
|
71
|
+
logo: this.logo,
|
|
72
|
+
inputAsset: this.nativeToken.slug,
|
|
73
|
+
isAvailable: true,
|
|
74
|
+
allowCancelUnstaking: false
|
|
75
|
+
};
|
|
76
|
+
}
|
|
69
77
|
|
|
70
78
|
/** Can mint when haven't enough native token (use input token for fee) */
|
|
71
79
|
get isPoolSupportAlternativeFee() {
|
|
@@ -86,6 +94,16 @@ export default class BasePoolHandler {
|
|
|
86
94
|
|
|
87
95
|
/* Join action */
|
|
88
96
|
|
|
97
|
+
/* Early validate */
|
|
98
|
+
|
|
99
|
+
earlyValidate(request) {
|
|
100
|
+
return Promise.resolve({
|
|
101
|
+
passed: false
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/* Early validate */
|
|
106
|
+
|
|
89
107
|
/* Generate steps */
|
|
90
108
|
|
|
91
109
|
/**
|
|
@@ -3,7 +3,6 @@ import KoniState from '@subwallet/extension-base/koni/background/handlers/State'
|
|
|
3
3
|
import { BaseYieldStepDetail, HandleYieldStepData, LendingYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
4
4
|
import BaseLendingPoolHandler from './base';
|
|
5
5
|
export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
6
|
-
protected readonly description: string;
|
|
7
6
|
protected readonly name: string;
|
|
8
7
|
protected readonly shortName: string;
|
|
9
8
|
protected readonly altInputAsset: string;
|
|
@@ -13,6 +12,7 @@ export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
|
13
12
|
protected readonly feeAssets: string[];
|
|
14
13
|
slug: string;
|
|
15
14
|
constructor(state: KoniState, chain: string);
|
|
15
|
+
protected getDescription(): string;
|
|
16
16
|
getPoolStat(): Promise<LendingYieldPoolInfo>;
|
|
17
17
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
18
18
|
get submitJoinStepInfo(): BaseYieldStepDetail;
|
|
@@ -21,7 +21,9 @@ export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
|
21
21
|
this.slug = `DOT___lending___${chain}`;
|
|
22
22
|
this.name = `${chainInfo.name} Lending`;
|
|
23
23
|
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
24
|
-
|
|
24
|
+
}
|
|
25
|
+
getDescription() {
|
|
26
|
+
return 'Earn rewards by lending DOT';
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
/* Subscribe pool info */
|
|
@@ -34,13 +36,13 @@ export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
|
34
36
|
const exchangeRate = _exchangeRate.toPrimitive();
|
|
35
37
|
const decimals = 10 ** 18;
|
|
36
38
|
return {
|
|
37
|
-
...this.
|
|
38
|
-
description: this.description,
|
|
39
|
+
...this.baseInfo,
|
|
39
40
|
type: this.type,
|
|
40
41
|
metadata: {
|
|
41
|
-
...this.
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
...this.metadataInfo,
|
|
43
|
+
description: this.getDescription()
|
|
44
|
+
},
|
|
45
|
+
statistic: {
|
|
44
46
|
assetEarning: [{
|
|
45
47
|
slug: this.rewardAssets[0],
|
|
46
48
|
apr: 1.29,
|
|
@@ -78,7 +80,7 @@ export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
|
78
80
|
const bnTotalBalance = balanceItem.free || BN_ZERO;
|
|
79
81
|
const totalBalance = bnTotalBalance.toString();
|
|
80
82
|
const result = {
|
|
81
|
-
...this.
|
|
83
|
+
...this.baseInfo,
|
|
82
84
|
type: this.type,
|
|
83
85
|
address,
|
|
84
86
|
balanceToken: this.inputAsset,
|
|
@@ -3,7 +3,6 @@ import KoniState from '@subwallet/extension-base/koni/background/handlers/State'
|
|
|
3
3
|
import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
4
4
|
import BaseLiquidStakingPoolHandler from './base';
|
|
5
5
|
export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
|
|
6
|
-
protected readonly description: string;
|
|
7
6
|
protected readonly name: string;
|
|
8
7
|
protected readonly shortName: string;
|
|
9
8
|
protected readonly altInputAsset: string;
|
|
@@ -12,11 +11,12 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
12
11
|
protected readonly rewardAssets: string[];
|
|
13
12
|
protected readonly feeAssets: string[];
|
|
14
13
|
/** @inner */
|
|
15
|
-
|
|
14
|
+
readonly minAmountPercent = 0.98;
|
|
16
15
|
/** @inner */
|
|
17
16
|
protected readonly allowDefaultUnstake = true;
|
|
18
17
|
slug: string;
|
|
19
18
|
constructor(state: KoniState, chain: string);
|
|
19
|
+
protected getDescription(): string;
|
|
20
20
|
getPoolStat(): Promise<LiquidYieldPoolInfo>;
|
|
21
21
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
22
22
|
get submitJoinStepInfo(): BaseYieldStepDetail;
|
|
@@ -26,7 +26,9 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
26
26
|
this.slug = `DOT___liquid_staking___${chain}`;
|
|
27
27
|
this.name = `${chainInfo.name} Liquid Staking`;
|
|
28
28
|
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
29
|
-
|
|
29
|
+
}
|
|
30
|
+
getDescription() {
|
|
31
|
+
return 'Stake DOT to earn yield on LDOT';
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
/* Subscribe pool info */
|
|
@@ -58,13 +60,13 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
58
60
|
const toBondPool = new BN(_toBondPool.toString());
|
|
59
61
|
const totalStakingBonded = new BN(_totalStakingBonded.toString());
|
|
60
62
|
return {
|
|
61
|
-
...this.
|
|
62
|
-
description: this.description,
|
|
63
|
+
...this.baseInfo,
|
|
63
64
|
type: this.type,
|
|
64
65
|
metadata: {
|
|
65
|
-
...this.
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
...this.metadataInfo,
|
|
67
|
+
description: this.getDescription()
|
|
68
|
+
},
|
|
69
|
+
statistic: {
|
|
68
70
|
assetEarning: [{
|
|
69
71
|
slug: this.rewardAssets[0],
|
|
70
72
|
apy: apy * 100,
|
|
@@ -102,7 +104,7 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
102
104
|
const bnTotalBalance = balanceItem.free || BN_ZERO;
|
|
103
105
|
const totalBalance = bnTotalBalance.toString();
|
|
104
106
|
const result = {
|
|
105
|
-
...this.
|
|
107
|
+
...this.baseInfo,
|
|
106
108
|
type: this.type,
|
|
107
109
|
address,
|
|
108
110
|
balanceToken: this.inputAsset,
|
|
@@ -3,6 +3,7 @@ import BaseSpecialStakingPoolHandler from '../special';
|
|
|
3
3
|
export default abstract class BaseLiquidStakingPoolHandler extends BaseSpecialStakingPoolHandler {
|
|
4
4
|
readonly type = YieldPoolType.LIQUID_STAKING;
|
|
5
5
|
/** Rate convert token when redeem */
|
|
6
|
-
|
|
6
|
+
readonly minAmountPercent: number;
|
|
7
|
+
static get defaultMinAmountPercent(): number;
|
|
7
8
|
createParamToRedeem(amount: string, address: string): Promise<number>;
|
|
8
9
|
}
|
|
@@ -6,10 +6,14 @@ import { BasicTxErrorType } from '@subwallet/extension-base/background/KoniTypes
|
|
|
6
6
|
import { convertDerivativeToOriginToken } from '@subwallet/extension-base/koni/api/yield/helper/utils';
|
|
7
7
|
import { YieldPoolType } from '@subwallet/extension-base/types';
|
|
8
8
|
import BaseSpecialStakingPoolHandler from "../special.js";
|
|
9
|
+
const DEFAULT_MIN_AMOUNT_PERCENT = 0.98;
|
|
9
10
|
export default class BaseLiquidStakingPoolHandler extends BaseSpecialStakingPoolHandler {
|
|
10
11
|
type = YieldPoolType.LIQUID_STAKING;
|
|
11
12
|
/** Rate convert token when redeem */
|
|
12
|
-
minAmountPercent =
|
|
13
|
+
minAmountPercent = DEFAULT_MIN_AMOUNT_PERCENT;
|
|
14
|
+
static get defaultMinAmountPercent() {
|
|
15
|
+
return DEFAULT_MIN_AMOUNT_PERCENT;
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
/* Leave pool action */
|
|
15
19
|
|
|
@@ -23,7 +23,6 @@ export interface BifrostVtokenExchangeRate {
|
|
|
23
23
|
token_pool: number;
|
|
24
24
|
}
|
|
25
25
|
export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
|
|
26
|
-
protected readonly description: string;
|
|
27
26
|
protected readonly name: string;
|
|
28
27
|
protected readonly shortName: string;
|
|
29
28
|
protected readonly altInputAsset: string;
|
|
@@ -32,9 +31,10 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
32
31
|
protected readonly rewardAssets: string[];
|
|
33
32
|
protected readonly feeAssets: string[];
|
|
34
33
|
/** @inner */
|
|
35
|
-
|
|
34
|
+
readonly minAmountPercent = 0.99;
|
|
36
35
|
slug: string;
|
|
37
36
|
constructor(state: KoniState, chain: string);
|
|
37
|
+
protected getDescription(): string;
|
|
38
38
|
getPoolStat(): Promise<LiquidYieldPoolInfo>;
|
|
39
39
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
40
40
|
get submitJoinStepInfo(): BaseYieldStepDetail;
|
|
@@ -26,9 +26,11 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
26
26
|
const chainInfo = this.chainInfo;
|
|
27
27
|
this.slug = `DOT___liquid_staking___${chain}`;
|
|
28
28
|
this.name = `${chainInfo.name} Liquid Staking`;
|
|
29
|
-
this.description = 'Stake DOT to earn yield on vDOT';
|
|
30
29
|
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
31
30
|
}
|
|
31
|
+
getDescription() {
|
|
32
|
+
return 'Stake DOT to earn yield on vDOT';
|
|
33
|
+
}
|
|
32
34
|
|
|
33
35
|
/* Subscribe pool info */
|
|
34
36
|
|
|
@@ -60,13 +62,13 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
60
62
|
const assetInfo = this.state.getAssetBySlug(this.inputAsset);
|
|
61
63
|
const assetDecimals = 10 ** _getAssetDecimals(assetInfo);
|
|
62
64
|
return {
|
|
63
|
-
...this.
|
|
64
|
-
description: this.description,
|
|
65
|
+
...this.baseInfo,
|
|
65
66
|
type: this.type,
|
|
66
67
|
metadata: {
|
|
67
|
-
...this.
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
...this.metadataInfo,
|
|
69
|
+
description: this.getDescription()
|
|
70
|
+
},
|
|
71
|
+
statistic: {
|
|
70
72
|
assetEarning: [{
|
|
71
73
|
slug: this.rewardAssets[0],
|
|
72
74
|
apy: parseFloat(vDOTStats.apyBase),
|
|
@@ -173,7 +175,7 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
173
175
|
}
|
|
174
176
|
const totalBalance = bnActiveBalance.add(unlockBalance);
|
|
175
177
|
const result = {
|
|
176
|
-
...this.
|
|
178
|
+
...this.baseInfo,
|
|
177
179
|
type: this.type,
|
|
178
180
|
address,
|
|
179
181
|
balanceToken: this.inputAsset,
|
|
@@ -3,7 +3,6 @@ import KoniState from '@subwallet/extension-base/koni/background/handlers/State'
|
|
|
3
3
|
import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
4
4
|
import BaseLiquidStakingPoolHandler from './base';
|
|
5
5
|
export default class ParallelLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
|
|
6
|
-
protected readonly description: string;
|
|
7
6
|
protected readonly name: string;
|
|
8
7
|
protected readonly shortName: string;
|
|
9
8
|
protected readonly altInputAsset: string;
|
|
@@ -12,11 +11,12 @@ export default class ParallelLiquidStakingPoolHandler extends BaseLiquidStakingP
|
|
|
12
11
|
protected readonly rewardAssets: string[];
|
|
13
12
|
protected readonly feeAssets: string[];
|
|
14
13
|
/** @inner */
|
|
15
|
-
|
|
14
|
+
readonly minAmountPercent = 0.97;
|
|
16
15
|
/** @inner */
|
|
17
16
|
protected readonly allowDefaultUnstake = true;
|
|
18
17
|
slug: string;
|
|
19
18
|
constructor(state: KoniState, chain: string);
|
|
19
|
+
protected getDescription(): string;
|
|
20
20
|
getPoolStat(): Promise<LiquidYieldPoolInfo>;
|
|
21
21
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
22
22
|
get submitJoinStepInfo(): BaseYieldStepDetail;
|
|
@@ -23,7 +23,9 @@ export default class ParallelLiquidStakingPoolHandler extends BaseLiquidStakingP
|
|
|
23
23
|
this.slug = `DOT___liquid_staking___${chain}`;
|
|
24
24
|
this.name = `${chainInfo.name} Liquid Staking`;
|
|
25
25
|
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
26
|
-
|
|
26
|
+
}
|
|
27
|
+
getDescription() {
|
|
28
|
+
return 'Stake DOT to earn yield on sDOT';
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
/* Subscribe pool info */
|
|
@@ -49,13 +51,13 @@ export default class ParallelLiquidStakingPoolHandler extends BaseLiquidStakingP
|
|
|
49
51
|
const decimals = 10 ** 18;
|
|
50
52
|
const apy = (exchangeRate / beginExchangeRate) ** (365 * 24 * 60 * 60000 / (currentTimestamp - beginTimestamp)) - 1;
|
|
51
53
|
return {
|
|
52
|
-
...this.
|
|
53
|
-
description: this.description,
|
|
54
|
+
...this.baseInfo,
|
|
54
55
|
type: this.type,
|
|
55
56
|
metadata: {
|
|
56
|
-
...this.
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
...this.metadataInfo,
|
|
58
|
+
description: this.getDescription()
|
|
59
|
+
},
|
|
60
|
+
statistic: {
|
|
59
61
|
assetEarning: [{
|
|
60
62
|
slug: this.rewardAssets[0],
|
|
61
63
|
apy: apy * 100,
|
|
@@ -98,7 +100,7 @@ export default class ParallelLiquidStakingPoolHandler extends BaseLiquidStakingP
|
|
|
98
100
|
const bnTotalBalance = bdata && bdata.balance ? new BN(String(bdata === null || bdata === void 0 ? void 0 : bdata.balance).replaceAll(',', '') || '0') : BN_ZERO;
|
|
99
101
|
const totalBalance = bnTotalBalance.toString();
|
|
100
102
|
const result = {
|
|
101
|
-
...this.
|
|
103
|
+
...this.baseInfo,
|
|
102
104
|
type: this.type,
|
|
103
105
|
address,
|
|
104
106
|
balanceToken: this.inputAsset,
|
|
@@ -7,7 +7,6 @@ import { Contract } from 'web3-eth-contract';
|
|
|
7
7
|
import BaseLiquidStakingPoolHandler from './base';
|
|
8
8
|
export declare const getStellaswapLiquidStakingContract: (networkKey: string, assetAddress: string, evmApi: _EvmApi, options?: {}) => Contract;
|
|
9
9
|
export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
|
|
10
|
-
protected readonly description: string;
|
|
11
10
|
protected readonly name: string;
|
|
12
11
|
protected readonly shortName: string;
|
|
13
12
|
protected readonly inputAsset: string;
|
|
@@ -22,6 +21,7 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
22
21
|
slug: string;
|
|
23
22
|
transactionChainType: ChainType;
|
|
24
23
|
constructor(state: KoniState, chain: string);
|
|
24
|
+
protected getDescription(): string;
|
|
25
25
|
getPoolStat(): Promise<LiquidYieldPoolInfo>;
|
|
26
26
|
subscribePoolPosition(useAddresses: string[], resultCallback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
27
27
|
get submitJoinStepInfo(): BaseYieldStepDetail;
|
|
@@ -33,10 +33,12 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
33
33
|
super(state, chain);
|
|
34
34
|
this.slug = 'xcDOT___liquid_staking___stellaswap';
|
|
35
35
|
this.name = 'Stellaswap Liquid Staking';
|
|
36
|
-
this.description = 'Earn rewards by staking xcDOT for stDOT';
|
|
37
36
|
this._logo = 'stellaswap';
|
|
38
37
|
this.shortName = 'Stellaswap';
|
|
39
38
|
}
|
|
39
|
+
getDescription() {
|
|
40
|
+
return 'Earn rewards by staking xcDOT for stDOT';
|
|
41
|
+
}
|
|
40
42
|
|
|
41
43
|
/* Subscribe pool info */
|
|
42
44
|
|
|
@@ -67,13 +69,13 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
67
69
|
exchangeRateCall.call()]);
|
|
68
70
|
const exchangeRate = equivalentTokenShare / 10 ** _getAssetDecimals(derivativeTokenInfo);
|
|
69
71
|
return {
|
|
70
|
-
...this.
|
|
71
|
-
description: this.description,
|
|
72
|
+
...this.baseInfo,
|
|
72
73
|
type: this.type,
|
|
73
74
|
metadata: {
|
|
74
|
-
...this.
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
...this.metadataInfo,
|
|
76
|
+
description: this.getDescription()
|
|
77
|
+
},
|
|
78
|
+
statistic: {
|
|
77
79
|
assetEarning: [{
|
|
78
80
|
slug: this.rewardAssets[0],
|
|
79
81
|
apr: aprObject.result,
|
|
@@ -135,7 +137,7 @@ export default class StellaSwapLiquidStakingPoolHandler extends BaseLiquidStakin
|
|
|
135
137
|
|
|
136
138
|
const totalBalance = new BN(balance).add(unlockBalance);
|
|
137
139
|
const result = {
|
|
138
|
-
...this.
|
|
140
|
+
...this.baseInfo,
|
|
139
141
|
type: this.type,
|
|
140
142
|
address,
|
|
141
143
|
balanceToken: this.inputAsset,
|