@imtbl/sdk 0.27.13 → 0.27.14
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.js +75 -58
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +4 -4
- package/dist/index.browser.js +4 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +81 -64
- package/dist/index.js +81 -64
- package/dist/passport.js +5 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3632,7 +3632,7 @@ class MultiRollupApiClients {
|
|
|
3632
3632
|
}
|
|
3633
3633
|
|
|
3634
3634
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3635
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.
|
|
3635
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.14' };
|
|
3636
3636
|
const createConfig = ({ basePath, headers, }) => {
|
|
3637
3637
|
if (!basePath.trim()) {
|
|
3638
3638
|
throw Error('basePath can not be empty');
|
|
@@ -3692,7 +3692,7 @@ class APIError extends Error {
|
|
|
3692
3692
|
|
|
3693
3693
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3694
3694
|
const defaultHeaders = {
|
|
3695
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.
|
|
3695
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.14',
|
|
3696
3696
|
};
|
|
3697
3697
|
/**
|
|
3698
3698
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4103,7 +4103,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4103
4103
|
chainID,
|
|
4104
4104
|
coreContractAddress,
|
|
4105
4105
|
registrationContractAddress,
|
|
4106
|
-
sdkVersion: 'ts-immutable-sdk-0.27.
|
|
4106
|
+
sdkVersion: 'ts-immutable-sdk-0.27.14',
|
|
4107
4107
|
});
|
|
4108
4108
|
/**
|
|
4109
4109
|
* Sets `sdkVersion` at the time of build
|
|
@@ -4119,9 +4119,9 @@ const production = () => createImmutableXConfiguration({
|
|
|
4119
4119
|
*/
|
|
4120
4120
|
const sandbox = () => createImmutableXConfiguration({
|
|
4121
4121
|
basePath: 'https://api.sandbox.x.immutable.com',
|
|
4122
|
-
chainID:
|
|
4123
|
-
coreContractAddress: '
|
|
4124
|
-
registrationContractAddress: '
|
|
4122
|
+
chainID: 11155111,
|
|
4123
|
+
coreContractAddress: '0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98',
|
|
4124
|
+
registrationContractAddress: '0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97',
|
|
4125
4125
|
});
|
|
4126
4126
|
class ImxConfiguration {
|
|
4127
4127
|
immutableXConfig;
|
|
@@ -28458,8 +28458,9 @@ const doesChainSupportEIP1559 = (fee) => {
|
|
|
28458
28458
|
/**
|
|
28459
28459
|
* Fetch the current gas price estimate. Supports both EIP-1559 and non-EIP1559 chains
|
|
28460
28460
|
* @param {JsonRpcProvider} provider - The JSON RPC provider used to fetch fee data
|
|
28461
|
+
* @param {Coin} nativeToken - The native token of the chain. Gas prices will be denominated in this token
|
|
28461
28462
|
* @returns {Amount | null} - The gas price in the smallest denomination of the chain's currency,
|
|
28462
|
-
*
|
|
28463
|
+
* or null if no gas price is available
|
|
28463
28464
|
*/
|
|
28464
28465
|
const fetchGasPrice = async (provider, nativeToken) => {
|
|
28465
28466
|
const feeData = await provider.getFeeData().catch(() => null);
|
|
@@ -28473,8 +28474,8 @@ const fetchGasPrice = async (provider, nativeToken) => {
|
|
|
28473
28474
|
/**
|
|
28474
28475
|
* Calculate the gas fee from the gas price and gas units used for the transaction
|
|
28475
28476
|
*
|
|
28476
|
-
* @param {Amount}
|
|
28477
|
-
* @param {BigNumber}
|
|
28477
|
+
* @param {Amount} gasPrice - The price of gas
|
|
28478
|
+
* @param {BigNumber} gasEstimate - The total gas units that will be used for the transaction
|
|
28478
28479
|
* @returns - The cost of the transaction in the gas token's smallest denomination (e.g. WEI)
|
|
28479
28480
|
*/
|
|
28480
28481
|
const calculateGasFee = (gasPrice, gasEstimate) =>
|
|
@@ -28818,21 +28819,19 @@ function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn
|
|
|
28818
28819
|
* @param options additional swap options
|
|
28819
28820
|
* @returns calldata for the swap
|
|
28820
28821
|
*/
|
|
28821
|
-
function buildSwapParameters(fromAddress, trade, options, secondaryFees, secondaryFeeContract) {
|
|
28822
|
+
function buildSwapParameters(fromAddress, trade, options, secondaryFees, secondaryFeeContract, maximumAmountIn, minimumAmountOut) {
|
|
28822
28823
|
// @dev we don't support multiple swaps in a single transaction
|
|
28823
28824
|
// there will always be only one swap in the trade regardless of the trade type
|
|
28824
|
-
const { route
|
|
28825
|
-
const amountIn = v3Sdk.toHex(trade.maximumAmountIn(options.slippageTolerance, inputAmount).quotient);
|
|
28826
|
-
const amountOut = v3Sdk.toHex(trade.minimumAmountOut(options.slippageTolerance, outputAmount).quotient);
|
|
28825
|
+
const { route } = trade.swaps[0];
|
|
28827
28826
|
const isSinglePoolSwap = route.pools.length === 1;
|
|
28828
28827
|
if (isSinglePoolSwap) {
|
|
28829
|
-
return buildSwapParametersForSinglePoolSwap(fromAddress, trade, route,
|
|
28828
|
+
return buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, maximumAmountIn, minimumAmountOut, secondaryFees, secondaryFeeContract);
|
|
28830
28829
|
}
|
|
28831
|
-
return buildSwapParametersForMultiPoolSwap(fromAddress, trade, route,
|
|
28830
|
+
return buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, maximumAmountIn, minimumAmountOut, secondaryFees, secondaryFeeContract);
|
|
28832
28831
|
}
|
|
28833
|
-
function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees) {
|
|
28832
|
+
function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees, maximumAmountIn, minimumAmountOut) {
|
|
28834
28833
|
const secondaryFeeContract = SecondaryFee__factory.createInterface();
|
|
28835
|
-
const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract);
|
|
28834
|
+
const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract, maximumAmountIn, minimumAmountOut);
|
|
28836
28835
|
return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [
|
|
28837
28836
|
swapOptions.deadlineOrPreviousBlockhash,
|
|
28838
28837
|
[swapWithFeesCalldata],
|
|
@@ -28852,25 +28851,34 @@ function createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, se
|
|
|
28852
28851
|
recipient: fromAddress,
|
|
28853
28852
|
deadlineOrPreviousBlockhash: deadline,
|
|
28854
28853
|
};
|
|
28854
|
+
// If the trade type is EXACT_INPUT, then the maximum amount-in is the user-specified amount (no slippage applied)
|
|
28855
|
+
// https://github.com/Uniswap/v3-sdk/blob/81d66099f07d1ec350767f497ef73222575fe032/src/entities/trade.ts#L456
|
|
28856
|
+
const maximumAmountIn = v3Sdk.toHex(uncheckedTrade.maximumAmountIn(options.slippageTolerance).quotient);
|
|
28857
|
+
const minimumAmountOut = v3Sdk.toHex(uncheckedTrade.minimumAmountOut(options.slippageTolerance).quotient);
|
|
28855
28858
|
if (secondaryFees.length === 0) {
|
|
28856
28859
|
// Generate swap parameters without secondary fee contract details
|
|
28857
|
-
return routerSdk.SwapRouter.swapCallParameters([uncheckedTrade], options).calldata;
|
|
28860
|
+
return { calldata: routerSdk.SwapRouter.swapCallParameters([uncheckedTrade], options).calldata, maximumAmountIn };
|
|
28858
28861
|
}
|
|
28859
|
-
return
|
|
28862
|
+
return {
|
|
28863
|
+
calldata: createSwapCallParametersWithFees(uncheckedTrade, fromAddress, options, secondaryFees, maximumAmountIn, minimumAmountOut),
|
|
28864
|
+
maximumAmountIn,
|
|
28865
|
+
};
|
|
28860
28866
|
}
|
|
28861
|
-
|
|
28862
|
-
|
|
28867
|
+
const getTransactionValue = (tokenIn, maximumAmountIn) => tokenIn.type === 'native' ? maximumAmountIn : zeroNativeCurrencyValue;
|
|
28868
|
+
function getSwap(tokenIn, adjustedQuote, fromAddress, slippage, deadline, peripheryRouterAddress, secondaryFeesAddress, gasPrice, secondaryFees) {
|
|
28869
|
+
// TODO: TP-1651: Include `refundETH` transaction as final step for native Exact Output swaps
|
|
28870
|
+
const { calldata, maximumAmountIn } = createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, secondaryFees);
|
|
28863
28871
|
// TODO: Add additional gas fee estimates for secondary fees
|
|
28864
28872
|
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, adjustedQuote.gasEstimate) : null;
|
|
28873
|
+
const transactionValue = getTransactionValue(tokenIn, maximumAmountIn);
|
|
28865
28874
|
return {
|
|
28866
28875
|
transaction: {
|
|
28867
28876
|
data: calldata,
|
|
28868
28877
|
to: secondaryFees.length > 0 ? secondaryFeesAddress : peripheryRouterAddress,
|
|
28869
|
-
value:
|
|
28878
|
+
value: transactionValue,
|
|
28870
28879
|
from: fromAddress,
|
|
28871
28880
|
},
|
|
28872
|
-
|
|
28873
|
-
gasFeeEstimate: gasFeeEstimate ? nativeTokenService.maybeWrapAmount(gasFeeEstimate) : null,
|
|
28881
|
+
gasFeeEstimate: gasFeeEstimate ? toPublicAmount(gasFeeEstimate) : null,
|
|
28874
28882
|
};
|
|
28875
28883
|
}
|
|
28876
28884
|
const adjustAmountIn = (ourQuote, amountSpecified, fees, nativeTokenService) => {
|
|
@@ -28967,7 +28975,7 @@ class ExchangeConfiguration {
|
|
|
28967
28975
|
baseConfig;
|
|
28968
28976
|
chain;
|
|
28969
28977
|
secondaryFees = [];
|
|
28970
|
-
constructor({ chainId, baseConfig, secondaryFees, overrides
|
|
28978
|
+
constructor({ chainId, baseConfig, secondaryFees, overrides }) {
|
|
28971
28979
|
this.baseConfig = baseConfig;
|
|
28972
28980
|
this.secondaryFees = secondaryFees || [];
|
|
28973
28981
|
validateSecondaryFees(this.secondaryFees);
|
|
@@ -29080,7 +29088,7 @@ class Exchange {
|
|
|
29080
29088
|
fetchGasPrice(this.provider, this.nativeToken),
|
|
29081
29089
|
]);
|
|
29082
29090
|
const adjustedQuote = adjustQuoteWithFees(ourQuote, amountSpecified, fees, this.nativeTokenService);
|
|
29083
|
-
const swap = getSwap(adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees
|
|
29091
|
+
const swap = getSwap(tokenIn, adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees);
|
|
29084
29092
|
const { quotedAmount, quotedAmountWithMaxSlippage } = prepareUserQuote(this.nativeTokenService, adjustedQuote, slippagePercent, otherToken);
|
|
29085
29093
|
const preparedApproval = prepareApproval(tradeType, amountSpecified, quotedAmountWithMaxSlippage, {
|
|
29086
29094
|
routerAddress: this.routerContractAddress,
|
|
@@ -30179,44 +30187,53 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
|
30179
30187
|
// Hold the items in an array for post-fetching processing
|
|
30180
30188
|
const items = [];
|
|
30181
30189
|
const tokenType = ($887a00f8f72d61f0$export$5bd1ea2b3d18210).ERC20;
|
|
30182
|
-
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
|
|
30188
|
-
|
|
30189
|
-
|
|
30190
|
-
|
|
30191
|
-
|
|
30190
|
+
const erc20Balances = async (client)=>{
|
|
30191
|
+
// Given that the widgets aren't yet designed to support pagination,
|
|
30192
|
+
// fetch all the possible tokens associated to a given wallet address.
|
|
30193
|
+
let resp;
|
|
30194
|
+
try {
|
|
30195
|
+
do {
|
|
30196
|
+
// eslint-disable-next-line no-await-in-loop
|
|
30197
|
+
resp = await client.getTokensByWalletAddress({
|
|
30198
|
+
walletAddress: walletAddress,
|
|
30199
|
+
tokenType: tokenType,
|
|
30200
|
+
nextPage: resp?.next_page_params
|
|
30201
|
+
});
|
|
30202
|
+
items.push(...resp.items);
|
|
30203
|
+
}while (resp.next_page_params);
|
|
30204
|
+
} catch (err) {
|
|
30205
|
+
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
30206
|
+
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
30207
|
+
// activity on the chain. In this case, simply ignore the error and return
|
|
30208
|
+
// no currencies.
|
|
30209
|
+
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
30210
|
+
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
30211
|
+
// or simply an incorrect wallet address was provided.
|
|
30212
|
+
if (err?.code !== (globalAxios$1.HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30213
|
+
}
|
|
30214
|
+
};
|
|
30215
|
+
const nativeBalances = async (client)=>{
|
|
30216
|
+
try {
|
|
30217
|
+
const respNative = await client.getNativeTokenByWalletAddress({
|
|
30218
|
+
walletAddress: walletAddress
|
|
30192
30219
|
});
|
|
30193
|
-
items.push(
|
|
30194
|
-
}
|
|
30195
|
-
|
|
30196
|
-
|
|
30197
|
-
|
|
30198
|
-
|
|
30199
|
-
|
|
30200
|
-
|
|
30201
|
-
|
|
30202
|
-
|
|
30203
|
-
|
|
30204
|
-
}
|
|
30205
|
-
|
|
30206
|
-
|
|
30207
|
-
|
|
30208
|
-
|
|
30209
|
-
|
|
30210
|
-
} catch (err) {
|
|
30211
|
-
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
30212
|
-
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
30213
|
-
// activity on the chain. In this case, simply ignore the error and return
|
|
30214
|
-
// no currencies.
|
|
30215
|
-
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
30216
|
-
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
30217
|
-
// or simply an incorrect wallet address was provided.
|
|
30218
|
-
if (err?.code !== (globalAxios$1.HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30219
|
-
}
|
|
30220
|
+
items.push(respNative);
|
|
30221
|
+
} catch (err) {
|
|
30222
|
+
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
30223
|
+
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
30224
|
+
// activity on the chain. In this case, simply ignore the error and return
|
|
30225
|
+
// no currencies.
|
|
30226
|
+
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
30227
|
+
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
30228
|
+
// or simply an incorrect wallet address was provided.
|
|
30229
|
+
if (err?.code !== (globalAxios$1.HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30230
|
+
}
|
|
30231
|
+
};
|
|
30232
|
+
// Promise all() rather than allSettled() so that the function can fail fast.
|
|
30233
|
+
await Promise.all([
|
|
30234
|
+
erc20Balances(blockscoutClient),
|
|
30235
|
+
nativeBalances(blockscoutClient)
|
|
30236
|
+
]);
|
|
30220
30237
|
const balances = [];
|
|
30221
30238
|
items.forEach((item)=>{
|
|
30222
30239
|
if (shouldFilter && !mapFilterTokens[item.token.address]) return;
|
|
@@ -33338,7 +33355,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
|
33338
33355
|
})($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
|
|
33339
33356
|
|
|
33340
33357
|
|
|
33341
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.
|
|
33358
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.14";
|
|
33342
33359
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
33343
33360
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
33344
33361
|
|
package/dist/index.js
CHANGED
|
@@ -3610,7 +3610,7 @@ class MultiRollupApiClients {
|
|
|
3610
3610
|
}
|
|
3611
3611
|
|
|
3612
3612
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
3613
|
-
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.
|
|
3613
|
+
const defaultHeaders$1 = { 'x-sdk-version': 'ts-immutable-sdk-0.27.14' };
|
|
3614
3614
|
const createConfig = ({ basePath, headers, }) => {
|
|
3615
3615
|
if (!basePath.trim()) {
|
|
3616
3616
|
throw Error('basePath can not be empty');
|
|
@@ -3670,7 +3670,7 @@ class APIError extends Error {
|
|
|
3670
3670
|
|
|
3671
3671
|
/* eslint-disable implicit-arrow-linebreak */
|
|
3672
3672
|
const defaultHeaders = {
|
|
3673
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.
|
|
3673
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.27.14',
|
|
3674
3674
|
};
|
|
3675
3675
|
/**
|
|
3676
3676
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4081,7 +4081,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
4081
4081
|
chainID,
|
|
4082
4082
|
coreContractAddress,
|
|
4083
4083
|
registrationContractAddress,
|
|
4084
|
-
sdkVersion: 'ts-immutable-sdk-0.27.
|
|
4084
|
+
sdkVersion: 'ts-immutable-sdk-0.27.14',
|
|
4085
4085
|
});
|
|
4086
4086
|
/**
|
|
4087
4087
|
* Sets `sdkVersion` at the time of build
|
|
@@ -4097,9 +4097,9 @@ const production = () => createImmutableXConfiguration({
|
|
|
4097
4097
|
*/
|
|
4098
4098
|
const sandbox = () => createImmutableXConfiguration({
|
|
4099
4099
|
basePath: 'https://api.sandbox.x.immutable.com',
|
|
4100
|
-
chainID:
|
|
4101
|
-
coreContractAddress: '
|
|
4102
|
-
registrationContractAddress: '
|
|
4100
|
+
chainID: 11155111,
|
|
4101
|
+
coreContractAddress: '0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98',
|
|
4102
|
+
registrationContractAddress: '0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97',
|
|
4103
4103
|
});
|
|
4104
4104
|
class ImxConfiguration {
|
|
4105
4105
|
immutableXConfig;
|
|
@@ -28436,8 +28436,9 @@ const doesChainSupportEIP1559 = (fee) => {
|
|
|
28436
28436
|
/**
|
|
28437
28437
|
* Fetch the current gas price estimate. Supports both EIP-1559 and non-EIP1559 chains
|
|
28438
28438
|
* @param {JsonRpcProvider} provider - The JSON RPC provider used to fetch fee data
|
|
28439
|
+
* @param {Coin} nativeToken - The native token of the chain. Gas prices will be denominated in this token
|
|
28439
28440
|
* @returns {Amount | null} - The gas price in the smallest denomination of the chain's currency,
|
|
28440
|
-
*
|
|
28441
|
+
* or null if no gas price is available
|
|
28441
28442
|
*/
|
|
28442
28443
|
const fetchGasPrice = async (provider, nativeToken) => {
|
|
28443
28444
|
const feeData = await provider.getFeeData().catch(() => null);
|
|
@@ -28451,8 +28452,8 @@ const fetchGasPrice = async (provider, nativeToken) => {
|
|
|
28451
28452
|
/**
|
|
28452
28453
|
* Calculate the gas fee from the gas price and gas units used for the transaction
|
|
28453
28454
|
*
|
|
28454
|
-
* @param {Amount}
|
|
28455
|
-
* @param {BigNumber}
|
|
28455
|
+
* @param {Amount} gasPrice - The price of gas
|
|
28456
|
+
* @param {BigNumber} gasEstimate - The total gas units that will be used for the transaction
|
|
28456
28457
|
* @returns - The cost of the transaction in the gas token's smallest denomination (e.g. WEI)
|
|
28457
28458
|
*/
|
|
28458
28459
|
const calculateGasFee = (gasPrice, gasEstimate) =>
|
|
@@ -28796,21 +28797,19 @@ function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn
|
|
|
28796
28797
|
* @param options additional swap options
|
|
28797
28798
|
* @returns calldata for the swap
|
|
28798
28799
|
*/
|
|
28799
|
-
function buildSwapParameters(fromAddress, trade, options, secondaryFees, secondaryFeeContract) {
|
|
28800
|
+
function buildSwapParameters(fromAddress, trade, options, secondaryFees, secondaryFeeContract, maximumAmountIn, minimumAmountOut) {
|
|
28800
28801
|
// @dev we don't support multiple swaps in a single transaction
|
|
28801
28802
|
// there will always be only one swap in the trade regardless of the trade type
|
|
28802
|
-
const { route
|
|
28803
|
-
const amountIn = toHex$1(trade.maximumAmountIn(options.slippageTolerance, inputAmount).quotient);
|
|
28804
|
-
const amountOut = toHex$1(trade.minimumAmountOut(options.slippageTolerance, outputAmount).quotient);
|
|
28803
|
+
const { route } = trade.swaps[0];
|
|
28805
28804
|
const isSinglePoolSwap = route.pools.length === 1;
|
|
28806
28805
|
if (isSinglePoolSwap) {
|
|
28807
|
-
return buildSwapParametersForSinglePoolSwap(fromAddress, trade, route,
|
|
28806
|
+
return buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, maximumAmountIn, minimumAmountOut, secondaryFees, secondaryFeeContract);
|
|
28808
28807
|
}
|
|
28809
|
-
return buildSwapParametersForMultiPoolSwap(fromAddress, trade, route,
|
|
28808
|
+
return buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, maximumAmountIn, minimumAmountOut, secondaryFees, secondaryFeeContract);
|
|
28810
28809
|
}
|
|
28811
|
-
function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees) {
|
|
28810
|
+
function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees, maximumAmountIn, minimumAmountOut) {
|
|
28812
28811
|
const secondaryFeeContract = SecondaryFee__factory.createInterface();
|
|
28813
|
-
const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract);
|
|
28812
|
+
const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract, maximumAmountIn, minimumAmountOut);
|
|
28814
28813
|
return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [
|
|
28815
28814
|
swapOptions.deadlineOrPreviousBlockhash,
|
|
28816
28815
|
[swapWithFeesCalldata],
|
|
@@ -28830,25 +28829,34 @@ function createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, se
|
|
|
28830
28829
|
recipient: fromAddress,
|
|
28831
28830
|
deadlineOrPreviousBlockhash: deadline,
|
|
28832
28831
|
};
|
|
28832
|
+
// If the trade type is EXACT_INPUT, then the maximum amount-in is the user-specified amount (no slippage applied)
|
|
28833
|
+
// https://github.com/Uniswap/v3-sdk/blob/81d66099f07d1ec350767f497ef73222575fe032/src/entities/trade.ts#L456
|
|
28834
|
+
const maximumAmountIn = toHex$1(uncheckedTrade.maximumAmountIn(options.slippageTolerance).quotient);
|
|
28835
|
+
const minimumAmountOut = toHex$1(uncheckedTrade.minimumAmountOut(options.slippageTolerance).quotient);
|
|
28833
28836
|
if (secondaryFees.length === 0) {
|
|
28834
28837
|
// Generate swap parameters without secondary fee contract details
|
|
28835
|
-
return SwapRouter.swapCallParameters([uncheckedTrade], options).calldata;
|
|
28838
|
+
return { calldata: SwapRouter.swapCallParameters([uncheckedTrade], options).calldata, maximumAmountIn };
|
|
28836
28839
|
}
|
|
28837
|
-
return
|
|
28840
|
+
return {
|
|
28841
|
+
calldata: createSwapCallParametersWithFees(uncheckedTrade, fromAddress, options, secondaryFees, maximumAmountIn, minimumAmountOut),
|
|
28842
|
+
maximumAmountIn,
|
|
28843
|
+
};
|
|
28838
28844
|
}
|
|
28839
|
-
|
|
28840
|
-
|
|
28845
|
+
const getTransactionValue = (tokenIn, maximumAmountIn) => tokenIn.type === 'native' ? maximumAmountIn : zeroNativeCurrencyValue;
|
|
28846
|
+
function getSwap(tokenIn, adjustedQuote, fromAddress, slippage, deadline, peripheryRouterAddress, secondaryFeesAddress, gasPrice, secondaryFees) {
|
|
28847
|
+
// TODO: TP-1651: Include `refundETH` transaction as final step for native Exact Output swaps
|
|
28848
|
+
const { calldata, maximumAmountIn } = createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, secondaryFees);
|
|
28841
28849
|
// TODO: Add additional gas fee estimates for secondary fees
|
|
28842
28850
|
const gasFeeEstimate = gasPrice ? calculateGasFee(gasPrice, adjustedQuote.gasEstimate) : null;
|
|
28851
|
+
const transactionValue = getTransactionValue(tokenIn, maximumAmountIn);
|
|
28843
28852
|
return {
|
|
28844
28853
|
transaction: {
|
|
28845
28854
|
data: calldata,
|
|
28846
28855
|
to: secondaryFees.length > 0 ? secondaryFeesAddress : peripheryRouterAddress,
|
|
28847
|
-
value:
|
|
28856
|
+
value: transactionValue,
|
|
28848
28857
|
from: fromAddress,
|
|
28849
28858
|
},
|
|
28850
|
-
|
|
28851
|
-
gasFeeEstimate: gasFeeEstimate ? nativeTokenService.maybeWrapAmount(gasFeeEstimate) : null,
|
|
28859
|
+
gasFeeEstimate: gasFeeEstimate ? toPublicAmount(gasFeeEstimate) : null,
|
|
28852
28860
|
};
|
|
28853
28861
|
}
|
|
28854
28862
|
const adjustAmountIn = (ourQuote, amountSpecified, fees, nativeTokenService) => {
|
|
@@ -28945,7 +28953,7 @@ class ExchangeConfiguration {
|
|
|
28945
28953
|
baseConfig;
|
|
28946
28954
|
chain;
|
|
28947
28955
|
secondaryFees = [];
|
|
28948
|
-
constructor({ chainId, baseConfig, secondaryFees, overrides
|
|
28956
|
+
constructor({ chainId, baseConfig, secondaryFees, overrides }) {
|
|
28949
28957
|
this.baseConfig = baseConfig;
|
|
28950
28958
|
this.secondaryFees = secondaryFees || [];
|
|
28951
28959
|
validateSecondaryFees(this.secondaryFees);
|
|
@@ -29058,7 +29066,7 @@ class Exchange {
|
|
|
29058
29066
|
fetchGasPrice(this.provider, this.nativeToken),
|
|
29059
29067
|
]);
|
|
29060
29068
|
const adjustedQuote = adjustQuoteWithFees(ourQuote, amountSpecified, fees, this.nativeTokenService);
|
|
29061
|
-
const swap = getSwap(adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees
|
|
29069
|
+
const swap = getSwap(tokenIn, adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees);
|
|
29062
29070
|
const { quotedAmount, quotedAmountWithMaxSlippage } = prepareUserQuote(this.nativeTokenService, adjustedQuote, slippagePercent, otherToken);
|
|
29063
29071
|
const preparedApproval = prepareApproval(tradeType, amountSpecified, quotedAmountWithMaxSlippage, {
|
|
29064
29072
|
routerAddress: this.routerContractAddress,
|
|
@@ -30157,44 +30165,53 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
|
30157
30165
|
// Hold the items in an array for post-fetching processing
|
|
30158
30166
|
const items = [];
|
|
30159
30167
|
const tokenType = ($887a00f8f72d61f0$export$5bd1ea2b3d18210).ERC20;
|
|
30160
|
-
|
|
30161
|
-
|
|
30162
|
-
|
|
30163
|
-
|
|
30164
|
-
|
|
30165
|
-
|
|
30166
|
-
|
|
30167
|
-
|
|
30168
|
-
|
|
30169
|
-
|
|
30168
|
+
const erc20Balances = async (client)=>{
|
|
30169
|
+
// Given that the widgets aren't yet designed to support pagination,
|
|
30170
|
+
// fetch all the possible tokens associated to a given wallet address.
|
|
30171
|
+
let resp;
|
|
30172
|
+
try {
|
|
30173
|
+
do {
|
|
30174
|
+
// eslint-disable-next-line no-await-in-loop
|
|
30175
|
+
resp = await client.getTokensByWalletAddress({
|
|
30176
|
+
walletAddress: walletAddress,
|
|
30177
|
+
tokenType: tokenType,
|
|
30178
|
+
nextPage: resp?.next_page_params
|
|
30179
|
+
});
|
|
30180
|
+
items.push(...resp.items);
|
|
30181
|
+
}while (resp.next_page_params);
|
|
30182
|
+
} catch (err) {
|
|
30183
|
+
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
30184
|
+
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
30185
|
+
// activity on the chain. In this case, simply ignore the error and return
|
|
30186
|
+
// no currencies.
|
|
30187
|
+
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
30188
|
+
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
30189
|
+
// or simply an incorrect wallet address was provided.
|
|
30190
|
+
if (err?.code !== (HttpStatusCode$2).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30191
|
+
}
|
|
30192
|
+
};
|
|
30193
|
+
const nativeBalances = async (client)=>{
|
|
30194
|
+
try {
|
|
30195
|
+
const respNative = await client.getNativeTokenByWalletAddress({
|
|
30196
|
+
walletAddress: walletAddress
|
|
30170
30197
|
});
|
|
30171
|
-
items.push(
|
|
30172
|
-
}
|
|
30173
|
-
|
|
30174
|
-
|
|
30175
|
-
|
|
30176
|
-
|
|
30177
|
-
|
|
30178
|
-
|
|
30179
|
-
|
|
30180
|
-
|
|
30181
|
-
|
|
30182
|
-
}
|
|
30183
|
-
|
|
30184
|
-
|
|
30185
|
-
|
|
30186
|
-
|
|
30187
|
-
|
|
30188
|
-
} catch (err) {
|
|
30189
|
-
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
30190
|
-
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
30191
|
-
// activity on the chain. In this case, simply ignore the error and return
|
|
30192
|
-
// no currencies.
|
|
30193
|
-
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
30194
|
-
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
30195
|
-
// or simply an incorrect wallet address was provided.
|
|
30196
|
-
if (err?.code !== (HttpStatusCode$2).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30197
|
-
}
|
|
30198
|
+
items.push(respNative);
|
|
30199
|
+
} catch (err) {
|
|
30200
|
+
// In case of a 404, the wallet is a new wallet that hasn't been indexed by
|
|
30201
|
+
// the Blockscout just yet. This happens when a wallet hasn't had any
|
|
30202
|
+
// activity on the chain. In this case, simply ignore the error and return
|
|
30203
|
+
// no currencies.
|
|
30204
|
+
// In case of a malformed wallet address, Blockscout returns a 422, which
|
|
30205
|
+
// means we are safe to assume that a 404 is a missing wallet due to inactivity
|
|
30206
|
+
// or simply an incorrect wallet address was provided.
|
|
30207
|
+
if (err?.code !== (HttpStatusCode$2).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30208
|
+
}
|
|
30209
|
+
};
|
|
30210
|
+
// Promise all() rather than allSettled() so that the function can fail fast.
|
|
30211
|
+
await Promise.all([
|
|
30212
|
+
erc20Balances(blockscoutClient),
|
|
30213
|
+
nativeBalances(blockscoutClient)
|
|
30214
|
+
]);
|
|
30198
30215
|
const balances = [];
|
|
30199
30216
|
items.forEach((item)=>{
|
|
30200
30217
|
if (shouldFilter && !mapFilterTokens[item.token.address]) return;
|
|
@@ -33316,7 +33333,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
|
33316
33333
|
})($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
|
|
33317
33334
|
|
|
33318
33335
|
|
|
33319
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.
|
|
33336
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.14";
|
|
33320
33337
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
33321
33338
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
33322
33339
|
|
package/dist/passport.js
CHANGED
|
@@ -2072,7 +2072,7 @@ class MultiRollupApiClients {
|
|
|
2072
2072
|
}
|
|
2073
2073
|
|
|
2074
2074
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2075
|
-
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.27.
|
|
2075
|
+
const defaultHeaders = { 'x-sdk-version': 'ts-immutable-sdk-0.27.14' };
|
|
2076
2076
|
const createConfig = ({ basePath, headers, }) => {
|
|
2077
2077
|
if (!basePath.trim()) {
|
|
2078
2078
|
throw Error('basePath can not be empty');
|
|
@@ -2128,7 +2128,7 @@ const createImmutableXConfiguration = ({ basePath, chainID, coreContractAddress,
|
|
|
2128
2128
|
chainID,
|
|
2129
2129
|
coreContractAddress,
|
|
2130
2130
|
registrationContractAddress,
|
|
2131
|
-
sdkVersion: 'ts-immutable-sdk-0.27.
|
|
2131
|
+
sdkVersion: 'ts-immutable-sdk-0.27.14',
|
|
2132
2132
|
});
|
|
2133
2133
|
/**
|
|
2134
2134
|
* Sets `sdkVersion` at the time of build
|
|
@@ -2144,9 +2144,9 @@ const production = () => createImmutableXConfiguration({
|
|
|
2144
2144
|
*/
|
|
2145
2145
|
const sandbox = () => createImmutableXConfiguration({
|
|
2146
2146
|
basePath: 'https://api.sandbox.x.immutable.com',
|
|
2147
|
-
chainID:
|
|
2148
|
-
coreContractAddress: '
|
|
2149
|
-
registrationContractAddress: '
|
|
2147
|
+
chainID: 11155111,
|
|
2148
|
+
coreContractAddress: '0x2d5C349fD8464DA06a3f90b4B0E9195F3d1b7F98',
|
|
2149
|
+
registrationContractAddress: '0xDbA6129C02E69405622fAdc3d5A7f8d23eac3b97',
|
|
2150
2150
|
});
|
|
2151
2151
|
class ImxConfiguration {
|
|
2152
2152
|
immutableXConfig;
|
package/package.json
CHANGED