@subwallet/extension-base 1.3.62-0 → 1.3.63-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/smart-contract.js +14 -10
- package/cjs/services/balance-service/transfer/xcm/acrossBridge/index.js +0 -6
- package/cjs/services/balance-service/transfer/xcm/utils.js +2 -0
- package/cjs/services/chain-service/constants.js +16 -0
- package/cjs/services/chain-service/utils/index.js +24 -4
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +2 -1
- package/cjs/services/earning-service/handlers/native-staking/base-para.js +6 -3
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +4 -1
- package/cjs/services/earning-service/handlers/native-staking/tanssi.js +496 -0
- package/cjs/services/earning-service/service.js +4 -0
- package/cjs/services/earning-service/utils/index.js +2 -0
- package/cjs/services/swap-service/handler/base-handler.js +4 -1
- package/cjs/services/swap-service/handler/chainflip-handler.js +1 -17
- package/cjs/services/swap-service/handler/optimex-handler.js +421 -0
- package/cjs/services/swap-service/handler/simpleswap-handler.js +4 -2
- package/cjs/services/swap-service/index.js +38 -140
- package/cjs/services/swap-service/utils.js +16 -157
- package/cjs/services/transaction-service/helpers/index.js +2 -1
- package/cjs/types/service-base.js +0 -1
- package/cjs/types/swap/index.js +5 -8
- package/cjs/utils/account/common.js +1 -2
- package/package.json +16 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/smart-contract.d.ts +3 -2
- package/services/balance-service/transfer/smart-contract.js +35 -29
- package/services/balance-service/transfer/xcm/acrossBridge/index.d.ts +0 -4
- package/services/balance-service/transfer/xcm/acrossBridge/index.js +0 -4
- package/services/balance-service/transfer/xcm/utils.js +2 -0
- package/services/chain-service/constants.js +16 -0
- package/services/chain-service/utils/index.d.ts +3 -2
- package/services/chain-service/utils/index.js +20 -1
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +2 -1
- package/services/earning-service/handlers/native-staking/base-para.js +6 -3
- package/services/earning-service/handlers/native-staking/relay-chain.js +4 -1
- package/services/earning-service/handlers/native-staking/tanssi.d.ts +16 -0
- package/services/earning-service/handlers/native-staking/tanssi.js +478 -0
- package/services/earning-service/service.js +4 -0
- package/services/earning-service/utils/index.js +2 -0
- package/services/swap-service/handler/base-handler.js +6 -3
- package/services/swap-service/handler/chainflip-handler.d.ts +0 -2
- package/services/swap-service/handler/chainflip-handler.js +2 -18
- package/services/swap-service/handler/optimex-handler.d.ts +43 -0
- package/services/swap-service/handler/optimex-handler.js +410 -0
- package/services/swap-service/handler/simpleswap-handler.js +5 -3
- package/services/swap-service/index.d.ts +0 -1
- package/services/swap-service/index.js +21 -123
- package/services/swap-service/utils.d.ts +6 -12
- package/services/swap-service/utils.js +8 -138
- package/services/transaction-service/helpers/index.js +2 -1
- package/types/service-base.d.ts +3 -4
- package/types/service-base.js +0 -2
- package/types/swap/index.d.ts +3 -1
- package/types/swap/index.js +7 -6
- package/types/yield/info/account/info.d.ts +5 -0
- package/utils/account/common.js +2 -3
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
2
2
|
import { CommonStepDetail, DynamicSwapAction, DynamicSwapType } from '@subwallet/extension-base/types';
|
|
3
3
|
import { SwapPair } from '@subwallet/extension-base/types/swap';
|
|
4
4
|
export declare const CHAIN_FLIP_TESTNET_EXPLORER = "https://blocks-perseverance.chainflip.io";
|
|
5
5
|
export declare const CHAIN_FLIP_MAINNET_EXPLORER = "https://scan.chainflip.io";
|
|
6
6
|
export declare const SIMPLE_SWAP_EXPLORER = "https://simpleswap.io";
|
|
7
|
-
export declare const SIMPLE_SWAP_SUPPORTED_TESTNET_ASSET_MAPPING: Record<string, string>;
|
|
8
7
|
export declare const SWAP_QUOTE_TIMEOUT_MAP: Record<string, number>;
|
|
9
|
-
export declare const _PROVIDER_TO_SUPPORTED_PAIR_MAP: Record<string, string[]>;
|
|
10
8
|
export declare const FEE_RATE_MULTIPLIER: Record<string, number>;
|
|
11
|
-
export declare function getSupportedSwapChains(): string[];
|
|
12
9
|
export declare function getSwapAlternativeAsset(swapPair: SwapPair): string | undefined;
|
|
13
10
|
export declare function getSwapAltToken(chainAsset: _ChainAsset): string | undefined;
|
|
14
|
-
export declare function calculateSwapRate(fromAmount: string, toAmount: string, fromAsset: _ChainAsset, toAsset: _ChainAsset): number;
|
|
15
|
-
export declare function convertSwapRate(rate: string, fromAsset: _ChainAsset, toAsset: _ChainAsset): number;
|
|
16
|
-
export declare function getBridgeStep(from: string, to: string): DynamicSwapAction;
|
|
17
|
-
export declare function getSwapStep(from: string, to: string): DynamicSwapAction;
|
|
18
|
-
export declare function findBridgeTransitDestination(assetRefMap: Record<string, _AssetRef>, fromToken: _ChainAsset, toToken: _ChainAsset): string | undefined;
|
|
19
|
-
export declare function findSwapTransitDestination(assetRefMap: Record<string, _AssetRef>, fromToken: _ChainAsset, toToken: _ChainAsset): string | undefined;
|
|
20
|
-
export declare function findAllBridgeDestinations(assetRefMap: Record<string, _AssetRef>, fromToken: _ChainAsset): string[];
|
|
21
11
|
export declare function getAmountAfterSlippage(amount: string, slippage: number): string;
|
|
22
|
-
export declare function isChainsHasSameProvider(fromChain: string, toChain: string): boolean;
|
|
23
12
|
export declare function getLastAmountFromSteps(steps: CommonStepDetail[]): string | undefined;
|
|
24
13
|
export declare function getFirstAmountFromSteps(steps: CommonStepDetail[]): string | undefined;
|
|
25
14
|
export declare function getChainRouteFromSteps(steps: CommonStepDetail[]): string[];
|
|
@@ -27,3 +16,8 @@ export declare function getTokenPairFromStep(steps: CommonStepDetail[]): SwapPai
|
|
|
27
16
|
export declare function getSwapChainsFromPath(path: DynamicSwapAction[]): string[];
|
|
28
17
|
export declare function processStepsToPathActions(steps: CommonStepDetail[]): DynamicSwapType[];
|
|
29
18
|
export declare const DEFAULT_EXCESS_AMOUNT_WEIGHT = 1.04;
|
|
19
|
+
export declare const DetectedGenOptimalProcessErrMsg: {
|
|
20
|
+
AMOUNT_TOO_LOW: string;
|
|
21
|
+
AMOUNT_TOO_HIGH: string;
|
|
22
|
+
NOT_ENOUGHT_BITCOIN: string;
|
|
23
|
+
};
|
|
@@ -1,24 +1,13 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
import { _AssetRefPath } from '@subwallet/chain-list/types';
|
|
6
|
-
import { _getAssetDecimals, _getAssetOriginChain, _getOriginChainOfAsset, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
4
|
+
import { _getOriginChainOfAsset, _parseAssetRefKey } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
5
|
import { CommonStepType, DynamicSwapType, SwapStepType } from '@subwallet/extension-base/types';
|
|
8
6
|
import { SwapProviderId } from '@subwallet/extension-base/types/swap';
|
|
9
7
|
import BigN from 'bignumber.js';
|
|
10
8
|
export const CHAIN_FLIP_TESTNET_EXPLORER = 'https://blocks-perseverance.chainflip.io';
|
|
11
9
|
export const CHAIN_FLIP_MAINNET_EXPLORER = 'https://scan.chainflip.io';
|
|
12
10
|
export const SIMPLE_SWAP_EXPLORER = 'https://simpleswap.io';
|
|
13
|
-
|
|
14
|
-
// Deprecated
|
|
15
|
-
export const SIMPLE_SWAP_SUPPORTED_TESTNET_ASSET_MAPPING = {
|
|
16
|
-
'bittensor-NATIVE-TAO': 'tao',
|
|
17
|
-
[COMMON_ASSETS.ETH]: 'eth',
|
|
18
|
-
[COMMON_ASSETS.DOT]: 'dot',
|
|
19
|
-
[COMMON_ASSETS.USDC_ETHEREUM]: 'usdc',
|
|
20
|
-
[COMMON_ASSETS.USDT_ETHEREUM]: 'usdterc20'
|
|
21
|
-
};
|
|
22
11
|
export const SWAP_QUOTE_TIMEOUT_MAP = {
|
|
23
12
|
// in milliseconds
|
|
24
13
|
default: 90000,
|
|
@@ -26,29 +15,11 @@ export const SWAP_QUOTE_TIMEOUT_MAP = {
|
|
|
26
15
|
[SwapProviderId.CHAIN_FLIP_MAINNET]: 30000,
|
|
27
16
|
error: 10000
|
|
28
17
|
};
|
|
29
|
-
|
|
30
|
-
// deprecated
|
|
31
|
-
export const _PROVIDER_TO_SUPPORTED_PAIR_MAP = {
|
|
32
|
-
[SwapProviderId.HYDRADX_MAINNET]: [COMMON_CHAIN_SLUGS.HYDRADX],
|
|
33
|
-
[SwapProviderId.CHAIN_FLIP_MAINNET]: [COMMON_CHAIN_SLUGS.POLKADOT, COMMON_CHAIN_SLUGS.ETHEREUM, COMMON_CHAIN_SLUGS.ARBITRUM],
|
|
34
|
-
[SwapProviderId.POLKADOT_ASSET_HUB]: [COMMON_CHAIN_SLUGS.POLKADOT_ASSET_HUB],
|
|
35
|
-
[SwapProviderId.KUSAMA_ASSET_HUB]: [COMMON_CHAIN_SLUGS.KUSAMA_ASSET_HUB],
|
|
36
|
-
[SwapProviderId.SIMPLE_SWAP]: ['bittensor', COMMON_CHAIN_SLUGS.ETHEREUM, COMMON_CHAIN_SLUGS.POLKADOT],
|
|
37
|
-
[SwapProviderId.UNISWAP]: [COMMON_CHAIN_SLUGS.ETHEREUM, COMMON_CHAIN_SLUGS.ARBITRUM],
|
|
38
|
-
// testnet
|
|
39
|
-
[SwapProviderId.CHAIN_FLIP_TESTNET]: [COMMON_CHAIN_SLUGS.CHAINFLIP_POLKADOT, COMMON_CHAIN_SLUGS.ETHEREUM_SEPOLIA],
|
|
40
|
-
[SwapProviderId.HYDRADX_TESTNET]: [COMMON_CHAIN_SLUGS.HYDRADX_TESTNET],
|
|
41
|
-
[SwapProviderId.ROCOCO_ASSET_HUB]: [COMMON_CHAIN_SLUGS.ROCOCO_ASSET_HUB],
|
|
42
|
-
[SwapProviderId.WESTEND_ASSET_HUB]: ['westend_assethub']
|
|
43
|
-
};
|
|
44
18
|
export const FEE_RATE_MULTIPLIER = {
|
|
45
19
|
default: 1,
|
|
46
20
|
medium: 1.2,
|
|
47
21
|
high: 2
|
|
48
22
|
};
|
|
49
|
-
export function getSupportedSwapChains() {
|
|
50
|
-
return [...new Set(Object.values(_PROVIDER_TO_SUPPORTED_PAIR_MAP).flat())];
|
|
51
|
-
}
|
|
52
23
|
export function getSwapAlternativeAsset(swapPair) {
|
|
53
24
|
var _swapPair$metadata;
|
|
54
25
|
return swapPair === null || swapPair === void 0 ? void 0 : (_swapPair$metadata = swapPair.metadata) === null || _swapPair$metadata === void 0 ? void 0 : _swapPair$metadata.alternativeAsset;
|
|
@@ -57,116 +28,9 @@ export function getSwapAltToken(chainAsset) {
|
|
|
57
28
|
var _chainAsset$metadata;
|
|
58
29
|
return (_chainAsset$metadata = chainAsset.metadata) === null || _chainAsset$metadata === void 0 ? void 0 : _chainAsset$metadata.alternativeSwapAsset;
|
|
59
30
|
}
|
|
60
|
-
export function calculateSwapRate(fromAmount, toAmount, fromAsset, toAsset) {
|
|
61
|
-
const bnFromAmount = BigN(fromAmount);
|
|
62
|
-
const bnToAmount = BigN(toAmount);
|
|
63
|
-
const decimalDiff = _getAssetDecimals(toAsset) - _getAssetDecimals(fromAsset);
|
|
64
|
-
const bnRate = bnFromAmount.div(bnToAmount);
|
|
65
|
-
return 1 / bnRate.times(10 ** decimalDiff).toNumber();
|
|
66
|
-
}
|
|
67
|
-
export function convertSwapRate(rate, fromAsset, toAsset) {
|
|
68
|
-
const decimalDiff = _getAssetDecimals(toAsset) - _getAssetDecimals(fromAsset);
|
|
69
|
-
const bnRate = BigN(rate);
|
|
70
|
-
return bnRate.times(10 ** decimalDiff).pow(-1).toNumber();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// export function getChainflipOptions (isTestnet: boolean) {
|
|
74
|
-
// if (isTestnet) {
|
|
75
|
-
// return {
|
|
76
|
-
// network: getChainflipNetwork(isTestnet)
|
|
77
|
-
// };
|
|
78
|
-
// }
|
|
79
|
-
|
|
80
|
-
// return {
|
|
81
|
-
// network: getChainflipNetwork(isTestnet),
|
|
82
|
-
// broker: getChainflipBroker(isTestnet)
|
|
83
|
-
// };
|
|
84
|
-
// }
|
|
85
|
-
|
|
86
|
-
// function getChainflipNetwork (isTestnet: boolean) {
|
|
87
|
-
// return isTestnet ? 'perseverance' : 'mainnet';
|
|
88
|
-
// }
|
|
89
|
-
|
|
90
|
-
// export function getChainflipBroker (isTestnet: boolean) { // noted: currently not use testnet broker
|
|
91
|
-
// if (isTestnet) {
|
|
92
|
-
// return {
|
|
93
|
-
// url: `https://perseverance.chainflip-broker.io/rpc/${CHAINFLIP_BROKER_API}`
|
|
94
|
-
// };
|
|
95
|
-
// } else {
|
|
96
|
-
// return {
|
|
97
|
-
// url: `https://chainflip-broker.io/rpc/${CHAINFLIP_BROKER_API}`
|
|
98
|
-
// };
|
|
99
|
-
// }
|
|
100
|
-
// }
|
|
101
|
-
|
|
102
|
-
// export function getChainflipSwap (isTestnet: boolean) {
|
|
103
|
-
// if (isTestnet) {
|
|
104
|
-
// return `https://perseverance.chainflip-broker.io/swap?apikey=${CHAINFLIP_BROKER_API}`;
|
|
105
|
-
// } else {
|
|
106
|
-
// return `https://chainflip-broker.io/swap?apikey=${CHAINFLIP_BROKER_API}`;
|
|
107
|
-
// }
|
|
108
|
-
// }
|
|
109
|
-
|
|
110
|
-
// export function getAssetsUrl (isTestnet: boolean) {
|
|
111
|
-
// if (isTestnet) {
|
|
112
|
-
// return 'https://perseverance.chainflip-broker.io/assets';
|
|
113
|
-
// } else {
|
|
114
|
-
// return 'https://chainflip-broker.io/assets';
|
|
115
|
-
// }
|
|
116
|
-
// }
|
|
117
|
-
|
|
118
|
-
export function getBridgeStep(from, to) {
|
|
119
|
-
return {
|
|
120
|
-
action: DynamicSwapType.BRIDGE,
|
|
121
|
-
pair: {
|
|
122
|
-
slug: `${from}___${to}`,
|
|
123
|
-
// todo: recheck with assetRef format from chain list
|
|
124
|
-
from,
|
|
125
|
-
to
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
export function getSwapStep(from, to) {
|
|
130
|
-
return {
|
|
131
|
-
action: DynamicSwapType.SWAP,
|
|
132
|
-
pair: {
|
|
133
|
-
slug: `${from}___${to}`,
|
|
134
|
-
// todo: recheck with assetRef format from chain list
|
|
135
|
-
from,
|
|
136
|
-
to
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
export function findBridgeTransitDestination(assetRefMap, fromToken, toToken) {
|
|
141
|
-
const foundAssetRef = Object.values(assetRefMap).find(assetRef => assetRef.srcAsset === fromToken.slug && assetRef.destChain === _getAssetOriginChain(toToken) && assetRef.path === _AssetRefPath.XCM);
|
|
142
|
-
if (foundAssetRef) {
|
|
143
|
-
return foundAssetRef.destAsset;
|
|
144
|
-
}
|
|
145
|
-
return undefined;
|
|
146
|
-
}
|
|
147
|
-
export function findSwapTransitDestination(assetRefMap, fromToken, toToken) {
|
|
148
|
-
const foundAssetRef = Object.values(assetRefMap).find(assetRef => assetRef.destAsset === toToken.slug && assetRef.srcChain === _getAssetOriginChain(fromToken) && assetRef.path === _AssetRefPath.XCM);
|
|
149
|
-
if (foundAssetRef) {
|
|
150
|
-
return foundAssetRef.srcAsset;
|
|
151
|
-
}
|
|
152
|
-
return undefined;
|
|
153
|
-
}
|
|
154
|
-
export function findAllBridgeDestinations(assetRefMap, fromToken) {
|
|
155
|
-
const foundAssetRefs = Object.values(assetRefMap).filter(assetRef => assetRef.srcAsset === fromToken.slug && assetRef.path === _AssetRefPath.XCM);
|
|
156
|
-
return foundAssetRefs.map(assetRef => assetRef.destAsset);
|
|
157
|
-
}
|
|
158
31
|
export function getAmountAfterSlippage(amount, slippage) {
|
|
159
32
|
return BigN(amount).multipliedBy(BigN(1).minus(BigN(slippage))).integerValue(BigN.ROUND_DOWN).toString();
|
|
160
33
|
}
|
|
161
|
-
export function isChainsHasSameProvider(fromChain, toChain) {
|
|
162
|
-
// todo: a provider may support multiple chains but not cross-chain swaps
|
|
163
|
-
for (const group of Object.values(_PROVIDER_TO_SUPPORTED_PAIR_MAP)) {
|
|
164
|
-
if (group.includes(fromChain) && group.includes(toChain)) {
|
|
165
|
-
return true;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
34
|
export function getLastAmountFromSteps(steps) {
|
|
171
35
|
var _lastStep$metadata;
|
|
172
36
|
const lastStep = steps[steps.length - 1]; // last step
|
|
@@ -265,4 +129,10 @@ export function processStepsToPathActions(steps) {
|
|
|
265
129
|
}
|
|
266
130
|
return path;
|
|
267
131
|
}
|
|
268
|
-
export const DEFAULT_EXCESS_AMOUNT_WEIGHT = 1.04; // add 2%
|
|
132
|
+
export const DEFAULT_EXCESS_AMOUNT_WEIGHT = 1.04; // add 2%
|
|
133
|
+
|
|
134
|
+
export const DetectedGenOptimalProcessErrMsg = {
|
|
135
|
+
AMOUNT_TOO_LOW: 'amount too low',
|
|
136
|
+
AMOUNT_TOO_HIGH: 'amount too high',
|
|
137
|
+
NOT_ENOUGHT_BITCOIN: 'for the transaction. lower your btc amount and try again' // todo: improve handle msg error
|
|
138
|
+
};
|
|
@@ -24,7 +24,8 @@ export const isCardanoTransaction = tx => {
|
|
|
24
24
|
|
|
25
25
|
// TODO: [Review] this function
|
|
26
26
|
export const isBitcoinTransaction = tx => {
|
|
27
|
-
|
|
27
|
+
var _data;
|
|
28
|
+
return 'data' in tx && Array.isArray((_data = tx.data) === null || _data === void 0 ? void 0 : _data.inputs);
|
|
28
29
|
};
|
|
29
30
|
const typeName = type => {
|
|
30
31
|
switch (type) {
|
package/types/service-base.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { DynamicSwapAction,
|
|
2
|
-
import {
|
|
3
|
-
export declare type OptimalProcessParams = OptimalYieldPathParams | OptimalSwapPathParamsV2;
|
|
4
|
-
export declare type OptimalProcessResult = OptimalYieldPath | CommonOptimalSwapPath;
|
|
1
|
+
import { DynamicSwapAction, SwapFeeType, SwapStepType } from '@subwallet/extension-base/types/swap';
|
|
2
|
+
import { YieldStepType } from '@subwallet/extension-base/types/yield';
|
|
5
3
|
export declare enum CommonStepType {
|
|
6
4
|
DEFAULT = "DEFAULT",
|
|
7
5
|
XCM = "XCM",
|
|
@@ -21,6 +19,7 @@ export interface CommonFeeComponent {
|
|
|
21
19
|
amount: string;
|
|
22
20
|
tokenSlug: string;
|
|
23
21
|
percentage?: number;
|
|
22
|
+
metadata?: any;
|
|
24
23
|
}
|
|
25
24
|
export interface CommonStepFeeInfo {
|
|
26
25
|
feeComponent: CommonFeeComponent[];
|
package/types/service-base.js
CHANGED
package/types/swap/index.d.ts
CHANGED
|
@@ -63,7 +63,9 @@ export declare enum SwapProviderId {
|
|
|
63
63
|
WESTEND_ASSET_HUB = "WESTEND_ASSET_HUB",
|
|
64
64
|
SIMPLE_SWAP = "SIMPLE_SWAP",
|
|
65
65
|
UNISWAP = "UNISWAP",
|
|
66
|
-
KYBER = "KYBER"
|
|
66
|
+
KYBER = "KYBER",
|
|
67
|
+
OPTIMEX = "OPTIMEX",
|
|
68
|
+
OPTIMEX_TESTNET = "OPTIMEX_TESTNET"
|
|
67
69
|
}
|
|
68
70
|
export declare const _SUPPORTED_SWAP_PROVIDERS: SwapProviderId[];
|
|
69
71
|
export interface SwapProvider {
|
package/types/swap/index.js
CHANGED
|
@@ -19,11 +19,15 @@ export let SwapErrorType;
|
|
|
19
19
|
SwapErrorType["NOT_MEET_MIN_EXPECTED"] = "NOT_MEET_MIN_EXPECTED";
|
|
20
20
|
})(SwapErrorType || (SwapErrorType = {}));
|
|
21
21
|
export let SwapStepType;
|
|
22
|
+
|
|
23
|
+
// todo: export this to use from sdk
|
|
22
24
|
(function (SwapStepType) {
|
|
23
25
|
SwapStepType["SWAP"] = "SWAP";
|
|
24
26
|
SwapStepType["PERMIT"] = "PERMIT";
|
|
25
27
|
})(SwapStepType || (SwapStepType = {}));
|
|
26
28
|
export let SwapProviderId;
|
|
29
|
+
|
|
30
|
+
// todo: export this to use from sdk
|
|
27
31
|
(function (SwapProviderId) {
|
|
28
32
|
SwapProviderId["CHAIN_FLIP_TESTNET"] = "CHAIN_FLIP_TESTNET";
|
|
29
33
|
SwapProviderId["CHAIN_FLIP_MAINNET"] = "CHAIN_FLIP_MAINNET";
|
|
@@ -36,13 +40,10 @@ export let SwapProviderId;
|
|
|
36
40
|
SwapProviderId["SIMPLE_SWAP"] = "SIMPLE_SWAP";
|
|
37
41
|
SwapProviderId["UNISWAP"] = "UNISWAP";
|
|
38
42
|
SwapProviderId["KYBER"] = "KYBER";
|
|
43
|
+
SwapProviderId["OPTIMEX"] = "OPTIMEX";
|
|
44
|
+
SwapProviderId["OPTIMEX_TESTNET"] = "OPTIMEX_TESTNET";
|
|
39
45
|
})(SwapProviderId || (SwapProviderId = {}));
|
|
40
|
-
export const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET,
|
|
41
|
-
// SwapProviderId.HYDRADX_TESTNET,
|
|
42
|
-
SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB,
|
|
43
|
-
// SwapProviderId.ROCOCO_ASSET_HUB,
|
|
44
|
-
// SwapProviderId.WESTEND_ASSET_HUB,
|
|
45
|
-
SwapProviderId.SIMPLE_SWAP, SwapProviderId.UNISWAP, SwapProviderId.KYBER];
|
|
46
|
+
export const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET, SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB, SwapProviderId.SIMPLE_SWAP, SwapProviderId.UNISWAP, SwapProviderId.KYBER, SwapProviderId.OPTIMEX, SwapProviderId.OPTIMEX_TESTNET];
|
|
46
47
|
// process handling
|
|
47
48
|
export let SwapFeeType;
|
|
48
49
|
(function (SwapFeeType) {
|
|
@@ -48,6 +48,11 @@ export interface AbstractYieldPositionInfo extends BaseYieldPositionInfo {
|
|
|
48
48
|
subnetShortName: string;
|
|
49
49
|
originalTotalStake: string;
|
|
50
50
|
};
|
|
51
|
+
metadata?: {
|
|
52
|
+
pendingStake?: string;
|
|
53
|
+
compoundingStake?: string;
|
|
54
|
+
manualStake?: string;
|
|
55
|
+
};
|
|
51
56
|
}
|
|
52
57
|
/**
|
|
53
58
|
* @interface SpecialYieldPositionInfo
|
package/utils/account/common.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
5
|
-
import {
|
|
5
|
+
import { _chainInfoToAccountChainType, _getChainSubstrateAddressPrefix, _getSubstrateGenesisHash, _isChainBitcoinCompatible, _isChainCardanoCompatible, _isChainEvmCompatible, _isChainTonCompatible, _isSubstrateEvmCompatibleChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
6
6
|
import { AccountChainType } from '@subwallet/extension-base/types';
|
|
7
7
|
import { getAccountChainTypeFromKeypairType, pairToAccount } from '@subwallet/extension-base/utils';
|
|
8
8
|
import { decodeAddress, encodeAddress, getKeypairTypeByAddress, isAddress, isBitcoinAddress, isCardanoAddress, isTonAddress } from '@subwallet/keyring';
|
|
@@ -41,8 +41,7 @@ export function reformatAddress(address, networkPrefix = 42, isEthereum = false,
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
export const _reformatAddressWithChain = (address, chainInfo) => {
|
|
44
|
-
|
|
45
|
-
const chainType = _chainInfoToChainType(chainInfo);
|
|
44
|
+
const chainType = _chainInfoToAccountChainType(chainInfo);
|
|
46
45
|
if (chainType === AccountChainType.SUBSTRATE) {
|
|
47
46
|
return reformatAddress(address, _getChainSubstrateAddressPrefix(chainInfo));
|
|
48
47
|
} else if (chainType === AccountChainType.TON || chainType === AccountChainType.CARDANO) {
|