@subwallet/extension-base 1.3.10-0 → 1.3.12-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 +3 -0
- package/background/errors/SwapError.js +5 -0
- package/cjs/background/errors/SwapError.js +5 -0
- package/cjs/core/logic-validation/swap.js +27 -0
- package/cjs/core/substrate/xcm-parser.js +16 -2
- package/cjs/koni/api/contract-handler/utils/index.js +29 -1
- package/cjs/koni/background/handlers/Extension.js +16 -4
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/transfer/smart-contract.js +2 -0
- package/cjs/services/balance-service/transfer/xcm/index.js +6 -6
- package/cjs/services/balance-service/transfer/xcm/polygonBridge.js +2 -2
- package/cjs/services/balance-service/transfer/xcm/posBridge.js +144 -0
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +4 -2
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost-manta.js +2 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +2 -2
- package/cjs/services/inapp-notification-service/index.js +2 -0
- package/cjs/services/inapp-notification-service/utils/polygon.js +1 -1
- package/cjs/services/keyring-service/context/handlers/Ledger.js +3 -1
- package/cjs/services/swap-service/handler/chainflip-handler.js +0 -1
- package/cjs/services/swap-service/handler/simpleswap-handler.js +444 -0
- package/cjs/services/swap-service/index.js +15 -3
- package/cjs/services/swap-service/utils.js +13 -2
- package/cjs/services/transaction-service/index.js +14 -10
- package/cjs/services/transaction-service/utils.js +12 -1
- package/cjs/types/swap/index.js +7 -3
- package/cjs/utils/number.js +10 -0
- package/constants/staking.d.ts +4 -0
- package/core/logic-validation/swap.d.ts +2 -1
- package/core/logic-validation/swap.js +26 -0
- package/core/substrate/xcm-parser.d.ts +1 -0
- package/core/substrate/xcm-parser.js +15 -2
- package/koni/api/contract-handler/utils/index.d.ts +4 -0
- package/koni/api/contract-handler/utils/index.js +24 -0
- package/koni/api/contract-handler/utils/pos_bridge_abi.json +783 -0
- package/koni/api/contract-handler/utils/pos_bridge_l2_abi.json +793 -0
- package/koni/background/handlers/Extension.js +18 -6
- package/package.json +18 -6
- package/packageInfo.js +1 -1
- package/services/balance-service/transfer/smart-contract.js +2 -0
- package/services/balance-service/transfer/xcm/index.js +7 -7
- package/services/balance-service/transfer/xcm/polygonBridge.js +2 -2
- package/services/balance-service/transfer/xcm/posBridge.d.ts +14 -0
- package/services/balance-service/transfer/xcm/posBridge.js +131 -0
- 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/liquid-staking/bifrost-manta.js +2 -1
- package/services/earning-service/handlers/liquid-staking/bifrost.js +3 -3
- package/services/inapp-notification-service/index.js +2 -0
- package/services/inapp-notification-service/interfaces.d.ts +7 -6
- package/services/inapp-notification-service/utils/polygon.d.ts +6 -6
- package/services/inapp-notification-service/utils/polygon.js +1 -1
- package/services/keyring-service/context/handlers/Ledger.js +3 -1
- package/services/swap-service/handler/chainflip-handler.js +0 -1
- package/services/swap-service/handler/simpleswap-handler.d.ts +24 -0
- package/services/swap-service/handler/simpleswap-handler.js +434 -0
- package/services/swap-service/index.d.ts +2 -1
- package/services/swap-service/index.js +13 -2
- package/services/swap-service/utils.d.ts +2 -0
- package/services/swap-service/utils.js +10 -1
- package/services/transaction-service/index.js +15 -11
- package/services/transaction-service/utils.d.ts +2 -1
- package/services/transaction-service/utils.js +12 -2
- package/types/account/info/keyring.d.ts +2 -0
- package/types/swap/index.d.ts +15 -3
- package/types/swap/index.js +5 -2
- package/utils/number.d.ts +9 -0
- package/utils/number.js +10 -0
package/types/swap/index.d.ts
CHANGED
|
@@ -40,7 +40,8 @@ export declare enum SwapErrorType {
|
|
|
40
40
|
SWAP_NOT_ENOUGH_BALANCE = "SWAP_NOT_ENOUGH_BALANCE",
|
|
41
41
|
NOT_ENOUGH_LIQUIDITY = "NOT_ENOUGH_LIQUIDITY",
|
|
42
42
|
MAKE_POOL_NOT_ENOUGH_EXISTENTIAL_DEPOSIT = "MAKE_POOL_NOT_ENOUGH_EXISTENTIAL_DEPOSIT",
|
|
43
|
-
AMOUNT_CANNOT_BE_ZERO = "AMOUNT_CANNOT_BE_ZERO"
|
|
43
|
+
AMOUNT_CANNOT_BE_ZERO = "AMOUNT_CANNOT_BE_ZERO",
|
|
44
|
+
NOT_MEET_MIN_EXPECTED = "NOT_MEET_MIN_EXPECTED"
|
|
44
45
|
}
|
|
45
46
|
export declare enum SwapStepType {
|
|
46
47
|
SWAP = "SWAP"
|
|
@@ -52,7 +53,8 @@ export declare enum SwapProviderId {
|
|
|
52
53
|
HYDRADX_TESTNET = "HYDRADX_TESTNET",
|
|
53
54
|
POLKADOT_ASSET_HUB = "POLKADOT_ASSET_HUB",
|
|
54
55
|
KUSAMA_ASSET_HUB = "KUSAMA_ASSET_HUB",
|
|
55
|
-
ROCOCO_ASSET_HUB = "ROCOCO_ASSET_HUB"
|
|
56
|
+
ROCOCO_ASSET_HUB = "ROCOCO_ASSET_HUB",
|
|
57
|
+
SIMPLE_SWAP = "SIMPLE_SWAP"
|
|
56
58
|
}
|
|
57
59
|
export declare const _SUPPORTED_SWAP_PROVIDERS: SwapProviderId[];
|
|
58
60
|
export interface SwapProvider {
|
|
@@ -65,7 +67,7 @@ export declare enum SwapFeeType {
|
|
|
65
67
|
NETWORK_FEE = "NETWORK_FEE",
|
|
66
68
|
WALLET_FEE = "WALLET_FEE"
|
|
67
69
|
}
|
|
68
|
-
export declare type SwapTxData = ChainflipSwapTxData | HydradxSwapTxData;
|
|
70
|
+
export declare type SwapTxData = ChainflipSwapTxData | HydradxSwapTxData | SimpleSwapTxData;
|
|
69
71
|
export interface SwapBaseTxData {
|
|
70
72
|
provider: SwapProvider;
|
|
71
73
|
quote: SwapQuote;
|
|
@@ -79,6 +81,9 @@ export interface ChainflipSwapTxData extends SwapBaseTxData {
|
|
|
79
81
|
depositAddress: string;
|
|
80
82
|
estimatedDepositChannelExpiryTime?: number;
|
|
81
83
|
}
|
|
84
|
+
export interface SimpleSwapTxData extends SwapBaseTxData {
|
|
85
|
+
id: string;
|
|
86
|
+
}
|
|
82
87
|
export interface HydradxSwapTxData extends SwapBaseTxData {
|
|
83
88
|
txHex: string;
|
|
84
89
|
}
|
|
@@ -98,6 +103,11 @@ export interface AssetHubPreValidationMetadata {
|
|
|
98
103
|
quoteRate: string;
|
|
99
104
|
priceImpactPct?: string;
|
|
100
105
|
}
|
|
106
|
+
export interface SimpleSwapValidationMetadata {
|
|
107
|
+
minSwap: AmountData;
|
|
108
|
+
maxSwap: AmountData;
|
|
109
|
+
chain: _ChainInfo;
|
|
110
|
+
}
|
|
101
111
|
export interface QuoteAskResponse {
|
|
102
112
|
quote?: SwapQuote;
|
|
103
113
|
error?: SwapError;
|
|
@@ -109,6 +119,7 @@ export interface SwapRequest {
|
|
|
109
119
|
slippage: number;
|
|
110
120
|
recipient?: string;
|
|
111
121
|
feeToken?: string;
|
|
122
|
+
currentQuote?: SwapProvider;
|
|
112
123
|
}
|
|
113
124
|
export interface SwapRequestResult {
|
|
114
125
|
process: CommonOptimalPath;
|
|
@@ -158,3 +169,4 @@ export interface SlippageType {
|
|
|
158
169
|
isCustomType: boolean;
|
|
159
170
|
}
|
|
160
171
|
export declare const CHAINFLIP_SLIPPAGE = 0.02;
|
|
172
|
+
export declare const SIMPLE_SWAP_SLIPPAGE = 0.05;
|
package/types/swap/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export let SwapErrorType;
|
|
|
16
16
|
SwapErrorType["NOT_ENOUGH_LIQUIDITY"] = "NOT_ENOUGH_LIQUIDITY";
|
|
17
17
|
SwapErrorType["MAKE_POOL_NOT_ENOUGH_EXISTENTIAL_DEPOSIT"] = "MAKE_POOL_NOT_ENOUGH_EXISTENTIAL_DEPOSIT";
|
|
18
18
|
SwapErrorType["AMOUNT_CANNOT_BE_ZERO"] = "AMOUNT_CANNOT_BE_ZERO";
|
|
19
|
+
SwapErrorType["NOT_MEET_MIN_EXPECTED"] = "NOT_MEET_MIN_EXPECTED";
|
|
19
20
|
})(SwapErrorType || (SwapErrorType = {}));
|
|
20
21
|
export let SwapStepType;
|
|
21
22
|
(function (SwapStepType) {
|
|
@@ -30,8 +31,9 @@ export let SwapProviderId;
|
|
|
30
31
|
SwapProviderId["POLKADOT_ASSET_HUB"] = "POLKADOT_ASSET_HUB";
|
|
31
32
|
SwapProviderId["KUSAMA_ASSET_HUB"] = "KUSAMA_ASSET_HUB";
|
|
32
33
|
SwapProviderId["ROCOCO_ASSET_HUB"] = "ROCOCO_ASSET_HUB";
|
|
34
|
+
SwapProviderId["SIMPLE_SWAP"] = "SIMPLE_SWAP";
|
|
33
35
|
})(SwapProviderId || (SwapProviderId = {}));
|
|
34
|
-
export const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET, SwapProviderId.HYDRADX_TESTNET, SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB, SwapProviderId.ROCOCO_ASSET_HUB];
|
|
36
|
+
export const _SUPPORTED_SWAP_PROVIDERS = [SwapProviderId.CHAIN_FLIP_TESTNET, SwapProviderId.CHAIN_FLIP_MAINNET, SwapProviderId.HYDRADX_MAINNET, SwapProviderId.HYDRADX_TESTNET, SwapProviderId.POLKADOT_ASSET_HUB, SwapProviderId.KUSAMA_ASSET_HUB, SwapProviderId.ROCOCO_ASSET_HUB, SwapProviderId.SIMPLE_SWAP];
|
|
35
37
|
// process handling
|
|
36
38
|
export let SwapFeeType;
|
|
37
39
|
(function (SwapFeeType) {
|
|
@@ -39,4 +41,5 @@ export let SwapFeeType;
|
|
|
39
41
|
SwapFeeType["NETWORK_FEE"] = "NETWORK_FEE";
|
|
40
42
|
SwapFeeType["WALLET_FEE"] = "WALLET_FEE";
|
|
41
43
|
})(SwapFeeType || (SwapFeeType = {}));
|
|
42
|
-
export const CHAINFLIP_SLIPPAGE = 0.02; // Example: 0.01 for 1%
|
|
44
|
+
export const CHAINFLIP_SLIPPAGE = 0.02; // Example: 0.01 for 1%
|
|
45
|
+
export const SIMPLE_SWAP_SLIPPAGE = 0.05;
|
package/utils/number.d.ts
CHANGED
|
@@ -10,4 +10,13 @@ export declare const balanceFormatter: NumberFormatter;
|
|
|
10
10
|
export declare const balanceNoPrefixFormater: NumberFormatter;
|
|
11
11
|
export declare const PREDEFINED_FORMATTER: Record<string, NumberFormatter>;
|
|
12
12
|
export declare const toBNString: (input: string | number | BigNumber, decimal: number) => string;
|
|
13
|
+
/** @function formatNumber
|
|
14
|
+
* Convert number to a formatted string by dividing by 10^decimal
|
|
15
|
+
* @param {string | number | BigNumber} input - Input number
|
|
16
|
+
* @param {number} decimal - Decimal number
|
|
17
|
+
* @param {NumberFormatter} [formatter] - Formatter function
|
|
18
|
+
* - Default: balanceFormatter: With number > 1, show decimal with 2 numbers,
|
|
19
|
+
* with number < 1, show decimal with 6 (default) number
|
|
20
|
+
* @param {Record<string, number>} [metadata] - Metadata for formatter
|
|
21
|
+
*/
|
|
13
22
|
export declare const formatNumber: (input: string | number | BigNumber, decimal: number, formatter?: NumberFormatter, metadata?: Record<string, number>) => string;
|
package/utils/number.js
CHANGED
|
@@ -186,6 +186,16 @@ export const toBNString = (input, decimal) => {
|
|
|
186
186
|
const raw = new BigNumber(input);
|
|
187
187
|
return raw.multipliedBy(BN_TEN.pow(decimal)).toFixed();
|
|
188
188
|
};
|
|
189
|
+
|
|
190
|
+
/** @function formatNumber
|
|
191
|
+
* Convert number to a formatted string by dividing by 10^decimal
|
|
192
|
+
* @param {string | number | BigNumber} input - Input number
|
|
193
|
+
* @param {number} decimal - Decimal number
|
|
194
|
+
* @param {NumberFormatter} [formatter] - Formatter function
|
|
195
|
+
* - Default: balanceFormatter: With number > 1, show decimal with 2 numbers,
|
|
196
|
+
* with number < 1, show decimal with 6 (default) number
|
|
197
|
+
* @param {Record<string, number>} [metadata] - Metadata for formatter
|
|
198
|
+
*/
|
|
189
199
|
export const formatNumber = (input, decimal, formatter = balanceFormatter, metadata) => {
|
|
190
200
|
const raw = new BigNumber(input).dividedBy(BN_TEN.pow(decimal)).toFixed();
|
|
191
201
|
return formatter(raw, metadata);
|