@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/checkout.js
CHANGED
|
@@ -138,7 +138,7 @@ const flattenProperties$1 = (properties) => {
|
|
|
138
138
|
};
|
|
139
139
|
|
|
140
140
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
141
|
-
const SDK_VERSION$1 = '1.5.
|
|
141
|
+
const SDK_VERSION$1 = '1.5.2';
|
|
142
142
|
let initialised$1 = false;
|
|
143
143
|
const isInitialised$1 = () => initialised$1;
|
|
144
144
|
const getReferrer$1 = () => {
|
|
@@ -17088,7 +17088,7 @@ const flattenProperties = (properties) => {
|
|
|
17088
17088
|
};
|
|
17089
17089
|
|
|
17090
17090
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
17091
|
-
const SDK_VERSION = '1.5.
|
|
17091
|
+
const SDK_VERSION = '1.5.2';
|
|
17092
17092
|
let initialised = false;
|
|
17093
17093
|
const isInitialised = () => initialised;
|
|
17094
17094
|
const getReferrer = () => {
|
|
@@ -19907,6 +19907,9 @@ const MIN_MAX_HOPS = 1;
|
|
|
19907
19907
|
const BASIS_POINT_PRECISION = 10000;
|
|
19908
19908
|
// 10% maximum secondary fee
|
|
19909
19909
|
const MAX_SECONDARY_FEE_BASIS_POINTS = 1000;
|
|
19910
|
+
// How much more gas does a swap with secondary fees cost?
|
|
19911
|
+
// This number is the average difference of a number of different swaps with different hop amounts, etc.
|
|
19912
|
+
const AVERAGE_SECONDARY_FEE_EXTRA_GAS = 50876;
|
|
19910
19913
|
|
|
19911
19914
|
const quoteReturnMapping = {
|
|
19912
19915
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
@@ -20327,6 +20330,59 @@ startTokenIn = tokenIn) => {
|
|
|
20327
20330
|
return routes;
|
|
20328
20331
|
};
|
|
20329
20332
|
|
|
20333
|
+
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
20334
|
+
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
20335
|
+
|
|
20336
|
+
const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
|
|
20337
|
+
const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
|
|
20338
|
+
|
|
20339
|
+
const NATIVE_IMX_IMMUTABLE_TESTNET = {
|
|
20340
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
20341
|
+
decimals: 18,
|
|
20342
|
+
symbol: 'tIMX',
|
|
20343
|
+
name: 'Immutable Testnet Token',
|
|
20344
|
+
type: 'native',
|
|
20345
|
+
};
|
|
20346
|
+
const WIMX_IMMUTABLE_TESTNET = {
|
|
20347
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
20348
|
+
address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
20349
|
+
decimals: 18,
|
|
20350
|
+
symbol: 'WIMX',
|
|
20351
|
+
name: 'Wrapped Immutable Testnet Token',
|
|
20352
|
+
type: 'erc20',
|
|
20353
|
+
};
|
|
20354
|
+
const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
|
|
20355
|
+
WIMX_IMMUTABLE_TESTNET,
|
|
20356
|
+
];
|
|
20357
|
+
|
|
20358
|
+
const NATIVE_IMX_IMMUTABLE_MAINNET = {
|
|
20359
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
20360
|
+
decimals: 18,
|
|
20361
|
+
symbol: 'IMX',
|
|
20362
|
+
name: 'Immutable Token',
|
|
20363
|
+
type: 'native',
|
|
20364
|
+
};
|
|
20365
|
+
const WIMX_IMMUTABLE_MAINNET = {
|
|
20366
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
20367
|
+
address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
|
|
20368
|
+
decimals: 18,
|
|
20369
|
+
symbol: 'WIMX',
|
|
20370
|
+
name: 'Wrapped Immutable Token',
|
|
20371
|
+
type: 'erc20',
|
|
20372
|
+
};
|
|
20373
|
+
const ETH_IMMUTABLE_MAINNET = {
|
|
20374
|
+
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
20375
|
+
address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
|
|
20376
|
+
decimals: 18,
|
|
20377
|
+
symbol: 'ETH',
|
|
20378
|
+
name: 'Ethereum',
|
|
20379
|
+
type: 'erc20',
|
|
20380
|
+
};
|
|
20381
|
+
const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
|
|
20382
|
+
WIMX_IMMUTABLE_MAINNET,
|
|
20383
|
+
ETH_IMMUTABLE_MAINNET,
|
|
20384
|
+
];
|
|
20385
|
+
|
|
20330
20386
|
const getFeeData = async (provider) => {
|
|
20331
20387
|
const [block, maxPriorityFeePerGas] = await Promise.all([
|
|
20332
20388
|
provider.getBlock('latest'),
|
|
@@ -20362,9 +20418,13 @@ const fetchGasPrice = async (provider, nativeToken) => {
|
|
|
20362
20418
|
* @param {BigNumber} gasEstimate - The total gas units that will be used for the transaction
|
|
20363
20419
|
* @returns - The cost of the transaction in the gas token's smallest denomination (e.g. WEI)
|
|
20364
20420
|
*/
|
|
20365
|
-
const calculateGasFee = (gasPrice, gasEstimate) =>
|
|
20366
|
-
|
|
20367
|
-
|
|
20421
|
+
const calculateGasFee = (hasSecondaryFees, gasPrice, gasEstimate) => {
|
|
20422
|
+
const baseGasFee = newAmount(gasEstimate.mul(gasPrice.value), gasPrice.token);
|
|
20423
|
+
if (!hasSecondaryFees)
|
|
20424
|
+
return baseGasFee;
|
|
20425
|
+
return newAmount(baseGasFee.value.add(gasPrice.value.mul(AVERAGE_SECONDARY_FEE_EXTRA_GAS)), gasPrice.token);
|
|
20426
|
+
// eslint-disable-next-line implicit-arrow-linebreak
|
|
20427
|
+
};
|
|
20368
20428
|
|
|
20369
20429
|
/**
|
|
20370
20430
|
* Check if the spender needs approval for the token
|
|
@@ -20451,7 +20511,7 @@ const getApproval = async (provider, ownerAddress, preparedApproval, gasPrice) =
|
|
|
20451
20511
|
return null;
|
|
20452
20512
|
}
|
|
20453
20513
|
const gasEstimate = await getApproveGasEstimate(provider, ownerAddress, preparedApproval.spender, preparedApproval.amount.token.address);
|
|
20454
|
-
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, gasEstimate) : null;
|
|
20514
|
+
const gasFeeEstimate = gasPrice ? calculateGasFee(false, gasPrice, gasEstimate) : null;
|
|
20455
20515
|
return {
|
|
20456
20516
|
transaction: approveTransaction,
|
|
20457
20517
|
gasFeeEstimate: gasFeeEstimate ? toPublicAmount(gasFeeEstimate) : null,
|
|
@@ -20600,59 +20660,6 @@ const IMX_WRAP_GAS_COST = 45038;
|
|
|
20600
20660
|
// to avoid an extra remote call.
|
|
20601
20661
|
const IMX_UNWRAP_GAS_COST = 35216;
|
|
20602
20662
|
|
|
20603
|
-
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
20604
|
-
const IMMUTABLE_TESTNET_CHAIN_ID = 13473;
|
|
20605
|
-
|
|
20606
|
-
const IMMUTABLE_MAINNET_RPC_URL = 'https://rpc.immutable.com';
|
|
20607
|
-
const IMMUTABLE_MAINNET_CHAIN_ID = 13371;
|
|
20608
|
-
|
|
20609
|
-
const NATIVE_IMX_IMMUTABLE_TESTNET = {
|
|
20610
|
-
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
20611
|
-
decimals: 18,
|
|
20612
|
-
symbol: 'tIMX',
|
|
20613
|
-
name: 'Immutable Testnet Token',
|
|
20614
|
-
type: 'native',
|
|
20615
|
-
};
|
|
20616
|
-
const WIMX_IMMUTABLE_TESTNET = {
|
|
20617
|
-
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
20618
|
-
address: '0x1CcCa691501174B4A623CeDA58cC8f1a76dc3439',
|
|
20619
|
-
decimals: 18,
|
|
20620
|
-
symbol: 'WIMX',
|
|
20621
|
-
name: 'Wrapped Immutable Testnet Token',
|
|
20622
|
-
type: 'erc20',
|
|
20623
|
-
};
|
|
20624
|
-
const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
|
|
20625
|
-
WIMX_IMMUTABLE_TESTNET,
|
|
20626
|
-
];
|
|
20627
|
-
|
|
20628
|
-
const NATIVE_IMX_IMMUTABLE_MAINNET = {
|
|
20629
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
20630
|
-
decimals: 18,
|
|
20631
|
-
symbol: 'IMX',
|
|
20632
|
-
name: 'Immutable Token',
|
|
20633
|
-
type: 'native',
|
|
20634
|
-
};
|
|
20635
|
-
const WIMX_IMMUTABLE_MAINNET = {
|
|
20636
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
20637
|
-
address: '0x3a0c2ba54d6cbd3121f01b96dfd20e99d1696c9d',
|
|
20638
|
-
decimals: 18,
|
|
20639
|
-
symbol: 'WIMX',
|
|
20640
|
-
name: 'Wrapped Immutable Token',
|
|
20641
|
-
type: 'erc20',
|
|
20642
|
-
};
|
|
20643
|
-
const ETH_IMMUTABLE_MAINNET = {
|
|
20644
|
-
chainId: IMMUTABLE_MAINNET_CHAIN_ID,
|
|
20645
|
-
address: '0x52a6c53869ce09a731cd772f245b97a4401d3348',
|
|
20646
|
-
decimals: 18,
|
|
20647
|
-
symbol: 'ETH',
|
|
20648
|
-
name: 'Ethereum',
|
|
20649
|
-
type: 'erc20',
|
|
20650
|
-
};
|
|
20651
|
-
const IMMUTABLE_MAINNET_COMMON_ROUTING_TOKENS = [
|
|
20652
|
-
WIMX_IMMUTABLE_MAINNET,
|
|
20653
|
-
ETH_IMMUTABLE_MAINNET,
|
|
20654
|
-
];
|
|
20655
|
-
|
|
20656
20663
|
const zeroNativeCurrencyValue = '0x00';
|
|
20657
20664
|
const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
|
|
20658
20665
|
function buildSinglePoolSwap(tokenIn, tokenOut, recipient, trade, route, amountIn, amountOut, routerContract, paymentsContract) {
|
|
@@ -20893,8 +20900,8 @@ const getSwapRecipient = (tokenOut, fromAddress, routerContractAddress, secondar
|
|
|
20893
20900
|
function getSwap(tokenIn, tokenOut, adjustedQuote, fromAddress, slippage, deadline, routerContractAddress, secondaryFeesContractAddress, gasPrice, secondaryFees) {
|
|
20894
20901
|
const swapRecipient = getSwapRecipient(tokenOut, fromAddress, routerContractAddress, secondaryFeesContractAddress, secondaryFees);
|
|
20895
20902
|
const { calldata, maximumAmountIn } = createSwapParameters(tokenIn, tokenOut, adjustedQuote, swapRecipient, slippage, deadline, secondaryFees);
|
|
20896
|
-
|
|
20897
|
-
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, adjustedQuote.gasEstimate) : null;
|
|
20903
|
+
const hasSecondaryFees = secondaryFees.length > 0;
|
|
20904
|
+
const gasFeeEstimate = gasPrice ? calculateGasFee(hasSecondaryFees, gasPrice, adjustedQuote.gasEstimate) : null;
|
|
20898
20905
|
const transactionValue = getTransactionValue(tokenIn, maximumAmountIn);
|
|
20899
20906
|
return {
|
|
20900
20907
|
transaction: {
|
|
@@ -21116,7 +21123,7 @@ class Exchange {
|
|
|
21116
21123
|
async getUnwrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
21117
21124
|
const calldata = wimxInterface.encodeFunctionData('withdraw', [tokenAmount]);
|
|
21118
21125
|
const gasEstimate = ethers.BigNumber.from(IMX_UNWRAP_GAS_COST);
|
|
21119
|
-
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
21126
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
|
|
21120
21127
|
// This transaction is for calling calling `withdraw` on the WETH/WIMX contract.
|
|
21121
21128
|
const transactionDetails = {
|
|
21122
21129
|
transaction: {
|
|
@@ -21134,7 +21141,7 @@ class Exchange {
|
|
|
21134
21141
|
getWrapTransaction(fromAddress, tokenAmount, wimxInterface, gasPrice) {
|
|
21135
21142
|
const calldata = wimxInterface.encodeFunctionData('deposit');
|
|
21136
21143
|
const gasEstimate = ethers.BigNumber.from(IMX_WRAP_GAS_COST);
|
|
21137
|
-
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(gasPrice, gasEstimate)) : null;
|
|
21144
|
+
const gasFeeEstimate = gasPrice ? toPublicAmount(calculateGasFee(false, gasPrice, gasEstimate)) : null;
|
|
21138
21145
|
// This transaction is for calling calling `deposit` on the WETH/WIMX contract.
|
|
21139
21146
|
const transactionDetails = {
|
|
21140
21147
|
transaction: {
|
|
@@ -27266,7 +27273,7 @@ class APIError extends Error {
|
|
|
27266
27273
|
|
|
27267
27274
|
/* eslint-disable implicit-arrow-linebreak */
|
|
27268
27275
|
const defaultHeaders = {
|
|
27269
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.
|
|
27276
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-1.5.2',
|
|
27270
27277
|
};
|
|
27271
27278
|
/**
|
|
27272
27279
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -28633,7 +28640,7 @@ const IMMUTABLE_ZKVEM_GAS_OVERRIDES = {
|
|
|
28633
28640
|
maxPriorityFeePerGas: BigNumber$1.from(10e9),
|
|
28634
28641
|
};
|
|
28635
28642
|
|
|
28636
|
-
const SDK_VERSION_MARKER = '1.5.
|
|
28643
|
+
const SDK_VERSION_MARKER = '1.5.2';
|
|
28637
28644
|
// This SDK version is replaced by the `yarn build` command ran on the root level
|
|
28638
28645
|
const globalPackageVersion = () => SDK_VERSION_MARKER;
|
|
28639
28646
|
|
package/dist/config.js
CHANGED
|
@@ -127,7 +127,7 @@ const flattenProperties = (properties) => {
|
|
|
127
127
|
};
|
|
128
128
|
|
|
129
129
|
// WARNING: DO NOT CHANGE THE STRING BELOW. IT GETS REPLACED AT BUILD TIME.
|
|
130
|
-
const SDK_VERSION = '1.5.
|
|
130
|
+
const SDK_VERSION = '1.5.2';
|
|
131
131
|
let initialised = false;
|
|
132
132
|
const isInitialised = () => initialised;
|
|
133
133
|
const getReferrer = () => {
|