@imtbl/sdk 1.5.1 → 1.5.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/dist/blockchain_data.js +2 -2
- package/dist/browser/checkout/sdk.js +6 -6
- package/dist/browser/checkout/widgets.js +61 -61
- package/dist/checkout.js +72 -65
- package/dist/config.js +1 -1
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +74 -67
- package/dist/index.js +74 -67
- package/dist/orderbook.js +1 -1
- package/dist/passport.js +3 -3
- package/dist/x.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -173,7 +173,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
173
173
|
};
|
|
174
174
|
|
|
175
175
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
176
|
-
const SDK_VERSION$1 = '1.5.
|
|
176
|
+
const SDK_VERSION$1 = '1.5.2';
|
|
177
177
|
let initialised$1 = false;
|
|
178
178
|
const isInitialised$1 = () => initialised$1;
|
|
179
179
|
const getReferrer$1 = () => {
|
|
@@ -11260,7 +11260,7 @@ class MultiRollupApiClients {
|
|
|
11260
11260
|
}
|
|
11261
11261
|
|
|
11262
11262
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11263
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.
|
|
11263
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.2' };
|
|
11264
11264
|
const createConfig = ({ basePath, headers, }) => {
|
|
11265
11265
|
if (!basePath.trim()) {
|
|
11266
11266
|
throw Error('basePath can not be empty');
|
|
@@ -11332,7 +11332,7 @@ class APIError extends Error {
|
|
|
11332
11332
|
|
|
11333
11333
|
/* eslint-disable implicit-arrow-linebreak */
|
|
11334
11334
|
const defaultHeaders = {
|
|
11335
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.
|
|
11335
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.2',
|
|
11336
11336
|
};
|
|
11337
11337
|
/**
|
|
11338
11338
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11765,7 +11765,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11765
11765
|
chainID,
|
|
11766
11766
|
coreContractAddress,
|
|
11767
11767
|
registrationContractAddress,
|
|
11768
|
-
sdkVersion: 'ts-immutable-sdk-1.5.
|
|
11768
|
+
sdkVersion: 'ts-immutable-sdk-1.5.2',
|
|
11769
11769
|
});
|
|
11770
11770
|
/**
|
|
11771
11771
|
* Sets `sdkVersion` at the time of build
|
|
@@ -37066,7 +37066,7 @@ const flattenProperties = (properties) => {
|
|
|
37066
37066
|
};
|
|
37067
37067
|
|
|
37068
37068
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
37069
|
-
const SDK_VERSION = '1.5.
|
|
37069
|
+
const SDK_VERSION = '1.5.2';
|
|
37070
37070
|
let initialised = false;
|
|
37071
37071
|
const isInitialised = () => initialised;
|
|
37072
37072
|
const getReferrer = () => {
|
|
@@ -39885,6 +39885,9 @@ const MIN_MAX_HOPS = 1;
|
|
|
39885
39885
|
const BASIS_POINT_PRECISION = 10000;
|
|
39886
39886
|
// 10% maximum secondary fee
|
|
39887
39887
|
const MAX_SECONDARY_FEE_BASIS_POINTS = 1000;
|
|
39888
|
+
// How much more gas does a swap with secondary fees cost?
|
|
39889
|
+
// This number is the average difference of a number of different swaps with different hop amounts, etc.
|
|
39890
|
+
const AVERAGE_SECONDARY_FEE_EXTRA_GAS = 50876;
|
|
39888
39891
|
|
|
39889
39892
|
const quoteReturnMapping = {
|
|
39890
39893
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -40305,6 +40308,59 @@ startTokenIn = tokenIn) => {
|
|
|
40305
40308
|
return routes;
|
|
40306
40309
|
};
|
|
40307
40310
|
|
|
40311
|
+
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
40312
|
+
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
40313
|
+
|
|
40314
|
+
const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
|
|
40315
|
+
const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
|
|
40316
|
+
|
|
40317
|
+
const NATIVE_IMX_IMMUTABLE_TESTNET = {
|
|
40318
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40319
|
+
decimals: 18,
|
|
40320
|
+
symbol: 'tIMX',
|
|
40321
|
+
name: 'Immutable Testnet Token',
|
|
40322
|
+
type: 'native',
|
|
40323
|
+
};
|
|
40324
|
+
const WIMX_IMMUTABLE_TESTNET = {
|
|
40325
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40326
|
+
address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
40327
|
+
decimals: 18,
|
|
40328
|
+
symbol: 'WIMX',
|
|
40329
|
+
name: 'Wrapped Immutable Testnet Token',
|
|
40330
|
+
type: 'erc20',
|
|
40331
|
+
};
|
|
40332
|
+
const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
|
|
40333
|
+
WIMX_IMMUTABLE_TESTNET,
|
|
40334
|
+
];
|
|
40335
|
+
|
|
40336
|
+
const NATIVE_IMX_IMMUTABLE_MAINNET = {
|
|
40337
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40338
|
+
decimals: 18,
|
|
40339
|
+
symbol: 'IMX',
|
|
40340
|
+
name: 'Immutable Token',
|
|
40341
|
+
type: 'native',
|
|
40342
|
+
};
|
|
40343
|
+
const WIMX_IMMUTABLE_MAINNET = {
|
|
40344
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40345
|
+
address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
|
|
40346
|
+
decimals: 18,
|
|
40347
|
+
symbol: 'WIMX',
|
|
40348
|
+
name: 'Wrapped Immutable Token',
|
|
40349
|
+
type: 'erc20',
|
|
40350
|
+
};
|
|
40351
|
+
const ETH_IMMUTABLE_MAINNET = {
|
|
40352
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40353
|
+
address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
|
|
40354
|
+
decimals: 18,
|
|
40355
|
+
symbol: 'ETH',
|
|
40356
|
+
name: 'Ethereum',
|
|
40357
|
+
type: 'erc20',
|
|
40358
|
+
};
|
|
40359
|
+
const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
|
|
40360
|
+
WIMX_IMMUTABLE_MAINNET,
|
|
40361
|
+
ETH_IMMUTABLE_MAINNET,
|
|
40362
|
+
];
|
|
40363
|
+
|
|
40308
40364
|
const getFeeData = async (provider) => {
|
|
40309
40365
|
const [block, maxPriorityFeePerGas] = await Promise.all([
|
|
40310
40366
|
provider.getBlock('latest'),
|
|
@@ -40340,9 +40396,13 @@ const fetchGasPrice = async (provider, nativeToken) => {
|
|
|
40340
40396
|
* @param {BigNumber} gasEstimate - The total gas units that will be used for the transaction
|
|
40341
40397
|
* @returns - The cost of the transaction in the gas token's smallest denomination (e.g. WEI)
|
|
40342
40398
|
*/
|
|
40343
|
-
const calculateGasFee = (gasPrice, gasEstimate) =>
|
|
40344
|
-
|
|
40345
|
-
|
|
40399
|
+
const calculateGasFee = (hasSecondaryFees, gasPrice, gasEstimate) => {
|
|
40400
|
+
const baseGasFee = newAmount(gasEstimate.mul(gasPrice.value), gasPrice.token);
|
|
40401
|
+
if (!hasSecondaryFees)
|
|
40402
|
+
return baseGasFee;
|
|
40403
|
+
return newAmount(baseGasFee.value.add(gasPrice.value.mul(AVERAGE_SECONDARY_FEE_EXTRA_GAS)), gasPrice.token);
|
|
40404
|
+
// eslint-disable-next-line implicit-arrow-linebreak
|
|
40405
|
+
};
|
|
40346
40406
|
|
|
40347
40407
|
/**
|
|
40348
40408
|
* Check if the spender needs approval for the token
|
|
@@ -40429,7 +40489,7 @@ const getApproval = async (provider, ownerAddress, preparedApproval, gasPrice) =
|
|
|
40429
40489
|
return null;
|
|
40430
40490
|
}
|
|
40431
40491
|
const gasEstimate = await getApproveGasEstimate(provider, ownerAddress, preparedApproval.spender, preparedApproval.amount.token.address);
|
|
40432
|
-
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, gasEstimate) : null;
|
|
40492
|
+
const gasFeeEstimate = gasPrice ? calculateGasFee(false, gasPrice, gasEstimate) : null;
|
|
40433
40493
|
return {
|
|
40434
40494
|
transaction: approveTransaction,
|
|
40435
40495
|
gasFeeEstimate: gasFeeEstimate ? toPublicAmount(gasFeeEstimate) : null,
|
|
@@ -40578,59 +40638,6 @@ const IMX_WRAP_GAS_COST = 45038;
|
|
|
40578
40638
|
// to avoid an extra remote call.
|
|
40579
40639
|
const IMX_UNWRAP_GAS_COST = 35216;
|
|
40580
40640
|
|
|
40581
|
-
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
40582
|
-
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
40583
|
-
|
|
40584
|
-
const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
|
|
40585
|
-
const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
|
|
40586
|
-
|
|
40587
|
-
const NATIVE_IMX_IMMUTABLE_TESTNET = {
|
|
40588
|
-
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40589
|
-
decimals: 18,
|
|
40590
|
-
symbol: 'tIMX',
|
|
40591
|
-
name: 'Immutable Testnet Token',
|
|
40592
|
-
type: 'native',
|
|
40593
|
-
};
|
|
40594
|
-
const WIMX_IMMUTABLE_TESTNET = {
|
|
40595
|
-
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40596
|
-
address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
40597
|
-
decimals: 18,
|
|
40598
|
-
symbol: 'WIMX',
|
|
40599
|
-
name: 'Wrapped Immutable Testnet Token',
|
|
40600
|
-
type: 'erc20',
|
|
40601
|
-
};
|
|
40602
|
-
const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
|
|
40603
|
-
WIMX_IMMUTABLE_TESTNET,
|
|
40604
|
-
];
|
|
40605
|
-
|
|
40606
|
-
const NATIVE_IMX_IMMUTABLE_MAINNET = {
|
|
40607
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40608
|
-
decimals: 18,
|
|
40609
|
-
symbol: 'IMX',
|
|
40610
|
-
name: 'Immutable Token',
|
|
40611
|
-
type: 'native',
|
|
40612
|
-
};
|
|
40613
|
-
const WIMX_IMMUTABLE_MAINNET = {
|
|
40614
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40615
|
-
address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
|
|
40616
|
-
decimals: 18,
|
|
40617
|
-
symbol: 'WIMX',
|
|
40618
|
-
name: 'Wrapped Immutable Token',
|
|
40619
|
-
type: 'erc20',
|
|
40620
|
-
};
|
|
40621
|
-
const ETH_IMMUTABLE_MAINNET = {
|
|
40622
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40623
|
-
address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
|
|
40624
|
-
decimals: 18,
|
|
40625
|
-
symbol: 'ETH',
|
|
40626
|
-
name: 'Ethereum',
|
|
40627
|
-
type: 'erc20',
|
|
40628
|
-
};
|
|
40629
|
-
const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
|
|
40630
|
-
WIMX_IMMUTABLE_MAINNET,
|
|
40631
|
-
ETH_IMMUTABLE_MAINNET,
|
|
40632
|
-
];
|
|
40633
|
-
|
|
40634
40641
|
const zeroNativeCurrencyValue = '0x00';
|
|
40635
40642
|
const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
|
|
40636
40643
|
function buildSinglePoolSwap(tokenIn, tokenOut, recipient, trade, route, amountIn, amountOut, routerContract, paymentsContract) {
|
|
@@ -40871,8 +40878,8 @@ const getSwapRecipient = (tokenOut, fromAddress, routerContractAddress, secondar
|
|
|
40871
40878
|
function getSwap(tokenIn, tokenOut, adjustedQuote, fromAddress, slippage, deadline, routerContractAddress, secondaryFeesContractAddress, gasPrice, secondaryFees) {
|
|
40872
40879
|
const swapRecipient = getSwapRecipient(tokenOut, fromAddress, routerContractAddress, secondaryFeesContractAddress, secondaryFees);
|
|
40873
40880
|
const { calldata, maximumAmountIn } = createSwapParameters(tokenIn, tokenOut, adjustedQuote, swapRecipient, slippage, deadline, secondaryFees);
|
|
40874
|
-
|
|
40875
|
-
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, adjustedQuote.gasEstimate) : null;
|
|
40881
|
+
const hasSecondaryFees = secondaryFees.length > 0;
|
|
40882
|
+
const gasFeeEstimate = gasPrice ? calculateGasFee(hasSecondaryFees, gasPrice, adjustedQuote.gasEstimate) : null;
|
|
40876
40883
|
const transactionValue = getTransactionValue(tokenIn, maximumAmountIn);
|
|
40877
40884
|
return {
|
|
40878
40885
|
transaction: {
|
|
@@ -41094,7 +41101,7 @@ class Exchange {
|
|
|
41094
41101
|
async getUnwrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
41095
41102
|
const calldata = wimxInterface.encodeFunctionData('withdraw', [tokenAmount]);
|
|
41096
41103
|
const gasEstimate = ethers.ethers.BigNumber.from(IMX_UNWRAP_GAS_COST);
|
|
41097
|
-
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
41104
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
|
|
41098
41105
|
// This transaction is for calling calling `withdraw` on the WETH/WIMX contract.
|
|
41099
41106
|
const transactionDetails = {
|
|
41100
41107
|
transaction: {
|
|
@@ -41112,7 +41119,7 @@ class Exchange {
|
|
|
41112
41119
|
getWrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
41113
41120
|
const calldata = wimxInterface.encodeFunctionData('deposit');
|
|
41114
41121
|
const gasEstimate = ethers.ethers.BigNumber.from(IMX_WRAP_GAS_COST);
|
|
41115
|
-
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
41122
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
|
|
41116
41123
|
// This transaction is for calling calling `deposit` on the WETH/WIMX contract.
|
|
41117
41124
|
const transactionDetails = {
|
|
41118
41125
|
transaction: {
|
|
@@ -42174,7 +42181,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
42174
42181
|
maxPriorityFeePerGas: ethers.BigNumber.from(10e9),
|
|
42175
42182
|
};
|
|
42176
42183
|
|
|
42177
|
-
const SDK_VERSION_MARKER = '1.5.
|
|
42184
|
+
const SDK_VERSION_MARKER = '1.5.2';
|
|
42178
42185
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
42179
42186
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
42180
42187
|
|
package/dist/index.js
CHANGED
|
@@ -151,7 +151,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
151
151
|
};
|
|
152
152
|
|
|
153
153
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
154
|
-
const SDK_VERSION$1 = '1.5.
|
|
154
|
+
const SDK_VERSION$1 = '1.5.2';
|
|
155
155
|
let initialised$1 = false;
|
|
156
156
|
const isInitialised$1 = () => initialised$1;
|
|
157
157
|
const getReferrer$1 = () => {
|
|
@@ -11238,7 +11238,7 @@ class MultiRollupApiClients {
|
|
|
11238
11238
|
}
|
|
11239
11239
|
|
|
11240
11240
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
11241
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.
|
|
11241
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-1.5.2' };
|
|
11242
11242
|
const createConfig = ({ basePath, headers, }) => {
|
|
11243
11243
|
if (!basePath.trim()) {
|
|
11244
11244
|
throw Error('basePath can not be empty');
|
|
@@ -11310,7 +11310,7 @@ class APIError extends Error {
|
|
|
11310
11310
|
|
|
11311
11311
|
/* eslint-disable implicit-arrow-linebreak */
|
|
11312
11312
|
const defaultHeaders = {
|
|
11313
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.
|
|
11313
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.2',
|
|
11314
11314
|
};
|
|
11315
11315
|
/**
|
|
11316
11316
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -11743,7 +11743,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
11743
11743
|
chainID,
|
|
11744
11744
|
coreContractAddress,
|
|
11745
11745
|
registrationContractAddress,
|
|
11746
|
-
sdkVersion: 'ts-immutable-sdk-1.5.
|
|
11746
|
+
sdkVersion: 'ts-immutable-sdk-1.5.2',
|
|
11747
11747
|
});
|
|
11748
11748
|
/**
|
|
11749
11749
|
* Sets `sdkVersion` at the time of build
|
|
@@ -37044,7 +37044,7 @@ const flattenProperties = (properties) => {
|
|
|
37044
37044
|
};
|
|
37045
37045
|
|
|
37046
37046
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
37047
|
-
const SDK_VERSION = '1.5.
|
|
37047
|
+
const SDK_VERSION = '1.5.2';
|
|
37048
37048
|
let initialised = false;
|
|
37049
37049
|
const isInitialised = () => initialised;
|
|
37050
37050
|
const getReferrer = () => {
|
|
@@ -39863,6 +39863,9 @@ const MIN_MAX_HOPS = 1;
|
|
|
39863
39863
|
const BASIS_POINT_PRECISION = 10000;
|
|
39864
39864
|
// 10% maximum secondary fee
|
|
39865
39865
|
const MAX_SECONDARY_FEE_BASIS_POINTS = 1000;
|
|
39866
|
+
// How much more gas does a swap with secondary fees cost?
|
|
39867
|
+
// This number is the average difference of a number of different swaps with different hop amounts, etc.
|
|
39868
|
+
const AVERAGE_SECONDARY_FEE_EXTRA_GAS = 50876;
|
|
39866
39869
|
|
|
39867
39870
|
const quoteReturnMapping = {
|
|
39868
39871
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -40283,6 +40286,59 @@ startTokenIn = tokenIn) => {
|
|
|
40283
40286
|
return routes;
|
|
40284
40287
|
};
|
|
40285
40288
|
|
|
40289
|
+
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
40290
|
+
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
40291
|
+
|
|
40292
|
+
const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
|
|
40293
|
+
const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
|
|
40294
|
+
|
|
40295
|
+
const NATIVE_IMX_IMMUTABLE_TESTNET = {
|
|
40296
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40297
|
+
decimals: 18,
|
|
40298
|
+
symbol: 'tIMX',
|
|
40299
|
+
name: 'Immutable Testnet Token',
|
|
40300
|
+
type: 'native',
|
|
40301
|
+
};
|
|
40302
|
+
const WIMX_IMMUTABLE_TESTNET = {
|
|
40303
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40304
|
+
address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
40305
|
+
decimals: 18,
|
|
40306
|
+
symbol: 'WIMX',
|
|
40307
|
+
name: 'Wrapped Immutable Testnet Token',
|
|
40308
|
+
type: 'erc20',
|
|
40309
|
+
};
|
|
40310
|
+
const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
|
|
40311
|
+
WIMX_IMMUTABLE_TESTNET,
|
|
40312
|
+
];
|
|
40313
|
+
|
|
40314
|
+
const NATIVE_IMX_IMMUTABLE_MAINNET = {
|
|
40315
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40316
|
+
decimals: 18,
|
|
40317
|
+
symbol: 'IMX',
|
|
40318
|
+
name: 'Immutable Token',
|
|
40319
|
+
type: 'native',
|
|
40320
|
+
};
|
|
40321
|
+
const WIMX_IMMUTABLE_MAINNET = {
|
|
40322
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40323
|
+
address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
|
|
40324
|
+
decimals: 18,
|
|
40325
|
+
symbol: 'WIMX',
|
|
40326
|
+
name: 'Wrapped Immutable Token',
|
|
40327
|
+
type: 'erc20',
|
|
40328
|
+
};
|
|
40329
|
+
const ETH_IMMUTABLE_MAINNET = {
|
|
40330
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40331
|
+
address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
|
|
40332
|
+
decimals: 18,
|
|
40333
|
+
symbol: 'ETH',
|
|
40334
|
+
name: 'Ethereum',
|
|
40335
|
+
type: 'erc20',
|
|
40336
|
+
};
|
|
40337
|
+
const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
|
|
40338
|
+
WIMX_IMMUTABLE_MAINNET,
|
|
40339
|
+
ETH_IMMUTABLE_MAINNET,
|
|
40340
|
+
];
|
|
40341
|
+
|
|
40286
40342
|
const getFeeData = async (provider) => {
|
|
40287
40343
|
const [block, maxPriorityFeePerGas] = await Promise.all([
|
|
40288
40344
|
provider.getBlock('latest'),
|
|
@@ -40318,9 +40374,13 @@ const fetchGasPrice = async (provider, nativeToken) => {
|
|
|
40318
40374
|
* @param {BigNumber} gasEstimate - The total gas units that will be used for the transaction
|
|
40319
40375
|
* @returns - The cost of the transaction in the gas token's smallest denomination (e.g. WEI)
|
|
40320
40376
|
*/
|
|
40321
|
-
const calculateGasFee = (gasPrice, gasEstimate) =>
|
|
40322
|
-
|
|
40323
|
-
|
|
40377
|
+
const calculateGasFee = (hasSecondaryFees, gasPrice, gasEstimate) => {
|
|
40378
|
+
const baseGasFee = newAmount(gasEstimate.mul(gasPrice.value), gasPrice.token);
|
|
40379
|
+
if (!hasSecondaryFees)
|
|
40380
|
+
return baseGasFee;
|
|
40381
|
+
return newAmount(baseGasFee.value.add(gasPrice.value.mul(AVERAGE_SECONDARY_FEE_EXTRA_GAS)), gasPrice.token);
|
|
40382
|
+
// eslint-disable-next-line implicit-arrow-linebreak
|
|
40383
|
+
};
|
|
40324
40384
|
|
|
40325
40385
|
/**
|
|
40326
40386
|
* Check if the spender needs approval for the token
|
|
@@ -40407,7 +40467,7 @@ const getApproval = async (provider, ownerAddress, preparedApproval, gasPrice) =
|
|
|
40407
40467
|
return null;
|
|
40408
40468
|
}
|
|
40409
40469
|
const gasEstimate = await getApproveGasEstimate(provider, ownerAddress, preparedApproval.spender, preparedApproval.amount.token.address);
|
|
40410
|
-
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, gasEstimate) : null;
|
|
40470
|
+
const gasFeeEstimate = gasPrice ? calculateGasFee(false, gasPrice, gasEstimate) : null;
|
|
40411
40471
|
return {
|
|
40412
40472
|
transaction: approveTransaction,
|
|
40413
40473
|
gasFeeEstimate: gasFeeEstimate ? toPublicAmount(gasFeeEstimate) : null,
|
|
@@ -40556,59 +40616,6 @@ const IMX_WRAP_GAS_COST = 45038;
|
|
|
40556
40616
|
// to avoid an extra remote call.
|
|
40557
40617
|
const IMX_UNWRAP_GAS_COST = 35216;
|
|
40558
40618
|
|
|
40559
|
-
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
40560
|
-
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
40561
|
-
|
|
40562
|
-
const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
|
|
40563
|
-
const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
|
|
40564
|
-
|
|
40565
|
-
const NATIVE_IMX_IMMUTABLE_TESTNET = {
|
|
40566
|
-
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40567
|
-
decimals: 18,
|
|
40568
|
-
symbol: 'tIMX',
|
|
40569
|
-
name: 'Immutable Testnet Token',
|
|
40570
|
-
type: 'native',
|
|
40571
|
-
};
|
|
40572
|
-
const WIMX_IMMUTABLE_TESTNET = {
|
|
40573
|
-
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
40574
|
-
address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
40575
|
-
decimals: 18,
|
|
40576
|
-
symbol: 'WIMX',
|
|
40577
|
-
name: 'Wrapped Immutable Testnet Token',
|
|
40578
|
-
type: 'erc20',
|
|
40579
|
-
};
|
|
40580
|
-
const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
|
|
40581
|
-
WIMX_IMMUTABLE_TESTNET,
|
|
40582
|
-
];
|
|
40583
|
-
|
|
40584
|
-
const NATIVE_IMX_IMMUTABLE_MAINNET = {
|
|
40585
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40586
|
-
decimals: 18,
|
|
40587
|
-
symbol: 'IMX',
|
|
40588
|
-
name: 'Immutable Token',
|
|
40589
|
-
type: 'native',
|
|
40590
|
-
};
|
|
40591
|
-
const WIMX_IMMUTABLE_MAINNET = {
|
|
40592
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40593
|
-
address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
|
|
40594
|
-
decimals: 18,
|
|
40595
|
-
symbol: 'WIMX',
|
|
40596
|
-
name: 'Wrapped Immutable Token',
|
|
40597
|
-
type: 'erc20',
|
|
40598
|
-
};
|
|
40599
|
-
const ETH_IMMUTABLE_MAINNET = {
|
|
40600
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
40601
|
-
address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
|
|
40602
|
-
decimals: 18,
|
|
40603
|
-
symbol: 'ETH',
|
|
40604
|
-
name: 'Ethereum',
|
|
40605
|
-
type: 'erc20',
|
|
40606
|
-
};
|
|
40607
|
-
const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
|
|
40608
|
-
WIMX_IMMUTABLE_MAINNET,
|
|
40609
|
-
ETH_IMMUTABLE_MAINNET,
|
|
40610
|
-
];
|
|
40611
|
-
|
|
40612
40619
|
const zeroNativeCurrencyValue = '0x00';
|
|
40613
40620
|
const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
|
|
40614
40621
|
function buildSinglePoolSwap(tokenIn, tokenOut, recipient, trade, route, amountIn, amountOut, routerContract, paymentsContract) {
|
|
@@ -40849,8 +40856,8 @@ const getSwapRecipient = (tokenOut, fromAddress, routerContractAddress, secondar
|
|
|
40849
40856
|
function getSwap(tokenIn, tokenOut, adjustedQuote, fromAddress, slippage, deadline, routerContractAddress, secondaryFeesContractAddress, gasPrice, secondaryFees) {
|
|
40850
40857
|
const swapRecipient = getSwapRecipient(tokenOut, fromAddress, routerContractAddress, secondaryFeesContractAddress, secondaryFees);
|
|
40851
40858
|
const { calldata, maximumAmountIn } = createSwapParameters(tokenIn, tokenOut, adjustedQuote, swapRecipient, slippage, deadline, secondaryFees);
|
|
40852
|
-
|
|
40853
|
-
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, adjustedQuote.gasEstimate) : null;
|
|
40859
|
+
const hasSecondaryFees = secondaryFees.length > 0;
|
|
40860
|
+
const gasFeeEstimate = gasPrice ? calculateGasFee(hasSecondaryFees, gasPrice, adjustedQuote.gasEstimate) : null;
|
|
40854
40861
|
const transactionValue = getTransactionValue(tokenIn, maximumAmountIn);
|
|
40855
40862
|
return {
|
|
40856
40863
|
transaction: {
|
|
@@ -41072,7 +41079,7 @@ class Exchange {
|
|
|
41072
41079
|
async getUnwrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
41073
41080
|
const calldata = wimxInterface.encodeFunctionData('withdraw', [tokenAmount]);
|
|
41074
41081
|
const gasEstimate = ethers.BigNumber.from(IMX_UNWRAP_GAS_COST);
|
|
41075
|
-
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
41082
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
|
|
41076
41083
|
// This transaction is for calling calling `withdraw` on the WETH/WIMX contract.
|
|
41077
41084
|
const transactionDetails = {
|
|
41078
41085
|
transaction: {
|
|
@@ -41090,7 +41097,7 @@ class Exchange {
|
|
|
41090
41097
|
getWrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
41091
41098
|
const calldata = wimxInterface.encodeFunctionData('deposit');
|
|
41092
41099
|
const gasEstimate = ethers.BigNumber.from(IMX_WRAP_GAS_COST);
|
|
41093
|
-
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
41100
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
|
|
41094
41101
|
// This transaction is for calling calling `deposit` on the WETH/WIMX contract.
|
|
41095
41102
|
const transactionDetails = {
|
|
41096
41103
|
transaction: {
|
|
@@ -42152,7 +42159,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
42152
42159
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
42153
42160
|
};
|
|
42154
42161
|
|
|
42155
|
-
const SDK_VERSION_MARKER = '1.5.
|
|
42162
|
+
const SDK_VERSION_MARKER = '1.5.2';
|
|
42156
42163
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
42157
42164
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
42158
42165
|
|
package/dist/orderbook.js
CHANGED
|
@@ -126,7 +126,7 @@ const flattenProperties = (properties) => {
|
|
|
126
126
|
};
|
|
127
127
|
|
|
128
128
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
129
|
-
const SDK_VERSION = '1.5.
|
|
129
|
+
const SDK_VERSION = '1.5.2';
|
|
130
130
|
let initialised = false;
|
|
131
131
|
const isInitialised = () => initialised;
|
|
132
132
|
const getReferrer = () => {
|
package/dist/passport.js
CHANGED
|
@@ -9136,7 +9136,7 @@ class MultiRollupApiClients {
|
|
|
9136
9136
|
}
|
|
9137
9137
|
|
|
9138
9138
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9139
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.5.
|
|
9139
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-1.5.2' };
|
|
9140
9140
|
const createConfig = ({ basePath, headers, }) => {
|
|
9141
9141
|
if (!basePath.trim()) {
|
|
9142
9142
|
throw Error('basePath can not be empty');
|
|
@@ -9316,7 +9316,7 @@ const flattenProperties = (properties) => {
|
|
|
9316
9316
|
};
|
|
9317
9317
|
|
|
9318
9318
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
9319
|
-
const SDK_VERSION = '1.5.
|
|
9319
|
+
const SDK_VERSION = '1.5.2';
|
|
9320
9320
|
let initialised = false;
|
|
9321
9321
|
const isInitialised = () => initialised;
|
|
9322
9322
|
const getReferrer = () => {
|
|
@@ -9491,7 +9491,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
9491
9491
|
chainID,
|
|
9492
9492
|
coreContractAddress,
|
|
9493
9493
|
registrationContractAddress,
|
|
9494
|
-
sdkVersion: 'ts-immutable-sdk-1.5.
|
|
9494
|
+
sdkVersion: 'ts-immutable-sdk-1.5.2',
|
|
9495
9495
|
});
|
|
9496
9496
|
/**
|
|
9497
9497
|
* Sets `sdkVersion` at the time of build
|
package/dist/x.js
CHANGED
|
@@ -131,7 +131,7 @@ const flattenProperties = (properties) => {
|
|
|
131
131
|
};
|
|
132
132
|
|
|
133
133
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
134
|
-
const SDK_VERSION = '1.5.
|
|
134
|
+
const SDK_VERSION = '1.5.2';
|
|
135
135
|
let initialised = false;
|
|
136
136
|
const isInitialised = () => initialised;
|
|
137
137
|
const getReferrer = () => {
|
|
@@ -270,7 +270,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
270
270
|
chainID,
|
|
271
271
|
coreContractAddress,
|
|
272
272
|
registrationContractAddress,
|
|
273
|
-
sdkVersion: 'ts-immutable-sdk-1.5.
|
|
273
|
+
sdkVersion: 'ts-immutable-sdk-1.5.2',
|
|
274
274
|
});
|
|
275
275
|
/**
|
|
276
276
|
* Sets `sdkVersion` at the time of build
|
package/package.json
CHANGED