@subwallet/extension-base 1.1.29-beta.0 → 1.1.29-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +2 -1
- package/cjs/constants/index.js +11 -2
- package/cjs/koni/background/cron.js +10 -2
- package/cjs/koni/background/handlers/Extension.js +15 -0
- package/cjs/koni/background/subscription.js +12 -24
- package/cjs/services/earning-service/handlers/base.js +5 -3
- package/cjs/services/earning-service/handlers/lending/interlay.js +8 -0
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +16 -5
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +17 -1
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +9 -3
- package/cjs/services/earning-service/handlers/liquid-staking/stella-swap.js +38 -11
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +4 -2
- package/cjs/services/earning-service/handlers/native-staking/astar.js +11 -6
- package/cjs/services/earning-service/handlers/native-staking/base.js +45 -5
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +14 -1
- package/cjs/services/earning-service/handlers/special.js +7 -8
- package/cjs/services/earning-service/service.js +41 -5
- package/cjs/services/subscan-service/index.js +16 -0
- package/constants/index.d.ts +4 -1
- package/constants/index.js +4 -1
- package/koni/background/cron.d.ts +1 -0
- package/koni/background/cron.js +11 -3
- package/koni/background/handlers/Extension.d.ts +1 -0
- package/koni/background/handlers/Extension.js +15 -0
- package/koni/background/subscription.d.ts +1 -0
- package/koni/background/subscription.js +12 -23
- package/package.json +1 -1
- package/services/earning-service/handlers/base.d.ts +5 -1
- package/services/earning-service/handlers/base.js +5 -3
- package/services/earning-service/handlers/lending/interlay.d.ts +3 -2
- package/services/earning-service/handlers/lending/interlay.js +8 -0
- package/services/earning-service/handlers/liquid-staking/acala.d.ts +3 -4
- package/services/earning-service/handlers/liquid-staking/acala.js +16 -5
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +4 -3
- package/services/earning-service/handlers/liquid-staking/bifrost.js +17 -1
- package/services/earning-service/handlers/liquid-staking/parallel.d.ts +3 -5
- package/services/earning-service/handlers/liquid-staking/parallel.js +9 -3
- package/services/earning-service/handlers/liquid-staking/stella-swap.d.ts +4 -6
- package/services/earning-service/handlers/liquid-staking/stella-swap.js +38 -11
- package/services/earning-service/handlers/native-staking/amplitude.js +4 -2
- package/services/earning-service/handlers/native-staking/astar.d.ts +2 -2
- package/services/earning-service/handlers/native-staking/astar.js +11 -6
- package/services/earning-service/handlers/native-staking/base.d.ts +3 -2
- package/services/earning-service/handlers/native-staking/base.js +45 -5
- package/services/earning-service/handlers/native-staking/para-chain.js +3 -1
- package/services/earning-service/handlers/native-staking/relay-chain.js +3 -1
- package/services/earning-service/handlers/nomination-pool/index.d.ts +3 -1
- package/services/earning-service/handlers/nomination-pool/index.js +15 -2
- package/services/earning-service/handlers/special.d.ts +1 -4
- package/services/earning-service/handlers/special.js +7 -8
- package/services/earning-service/service.d.ts +7 -2
- package/services/earning-service/service.js +41 -5
- package/services/subscan-service/index.d.ts +2 -1
- package/services/subscan-service/index.js +15 -0
- package/services/subscan-service/types.d.ts +20 -0
- package/types/yield/info/account/info.d.ts +2 -11
- package/types/yield/info/account/reward.d.ts +15 -0
- package/types/yield/info/chain/info.d.ts +29 -3
|
@@ -21,6 +21,14 @@ var _base = _interopRequireDefault(require("../base"));
|
|
|
21
21
|
|
|
22
22
|
class NominationPoolHandler extends _base.default {
|
|
23
23
|
type = _types.YieldPoolType.NOMINATION_POOL;
|
|
24
|
+
availableMethod = {
|
|
25
|
+
join: true,
|
|
26
|
+
defaultUnstake: true,
|
|
27
|
+
fastUnstake: false,
|
|
28
|
+
cancelUnstake: false,
|
|
29
|
+
withdraw: true,
|
|
30
|
+
claimReward: true
|
|
31
|
+
};
|
|
24
32
|
constructor(state, chain) {
|
|
25
33
|
super(state, chain);
|
|
26
34
|
const _chainAsset = this.nativeToken;
|
|
@@ -83,7 +91,8 @@ class NominationPoolHandler extends _base.default {
|
|
|
83
91
|
const inflation = (0, _utils.calculateInflation)(bnTotalEraStake, bnTotalIssuance, numAuctions, chainInfo.slug);
|
|
84
92
|
const minPoolJoin = (_minPoolJoin === null || _minPoolJoin === void 0 ? void 0 : _minPoolJoin.toString()) || undefined;
|
|
85
93
|
const expectedReturn = (0, _utils.calculateChainStakedReturn)(inflation, bnTotalEraStake, bnTotalIssuance, chainInfo.slug);
|
|
86
|
-
const
|
|
94
|
+
const eraTime = _constants._STAKING_ERA_LENGTH_MAP[this.chain] || _constants._STAKING_ERA_LENGTH_MAP.default; // in hours
|
|
95
|
+
const unlockingPeriod = parseInt(unlockingEras) * eraTime; // in hours
|
|
87
96
|
|
|
88
97
|
const minToHuman = (0, _utils3.formatNumber)(minPoolJoin || '0', nativeToken.decimals || 0, _utils3.balanceFormatter);
|
|
89
98
|
const data = {
|
|
@@ -106,6 +115,7 @@ class NominationPoolHandler extends _base.default {
|
|
|
106
115
|
farmerCount: 0,
|
|
107
116
|
// TODO recheck
|
|
108
117
|
era: parseInt(currentEra),
|
|
118
|
+
eraTime,
|
|
109
119
|
tvl: bnTotalEraStake.toString(),
|
|
110
120
|
// TODO recheck
|
|
111
121
|
totalApy: expectedReturn,
|
|
@@ -274,6 +284,9 @@ class NominationPoolHandler extends _base.default {
|
|
|
274
284
|
cancel = false;
|
|
275
285
|
};
|
|
276
286
|
}
|
|
287
|
+
async getPoolRewardHistory(useAddresses, callBack) {
|
|
288
|
+
return new Promise(resolve => resolve(_util.noop));
|
|
289
|
+
}
|
|
277
290
|
|
|
278
291
|
/* Get pool reward */
|
|
279
292
|
|
|
@@ -21,10 +21,6 @@ var _base = _interopRequireDefault(require("./base"));
|
|
|
21
21
|
class BaseSpecialStakingPoolHandler extends _base.default {
|
|
22
22
|
/** Pool's type */
|
|
23
23
|
|
|
24
|
-
/** Allow to create default unstake transaction */
|
|
25
|
-
allowDefaultUnstake = false;
|
|
26
|
-
/** Allow to create fast unstake transaction */
|
|
27
|
-
allowFastUnstake = true;
|
|
28
24
|
get metadataInfo() {
|
|
29
25
|
return {
|
|
30
26
|
altInputAssets: this.altInputAsset,
|
|
@@ -36,9 +32,9 @@ class BaseSpecialStakingPoolHandler extends _base.default {
|
|
|
36
32
|
shortName: this.shortName,
|
|
37
33
|
name: this.name,
|
|
38
34
|
isAvailable: true,
|
|
39
|
-
allowCancelUnstaking: false,
|
|
40
35
|
maintainAsset: this.nativeToken.slug,
|
|
41
|
-
maintainBalance: this.maintainBalance
|
|
36
|
+
maintainBalance: this.maintainBalance,
|
|
37
|
+
availableMethod: this.availableMethod
|
|
42
38
|
};
|
|
43
39
|
}
|
|
44
40
|
get isPoolSupportAlternativeFee() {
|
|
@@ -99,6 +95,9 @@ class BaseSpecialStakingPoolHandler extends _base.default {
|
|
|
99
95
|
async getPoolReward() {
|
|
100
96
|
return new Promise(resolve => resolve(_util.noop));
|
|
101
97
|
}
|
|
98
|
+
async getPoolRewardHistory() {
|
|
99
|
+
return new Promise(resolve => resolve(_util.noop));
|
|
100
|
+
}
|
|
102
101
|
|
|
103
102
|
/* Get pool reward */
|
|
104
103
|
|
|
@@ -366,10 +365,10 @@ class BaseSpecialStakingPoolHandler extends _base.default {
|
|
|
366
365
|
if (!poolInfo || !poolInfo.statistic || !poolPosition) {
|
|
367
366
|
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
368
367
|
}
|
|
369
|
-
if (!this.
|
|
368
|
+
if (!this.availableMethod.defaultUnstake && !fastLeave) {
|
|
370
369
|
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
371
370
|
}
|
|
372
|
-
if (!this.
|
|
371
|
+
if (!this.availableMethod.fastUnstake && fastLeave) {
|
|
373
372
|
return [new _TransactionError.TransactionError(_KoniTypes.BasicTxErrorType.INTERNAL_ERROR)];
|
|
374
373
|
}
|
|
375
374
|
const errors = [];
|
|
@@ -23,6 +23,7 @@ class EarningService {
|
|
|
23
23
|
ready: false,
|
|
24
24
|
data: {}
|
|
25
25
|
});
|
|
26
|
+
earningRewardHistorySubject = new _rxjs.BehaviorSubject({});
|
|
26
27
|
minAmountPercentSubject = new _rxjs.BehaviorSubject({});
|
|
27
28
|
constructor(state) {
|
|
28
29
|
this.state = state;
|
|
@@ -156,14 +157,11 @@ class EarningService {
|
|
|
156
157
|
|
|
157
158
|
/* Get pools' reward */
|
|
158
159
|
|
|
159
|
-
updateEarningReward(stakingRewardData
|
|
160
|
+
updateEarningReward(stakingRewardData) {
|
|
160
161
|
const stakingRewardState = this.earningRewardSubject.getValue();
|
|
161
162
|
stakingRewardState.ready = true;
|
|
162
|
-
const key = `${stakingRewardData.slug}
|
|
163
|
+
const key = `${stakingRewardData.slug}---${stakingRewardData.address}`;
|
|
163
164
|
stakingRewardState.data[key] = stakingRewardData;
|
|
164
|
-
if (callback) {
|
|
165
|
-
callback(stakingRewardState);
|
|
166
|
-
}
|
|
167
165
|
this.earningRewardSubject.next(stakingRewardState);
|
|
168
166
|
}
|
|
169
167
|
async getPoolReward(addresses, callback) {
|
|
@@ -198,6 +196,44 @@ class EarningService {
|
|
|
198
196
|
getEarningRewards() {
|
|
199
197
|
return this.earningRewardSubject.getValue();
|
|
200
198
|
}
|
|
199
|
+
async fetchPoolRewardHistory(addresses, callback) {
|
|
200
|
+
let cancel = false;
|
|
201
|
+
await this.state.eventService.waitChainReady;
|
|
202
|
+
const [substrateAddresses, evmAddresses] = (0, _utils2.categoryAddresses)(addresses);
|
|
203
|
+
const activeChains = this.state.activeChainSlugs;
|
|
204
|
+
const unsubList = [];
|
|
205
|
+
for (const handler of Object.values(this.handlers)) {
|
|
206
|
+
if (activeChains.includes(handler.chain)) {
|
|
207
|
+
const chainInfo = handler.chainInfo;
|
|
208
|
+
const useAddresses = (0, _utils._isChainEvmCompatible)(chainInfo) ? evmAddresses : substrateAddresses;
|
|
209
|
+
handler.getPoolRewardHistory(useAddresses, callback).then(unsub => {
|
|
210
|
+
if (cancel) {
|
|
211
|
+
unsub();
|
|
212
|
+
} else {
|
|
213
|
+
unsubList.push(unsub);
|
|
214
|
+
}
|
|
215
|
+
}).catch(console.error);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return () => {
|
|
219
|
+
cancel = true;
|
|
220
|
+
unsubList.forEach(unsub => {
|
|
221
|
+
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
updateEarningRewardHistory(earningRewardHistory) {
|
|
226
|
+
const earningRewardHistoryState = this.earningRewardHistorySubject.getValue();
|
|
227
|
+
const key = `${earningRewardHistory.slug}---${earningRewardHistory.address}---${earningRewardHistory.blockTimestamp}`;
|
|
228
|
+
earningRewardHistoryState[key] = earningRewardHistory;
|
|
229
|
+
this.earningRewardHistorySubject.next(earningRewardHistoryState);
|
|
230
|
+
}
|
|
231
|
+
subscribeEarningRewardHistory() {
|
|
232
|
+
return this.earningRewardHistorySubject;
|
|
233
|
+
}
|
|
234
|
+
getEarningRewardHistory() {
|
|
235
|
+
return this.earningRewardHistorySubject.getValue();
|
|
236
|
+
}
|
|
201
237
|
|
|
202
238
|
/* Get pools' reward */
|
|
203
239
|
|
|
@@ -252,5 +252,21 @@ class SubscanService {
|
|
|
252
252
|
await _getTransferItems(0);
|
|
253
253
|
return resultMap;
|
|
254
254
|
}
|
|
255
|
+
getRewardHistoryList(chain, address) {
|
|
256
|
+
let page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
257
|
+
return this.addRequest(async () => {
|
|
258
|
+
const rs = await this.postRequest(this.getApiUrl(chain, 'api/scan/account/reward_slash'), {
|
|
259
|
+
page,
|
|
260
|
+
category: 'Reward',
|
|
261
|
+
row: 10,
|
|
262
|
+
address
|
|
263
|
+
});
|
|
264
|
+
if (rs.status !== 200) {
|
|
265
|
+
throw new _SWError.SWError('SubscanService.getRewardHistoryList', await rs.text());
|
|
266
|
+
}
|
|
267
|
+
const jsonData = await rs.json();
|
|
268
|
+
return jsonData.data;
|
|
269
|
+
});
|
|
270
|
+
}
|
|
255
271
|
}
|
|
256
272
|
exports.SubscanService = SubscanService;
|
package/constants/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare const BASE_SECOND_INTERVAL = 1000;
|
|
2
|
+
export declare const BASE_MINUTE_INTERVAL: number;
|
|
1
3
|
export declare const CRON_REFRESH_PRICE_INTERVAL = 30000;
|
|
2
4
|
export declare const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
3
5
|
export declare const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
@@ -6,7 +8,7 @@ export declare const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
|
|
|
6
8
|
export declare const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
|
|
7
9
|
export declare const CRON_REFRESH_NFT_INTERVAL = 7200000;
|
|
8
10
|
export declare const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
9
|
-
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
11
|
+
export declare const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
|
|
10
12
|
export declare const CRON_REFRESH_HISTORY_INTERVAL = 900000;
|
|
11
13
|
export declare const CRON_GET_API_MAP_STATUS = 10000;
|
|
12
14
|
export declare const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
@@ -14,6 +16,7 @@ export declare const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
|
14
16
|
export declare const CRON_RECOVER_HISTORY_INTERVAL = 30000;
|
|
15
17
|
export declare const CRON_SYNC_MANTA_PAY = 300000;
|
|
16
18
|
export declare const MANTA_PAY_BALANCE_INTERVAL = 30000;
|
|
19
|
+
export declare const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL: number;
|
|
17
20
|
export declare const ALL_ACCOUNT_KEY = "ALL";
|
|
18
21
|
export declare const ALL_NETWORK_KEY = "all";
|
|
19
22
|
export declare const ALL_GENESIS_HASH: null;
|
package/constants/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
export const BASE_SECOND_INTERVAL = 1000;
|
|
5
|
+
export const BASE_MINUTE_INTERVAL = 60 * BASE_SECOND_INTERVAL;
|
|
4
6
|
export const CRON_REFRESH_PRICE_INTERVAL = 30000;
|
|
5
7
|
export const CRON_AUTO_RECOVER_DOTSAMA_INTERVAL = 60000;
|
|
6
8
|
export const CRON_AUTO_RECOVER_WEB3_INTERVAL = 90000;
|
|
@@ -9,7 +11,7 @@ export const ASTAR_REFRESH_BALANCE_INTERVAL = 60000;
|
|
|
9
11
|
export const SUB_TOKEN_REFRESH_BALANCE_INTERVAL = 60000;
|
|
10
12
|
export const CRON_REFRESH_NFT_INTERVAL = 7200000;
|
|
11
13
|
export const CRON_REFRESH_STAKING_REWARD_INTERVAL = 900000;
|
|
12
|
-
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL =
|
|
14
|
+
export const CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL = 90000;
|
|
13
15
|
export const CRON_REFRESH_HISTORY_INTERVAL = 900000;
|
|
14
16
|
export const CRON_GET_API_MAP_STATUS = 10000;
|
|
15
17
|
export const CRON_REFRESH_CHAIN_STAKING_METADATA = 900000;
|
|
@@ -17,6 +19,7 @@ export const CRON_REFRESH_CHAIN_NOMINATOR_METADATA = 1800000;
|
|
|
17
19
|
export const CRON_RECOVER_HISTORY_INTERVAL = 30000;
|
|
18
20
|
export const CRON_SYNC_MANTA_PAY = 300000;
|
|
19
21
|
export const MANTA_PAY_BALANCE_INTERVAL = 30000;
|
|
22
|
+
export const CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL = 15 * BASE_MINUTE_INTERVAL;
|
|
20
23
|
export const ALL_ACCOUNT_KEY = 'ALL';
|
|
21
24
|
export const ALL_NETWORK_KEY = 'all';
|
|
22
25
|
export const ALL_GENESIS_HASH = null;
|
|
@@ -28,6 +28,7 @@ export declare class KoniCron {
|
|
|
28
28
|
resetNft: (newAddress: string) => void;
|
|
29
29
|
refreshStakingReward: (address: string) => () => void;
|
|
30
30
|
refreshStakingRewardFastInterval: (address: string) => () => void;
|
|
31
|
+
refreshEarningRewardHistoryInterval: (address: string) => () => void;
|
|
31
32
|
setStakingRewardReady: () => void;
|
|
32
33
|
checkNetworkAvailable: (serviceInfo: ServiceInfo) => boolean;
|
|
33
34
|
reloadNft(): Promise<boolean>;
|
package/koni/background/cron.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { CRON_REFRESH_NFT_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
|
|
4
|
+
import { CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL, CRON_REFRESH_NFT_INTERVAL, CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL, CRON_SYNC_MANTA_PAY } from '@subwallet/extension-base/constants';
|
|
5
5
|
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { waitTimeout } from '@subwallet/extension-base/utils';
|
|
7
7
|
import { Subject } from 'rxjs';
|
|
@@ -88,13 +88,15 @@ export class KoniCron {
|
|
|
88
88
|
// NFT
|
|
89
89
|
(commonReload || needUpdateNft) && this.resetNft(address);
|
|
90
90
|
(commonReload || needUpdateNft) && this.removeCron('refreshNft');
|
|
91
|
+
commonReload && this.removeCron('refreshPoolingStakingReward');
|
|
91
92
|
|
|
92
93
|
// Chains
|
|
93
94
|
if (this.checkNetworkAvailable(serviceInfo)) {
|
|
94
|
-
// only add cron
|
|
95
|
+
// only add cron jobs if there's at least 1 active network
|
|
95
96
|
(commonReload || needUpdateNft) && this.addCron('refreshNft', this.refreshNft(address, serviceInfo.chainApiMap, this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
96
97
|
reloadMantaPay && this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
97
|
-
commonReload && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
98
|
+
(commonReload || chainUpdated) && this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
99
|
+
(commonReload || chainUpdated) && this.addCron('refreshEarningRewardHistoryInterval', this.refreshEarningRewardHistoryInterval(currentAccountInfo.address), CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL);
|
|
98
100
|
} else {
|
|
99
101
|
this.setStakingRewardReady();
|
|
100
102
|
}
|
|
@@ -108,6 +110,7 @@ export class KoniCron {
|
|
|
108
110
|
this.addCron('refreshNft', this.refreshNft(currentAccountInfo.address, this.state.getApiMap(), this.state.getSmartContractNfts(), this.state.getActiveChainInfoMap()), CRON_REFRESH_NFT_INTERVAL);
|
|
109
111
|
// this.addCron('refreshStakingReward', this.refreshStakingReward(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_INTERVAL);
|
|
110
112
|
this.addCron('refreshPoolingStakingReward', this.refreshStakingRewardFastInterval(currentAccountInfo.address), CRON_REFRESH_STAKING_REWARD_FAST_INTERVAL);
|
|
113
|
+
this.addCron('refreshEarningRewardHistoryInterval', this.refreshEarningRewardHistoryInterval(currentAccountInfo.address), CRON_REFRESH_EARNING_REWARD_HISTORY_INTERVAL);
|
|
111
114
|
this.addCron('syncMantaPay', this.syncMantaPay, CRON_SYNC_MANTA_PAY);
|
|
112
115
|
} else {
|
|
113
116
|
this.setStakingRewardReady();
|
|
@@ -155,6 +158,11 @@ export class KoniCron {
|
|
|
155
158
|
this.subscriptions.subscribeStakingRewardFastInterval(address).catch(this.logger.error);
|
|
156
159
|
};
|
|
157
160
|
};
|
|
161
|
+
refreshEarningRewardHistoryInterval = address => {
|
|
162
|
+
return () => {
|
|
163
|
+
this.subscriptions.subscribeEarningRewardHistoryInterval(address).catch(this.logger.error);
|
|
164
|
+
};
|
|
165
|
+
};
|
|
158
166
|
setStakingRewardReady = () => {
|
|
159
167
|
this.state.updateStakingRewardReady(true);
|
|
160
168
|
};
|
|
@@ -222,6 +222,7 @@ export default class KoniExtension {
|
|
|
222
222
|
private getYieldPoolTargets;
|
|
223
223
|
private subscribeYieldPosition;
|
|
224
224
|
private subscribeYieldReward;
|
|
225
|
+
private subscribeYieldRewardHistory;
|
|
225
226
|
private subscribeEarningMinAmountPercent;
|
|
226
227
|
private handleValidateYieldProcess;
|
|
227
228
|
private yieldSubmitWithdrawal;
|
|
@@ -3660,6 +3660,19 @@ export default class KoniExtension {
|
|
|
3660
3660
|
});
|
|
3661
3661
|
return this.#koniState.earningService.getEarningRewards();
|
|
3662
3662
|
}
|
|
3663
|
+
subscribeYieldRewardHistory(id, port) {
|
|
3664
|
+
const cb = createSubscription(id, port);
|
|
3665
|
+
const rewardHistorySubscription = this.#koniState.earningService.subscribeEarningRewardHistory().subscribe({
|
|
3666
|
+
next: rs => {
|
|
3667
|
+
cb(rs);
|
|
3668
|
+
}
|
|
3669
|
+
});
|
|
3670
|
+
this.createUnsubscriptionHandle(id, rewardHistorySubscription.unsubscribe);
|
|
3671
|
+
port.onDisconnect.addListener(() => {
|
|
3672
|
+
this.cancelSubscription(id);
|
|
3673
|
+
});
|
|
3674
|
+
return this.#koniState.earningService.getEarningRewardHistory();
|
|
3675
|
+
}
|
|
3663
3676
|
subscribeEarningMinAmountPercent(id, port) {
|
|
3664
3677
|
const cb = createSubscription(id, port);
|
|
3665
3678
|
const earningMinAmountPercentSubscription = this.#koniState.earningService.subscribeMinAmountPercent().subscribe({
|
|
@@ -4001,6 +4014,8 @@ export default class KoniExtension {
|
|
|
4001
4014
|
return this.subscribeYieldPosition(id, port);
|
|
4002
4015
|
case 'pri(yield.subscribeYieldReward)':
|
|
4003
4016
|
return this.subscribeYieldReward(id, port);
|
|
4017
|
+
case 'pri(yield.subscribeRewardHistory)':
|
|
4018
|
+
return this.subscribeYieldRewardHistory(id, port);
|
|
4004
4019
|
case 'pri(yield.minAmountPercent)':
|
|
4005
4020
|
return this.subscribeEarningMinAmountPercent(id, port);
|
|
4006
4021
|
|
|
@@ -31,6 +31,7 @@ export declare class KoniSubscription {
|
|
|
31
31
|
initNftSubscription(addresses: string[], substrateApiMap: Record<string, _SubstrateApi>, evmApiMap: Record<string, _EvmApi>, smartContractNfts: _ChainAsset[], chainInfoMap: Record<string, _ChainInfo>): void;
|
|
32
32
|
subscribeStakingReward(address: string): Promise<void>;
|
|
33
33
|
subscribeStakingRewardFastInterval(address: string): Promise<void>;
|
|
34
|
+
subscribeEarningRewardHistoryInterval(address: string): Promise<void>;
|
|
34
35
|
reloadStaking(): Promise<void>;
|
|
35
36
|
reloadBalance(): Promise<void>;
|
|
36
37
|
reloadCrowdloan(): Promise<void>;
|
|
@@ -139,7 +139,7 @@ export class KoniSubscription {
|
|
|
139
139
|
}
|
|
140
140
|
initYieldPoolStatsSubscription(substrateApiMap, evmApiMap, onlyRunOnFirstTime) {
|
|
141
141
|
let cancel = false;
|
|
142
|
-
this.state.resetYieldPoolInfo(Object.keys(this.state.
|
|
142
|
+
this.state.resetYieldPoolInfo(Object.keys(this.state.getChainInfoMap()));
|
|
143
143
|
const updateYieldPoolStats = data => {
|
|
144
144
|
this.state.updateYieldPoolInfo(data);
|
|
145
145
|
};
|
|
@@ -289,32 +289,21 @@ export class KoniSubscription {
|
|
|
289
289
|
if (!addresses.length) {
|
|
290
290
|
return;
|
|
291
291
|
}
|
|
292
|
-
const pooledStakingItems = await this.state.getPooledPositionByAddress(addresses);
|
|
293
|
-
const pooledAddresses = [];
|
|
294
|
-
pooledStakingItems.forEach(pooledItem => {
|
|
295
|
-
if (!pooledAddresses.includes(pooledItem.address)) {
|
|
296
|
-
pooledAddresses.push(pooledItem.address);
|
|
297
|
-
}
|
|
298
|
-
});
|
|
299
|
-
const chainInfoMap = this.state.getChainInfoMap();
|
|
300
|
-
const targetChainMap = {};
|
|
301
|
-
Object.entries(chainInfoMap).forEach(([key, network]) => {
|
|
302
|
-
const chainState = this.state.getChainStateByKey(key);
|
|
303
|
-
if (_isChainEnabled(chainState) && _isChainSupportSubstrateStaking(network)) {
|
|
304
|
-
targetChainMap[key] = network;
|
|
305
|
-
}
|
|
306
|
-
});
|
|
307
|
-
const activeNetworks = [];
|
|
308
|
-
Object.keys(targetChainMap).forEach(key => {
|
|
309
|
-
activeNetworks.push(key);
|
|
310
|
-
});
|
|
311
292
|
const updateState = result => {
|
|
312
293
|
this.state.earningService.updateEarningReward(result);
|
|
313
294
|
};
|
|
314
|
-
await Promise.all([this.state.earningService.getPoolReward(addresses, updateState)
|
|
315
|
-
|
|
295
|
+
await Promise.all([this.state.earningService.getPoolReward(addresses, updateState)]);
|
|
296
|
+
}
|
|
297
|
+
async subscribeEarningRewardHistoryInterval(address) {
|
|
298
|
+
const addresses = this.state.getDecodedAddresses(address);
|
|
299
|
+
if (!addresses.length) {
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const updateState = result => {
|
|
303
|
+
this.state.earningService.updateEarningRewardHistory(result);
|
|
304
|
+
};
|
|
305
|
+
await Promise.all([this.state.earningService.fetchPoolRewardHistory(addresses, updateState)]);
|
|
316
306
|
}
|
|
317
|
-
|
|
318
307
|
async reloadStaking() {
|
|
319
308
|
// const currentAddress = this.state.keyringService.currentAccount?.address;
|
|
320
309
|
|
package/package.json
CHANGED
|
@@ -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 { BasePoolInfo, BaseYieldPoolMetadata, EarningRewardItem, HandleYieldStepData, OptimalYieldPath, OptimalYieldPathParams, RequestEarlyValidateYield, ResponseEarlyValidateYield, StakeCancelWithdrawalParams, SubmitYieldJoinData, TransactionData, UnstakingInfo, YieldPoolInfo, YieldPoolTarget, YieldPoolType, YieldPositionInfo, YieldStepBaseInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
6
|
+
import { BasePoolInfo, BaseYieldPoolMetadata, EarningRewardHistoryItem, EarningRewardItem, HandleYieldStepData, OptimalYieldPath, OptimalYieldPathParams, RequestEarlyValidateYield, ResponseEarlyValidateYield, StakeCancelWithdrawalParams, SubmitYieldJoinData, TransactionData, UnstakingInfo, YieldPoolInfo, YieldPoolMethodInfo, YieldPoolTarget, YieldPoolType, YieldPositionInfo, YieldStepBaseInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
7
7
|
/**
|
|
8
8
|
* @class BasePoolHandler
|
|
9
9
|
* @description Base pool handler
|
|
@@ -25,6 +25,8 @@ export default abstract class BasePoolHandler {
|
|
|
25
25
|
protected abstract shortName: string;
|
|
26
26
|
/** Pool's transaction type */
|
|
27
27
|
readonly transactionChainType: ChainType;
|
|
28
|
+
/** Pool's available method */
|
|
29
|
+
protected abstract readonly availableMethod: YieldPoolMethodInfo;
|
|
28
30
|
/**
|
|
29
31
|
* @constructor
|
|
30
32
|
* @param {KoniState} state - Koni state
|
|
@@ -52,6 +54,8 @@ export default abstract class BasePoolHandler {
|
|
|
52
54
|
abstract subscribePoolPosition(useAddresses: string[], callback: (rs: YieldPositionInfo) => void): Promise<VoidFunction>;
|
|
53
55
|
/** Get pool reward */
|
|
54
56
|
abstract getPoolReward(useAddresses: string[], callback: (rs: EarningRewardItem) => void): Promise<VoidFunction>;
|
|
57
|
+
/** Get pool reward history */
|
|
58
|
+
abstract getPoolRewardHistory(useAddresses: string[], callback: (rs: EarningRewardHistoryItem) => void): Promise<VoidFunction>;
|
|
55
59
|
/** Get pool target */
|
|
56
60
|
abstract getPoolTargets(): Promise<YieldPoolTarget[]>;
|
|
57
61
|
earlyValidate(request: RequestEarlyValidateYield): Promise<ResponseEarlyValidateYield>;
|
|
@@ -27,6 +27,8 @@ export default class BasePoolHandler {
|
|
|
27
27
|
/** Pool's transaction type */
|
|
28
28
|
transactionChainType = ChainType.SUBSTRATE;
|
|
29
29
|
|
|
30
|
+
/** Pool's available method */
|
|
31
|
+
|
|
30
32
|
/**
|
|
31
33
|
* @constructor
|
|
32
34
|
* @param {KoniState} state - Koni state
|
|
@@ -70,7 +72,7 @@ export default class BasePoolHandler {
|
|
|
70
72
|
const decimals = this.nativeToken.decimals || 0;
|
|
71
73
|
const defaultMaintainBalance = new BN(1).mul(BN_TEN.pow(new BN(decimals)));
|
|
72
74
|
const ed = new BN(this.nativeToken.minAmount || '0');
|
|
73
|
-
const maintainBalance = ed.
|
|
75
|
+
const maintainBalance = ed.gte(defaultMaintainBalance) ? ed.mul(new BN(1.5)) : defaultMaintainBalance;
|
|
74
76
|
return maintainBalance.toString();
|
|
75
77
|
}
|
|
76
78
|
get metadataInfo() {
|
|
@@ -80,9 +82,9 @@ export default class BasePoolHandler {
|
|
|
80
82
|
logo: this.logo,
|
|
81
83
|
inputAsset: this.nativeToken.slug,
|
|
82
84
|
isAvailable: true,
|
|
83
|
-
allowCancelUnstaking: false,
|
|
84
85
|
maintainAsset: this.nativeToken.slug,
|
|
85
|
-
maintainBalance: this.maintainBalance
|
|
86
|
+
maintainBalance: this.maintainBalance,
|
|
87
|
+
availableMethod: this.availableMethod
|
|
86
88
|
};
|
|
87
89
|
}
|
|
88
90
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
|
-
import { BaseYieldStepDetail, HandleYieldStepData, LendingYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
3
|
+
import { BaseYieldStepDetail, HandleYieldStepData, LendingYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPoolMethodInfo, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
4
4
|
import BaseLendingPoolHandler from './base';
|
|
5
5
|
export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
6
|
+
slug: string;
|
|
6
7
|
protected readonly name: string;
|
|
7
8
|
protected readonly shortName: string;
|
|
8
9
|
protected readonly altInputAsset: string;
|
|
@@ -10,7 +11,7 @@ export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
|
10
11
|
protected readonly inputAsset: string;
|
|
11
12
|
protected readonly rewardAssets: string[];
|
|
12
13
|
protected readonly feeAssets: string[];
|
|
13
|
-
|
|
14
|
+
protected readonly availableMethod: YieldPoolMethodInfo;
|
|
14
15
|
constructor(state: KoniState, chain: string);
|
|
15
16
|
protected getDescription(): string;
|
|
16
17
|
getPoolStat(): Promise<LendingYieldPoolInfo>;
|
|
@@ -14,6 +14,14 @@ export default class InterlayLendingPoolHandler extends BaseLendingPoolHandler {
|
|
|
14
14
|
inputAsset = 'interlay-LOCAL-DOT';
|
|
15
15
|
rewardAssets = ['interlay-LOCAL-DOT'];
|
|
16
16
|
feeAssets = ['interlay-NATIVE-INTR', 'interlay-LOCAL-DOT'];
|
|
17
|
+
availableMethod = {
|
|
18
|
+
join: true,
|
|
19
|
+
defaultUnstake: false,
|
|
20
|
+
fastUnstake: true,
|
|
21
|
+
cancelUnstake: false,
|
|
22
|
+
withdraw: false,
|
|
23
|
+
claimReward: false
|
|
24
|
+
};
|
|
17
25
|
constructor(state, chain) {
|
|
18
26
|
super(state, chain);
|
|
19
27
|
const chainInfo = this.chainInfo;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
|
-
import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
3
|
+
import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, UnstakingInfo, YieldPoolMethodInfo, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
4
4
|
import BaseLiquidStakingPoolHandler from './base';
|
|
5
5
|
export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
|
|
6
6
|
protected readonly name: string;
|
|
@@ -10,10 +10,8 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
10
10
|
protected readonly inputAsset: string;
|
|
11
11
|
protected readonly rewardAssets: string[];
|
|
12
12
|
protected readonly feeAssets: string[];
|
|
13
|
-
/** @inner */
|
|
14
13
|
readonly minAmountPercent = 0.98;
|
|
15
|
-
|
|
16
|
-
protected readonly allowDefaultUnstake = true;
|
|
14
|
+
protected readonly availableMethod: YieldPoolMethodInfo;
|
|
17
15
|
slug: string;
|
|
18
16
|
constructor(state: KoniState, chain: string);
|
|
19
17
|
protected getDescription(): string;
|
|
@@ -24,4 +22,5 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
24
22
|
handleSubmitStep(data: SubmitYieldJoinData, path: OptimalYieldPath): Promise<HandleYieldStepData>;
|
|
25
23
|
handleYieldRedeem(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
|
|
26
24
|
handleYieldUnstake(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
|
|
25
|
+
handleYieldWithdraw(address: string, unstakingInfo: UnstakingInfo): Promise<TransactionData>;
|
|
27
26
|
}
|
|
@@ -16,10 +16,15 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
16
16
|
inputAsset = 'acala-LOCAL-DOT';
|
|
17
17
|
rewardAssets = ['acala-LOCAL-DOT'];
|
|
18
18
|
feeAssets = ['acala-NATIVE-ACA', 'acala-LOCAL-DOT'];
|
|
19
|
-
/** @inner */
|
|
20
19
|
minAmountPercent = 0.98;
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
availableMethod = {
|
|
21
|
+
join: true,
|
|
22
|
+
defaultUnstake: true,
|
|
23
|
+
fastUnstake: true,
|
|
24
|
+
cancelUnstake: false,
|
|
25
|
+
withdraw: true,
|
|
26
|
+
claimReward: false
|
|
27
|
+
};
|
|
23
28
|
constructor(state, chain) {
|
|
24
29
|
super(state, chain);
|
|
25
30
|
const chainInfo = this.chainInfo;
|
|
@@ -33,6 +38,7 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
33
38
|
|
|
34
39
|
/* Subscribe pool info */
|
|
35
40
|
|
|
41
|
+
// Todo: Update with cache statistic data => Fetching periodically assetEarning, apy, exchangeRate, tvl, totalApy
|
|
36
42
|
async getPoolStat() {
|
|
37
43
|
const substrateApi = await this.substrateApi.isReady;
|
|
38
44
|
const stakingMetaPromise = new Promise(function (resolve) {
|
|
@@ -116,6 +122,7 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
116
122
|
derivativeToken: derivativeTokenSlug,
|
|
117
123
|
isBondedBefore: bnTotalBalance.gt(BN_ZERO),
|
|
118
124
|
nominations: [],
|
|
125
|
+
// TODO: add unstaking info from homa.redeemRequests
|
|
119
126
|
unstakings: []
|
|
120
127
|
};
|
|
121
128
|
resultCallback(result);
|
|
@@ -186,12 +193,16 @@ export default class AcalaLiquidStakingPoolHandler extends BaseLiquidStakingPool
|
|
|
186
193
|
weightedMinAmount // should always set a min target to prevent unexpected result
|
|
187
194
|
);
|
|
188
195
|
|
|
189
|
-
return [ExtrinsicType.
|
|
196
|
+
return [ExtrinsicType.REDEEM_LDOT, extrinsic];
|
|
190
197
|
}
|
|
191
198
|
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
192
199
|
const chainApi = await this.substrateApi.isReady;
|
|
193
200
|
const extrinsic = chainApi.api.tx.homa.requestRedeem(amount, false);
|
|
194
|
-
return [ExtrinsicType.
|
|
201
|
+
return [ExtrinsicType.UNSTAKE_LDOT, extrinsic];
|
|
202
|
+
}
|
|
203
|
+
async handleYieldWithdraw(address, unstakingInfo) {
|
|
204
|
+
const chainApi = await this.substrateApi.isReady;
|
|
205
|
+
return chainApi.api.tx.homa.claimRedemption(address);
|
|
195
206
|
}
|
|
196
207
|
|
|
197
208
|
/* Leave pool action */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
|
-
import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
3
|
+
import { BaseYieldStepDetail, HandleYieldStepData, LiquidYieldPoolInfo, OptimalYieldPath, OptimalYieldPathParams, SubmitYieldJoinData, TransactionData, YieldPoolMethodInfo, YieldPositionInfo, YieldTokenBaseInfo } from '@subwallet/extension-base/types';
|
|
4
4
|
import BaseLiquidStakingPoolHandler from './base';
|
|
5
5
|
export interface BifrostLiquidStakingMeta {
|
|
6
6
|
apy: string;
|
|
@@ -23,6 +23,7 @@ export interface BifrostVtokenExchangeRate {
|
|
|
23
23
|
token_pool: number;
|
|
24
24
|
}
|
|
25
25
|
export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
|
|
26
|
+
slug: string;
|
|
26
27
|
protected readonly name: string;
|
|
27
28
|
protected readonly shortName: string;
|
|
28
29
|
protected readonly altInputAsset: string;
|
|
@@ -30,9 +31,8 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
30
31
|
protected readonly inputAsset: string;
|
|
31
32
|
protected readonly rewardAssets: string[];
|
|
32
33
|
protected readonly feeAssets: string[];
|
|
33
|
-
/** @inner */
|
|
34
34
|
readonly minAmountPercent = 0.99;
|
|
35
|
-
|
|
35
|
+
protected readonly availableMethod: YieldPoolMethodInfo;
|
|
36
36
|
constructor(state: KoniState, chain: string);
|
|
37
37
|
protected getDescription(): string;
|
|
38
38
|
getPoolStat(): Promise<LiquidYieldPoolInfo>;
|
|
@@ -41,4 +41,5 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
41
41
|
getSubmitStepFee(params: OptimalYieldPathParams): Promise<YieldTokenBaseInfo>;
|
|
42
42
|
handleSubmitStep(data: SubmitYieldJoinData, path: OptimalYieldPath): Promise<HandleYieldStepData>;
|
|
43
43
|
handleYieldRedeem(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
|
|
44
|
+
handleYieldUnstake(amount: string, address: string, selectedTarget?: string): Promise<[ExtrinsicType, TransactionData]>;
|
|
44
45
|
}
|
|
@@ -19,8 +19,15 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
19
19
|
inputAsset = 'bifrost_dot-LOCAL-DOT';
|
|
20
20
|
rewardAssets = ['bifrost_dot-LOCAL-DOT'];
|
|
21
21
|
feeAssets = ['bifrost_dot-NATIVE-BNC', 'bifrost_dot-LOCAL-DOT'];
|
|
22
|
-
/** @inner */
|
|
23
22
|
minAmountPercent = 0.99;
|
|
23
|
+
availableMethod = {
|
|
24
|
+
join: true,
|
|
25
|
+
defaultUnstake: true,
|
|
26
|
+
fastUnstake: true,
|
|
27
|
+
cancelUnstake: false,
|
|
28
|
+
withdraw: false,
|
|
29
|
+
claimReward: false
|
|
30
|
+
};
|
|
24
31
|
constructor(state, chain) {
|
|
25
32
|
super(state, chain);
|
|
26
33
|
const chainInfo = this.chainInfo;
|
|
@@ -133,6 +140,8 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
133
140
|
}
|
|
134
141
|
|
|
135
142
|
const unlockingMap = {};
|
|
143
|
+
|
|
144
|
+
// TODO: review unstaking info vtokenMinting.userUnlockLedger
|
|
136
145
|
const _unlockInfoList = await substrateApi.api.query.vtokenMinting.tokenUnlockLedger.multi(unlockLedgerList.map(({
|
|
137
146
|
ledgerId
|
|
138
147
|
}) => [_getTokenOnChainInfo(inputTokenInfo), ledgerId]));
|
|
@@ -251,6 +260,13 @@ export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPo
|
|
|
251
260
|
const extrinsic = substrateApi.api.tx.stablePool.swap(0, 1, 0, amount, weightedMinAmount);
|
|
252
261
|
return [ExtrinsicType.REDEEM_VDOT, extrinsic];
|
|
253
262
|
}
|
|
263
|
+
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
264
|
+
const chainApi = await this.substrateApi.isReady;
|
|
265
|
+
const inputTokenSlug = this.inputAsset;
|
|
266
|
+
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
267
|
+
const extrinsic = chainApi.api.tx.vtokenMinting.redeem(_getTokenOnChainInfo(inputTokenInfo), amount);
|
|
268
|
+
return [ExtrinsicType.UNSTAKE_VDOT, extrinsic];
|
|
269
|
+
}
|
|
254
270
|
|
|
255
271
|
/* Leave pool action */
|
|
256
272
|
}
|