@subwallet/extension-base 1.1.33-beta.0 → 1.1.33-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 -0
- package/background/KoniTypes.js +3 -0
- package/cjs/background/KoniTypes.js +3 -0
- package/cjs/constants/staking.js +1 -1
- package/cjs/koni/api/yield/helper/utils.js +6 -3
- package/cjs/services/chain-service/constants.js +4 -2
- package/cjs/services/chain-service/handler/SubstrateApi.js +10 -5
- package/cjs/services/chain-service/index.js +144 -37
- package/cjs/services/chain-service/utils.js +68 -0
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +2 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +140 -0
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +2 -1
- package/cjs/services/earning-service/handlers/liquid-staking/index.js +7 -0
- package/cjs/services/earning-service/handlers/special.js +7 -3
- package/cjs/services/earning-service/service.js +1 -0
- package/cjs/services/storage-service/DatabaseService.js +34 -0
- package/cjs/services/storage-service/db-stores/AssetRef.js +24 -0
- package/cjs/services/transaction-service/index.js +3 -0
- package/cjs/types/yield/actions/join/step.js +1 -0
- package/constants/staking.js +1 -1
- package/koni/api/yield/helper/utils.d.ts +1 -1
- package/koni/api/yield/helper/utils.js +5 -3
- package/package.json +12 -2
- package/services/chain-service/constants.d.ts +1 -0
- package/services/chain-service/constants.js +1 -0
- package/services/chain-service/handler/SubstrateApi.js +10 -5
- package/services/chain-service/index.d.ts +12 -1
- package/services/chain-service/index.js +140 -34
- package/services/chain-service/utils.d.ts +10 -1
- package/services/chain-service/utils.js +66 -1
- package/services/earning-service/handlers/liquid-staking/base.d.ts +1 -1
- package/services/earning-service/handlers/liquid-staking/base.js +2 -1
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts +37 -0
- package/services/earning-service/handlers/liquid-staking/bifrost-manta.js +132 -0
- package/services/earning-service/handlers/liquid-staking/bifrost.d.ts +3 -3
- package/services/earning-service/handlers/liquid-staking/bifrost.js +2 -1
- package/services/earning-service/handlers/liquid-staking/index.d.ts +1 -0
- package/services/earning-service/handlers/liquid-staking/index.js +1 -0
- package/services/earning-service/handlers/special.js +7 -3
- package/services/earning-service/service.js +2 -1
- package/services/storage-service/DatabaseService.js +34 -0
- package/services/storage-service/databases/index.d.ts +4 -1
- package/services/storage-service/db-stores/AssetRef.d.ts +7 -0
- package/services/storage-service/db-stores/AssetRef.js +16 -0
- package/services/transaction-service/index.js +3 -0
- package/types/yield/actions/join/step.d.ts +1 -0
- package/types/yield/actions/join/step.js +1 -0
|
@@ -0,0 +1,140 @@
|
|
|
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 _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
9
|
+
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
10
|
+
var _types = require("@subwallet/extension-base/types");
|
|
11
|
+
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
12
|
+
var _bifrost = _interopRequireDefault(require("./bifrost"));
|
|
13
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
14
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
15
|
+
|
|
16
|
+
const STATS_URL = 'https://api.bifrost.app/api/site';
|
|
17
|
+
const RATIO_URL = 'https://api.bifrost.app/api/omni/MANTA';
|
|
18
|
+
class BifrostMantaLiquidStakingPoolHandler extends _bifrost.default {
|
|
19
|
+
altInputAsset = 'manta_network-NATIVE-MANTA';
|
|
20
|
+
derivativeAssets = ['bifrost_dot-LOCAL-vMANTA'];
|
|
21
|
+
inputAsset = 'bifrost_dot-LOCAL-MANTA';
|
|
22
|
+
rewardAssets = ['bifrost_dot-LOCAL-MANTA'];
|
|
23
|
+
feeAssets = ['bifrost_dot-NATIVE-BNC', 'bifrost_dot-LOCAL-MANTA'];
|
|
24
|
+
minAmountPercent = 0.985;
|
|
25
|
+
constructor(state, chain) {
|
|
26
|
+
super(state, chain);
|
|
27
|
+
const chainInfo = this.chainInfo;
|
|
28
|
+
this.slug = `MANTA___liquid_staking___${chain}`;
|
|
29
|
+
this.name = `${chainInfo.name} Liquid Staking Manta`;
|
|
30
|
+
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
31
|
+
}
|
|
32
|
+
getDescription() {
|
|
33
|
+
return 'Stake MANTA to earn yield on vMANTA';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Subscribe pool info */
|
|
37
|
+
|
|
38
|
+
async getPoolStat() {
|
|
39
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
40
|
+
const stakingMetaPromise = new Promise(function (resolve) {
|
|
41
|
+
(0, _crossFetch.default)(STATS_URL, {
|
|
42
|
+
method: 'GET'
|
|
43
|
+
}).then(res => {
|
|
44
|
+
resolve(res.json());
|
|
45
|
+
}).catch(console.error);
|
|
46
|
+
});
|
|
47
|
+
const exchangeRatePromise = new Promise(function (resolve) {
|
|
48
|
+
(0, _crossFetch.default)(RATIO_URL, {
|
|
49
|
+
method: 'GET'
|
|
50
|
+
}).then(resp => {
|
|
51
|
+
resolve(resp.json());
|
|
52
|
+
}).catch(console.error);
|
|
53
|
+
});
|
|
54
|
+
const derivativeTokenInfo = this.state.getAssetBySlug(this.derivativeAssets[0]);
|
|
55
|
+
const inputTokenInfo = this.state.getAssetBySlug(this.inputAsset);
|
|
56
|
+
const [_stakingMeta, _exchangeRate, _minimumRedeem, _minimumMint] = await Promise.all([stakingMetaPromise, exchangeRatePromise, substrateApi.api.query.vtokenMinting.minimumRedeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo)), substrateApi.api.query.vtokenMinting.minimumMint((0, _utils._getTokenOnChainInfo)(inputTokenInfo))]);
|
|
57
|
+
const minimumRedeem = _minimumRedeem.toString();
|
|
58
|
+
const minimumMint = _minimumMint.toString();
|
|
59
|
+
const stakingMeta = _stakingMeta;
|
|
60
|
+
const exchangeRate = _exchangeRate;
|
|
61
|
+
const vMANTAStats = stakingMeta.vMANTA;
|
|
62
|
+
const assetInfo = this.state.getAssetBySlug(this.inputAsset);
|
|
63
|
+
const assetDecimals = 10 ** (0, _utils._getAssetDecimals)(assetInfo);
|
|
64
|
+
const rate = parseFloat(exchangeRate.ratio[exchangeRate.ratio.length - 1].ratio); // TODO
|
|
65
|
+
|
|
66
|
+
this.updateExchangeRate(rate);
|
|
67
|
+
return {
|
|
68
|
+
...this.baseInfo,
|
|
69
|
+
type: this.type,
|
|
70
|
+
metadata: {
|
|
71
|
+
...this.metadataInfo,
|
|
72
|
+
description: this.getDescription()
|
|
73
|
+
},
|
|
74
|
+
statistic: {
|
|
75
|
+
assetEarning: [{
|
|
76
|
+
slug: this.rewardAssets[0],
|
|
77
|
+
apy: parseFloat(vMANTAStats.apyBase),
|
|
78
|
+
exchangeRate: rate
|
|
79
|
+
}],
|
|
80
|
+
farmerCount: vMANTAStats.holders,
|
|
81
|
+
unstakingPeriod: 24 * 7,
|
|
82
|
+
maxCandidatePerFarmer: 1,
|
|
83
|
+
maxWithdrawalRequestPerFarmer: 1,
|
|
84
|
+
earningThreshold: {
|
|
85
|
+
join: minimumMint,
|
|
86
|
+
defaultUnstake: minimumRedeem,
|
|
87
|
+
fastUnstake: '0'
|
|
88
|
+
},
|
|
89
|
+
totalApy: parseFloat(vMANTAStats.apyBase),
|
|
90
|
+
tvl: (vMANTAStats.tvm * assetDecimals).toString()
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/* Subscribe pool info */
|
|
96
|
+
|
|
97
|
+
/* Join pool action */
|
|
98
|
+
|
|
99
|
+
get submitJoinStepInfo() {
|
|
100
|
+
return {
|
|
101
|
+
name: 'Mint vMANTA',
|
|
102
|
+
type: _types.YieldStepType.MINT_VMANTA
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
async handleSubmitStep(data, path) {
|
|
106
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
107
|
+
const inputTokenSlug = this.inputAsset;
|
|
108
|
+
const inputTokenInfo = this.state.getAssetBySlug(inputTokenSlug);
|
|
109
|
+
const extrinsic = substrateApi.api.tx.vtokenMinting.mint((0, _utils._getTokenOnChainInfo)(inputTokenInfo), data.amount, undefined, undefined);
|
|
110
|
+
return {
|
|
111
|
+
txChain: this.chain,
|
|
112
|
+
extrinsicType: _KoniTypes.ExtrinsicType.MINT_VMANTA,
|
|
113
|
+
extrinsic,
|
|
114
|
+
txData: data,
|
|
115
|
+
transferNativeAmount: '0',
|
|
116
|
+
chainType: _KoniTypes.ChainType.SUBSTRATE
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/* Join pool action */
|
|
121
|
+
|
|
122
|
+
/* Leave pool action */
|
|
123
|
+
|
|
124
|
+
async handleYieldRedeem(amount, address, selectedTarget) {
|
|
125
|
+
const substrateApi = await this.substrateApi.isReady;
|
|
126
|
+
const weightedMinAmount = await this.createParamToRedeem(amount, address);
|
|
127
|
+
const extrinsic = substrateApi.api.tx.stablePool.swap(5, 1, 0, amount, weightedMinAmount);
|
|
128
|
+
return [_KoniTypes.ExtrinsicType.REDEEM_VMANTA, extrinsic];
|
|
129
|
+
}
|
|
130
|
+
async handleYieldUnstake(amount, address, selectedTarget) {
|
|
131
|
+
const chainApi = await this.substrateApi.isReady;
|
|
132
|
+
const derivativeTokenSlug = this.derivativeAssets[0];
|
|
133
|
+
const derivativeTokenInfo = this.state.getAssetBySlug(derivativeTokenSlug);
|
|
134
|
+
const extrinsic = chainApi.api.tx.vtokenMinting.redeem((0, _utils._getTokenOnChainInfo)(derivativeTokenInfo), amount);
|
|
135
|
+
return [_KoniTypes.ExtrinsicType.UNSTAKE_VMANTA, extrinsic];
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* Leave pool action */
|
|
139
|
+
}
|
|
140
|
+
exports.default = BifrostMantaLiquidStakingPoolHandler;
|
|
@@ -41,7 +41,7 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
41
41
|
super(state, chain);
|
|
42
42
|
const chainInfo = this.chainInfo;
|
|
43
43
|
this.slug = `DOT___liquid_staking___${chain}`;
|
|
44
|
-
this.name = `${chainInfo.name} Liquid Staking`;
|
|
44
|
+
this.name = `${chainInfo.name} Liquid Staking DOT`;
|
|
45
45
|
this.shortName = chainInfo.name.replaceAll(' Relay Chain', '');
|
|
46
46
|
}
|
|
47
47
|
getDescription() {
|
|
@@ -100,6 +100,7 @@ class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
|
100
100
|
unstakingPeriod: 24 * 28,
|
|
101
101
|
maxCandidatePerFarmer: 1,
|
|
102
102
|
maxWithdrawalRequestPerFarmer: 1,
|
|
103
|
+
farmerCount: vDOTStats.holders,
|
|
103
104
|
earningThreshold: {
|
|
104
105
|
join: minimumMint,
|
|
105
106
|
defaultUnstake: minimumRedeem,
|
|
@@ -16,6 +16,12 @@ Object.defineProperty(exports, "BifrostLiquidStakingPoolHandler", {
|
|
|
16
16
|
return _bifrost.default;
|
|
17
17
|
}
|
|
18
18
|
});
|
|
19
|
+
Object.defineProperty(exports, "BifrostMantaLiquidStakingPoolHandler", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () {
|
|
22
|
+
return _bifrostManta.default;
|
|
23
|
+
}
|
|
24
|
+
});
|
|
19
25
|
Object.defineProperty(exports, "ParallelLiquidStakingPoolHandler", {
|
|
20
26
|
enumerable: true,
|
|
21
27
|
get: function () {
|
|
@@ -30,5 +36,6 @@ Object.defineProperty(exports, "StellaSwapLiquidStakingPoolHandler", {
|
|
|
30
36
|
});
|
|
31
37
|
var _acala = _interopRequireDefault(require("./acala"));
|
|
32
38
|
var _bifrost = _interopRequireDefault(require("./bifrost"));
|
|
39
|
+
var _bifrostManta = _interopRequireDefault(require("./bifrost-manta"));
|
|
33
40
|
var _parallel = _interopRequireDefault(require("./parallel"));
|
|
34
41
|
var _stellaSwap = _interopRequireDefault(require("./stella-swap"));
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports.default = void 0;
|
|
8
|
-
var _chainList = require("@subwallet/chain-list");
|
|
9
8
|
var _TransactionError = require("@subwallet/extension-base/background/errors/TransactionError");
|
|
10
9
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
11
10
|
var _constants = require("@subwallet/extension-base/constants");
|
|
@@ -208,13 +207,16 @@ class BaseSpecialStakingPoolHandler extends _base.default {
|
|
|
208
207
|
const altInputTokenBalance = await this.state.balanceService.getTokenFreeBalance(address, altInputTokenInfo.originChain, altInputTokenSlug);
|
|
209
208
|
const bnAltInputTokenBalance = new _util.BN(altInputTokenBalance.value || '0');
|
|
210
209
|
if (bnAltInputTokenBalance.gt(_util.BN_ZERO)) {
|
|
210
|
+
const altChainInfo = this.state.getChainInfo(altInputTokenInfo.originChain);
|
|
211
|
+
const symbol = altInputTokenInfo.symbol;
|
|
212
|
+
const networkName = altChainInfo.name;
|
|
211
213
|
const step = {
|
|
212
214
|
metadata: {
|
|
213
215
|
sendingValue: bnAmount.toString(),
|
|
214
216
|
originTokenInfo: altInputTokenInfo,
|
|
215
217
|
destinationTokenInfo: inputTokenInfo
|
|
216
218
|
},
|
|
217
|
-
name:
|
|
219
|
+
name: `Transfer ${symbol} from ${networkName}`,
|
|
218
220
|
type: _types.YieldStepType.XCM
|
|
219
221
|
};
|
|
220
222
|
const xcmOriginSubstrateApi = await this.state.getSubstrateApi(altInputTokenInfo.originChain).isReady;
|
|
@@ -411,7 +413,9 @@ class BaseSpecialStakingPoolHandler extends _base.default {
|
|
|
411
413
|
amount
|
|
412
414
|
} = data;
|
|
413
415
|
const destinationTokenSlug = this.inputAsset;
|
|
414
|
-
const
|
|
416
|
+
const altInputTokenSlug = this.altInputAsset || '';
|
|
417
|
+
const altInputTokenInfo = this.state.getAssetBySlug(altInputTokenSlug);
|
|
418
|
+
const originChainInfo = this.state.getChainInfo(altInputTokenInfo.originChain);
|
|
415
419
|
const originTokenSlug = (0, _utils2._getChainNativeTokenSlug)(originChainInfo);
|
|
416
420
|
const originTokenInfo = this.state.getAssetBySlug(originTokenSlug);
|
|
417
421
|
const destinationTokenInfo = this.state.getAssetBySlug(destinationTokenSlug);
|
|
@@ -77,6 +77,7 @@ class EarningService {
|
|
|
77
77
|
if (_constants2._STAKING_CHAIN_GROUP.liquidStaking.includes(chain)) {
|
|
78
78
|
if (chain === 'bifrost_dot') {
|
|
79
79
|
handlers.push(new _handlers.BifrostLiquidStakingPoolHandler(this.state, chain));
|
|
80
|
+
handlers.push(new _handlers.BifrostMantaLiquidStakingPoolHandler(this.state, chain));
|
|
80
81
|
}
|
|
81
82
|
if (chain === 'acala') {
|
|
82
83
|
handlers.push(new _handlers.AcalaLiquidStakingPoolHandler(this.state, chain));
|
|
@@ -52,8 +52,10 @@ class DatabaseService {
|
|
|
52
52
|
nominatorMetadata: new _NominatorMetadata.default(this._db.nominatorMetadata),
|
|
53
53
|
mantaPay: new _MantaPay.default(this._db.mantaPay),
|
|
54
54
|
campaign: new _Campaign.default(this._db.campaign)
|
|
55
|
+
// assetRef: new AssetRefStore(this._db.assetRef)
|
|
55
56
|
};
|
|
56
57
|
}
|
|
58
|
+
|
|
57
59
|
async updatePriceStore(priceData) {
|
|
58
60
|
await this.stores.price.table.put(priceData);
|
|
59
61
|
}
|
|
@@ -387,5 +389,37 @@ class DatabaseService {
|
|
|
387
389
|
async getExportJson() {
|
|
388
390
|
return JSON.parse(await this.exportDB());
|
|
389
391
|
}
|
|
392
|
+
|
|
393
|
+
// public setAssetRef (assetRef: Record<string, _AssetRef>) {
|
|
394
|
+
// const assetRefList = Object.entries(assetRef).map(([slug, item]) => {
|
|
395
|
+
// return {
|
|
396
|
+
// slug,
|
|
397
|
+
// ...item
|
|
398
|
+
// } as IAssetRef;
|
|
399
|
+
// });
|
|
400
|
+
//
|
|
401
|
+
// return this.stores.assetRef.bulkUpsert(assetRefList);
|
|
402
|
+
// }
|
|
403
|
+
//
|
|
404
|
+
// public getAssetRef (slug: string) {
|
|
405
|
+
// return this.stores.assetRef.getAssetRef(slug);
|
|
406
|
+
// }
|
|
407
|
+
//
|
|
408
|
+
// public async getAssetRefMap (): Promise<Record<string, _AssetRef>> {
|
|
409
|
+
// const assetRefList = await this.stores.assetRef.getAll();
|
|
410
|
+
// const assetRefObj: Record<string, _AssetRef> = {};
|
|
411
|
+
//
|
|
412
|
+
// assetRefList.forEach((item) => {
|
|
413
|
+
// assetRefObj[item.slug] = {
|
|
414
|
+
// ...item
|
|
415
|
+
// };
|
|
416
|
+
// });
|
|
417
|
+
//
|
|
418
|
+
// return assetRefObj;
|
|
419
|
+
// }
|
|
420
|
+
//
|
|
421
|
+
// public subscribeAssetRef () {
|
|
422
|
+
// return this.stores.assetRef.subscribeAssetRef();
|
|
423
|
+
// }
|
|
390
424
|
}
|
|
391
425
|
exports.default = DatabaseService;
|
|
@@ -0,0 +1,24 @@
|
|
|
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 _BaseStore = _interopRequireDefault(require("@subwallet/extension-base/services/storage-service/db-stores/BaseStore"));
|
|
9
|
+
var _dexie = require("dexie");
|
|
10
|
+
// Copyright 2019-2022 @subwallet/extension-base authors & contributors
|
|
11
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
12
|
+
|
|
13
|
+
class AssetRefStore extends _BaseStore.default {
|
|
14
|
+
async getAll() {
|
|
15
|
+
return this.table.toArray();
|
|
16
|
+
}
|
|
17
|
+
async getAssetRef(slug) {
|
|
18
|
+
return this.table.get(slug);
|
|
19
|
+
}
|
|
20
|
+
subscribeAssetRef() {
|
|
21
|
+
return (0, _dexie.liveQuery)(async () => await this.table.toArray());
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.default = AssetRefStore;
|
|
@@ -529,6 +529,7 @@ class TransactionService {
|
|
|
529
529
|
case _KoniTypes.ExtrinsicType.MINT_QDOT:
|
|
530
530
|
case _KoniTypes.ExtrinsicType.MINT_LDOT:
|
|
531
531
|
case _KoniTypes.ExtrinsicType.MINT_SDOT:
|
|
532
|
+
case _KoniTypes.ExtrinsicType.MINT_VMANTA:
|
|
532
533
|
|
|
533
534
|
// eslint-disable-next-line no-fallthrough
|
|
534
535
|
case _KoniTypes.ExtrinsicType.MINT_VDOT:
|
|
@@ -582,12 +583,14 @@ class TransactionService {
|
|
|
582
583
|
break;
|
|
583
584
|
}
|
|
584
585
|
case _KoniTypes.ExtrinsicType.UNSTAKE_VDOT:
|
|
586
|
+
case _KoniTypes.ExtrinsicType.UNSTAKE_VMANTA:
|
|
585
587
|
case _KoniTypes.ExtrinsicType.UNSTAKE_LDOT:
|
|
586
588
|
case _KoniTypes.ExtrinsicType.UNSTAKE_SDOT:
|
|
587
589
|
case _KoniTypes.ExtrinsicType.UNSTAKE_STDOT:
|
|
588
590
|
case _KoniTypes.ExtrinsicType.REDEEM_STDOT:
|
|
589
591
|
case _KoniTypes.ExtrinsicType.REDEEM_LDOT:
|
|
590
592
|
case _KoniTypes.ExtrinsicType.REDEEM_SDOT:
|
|
593
|
+
case _KoniTypes.ExtrinsicType.REDEEM_VMANTA:
|
|
591
594
|
|
|
592
595
|
// eslint-disable-next-line no-fallthrough
|
|
593
596
|
case _KoniTypes.ExtrinsicType.REDEEM_VDOT:
|
|
@@ -39,6 +39,7 @@ exports.YieldStepType = YieldStepType;
|
|
|
39
39
|
YieldStepType["NOMINATE"] = "NOMINATE";
|
|
40
40
|
YieldStepType["JOIN_NOMINATION_POOL"] = "JOIN_NOMINATION_POOL";
|
|
41
41
|
YieldStepType["MINT_VDOT"] = "MINT_VDOT";
|
|
42
|
+
YieldStepType["MINT_VMANTA"] = "MINT_VMANTA";
|
|
42
43
|
YieldStepType["MINT_LDOT"] = "MINT_LDOT";
|
|
43
44
|
YieldStepType["MINT_QDOT"] = "MINT_QDOT";
|
|
44
45
|
YieldStepType["MINT_SDOT"] = "MINT_SDOT";
|
package/constants/staking.js
CHANGED
|
@@ -7,4 +7,4 @@ export declare const DEFAULT_YIELD_FIRST_STEP: YieldStepDetail;
|
|
|
7
7
|
export declare const YIELD_EXTRINSIC_TYPES: ExtrinsicType[];
|
|
8
8
|
export declare const YIELD_POOL_STAT_REFRESH_INTERVAL = 90000;
|
|
9
9
|
export declare const YIELD_POOL_MIN_AMOUNT_PERCENT: Record<string, number>;
|
|
10
|
-
export declare function convertDerivativeToOriginToken(amount: string, poolInfo: SpecialYieldPoolInfo, derivativeTokenInfo: _ChainAsset, originTokenInfo: _ChainAsset):
|
|
10
|
+
export declare function convertDerivativeToOriginToken(amount: string, poolInfo: SpecialYieldPoolInfo, derivativeTokenInfo: _ChainAsset, originTokenInfo: _ChainAsset): string;
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { _getAssetDecimals } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { YieldStepType } from '@subwallet/extension-base/types';
|
|
7
|
+
import { BN_TEN } from '@subwallet/extension-base/utils';
|
|
8
|
+
import BigN from 'bignumber.js';
|
|
7
9
|
export const syntheticSelectedValidators = ['15MLn9YQaHZ4GMkhK3qXqR5iGGSdULyJ995ctjeBgFRseyi6', '1REAJ1k691g5Eqqg9gL7vvZCBG7FCCZ8zgQkZWd4va5ESih', '1yGJ3h7TQuJWLYSsUVPZbM8aR8UsQXCqMvrFx5Fn1ktiAmq', '16GDRhRYxk42paoK6TfHAqWej8PdDDUwdDazjv4bAn4KGNeb', '13Ybj8CPEArUee78DxUAP9yX3ABmFNVQME1ZH4w8HVncHGzc', '14yx4vPAACZRhoDQm1dyvXD3QdRQyCRRCe5tj1zPomhhS29a', '14Vh8S1DzzycngbAB9vqEgPFR9JpSvmF1ezihTUES1EaHAV', '153YD8ZHD9dRh82U419bSCB5SzWhbdAFzjj4NtA5pMazR2yC', '1LUckyocmz9YzeQZHVpBvYYRGXb3rnSm2tvfz79h3G3JDgP', '14oRE62MB1SWR6h5RTx3GY5HK2oZipi1Gp3zdiLwVYLfEyRZ', '1cFsLn7o74nmjbRyDtMAnMpQMc5ZLsjgCSz9Np2mcejUK83', '15ZvLonEseaWZNy8LDkXXj3Y8bmAjxCjwvpy4pXWSL4nGSBs', '1NebF2xZHb4TJJpiqZZ3reeTo8dZov6LZ49qZqcHHbsmHfo', '1HmAqbBRrWvsqbLkvpiVDkdA2PcctUE5JUe3qokEh1FN455', '15tfUt4iQNjMyhZiJGBf4EpETE2KqtW1nfJwbBT1MvWjvcK9', '12RXTLiaYh59PokjZVhQvKzcfBEB5CvDnjKKUmDUotzcTH3S'];
|
|
8
10
|
export function calculateAlternativeFee(feeInfo) {
|
|
9
11
|
return feeInfo.partialFee;
|
|
@@ -26,7 +28,7 @@ export function convertDerivativeToOriginToken(amount, poolInfo, derivativeToken
|
|
|
26
28
|
const derivativeDecimals = _getAssetDecimals(derivativeTokenInfo);
|
|
27
29
|
const originDecimals = _getAssetDecimals(originTokenInfo);
|
|
28
30
|
const exchangeRate = ((_poolInfo$statistic = poolInfo.statistic) === null || _poolInfo$statistic === void 0 ? void 0 : (_poolInfo$statistic$a = _poolInfo$statistic.assetEarning) === null || _poolInfo$statistic$a === void 0 ? void 0 : _poolInfo$statistic$a[0].exchangeRate) || 1;
|
|
29
|
-
const formattedAmount =
|
|
30
|
-
const minAmount = formattedAmount
|
|
31
|
-
return
|
|
31
|
+
const formattedAmount = new BigN(amount).dividedBy(BN_TEN.pow(derivativeDecimals)); // TODO: decimals
|
|
32
|
+
const minAmount = formattedAmount.multipliedBy(exchangeRate);
|
|
33
|
+
return minAmount.multipliedBy(BN_TEN.pow(originDecimals)).toFixed(0);
|
|
32
34
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.33-beta.
|
|
20
|
+
"version": "1.1.33-beta.2",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -755,6 +755,11 @@
|
|
|
755
755
|
"require": "./cjs/services/earning-service/handlers/liquid-staking/bifrost.js",
|
|
756
756
|
"default": "./services/earning-service/handlers/liquid-staking/bifrost.js"
|
|
757
757
|
},
|
|
758
|
+
"./services/earning-service/handlers/liquid-staking/bifrost-manta": {
|
|
759
|
+
"types": "./services/earning-service/handlers/liquid-staking/bifrost-manta.d.ts",
|
|
760
|
+
"require": "./cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js",
|
|
761
|
+
"default": "./services/earning-service/handlers/liquid-staking/bifrost-manta.js"
|
|
762
|
+
},
|
|
758
763
|
"./services/earning-service/handlers/liquid-staking/parallel": {
|
|
759
764
|
"types": "./services/earning-service/handlers/liquid-staking/parallel.d.ts",
|
|
760
765
|
"require": "./cjs/services/earning-service/handlers/liquid-staking/parallel.js",
|
|
@@ -1165,6 +1170,11 @@
|
|
|
1165
1170
|
"require": "./cjs/services/storage-service/db-stores/Asset.js",
|
|
1166
1171
|
"default": "./services/storage-service/db-stores/Asset.js"
|
|
1167
1172
|
},
|
|
1173
|
+
"./services/storage-service/db-stores/AssetRef": {
|
|
1174
|
+
"types": "./services/storage-service/db-stores/AssetRef.d.ts",
|
|
1175
|
+
"require": "./cjs/services/storage-service/db-stores/AssetRef.js",
|
|
1176
|
+
"default": "./services/storage-service/db-stores/AssetRef.js"
|
|
1177
|
+
},
|
|
1168
1178
|
"./services/storage-service/db-stores/Balance": {
|
|
1169
1179
|
"types": "./services/storage-service/db-stores/Balance.d.ts",
|
|
1170
1180
|
"require": "./cjs/services/storage-service/db-stores/Balance.js",
|
|
@@ -1711,7 +1721,7 @@
|
|
|
1711
1721
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1712
1722
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1713
1723
|
"@substrate/connect": "^0.7.26",
|
|
1714
|
-
"@subwallet/chain-list": "0.2.
|
|
1724
|
+
"@subwallet/chain-list": "0.2.40-beta.2",
|
|
1715
1725
|
"@subwallet/extension-base": "^1.1.33-0",
|
|
1716
1726
|
"@subwallet/extension-chains": "^1.1.33-0",
|
|
1717
1727
|
"@subwallet/extension-dapp": "^1.1.33-0",
|
|
@@ -84,6 +84,7 @@ export declare const EVM_PASS_CONNECT_STATUS: Record<string, string[]>;
|
|
|
84
84
|
export declare const EVM_REFORMAT_DECIMALS: {
|
|
85
85
|
acala: string[];
|
|
86
86
|
};
|
|
87
|
+
export declare const LATEST_CHAIN_DATA_FETCHING_INTERVAL = 120000;
|
|
87
88
|
export declare const _CHAIN_INFO_SRC: string;
|
|
88
89
|
export declare const _CHAIN_ASSET_SRC: string;
|
|
89
90
|
export declare const _ASSET_REF_SRC: string;
|
|
@@ -238,6 +238,7 @@ export const EVM_PASS_CONNECT_STATUS = {
|
|
|
238
238
|
export const EVM_REFORMAT_DECIMALS = {
|
|
239
239
|
acala: ['acala_evm', 'karura_evm']
|
|
240
240
|
};
|
|
241
|
+
export const LATEST_CHAIN_DATA_FETCHING_INTERVAL = 120000;
|
|
241
242
|
|
|
242
243
|
// TODO: review
|
|
243
244
|
const TARGET_BRANCH = process.env.NODE_ENV !== 'production' ? 'koni-dev' : 'master';
|
|
@@ -57,7 +57,8 @@ export class SubstrateApi {
|
|
|
57
57
|
const apiOption = {
|
|
58
58
|
provider,
|
|
59
59
|
typesBundle,
|
|
60
|
-
registry: this.registry
|
|
60
|
+
registry: this.registry,
|
|
61
|
+
noInitWarn: true
|
|
61
62
|
};
|
|
62
63
|
if (this.metadata) {
|
|
63
64
|
const metadata = this.metadata;
|
|
@@ -71,27 +72,31 @@ export class SubstrateApi {
|
|
|
71
72
|
api = externalApiPromise;
|
|
72
73
|
} else if (_API_OPTIONS_CHAIN_GROUP.acala.includes(this.chainSlug)) {
|
|
73
74
|
api = new ApiPromise(acalaOptions({
|
|
74
|
-
provider
|
|
75
|
+
provider,
|
|
76
|
+
noInitWarn: true
|
|
75
77
|
}));
|
|
76
78
|
} else if (_API_OPTIONS_CHAIN_GROUP.turing.includes(this.chainSlug)) {
|
|
77
79
|
api = new ApiPromise({
|
|
78
80
|
provider,
|
|
79
81
|
rpc: oakRpc,
|
|
80
|
-
types: oakTypes
|
|
82
|
+
types: oakTypes,
|
|
83
|
+
noInitWarn: true
|
|
81
84
|
});
|
|
82
85
|
} else if (_API_OPTIONS_CHAIN_GROUP.avail.includes(this.chainSlug)) {
|
|
83
86
|
api = new ApiPromise({
|
|
84
87
|
provider,
|
|
85
88
|
rpc: availSpec.rpc,
|
|
86
89
|
types: availSpec.types,
|
|
87
|
-
signedExtensions: availSpec.signedExtensions
|
|
90
|
+
signedExtensions: availSpec.signedExtensions,
|
|
91
|
+
noInitWarn: true
|
|
88
92
|
});
|
|
89
93
|
} else if (_API_OPTIONS_CHAIN_GROUP.goldberg.includes(this.chainSlug)) {
|
|
90
94
|
api = new ApiPromise({
|
|
91
95
|
provider,
|
|
92
96
|
rpc: goldbergSpec.rpc,
|
|
93
97
|
types: goldbergSpec.types,
|
|
94
|
-
signedExtensions: goldbergSpec.signedExtensions
|
|
98
|
+
signedExtensions: goldbergSpec.signedExtensions,
|
|
99
|
+
noInitWarn: true
|
|
95
100
|
});
|
|
96
101
|
} else {
|
|
97
102
|
api = new ApiPromise(apiOption);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { _AssetRef, _AssetType, _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
3
|
import { AssetSetting, ValidateNetworkResponse } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
4
|
import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-service/handler/manta/MantaPrivateHandler';
|
|
@@ -14,6 +15,7 @@ export declare class ChainService {
|
|
|
14
15
|
private substrateChainHandler;
|
|
15
16
|
private evmChainHandler;
|
|
16
17
|
private mantaChainHandler;
|
|
18
|
+
refreshLatestChainDataTimeOut: NodeJS.Timer | undefined;
|
|
17
19
|
get mantaPay(): MantaPrivateHandler | undefined;
|
|
18
20
|
private chainInfoMapSubject;
|
|
19
21
|
private chainStateMapSubject;
|
|
@@ -69,6 +71,13 @@ export declare class ChainService {
|
|
|
69
71
|
deleteAssetsByChain(chainSlug: string): void;
|
|
70
72
|
deleteCustomAssets(targetAssets: string[]): void;
|
|
71
73
|
init(): Promise<void>;
|
|
74
|
+
initAssetRefMap(): Promise<void>;
|
|
75
|
+
checkLatestData(): void;
|
|
76
|
+
stopCheckLatestChainData(): void;
|
|
77
|
+
handleLatestProviderData(latestChainInfo: _ChainInfo[]): void;
|
|
78
|
+
handleLatestBlockedAssetRef(latestBlockedAssetRefList: string[]): void;
|
|
79
|
+
handleLatestPriceId(latestPriceIds: Record<string, string | null>): void;
|
|
80
|
+
handleLatestData(): void;
|
|
72
81
|
private initApis;
|
|
73
82
|
private initApiForChain;
|
|
74
83
|
private destroyApiForChain;
|
|
@@ -77,7 +86,9 @@ export declare class ChainService {
|
|
|
77
86
|
reconnectChain(chain: string): Promise<boolean>;
|
|
78
87
|
disableChain(chainSlug: string): boolean;
|
|
79
88
|
private checkExistedPredefinedChain;
|
|
80
|
-
private
|
|
89
|
+
private fetchLatestChainData;
|
|
90
|
+
private fetchLatestPriceIdsData;
|
|
91
|
+
private fetchLatestBlockedAssetRef;
|
|
81
92
|
private initChains;
|
|
82
93
|
private initAssetRegistry;
|
|
83
94
|
private updateChainStateMapSubscription;
|