@imtbl/sdk 0.4.4-alpha.1 → 0.6.0-alpha
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 +1 -1
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.d.ts +1 -1
- package/dist/checkout_sdk.js +173 -128
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +8 -8
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +220 -158
- package/dist/index.d.ts +1 -1
- package/dist/index.js +220 -158
- package/dist/passport.js +45 -28
- package/package.json +1 -1
package/dist/checkout_sdk.d.ts
CHANGED
package/dist/checkout_sdk.js
CHANGED
|
@@ -23,6 +23,63 @@ class ImmutableConfiguration {
|
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
/**
|
|
27
|
+
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
28
|
+
*/
|
|
29
|
+
const ETH_SEPOLIA_CHAIN_ID = '11155111';
|
|
30
|
+
/**
|
|
31
|
+
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
32
|
+
*/
|
|
33
|
+
const ETH_MAINNET_CHAIN_ID = '1';
|
|
34
|
+
/**
|
|
35
|
+
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
36
|
+
*/
|
|
37
|
+
const ZKEVM_DEVNET_CHAIN_ID = '13433';
|
|
38
|
+
/**
|
|
39
|
+
/**
|
|
40
|
+
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
41
|
+
*/
|
|
42
|
+
const ZKEVM_TESTNET_CHAIN_ID = '13472';
|
|
43
|
+
/**
|
|
44
|
+
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
45
|
+
*/
|
|
46
|
+
const ZKEVM_MAINNET_CHAIN_ID = '13371';
|
|
47
|
+
/**
|
|
48
|
+
* @constant {string} L2_STATE_SENDER_ADDRESS - Address of bridge contract to the rootchain
|
|
49
|
+
*/
|
|
50
|
+
const L2_STATE_SENDER_ADDRESS = '0x0000000000000000000000000000000000001002';
|
|
51
|
+
/**
|
|
52
|
+
* The constant value representing the native token in the token bridge context.
|
|
53
|
+
* The key is used to indicate the native token of a blockchain network (like Ether in Ethereum)
|
|
54
|
+
* in methods that normally require a token address.
|
|
55
|
+
* @constant {string}
|
|
56
|
+
*/
|
|
57
|
+
const NATIVE_TOKEN_BRIDGE_KEY = '0x0000000000000000000000000000000000000001';
|
|
58
|
+
/**
|
|
59
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
|
|
60
|
+
* the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
61
|
+
*/
|
|
62
|
+
const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
|
|
63
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
64
|
+
childChainID: ZKEVM_DEVNET_CHAIN_ID,
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
|
|
68
|
+
* between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
69
|
+
*/
|
|
70
|
+
const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
|
|
71
|
+
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
72
|
+
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
|
|
76
|
+
* between the Ethereum mainnet and the zkEVM mainnet.
|
|
77
|
+
*/
|
|
78
|
+
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
79
|
+
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
80
|
+
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
81
|
+
};
|
|
82
|
+
|
|
26
83
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
27
84
|
|
|
28
85
|
function getDefaultExportFromCjs (x) {
|
|
@@ -10888,63 +10945,6 @@ function decodeExtraData(extraData) {
|
|
|
10888
10945
|
return blockExtraData;
|
|
10889
10946
|
}
|
|
10890
10947
|
|
|
10891
|
-
/**
|
|
10892
|
-
* @constant {string} ETH_SEPOLIA_CHAIN_ID - The chain ID for the Ethereum Sepolia testnet (EIP-155 compatible format).
|
|
10893
|
-
*/
|
|
10894
|
-
const ETH_SEPOLIA_CHAIN_ID = '11155111';
|
|
10895
|
-
/**
|
|
10896
|
-
* @constant {string} ETH_MAINNET_CHAIN_ID - The chain ID for the Ethereum mainnet (EIP-155 compatible format).
|
|
10897
|
-
*/
|
|
10898
|
-
const ETH_MAINNET_CHAIN_ID = '1';
|
|
10899
|
-
/**
|
|
10900
|
-
* @constant {string} ZKEVM_DEVNET_CHAIN_ID - The chain ID for the zkEVM devnet (EIP-155 compatible format).
|
|
10901
|
-
*/
|
|
10902
|
-
const ZKEVM_DEVNET_CHAIN_ID = '13433';
|
|
10903
|
-
/**
|
|
10904
|
-
/**
|
|
10905
|
-
* @constant {string} ZKEVM_TESTNET_CHAIN_ID - The chain ID for the zkEVM testnet (EIP-155 compatible format).
|
|
10906
|
-
*/
|
|
10907
|
-
const ZKEVM_TESTNET_CHAIN_ID = '13372';
|
|
10908
|
-
/**
|
|
10909
|
-
* @constant {string} ZKEVM_MAINNET_CHAIN_ID - The chain ID for the zkEVM mainnet (EIP-155 compatible format).
|
|
10910
|
-
*/
|
|
10911
|
-
const ZKEVM_MAINNET_CHAIN_ID = '13371';
|
|
10912
|
-
/**
|
|
10913
|
-
* @constant {string} L2_STATE_SENDER_ADDRESS - Address of bridge contract to the rootchain
|
|
10914
|
-
*/
|
|
10915
|
-
const L2_STATE_SENDER_ADDRESS = '0x0000000000000000000000000000000000001002';
|
|
10916
|
-
/**
|
|
10917
|
-
* The constant value representing the native token in the token bridge context.
|
|
10918
|
-
* The key is used to indicate the native token of a blockchain network (like Ether in Ethereum)
|
|
10919
|
-
* in methods that normally require a token address.
|
|
10920
|
-
* @constant {string}
|
|
10921
|
-
*/
|
|
10922
|
-
const NATIVE_TOKEN_BRIDGE_KEY = '0x0000000000000000000000000000000000000001';
|
|
10923
|
-
/**
|
|
10924
|
-
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_DEVNET - A bridge instance configuration for bridging between
|
|
10925
|
-
* the Ethereum Sepolia testnet and the zkEVM devnet.
|
|
10926
|
-
*/
|
|
10927
|
-
const ETH_SEPOLIA_TO_ZKEVM_DEVNET = {
|
|
10928
|
-
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
10929
|
-
childChainID: ZKEVM_DEVNET_CHAIN_ID,
|
|
10930
|
-
};
|
|
10931
|
-
/**
|
|
10932
|
-
* @constant {BridgeInstance} ETH_SEPOLIA_TO_ZKEVM_TESTNET - A bridge instance configuration for bridging
|
|
10933
|
-
* between the Ethereum Sepolia testnet and the zkEVM testnet.
|
|
10934
|
-
*/
|
|
10935
|
-
const ETH_SEPOLIA_TO_ZKEVM_TESTNET = {
|
|
10936
|
-
rootChainID: ETH_SEPOLIA_CHAIN_ID,
|
|
10937
|
-
childChainID: ZKEVM_TESTNET_CHAIN_ID,
|
|
10938
|
-
};
|
|
10939
|
-
/**
|
|
10940
|
-
* @constant {BridgeInstance} ETH_MAINNET_TO_ZKEVM_MAINNET - A bridge instance configuration for bridging
|
|
10941
|
-
* between the Ethereum mainnet and the zkEVM mainnet.
|
|
10942
|
-
*/
|
|
10943
|
-
const ETH_MAINNET_TO_ZKEVM_MAINNET = {
|
|
10944
|
-
rootChainID: ETH_MAINNET_CHAIN_ID,
|
|
10945
|
-
childChainID: ZKEVM_MAINNET_CHAIN_ID,
|
|
10946
|
-
};
|
|
10947
|
-
|
|
10948
10948
|
const L2_STATE_SENDER = [
|
|
10949
10949
|
{
|
|
10950
10950
|
anonymous: false,
|
|
@@ -11940,13 +11940,13 @@ class TokenBridge {
|
|
|
11940
11940
|
const reqTokenAddress = (req.rootToken === 'NATIVE') ? NATIVE_TOKEN_BRIDGE_KEY : req.rootToken;
|
|
11941
11941
|
// Validate the request token address
|
|
11942
11942
|
if (!isAddress(reqTokenAddress)) {
|
|
11943
|
-
throw new BridgeError(`
|
|
11943
|
+
throw new BridgeError(`token address ${reqTokenAddress} is not a valid address`, BridgeErrorType.INVALID_ADDRESS);
|
|
11944
11944
|
}
|
|
11945
11945
|
// Create an instance of the root ERC20 predicate contract
|
|
11946
11946
|
const childTokenAddress = await withBridgeError(async () => {
|
|
11947
11947
|
const rootERC20Predicate = new Contract(this.config.bridgeContracts.rootChainERC20Predicate, ROOT_ERC20_PREDICATE, this.config.rootProvider);
|
|
11948
|
-
return await rootERC20Predicate.
|
|
11949
|
-
}, BridgeErrorType.PROVIDER_ERROR, 'failed to query
|
|
11948
|
+
return await rootERC20Predicate.rootTokenToChildToken(reqTokenAddress);
|
|
11949
|
+
}, BridgeErrorType.PROVIDER_ERROR, 'failed to query rootTokenToChildToken mapping');
|
|
11950
11950
|
// Return the child token address
|
|
11951
11951
|
return {
|
|
11952
11952
|
childToken: childTokenAddress,
|
|
@@ -12222,7 +12222,7 @@ class TokenBridge {
|
|
|
12222
12222
|
throw new Error('failed to find child deposit event');
|
|
12223
12223
|
if (!childDepositEvent.args)
|
|
12224
12224
|
throw new Error('child deposit event has no args');
|
|
12225
|
-
if (
|
|
12225
|
+
if (childDepositEvent.args.status == null)
|
|
12226
12226
|
throw new Error('child deposit event has no status');
|
|
12227
12227
|
// If the event's status argument is present, we consider that the state sync operation was successful
|
|
12228
12228
|
if (childDepositEvent.args.status) {
|
|
@@ -12324,10 +12324,10 @@ const CONTRACTS_FOR_BRIDGE = new Map()
|
|
|
12324
12324
|
childChainStateReceiver: '0x0000000000000000000000000000000000001001',
|
|
12325
12325
|
})
|
|
12326
12326
|
.set(ETH_SEPOLIA_TO_ZKEVM_TESTNET, {
|
|
12327
|
-
rootChainERC20Predicate: '
|
|
12328
|
-
rootChainStateSender: '
|
|
12329
|
-
rootChainCheckpointManager: '
|
|
12330
|
-
rootChainExitHelper: '
|
|
12327
|
+
rootChainERC20Predicate: '0x1118Cc83780d07ef99F84fD1C0E10CEd49AF3613',
|
|
12328
|
+
rootChainStateSender: '0x41716a0DD85ae257DD011A97cE1470F609871270',
|
|
12329
|
+
rootChainCheckpointManager: '0xfD69e3FCd72C6374623eeb156dd2C4159eBa7327',
|
|
12330
|
+
rootChainExitHelper: '0x270D2B290c8183De23eCD17C7DaAE59fd084fE70',
|
|
12331
12331
|
childChainERC20Predicate: '0x0000000000000000000000000000000000001004',
|
|
12332
12332
|
childChainStateReceiver: '0x0000000000000000000000000000000000001001',
|
|
12333
12333
|
})
|
|
@@ -12913,31 +12913,18 @@ function isValidNonZeroAddress(address) {
|
|
|
12913
12913
|
}
|
|
12914
12914
|
}
|
|
12915
12915
|
const tokenInfoToUniswapToken = (tokenInfo) => new Token(tokenInfo.chainId, tokenInfo.address, tokenInfo.decimals, tokenInfo.symbol, tokenInfo.name);
|
|
12916
|
+
const uniswapTokenToTokenInfo = (token) => ({
|
|
12917
|
+
chainId: token.chainId,
|
|
12918
|
+
address: token.address,
|
|
12919
|
+
decimals: token.decimals,
|
|
12920
|
+
symbol: token.symbol,
|
|
12921
|
+
name: token.name,
|
|
12922
|
+
});
|
|
12916
12923
|
const toBigNumber = (amount) => (ethers.BigNumber.from(amount.multiply(amount.decimalScale).toExact()));
|
|
12917
|
-
|
|
12918
|
-
|
|
12919
|
-
|
|
12920
|
-
|
|
12921
|
-
const DEFAULT_DEADLINE = Math.floor(Date.now() / 1000) + 60 * 15;
|
|
12922
|
-
// most swaps will be able to resolve with 2 hops
|
|
12923
|
-
const DEFAULT_MAX_HOPS = 2;
|
|
12924
|
-
// after 10 hops, it is very unlikely a route will be available
|
|
12925
|
-
const MAX_MAX_HOPS = 10;
|
|
12926
|
-
// a max hop of 1 will require a direct swap with no intermediary pools
|
|
12927
|
-
const MIN_MAX_HOPS = 1;
|
|
12928
|
-
// precision used to calculate percentage from basis points
|
|
12929
|
-
const BASIS_POINT_PRECISION = 10000;
|
|
12930
|
-
// 10% maximum secondary fee
|
|
12931
|
-
const MAX_SECONDARY_FEE_BASIS_POINTS = 10000;
|
|
12932
|
-
|
|
12933
|
-
function calculateFees(amount, secondaryFees) {
|
|
12934
|
-
let totalFees = ethers.BigNumber.from(0);
|
|
12935
|
-
for (let i = 0; i < secondaryFees.length; i++) {
|
|
12936
|
-
const feeAmount = amount.mul(secondaryFees[i].feeBasisPoints).div(BASIS_POINT_PRECISION);
|
|
12937
|
-
totalFees = totalFees.add(feeAmount);
|
|
12938
|
-
}
|
|
12939
|
-
return totalFees;
|
|
12940
|
-
}
|
|
12924
|
+
const newAmount = (amount, token) => ({
|
|
12925
|
+
value: amount,
|
|
12926
|
+
token,
|
|
12927
|
+
});
|
|
12941
12928
|
|
|
12942
12929
|
// slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
|
|
12943
12930
|
// converts it to the Uniswap equivalent type
|
|
@@ -12977,7 +12964,7 @@ function applySlippage(tradeType, amount, slippage) {
|
|
|
12977
12964
|
const amountWithSlippage = maybeInverted.multiply(amount.toString()).quotient;
|
|
12978
12965
|
return ethers.BigNumber.from(amountWithSlippage.toString());
|
|
12979
12966
|
}
|
|
12980
|
-
function prepareUserQuote(otherCurrency, tradeInfo, slippage) {
|
|
12967
|
+
function prepareUserQuote(otherCurrency, tradeInfo, slippage, fees) {
|
|
12981
12968
|
const resultToken = otherCurrency.wrapped;
|
|
12982
12969
|
const tokenInfo = {
|
|
12983
12970
|
chainId: resultToken.chainId,
|
|
@@ -12995,32 +12982,32 @@ function prepareUserQuote(otherCurrency, tradeInfo, slippage) {
|
|
|
12995
12982
|
value: amountWithSlippage,
|
|
12996
12983
|
},
|
|
12997
12984
|
slippage,
|
|
12985
|
+
fees: fees.withAmounts(),
|
|
12998
12986
|
};
|
|
12999
12987
|
}
|
|
13000
|
-
function getOurQuoteReqAmount(amount,
|
|
12988
|
+
function getOurQuoteReqAmount(amount, fees, tradeType) {
|
|
13001
12989
|
if (tradeType === TradeType.EXACT_OUTPUT) {
|
|
13002
12990
|
// For an exact output swap, we do not need to subtract fees from the given amount
|
|
13003
12991
|
return amount;
|
|
13004
12992
|
}
|
|
13005
|
-
|
|
13006
|
-
|
|
13007
|
-
// Subtract the fee amount from the given amount
|
|
13008
|
-
return amount.subtract(totalFeesCurrencyAmount);
|
|
12993
|
+
fees.addAmount(toBigNumber(amount));
|
|
12994
|
+
return CurrencyAmount.fromRawAmount(amount.currency, fees.amountLessFees().toString());
|
|
13009
12995
|
}
|
|
13010
12996
|
|
|
13011
|
-
|
|
13012
|
-
const
|
|
13013
|
-
|
|
13014
|
-
const
|
|
13015
|
-
|
|
13016
|
-
|
|
13017
|
-
|
|
13018
|
-
|
|
13019
|
-
|
|
13020
|
-
|
|
13021
|
-
|
|
13022
|
-
|
|
13023
|
-
|
|
12997
|
+
// 0.1% default slippage
|
|
12998
|
+
const DEFAULT_SLIPPAGE = 0.1;
|
|
12999
|
+
// 15 minutes from the current Unix time
|
|
13000
|
+
const DEFAULT_DEADLINE = Math.floor(Date.now() / 1000) + 60 * 15;
|
|
13001
|
+
// most swaps will be able to resolve with 2 hops
|
|
13002
|
+
const DEFAULT_MAX_HOPS = 2;
|
|
13003
|
+
// after 10 hops, it is very unlikely a route will be available
|
|
13004
|
+
const MAX_MAX_HOPS = 10;
|
|
13005
|
+
// a max hop of 1 will require a direct swap with no intermediary pools
|
|
13006
|
+
const MIN_MAX_HOPS = 1;
|
|
13007
|
+
// precision used to calculate percentage from basis points
|
|
13008
|
+
const BASIS_POINT_PRECISION = 10000;
|
|
13009
|
+
// 10% maximum secondary fee
|
|
13010
|
+
const MAX_SECONDARY_FEE_BASIS_POINTS = 10000;
|
|
13024
13011
|
|
|
13025
13012
|
/* Autogenerated file. Do not edit manually. */
|
|
13026
13013
|
/* tslint:disable */
|
|
@@ -15050,6 +15037,60 @@ startCurrencyIn = currencyIn) => {
|
|
|
15050
15037
|
return routes;
|
|
15051
15038
|
};
|
|
15052
15039
|
|
|
15040
|
+
class Fees {
|
|
15041
|
+
secondaryFees;
|
|
15042
|
+
token;
|
|
15043
|
+
amount = ethers.BigNumber.from(0);
|
|
15044
|
+
constructor(secondaryFees, token) {
|
|
15045
|
+
this.secondaryFees = secondaryFees;
|
|
15046
|
+
this.token = token;
|
|
15047
|
+
}
|
|
15048
|
+
addAmount(amount) {
|
|
15049
|
+
this.amount = this.amount.add(amount);
|
|
15050
|
+
}
|
|
15051
|
+
amountWithFeesApplied() {
|
|
15052
|
+
return this.amount.add(this.total());
|
|
15053
|
+
}
|
|
15054
|
+
amountLessFees() {
|
|
15055
|
+
return this.amount.sub(this.total());
|
|
15056
|
+
}
|
|
15057
|
+
withAmounts() {
|
|
15058
|
+
return this.secondaryFees.map((fee) => {
|
|
15059
|
+
const feeAmount = this.amount
|
|
15060
|
+
.mul(fee.feeBasisPoints)
|
|
15061
|
+
.div(BASIS_POINT_PRECISION);
|
|
15062
|
+
return {
|
|
15063
|
+
...fee,
|
|
15064
|
+
amount: newAmount(feeAmount, this.token),
|
|
15065
|
+
};
|
|
15066
|
+
});
|
|
15067
|
+
}
|
|
15068
|
+
total() {
|
|
15069
|
+
let totalFees = ethers.BigNumber.from(0);
|
|
15070
|
+
for (let i = 0; i < this.secondaryFees.length; i++) {
|
|
15071
|
+
const feeAmount = this.amount
|
|
15072
|
+
.mul(this.secondaryFees[i].feeBasisPoints)
|
|
15073
|
+
.div(BASIS_POINT_PRECISION);
|
|
15074
|
+
totalFees = totalFees.add(feeAmount);
|
|
15075
|
+
}
|
|
15076
|
+
return totalFees;
|
|
15077
|
+
}
|
|
15078
|
+
}
|
|
15079
|
+
|
|
15080
|
+
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
15081
|
+
const IMMUTABLE_TESTNET_CHAIN_ID = 13472;
|
|
15082
|
+
|
|
15083
|
+
const TIMX_IMMUTABLE_TESTNET = {
|
|
15084
|
+
chainId: IMMUTABLE_TESTNET_CHAIN_ID,
|
|
15085
|
+
address: '0x0000000000000000000000000000000000001010',
|
|
15086
|
+
decimals: 18,
|
|
15087
|
+
symbol: 'tIMX',
|
|
15088
|
+
name: 'Immutable Testnet Token',
|
|
15089
|
+
};
|
|
15090
|
+
const IMMUTABLE_TESTNET_COMMON_ROUTING_TOKENS = [
|
|
15091
|
+
TIMX_IMMUTABLE_TESTNET,
|
|
15092
|
+
];
|
|
15093
|
+
|
|
15053
15094
|
const zeroNativeCurrencyValue = '0x00';
|
|
15054
15095
|
const multicallWithDeadlineFunctionSignature = 'multicall(uint256,bytes[])';
|
|
15055
15096
|
function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
|
|
@@ -15161,33 +15202,36 @@ function getSwap(nativeToken, adjustedQuote, fromAddress, slippage, deadline, pe
|
|
|
15161
15202
|
gasFeeEstimate,
|
|
15162
15203
|
};
|
|
15163
15204
|
}
|
|
15164
|
-
function prepareSwap(ourQuote, amountSpecified,
|
|
15165
|
-
|
|
15166
|
-
|
|
15167
|
-
|
|
15168
|
-
|
|
15169
|
-
|
|
15170
|
-
|
|
15171
|
-
|
|
15172
|
-
|
|
15173
|
-
|
|
15205
|
+
function prepareSwap(ourQuote, amountSpecified, fees) {
|
|
15206
|
+
if (ourQuote.tradeType === TradeType.EXACT_OUTPUT) {
|
|
15207
|
+
fees.addAmount(ourQuote.amountIn);
|
|
15208
|
+
return {
|
|
15209
|
+
gasEstimate: ourQuote.gasEstimate,
|
|
15210
|
+
route: ourQuote.route,
|
|
15211
|
+
tokenIn: ourQuote.tokenIn,
|
|
15212
|
+
tokenOut: ourQuote.tokenOut,
|
|
15213
|
+
amountIn: fees.amountWithFeesApplied(),
|
|
15214
|
+
amountOut: amountSpecified,
|
|
15215
|
+
tradeType: ourQuote.tradeType,
|
|
15216
|
+
};
|
|
15217
|
+
}
|
|
15174
15218
|
return {
|
|
15175
15219
|
gasEstimate: ourQuote.gasEstimate,
|
|
15176
15220
|
route: ourQuote.route,
|
|
15177
15221
|
tokenIn: ourQuote.tokenIn,
|
|
15178
15222
|
tokenOut: ourQuote.tokenOut,
|
|
15179
|
-
amountIn,
|
|
15180
|
-
amountOut,
|
|
15223
|
+
amountIn: amountSpecified,
|
|
15224
|
+
amountOut: ourQuote.amountOut,
|
|
15181
15225
|
tradeType: ourQuote.tradeType,
|
|
15182
15226
|
};
|
|
15183
15227
|
}
|
|
15184
15228
|
|
|
15185
15229
|
const CONTRACTS_FOR_CHAIN_ID = {
|
|
15186
15230
|
[IMMUTABLE_TESTNET_CHAIN_ID]: {
|
|
15187
|
-
multicall: '
|
|
15188
|
-
coreFactory: '
|
|
15189
|
-
quoterV2: '
|
|
15190
|
-
peripheryRouter: '
|
|
15231
|
+
multicall: '0xD17c98b38bA28c7eA1080317EB9AB2b9663BEd92',
|
|
15232
|
+
coreFactory: '0x8AC26EfCbf5D700b37A27aA00E6934e6904e7B8e',
|
|
15233
|
+
quoterV2: '0x0Afe6F5f4DC34461A801420634239FFaD50A2e44',
|
|
15234
|
+
peripheryRouter: '0x87854A7D4b9BaC3D37f4516A1Ac7F36fB5ad539f',
|
|
15191
15235
|
secondaryFee: '0x8dBE1f0900C5e92ad87A54521902a33ba1598C51',
|
|
15192
15236
|
},
|
|
15193
15237
|
};
|
|
@@ -15317,13 +15361,14 @@ class Exchange {
|
|
|
15317
15361
|
amountSpecified = CurrencyAmount.fromRawAmount(tokenOut, amount.toString());
|
|
15318
15362
|
otherToken = tokenIn;
|
|
15319
15363
|
}
|
|
15320
|
-
const
|
|
15364
|
+
const fees = new Fees(this.secondaryFees, uniswapTokenToTokenInfo(tokenIn));
|
|
15365
|
+
const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType);
|
|
15321
15366
|
const ourQuote = await this.router.findOptimalRoute(ourQuoteReqAmount, otherToken, tradeType, maxHops);
|
|
15322
15367
|
// get gas details
|
|
15323
15368
|
const gasPrice = await fetchGasPrice(this.provider);
|
|
15324
|
-
const adjustedQuote = prepareSwap(ourQuote, amount,
|
|
15369
|
+
const adjustedQuote = prepareSwap(ourQuote, amount, fees);
|
|
15325
15370
|
const swap = getSwap(this.nativeToken, adjustedQuote, fromAddress, slippagePercent, deadline, this.router.routingContracts.peripheryRouterAddress, this.router.routingContracts.secondaryFeeAddress, gasPrice, this.secondaryFees);
|
|
15326
|
-
const userQuote = prepareUserQuote(otherToken, adjustedQuote, slippagePercent);
|
|
15371
|
+
const userQuote = prepareUserQuote(otherToken, adjustedQuote, slippagePercent, fees);
|
|
15327
15372
|
const preparedApproval = prepareApproval(tradeType, amount, userQuote.amountWithMaxSlippage.value, this.router.routingContracts, this.secondaryFees);
|
|
15328
15373
|
// we always use the tokenIn address because we are always selling the tokenIn
|
|
15329
15374
|
const approval = await getApproval(this.nativeToken, this.provider, fromAddress, tokenInAddress, preparedApproval, gasPrice);
|
|
@@ -15441,7 +15486,7 @@ const $762782b6c862d954$export$db5daa1b5156ccfe = [
|
|
|
15441
15486
|
*/ var $0472f23319457bfb$export$c06e1e7429de6283;
|
|
15442
15487
|
(function(ChainId) {
|
|
15443
15488
|
ChainId[ChainId["IMTBL_ZKEVM_MAINNET"] = 13371] = "IMTBL_ZKEVM_MAINNET";
|
|
15444
|
-
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] =
|
|
15489
|
+
ChainId[ChainId["IMTBL_ZKEVM_TESTNET"] = 13472] = "IMTBL_ZKEVM_TESTNET";
|
|
15445
15490
|
ChainId[ChainId["IMTBL_ZKEVM_DEVNET"] = 13433] = "IMTBL_ZKEVM_DEVNET";
|
|
15446
15491
|
ChainId[ChainId["ETHEREUM"] = 1] = "ETHEREUM";
|
|
15447
15492
|
ChainId[ChainId["SEPOLIA"] = 11155111] = "SEPOLIA";
|
package/dist/checkout_widgets.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useEffect } from 'react';
|
|
|
4
4
|
function $parcel$export(e, n, v, s) {
|
|
5
5
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
6
6
|
}
|
|
7
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.
|
|
7
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.6.0-alpha";
|
|
8
8
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
9
9
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
10
10
|
|
|
@@ -16,7 +16,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
16
16
|
chainID,
|
|
17
17
|
coreContractAddress,
|
|
18
18
|
registrationContractAddress,
|
|
19
|
-
sdkVersion: 'ts-immutable-sdk-0.
|
|
19
|
+
sdkVersion: 'ts-immutable-sdk-0.6.0-alpha',
|
|
20
20
|
});
|
|
21
21
|
/**
|
|
22
22
|
* Sets `sdkVersion` at the time of build
|