@subwallet/extension-base 1.3.29-1 → 1.3.30-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/background/KoniTypes.d.ts +4 -4
- package/background/errors/SwapError.js +1 -1
- package/cjs/background/errors/SwapError.js +1 -1
- package/cjs/constants/blocked-actions.js +2 -2
- package/cjs/constants/remind-notification-time.js +3 -3
- package/cjs/core/logic-validation/swap.js +63 -4
- package/cjs/core/utils.js +1 -1
- package/cjs/koni/background/handlers/Extension.js +5 -82
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/xcm/availBridge.js +6 -6
- package/cjs/services/earning-service/handlers/base.js +6 -3
- package/cjs/services/earning-service/handlers/native-staking/base.js +4 -1
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +68 -50
- package/cjs/services/earning-service/handlers/native-staking/tao.js +12 -2
- package/cjs/services/earning-service/service.js +2 -1
- package/cjs/services/fee-service/utils/index.js +16 -4
- package/cjs/services/inapp-notification-service/index.js +19 -13
- package/cjs/services/swap-service/handler/asset-hub/handler.js +61 -314
- package/cjs/services/swap-service/handler/base-handler.js +393 -231
- package/cjs/services/swap-service/handler/chainflip-handler.js +18 -40
- package/cjs/services/swap-service/handler/hydradx-handler.js +77 -269
- package/cjs/services/swap-service/handler/simpleswap-handler.js +27 -48
- package/cjs/services/swap-service/handler/uniswap-handler.js +33 -54
- package/cjs/services/swap-service/index.js +154 -143
- package/cjs/services/swap-service/utils.js +107 -17
- package/cjs/services/transaction-service/index.js +1 -1
- package/cjs/types/swap/index.js +13 -1
- package/cjs/utils/swap.js +5 -1
- package/constants/blocked-actions.d.ts +1 -1
- package/constants/blocked-actions.js +1 -1
- package/constants/remind-notification-time.d.ts +1 -1
- package/constants/remind-notification-time.js +1 -1
- package/core/logic-validation/swap.d.ts +15 -0
- package/core/logic-validation/swap.js +60 -4
- package/core/utils.js +1 -1
- package/koni/background/handlers/Extension.d.ts +0 -1
- package/koni/background/handlers/Extension.js +6 -83
- package/package.json +6 -12
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/xcm/availBridge.js +6 -6
- package/services/base/types.d.ts +0 -4
- package/services/earning-service/handlers/base.d.ts +4 -3
- package/services/earning-service/handlers/base.js +6 -4
- package/services/earning-service/handlers/native-staking/base.js +4 -1
- package/services/earning-service/handlers/native-staking/dtao.d.ts +9 -6
- package/services/earning-service/handlers/native-staking/dtao.js +69 -48
- package/services/earning-service/handlers/native-staking/tao.js +12 -2
- package/services/earning-service/service.d.ts +2 -1
- package/services/earning-service/service.js +2 -1
- package/services/fee-service/utils/index.d.ts +1 -0
- package/services/fee-service/utils/index.js +14 -4
- package/services/inapp-notification-service/index.js +13 -7
- package/services/swap-service/handler/asset-hub/handler.d.ts +2 -9
- package/services/swap-service/handler/asset-hub/handler.js +64 -317
- package/services/swap-service/handler/base-handler.d.ts +6 -9
- package/services/swap-service/handler/base-handler.js +391 -229
- package/services/swap-service/handler/chainflip-handler.d.ts +2 -4
- package/services/swap-service/handler/chainflip-handler.js +15 -37
- package/services/swap-service/handler/hydradx-handler.d.ts +3 -10
- package/services/swap-service/handler/hydradx-handler.js +78 -270
- package/services/swap-service/handler/simpleswap-handler.d.ts +2 -4
- package/services/swap-service/handler/simpleswap-handler.js +24 -45
- package/services/swap-service/handler/uniswap-handler.d.ts +4 -6
- package/services/swap-service/handler/uniswap-handler.js +25 -46
- package/services/swap-service/index.d.ts +8 -14
- package/services/swap-service/index.js +141 -129
- package/services/swap-service/utils.d.ts +11 -3
- package/services/swap-service/utils.js +96 -15
- package/services/transaction-service/index.js +2 -2
- package/types/service-base.d.ts +2 -3
- package/types/swap/index.d.ts +25 -9
- package/types/swap/index.js +10 -0
- package/types/transaction/process.d.ts +19 -0
- package/types/yield/actions/join/submit.d.ts +4 -1
- package/types/yield/actions/others.d.ts +2 -0
- package/utils/swap.d.ts +3 -0
- package/utils/swap.js +3 -0
- package/cjs/services/swap-service/interface.js +0 -14
- package/services/swap-service/interface.d.ts +0 -9
- package/services/swap-service/interface.js +0 -8
package/types/swap/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { SwapError } from '@subwallet/extension-base/background/errors/SwapError';
|
|
3
3
|
import { AmountData, ChainType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
|
-
import { DynamicSwapAction } from '@subwallet/extension-base/services/swap-service/interface';
|
|
5
4
|
import { BaseStepDetail, BaseStepType, CommonOptimalSwapPath, CommonStepFeeInfo } from '@subwallet/extension-base/types/service-base';
|
|
6
5
|
import BigN from 'bignumber.js';
|
|
7
6
|
import { BaseProcessRequestSign, TransactionData } from '../transaction';
|
|
@@ -96,8 +95,7 @@ export interface SimpleSwapTxData extends SwapBaseTxData {
|
|
|
96
95
|
export interface HydradxSwapTxData extends SwapBaseTxData {
|
|
97
96
|
txHex: string;
|
|
98
97
|
}
|
|
99
|
-
export declare type
|
|
100
|
-
export declare type GenSwapStepFuncV2 = (params: OptimalSwapPathParamsV2) => Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
98
|
+
export declare type GenSwapStepFuncV2 = (params: OptimalSwapPathParamsV2, stepIndex: number) => Promise<[BaseStepDetail, CommonStepFeeInfo] | undefined>;
|
|
101
99
|
export interface ChainflipPreValidationMetadata {
|
|
102
100
|
minSwap: AmountData;
|
|
103
101
|
maxSwap?: AmountData;
|
|
@@ -131,6 +129,15 @@ export interface SwapRequest {
|
|
|
131
129
|
feeToken?: string;
|
|
132
130
|
currentQuote?: SwapProvider;
|
|
133
131
|
}
|
|
132
|
+
export interface SwapRequestV2 {
|
|
133
|
+
address: string;
|
|
134
|
+
pair: SwapPair;
|
|
135
|
+
fromAmount: string;
|
|
136
|
+
slippage: number;
|
|
137
|
+
recipient?: string;
|
|
138
|
+
feeToken?: string;
|
|
139
|
+
preferredProvider?: SwapProviderId;
|
|
140
|
+
}
|
|
134
141
|
export interface SwapRequestResult {
|
|
135
142
|
process: CommonOptimalSwapPath;
|
|
136
143
|
quote: SwapQuoteResponse;
|
|
@@ -159,9 +166,17 @@ export interface SwapSubmitStepData {
|
|
|
159
166
|
chainType: ChainType;
|
|
160
167
|
isPermit?: boolean;
|
|
161
168
|
}
|
|
162
|
-
export
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
export declare enum DynamicSwapType {
|
|
170
|
+
SWAP = "SWAP",
|
|
171
|
+
BRIDGE = "BRIDGE"
|
|
172
|
+
}
|
|
173
|
+
export interface DynamicSwapAction {
|
|
174
|
+
action: DynamicSwapType;
|
|
175
|
+
pair: ActionPair;
|
|
176
|
+
}
|
|
177
|
+
export declare const enum BridgeStepPosition {
|
|
178
|
+
FIRST = 0,
|
|
179
|
+
AFTER_SWAP = 1
|
|
165
180
|
}
|
|
166
181
|
export interface OptimalSwapPathParamsV2 {
|
|
167
182
|
request: SwapRequest;
|
|
@@ -194,11 +209,12 @@ export declare const CHAINFLIP_SLIPPAGE = 0.02;
|
|
|
194
209
|
export declare const SIMPLE_SWAP_SLIPPAGE = 0.05;
|
|
195
210
|
export interface BaseSwapStepMetadata {
|
|
196
211
|
sendingValue: string;
|
|
212
|
+
expectedReceive: string;
|
|
197
213
|
originTokenInfo: _ChainAsset;
|
|
198
214
|
destinationTokenInfo: _ChainAsset;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
215
|
+
sender: string;
|
|
216
|
+
receiver: string;
|
|
217
|
+
version: number;
|
|
202
218
|
}
|
|
203
219
|
export interface HydrationSwapStepMetadata extends BaseSwapStepMetadata {
|
|
204
220
|
txHex: `0x${string}`;
|
package/types/swap/index.js
CHANGED
|
@@ -49,5 +49,15 @@ export let SwapFeeType;
|
|
|
49
49
|
SwapFeeType["NETWORK_FEE"] = "NETWORK_FEE";
|
|
50
50
|
SwapFeeType["WALLET_FEE"] = "WALLET_FEE";
|
|
51
51
|
})(SwapFeeType || (SwapFeeType = {}));
|
|
52
|
+
export let DynamicSwapType;
|
|
53
|
+
(function (DynamicSwapType) {
|
|
54
|
+
DynamicSwapType["SWAP"] = "SWAP";
|
|
55
|
+
DynamicSwapType["BRIDGE"] = "BRIDGE";
|
|
56
|
+
})(DynamicSwapType || (DynamicSwapType = {}));
|
|
57
|
+
export let BridgeStepPosition;
|
|
58
|
+
(function (BridgeStepPosition) {
|
|
59
|
+
BridgeStepPosition[BridgeStepPosition["FIRST"] = 0] = "FIRST";
|
|
60
|
+
BridgeStepPosition[BridgeStepPosition["AFTER_SWAP"] = 1] = "AFTER_SWAP";
|
|
61
|
+
})(BridgeStepPosition || (BridgeStepPosition = {}));
|
|
52
62
|
export const CHAINFLIP_SLIPPAGE = 0.02; // Example: 0.01 for 1%
|
|
53
63
|
export const SIMPLE_SWAP_SLIPPAGE = 0.05;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { _ChainAsset } from '@subwallet/chain-list/types';
|
|
1
2
|
import { TransactionEventResponse } from '@subwallet/extension-base/services/transaction-service/types';
|
|
2
3
|
import { CommonStepDetail, CommonStepFeeInfo } from '../service-base';
|
|
3
4
|
import { SwapPair, SwapProvider, SwapRate, SwapRoute, SwapSubmitParams } from '../swap';
|
|
@@ -51,6 +52,24 @@ export interface BriefProcessStep {
|
|
|
51
52
|
processId: string;
|
|
52
53
|
stepId: number;
|
|
53
54
|
}
|
|
55
|
+
export interface BriefXcmStep {
|
|
56
|
+
sendingValue: string;
|
|
57
|
+
originTokenInfo: _ChainAsset;
|
|
58
|
+
destinationTokenInfo: _ChainAsset;
|
|
59
|
+
}
|
|
60
|
+
export interface BriefXcmStepV2 {
|
|
61
|
+
sendingValue: string;
|
|
62
|
+
originTokenInfo: _ChainAsset;
|
|
63
|
+
destinationValue: string;
|
|
64
|
+
destinationTokenInfo: _ChainAsset;
|
|
65
|
+
}
|
|
66
|
+
export interface BriefSwapStepV2 {
|
|
67
|
+
sendingValue: string;
|
|
68
|
+
originTokenInfo: _ChainAsset;
|
|
69
|
+
destinationValue: string;
|
|
70
|
+
destinationTokenInfo: _ChainAsset;
|
|
71
|
+
}
|
|
72
|
+
export declare type BriefStepV2 = BriefXcmStepV2 | BriefSwapStepV2;
|
|
54
73
|
export interface BriefSwapStep {
|
|
55
74
|
pair: SwapPair;
|
|
56
75
|
fromAmount: string;
|
|
@@ -20,7 +20,10 @@ export interface SubmitJoinNativeStaking extends AbstractSubmitYieldJoinData {
|
|
|
20
20
|
mindBond: string;
|
|
21
21
|
};
|
|
22
22
|
selectedValidators: ValidatorInfo[];
|
|
23
|
-
|
|
23
|
+
subnetData: {
|
|
24
|
+
netuid: number;
|
|
25
|
+
slippage: number;
|
|
26
|
+
};
|
|
24
27
|
}
|
|
25
28
|
export interface SubmitJoinNominationPool extends AbstractSubmitYieldJoinData {
|
|
26
29
|
selectedPool: NominationPoolInfo;
|
|
@@ -24,6 +24,8 @@ export interface YieldLeaveParams extends BaseRequestSign {
|
|
|
24
24
|
fastLeave: boolean;
|
|
25
25
|
/** Pool's info - use for create history */
|
|
26
26
|
poolInfo: YieldPoolInfo;
|
|
27
|
+
/** Slippage (subnet staking) */
|
|
28
|
+
slippage?: number;
|
|
27
29
|
}
|
|
28
30
|
export declare type RequestYieldLeave = InternalRequestSign<YieldLeaveParams>;
|
|
29
31
|
/**
|
package/utils/swap.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { NumberFormatter } from '@subwallet/extension-base/utils/number';
|
|
2
|
+
export declare const swapNumberMetadata: {
|
|
3
|
+
minNumberFormat: number;
|
|
4
|
+
};
|
|
2
5
|
export declare const swapCustomFormatter: NumberFormatter;
|
|
3
6
|
export declare const formatNumberString: (numberString: string) => string;
|
package/utils/swap.js
CHANGED
|
@@ -19,6 +19,9 @@ const NUM_1B = new BigNumber(1e9);
|
|
|
19
19
|
const BLIM = new BigNumber(1e14);
|
|
20
20
|
const NUM_1M = new BigNumber(1e6);
|
|
21
21
|
const NUM_100M = new BigNumber(1e8);
|
|
22
|
+
export const swapNumberMetadata = {
|
|
23
|
+
minNumberFormat: 4
|
|
24
|
+
};
|
|
22
25
|
export const swapCustomFormatter = (input, metadata) => {
|
|
23
26
|
const minNumberFormat = 2;
|
|
24
27
|
const maxNumberFormat = (metadata === null || metadata === void 0 ? void 0 : metadata.maxNumberFormat) || 6;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.DynamicSwapType = void 0;
|
|
7
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
8
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
let DynamicSwapType;
|
|
10
|
-
exports.DynamicSwapType = DynamicSwapType;
|
|
11
|
-
(function (DynamicSwapType) {
|
|
12
|
-
DynamicSwapType["SWAP"] = "SWAP";
|
|
13
|
-
DynamicSwapType["BRIDGE"] = "BRIDGE";
|
|
14
|
-
})(DynamicSwapType || (exports.DynamicSwapType = DynamicSwapType = {}));
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
export let DynamicSwapType;
|
|
5
|
-
(function (DynamicSwapType) {
|
|
6
|
-
DynamicSwapType["SWAP"] = "SWAP";
|
|
7
|
-
DynamicSwapType["BRIDGE"] = "BRIDGE";
|
|
8
|
-
})(DynamicSwapType || (DynamicSwapType = {}));
|