@imtbl/sdk 0.27.10 → 0.27.12
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.d.ts +1 -1
- package/dist/blockchain_data.js +2 -2
- package/dist/browser/checkout.js +2 -2
- package/dist/checkout_sdk.js +286 -195
- package/dist/checkout_widgets.d.ts +1 -1
- package/dist/checkout_widgets.js +2 -2
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +10 -10
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +297 -206
- package/dist/index.d.ts +53 -33
- package/dist/index.js +297 -206
- package/dist/orderbook.d.ts +45 -25
- package/dist/orderbook.js +14 -2
- package/dist/passport.js +2 -2
- 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.12' };
|
|
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.12',
|
|
3696
3696
|
};
|
|
3697
3697
|
/**
|
|
3698
3698
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -4084,14 +4084,14 @@ class BlockchainData {
|
|
|
4084
4084
|
var blockchain_data = /*#__PURE__*/Object.freeze({
|
|
4085
4085
|
__proto__: null,
|
|
4086
4086
|
APIError: APIError,
|
|
4087
|
-
|
|
4087
|
+
ActivitiesTypes: activitiesApiTypes,
|
|
4088
4088
|
BlockchainData: BlockchainData,
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4089
|
+
ChainsTypes: chainsApiTypes,
|
|
4090
|
+
CollectionsTypes: collectionsApiTypes,
|
|
4091
|
+
MetadataTypes: metadataApiTypes,
|
|
4092
|
+
NFTOwnersTypes: nftOwnersApiTypes,
|
|
4093
|
+
NFTsTypes: nftsApiTypes,
|
|
4094
|
+
TokensTypes: tokensApiTypes
|
|
4095
4095
|
});
|
|
4096
4096
|
|
|
4097
4097
|
/**
|
|
@@ -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.12',
|
|
4107
4107
|
});
|
|
4108
4108
|
/**
|
|
4109
4109
|
* Sets `sdkVersion` at the time of build
|
|
@@ -11245,7 +11245,7 @@ class OrdersService {
|
|
|
11245
11245
|
* @returns ListListingsResult OK response.
|
|
11246
11246
|
* @throws ApiError
|
|
11247
11247
|
*/
|
|
11248
|
-
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
11248
|
+
listListings({ chainName, status, sellItemContractAddress, buyItemContractAddress, sellItemTokenId, fromUpdatedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
11249
11249
|
return this.httpRequest.request({
|
|
11250
11250
|
method: 'GET',
|
|
11251
11251
|
url: '/v1/chains/{chain_name}/orders/listings',
|
|
@@ -11257,6 +11257,7 @@ class OrdersService {
|
|
|
11257
11257
|
'sell_item_contract_address': sellItemContractAddress,
|
|
11258
11258
|
'buy_item_contract_address': buyItemContractAddress,
|
|
11259
11259
|
'sell_item_token_id': sellItemTokenId,
|
|
11260
|
+
'from_updated_at': fromUpdatedAt,
|
|
11260
11261
|
'page_size': pageSize,
|
|
11261
11262
|
'sort_by': sortBy,
|
|
11262
11263
|
'sort_direction': sortDirection,
|
|
@@ -11340,7 +11341,7 @@ class OrdersService {
|
|
|
11340
11341
|
* @returns ListTradeResult OK response.
|
|
11341
11342
|
* @throws ApiError
|
|
11342
11343
|
*/
|
|
11343
|
-
listTrades({ chainName, accountAddress, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
11344
|
+
listTrades({ chainName, accountAddress, fromIndexedAt, pageSize, sortBy, sortDirection, pageCursor, }) {
|
|
11344
11345
|
return this.httpRequest.request({
|
|
11345
11346
|
method: 'GET',
|
|
11346
11347
|
url: '/v1/chains/{chain_name}/trades',
|
|
@@ -11349,6 +11350,7 @@ class OrdersService {
|
|
|
11349
11350
|
},
|
|
11350
11351
|
query: {
|
|
11351
11352
|
'account_address': accountAddress,
|
|
11353
|
+
'from_indexed_at': fromIndexedAt,
|
|
11352
11354
|
'page_size': pageSize,
|
|
11353
11355
|
'sort_by': sortBy,
|
|
11354
11356
|
'sort_direction': sortDirection,
|
|
@@ -11414,6 +11416,16 @@ var CancelledOrderStatus;
|
|
|
11414
11416
|
})(CancelledOrderStatus.cancellation_type || (CancelledOrderStatus.cancellation_type = {}));
|
|
11415
11417
|
})(CancelledOrderStatus || (CancelledOrderStatus = {}));
|
|
11416
11418
|
|
|
11419
|
+
/* istanbul ignore file */
|
|
11420
|
+
/* tslint:disable */
|
|
11421
|
+
/* eslint-disable */
|
|
11422
|
+
var FailedOrderCancellation;
|
|
11423
|
+
(function (FailedOrderCancellation) {
|
|
11424
|
+
(function (reason_code) {
|
|
11425
|
+
reason_code["ALREADY_FILLED"] = "ALREADY_FILLED";
|
|
11426
|
+
})(FailedOrderCancellation.reason_code || (FailedOrderCancellation.reason_code = {}));
|
|
11427
|
+
})(FailedOrderCancellation || (FailedOrderCancellation = {}));
|
|
11428
|
+
|
|
11417
11429
|
/* istanbul ignore file */
|
|
11418
11430
|
/* tslint:disable */
|
|
11419
11431
|
/* eslint-disable */
|
|
@@ -28033,8 +28045,11 @@ function poolEquals(poolA, poolB) {
|
|
|
28033
28045
|
return (poolA === poolB ||
|
|
28034
28046
|
(poolA.token0.equals(poolB.token0) && poolA.token1.equals(poolB.token1) && poolA.fee === poolB.fee));
|
|
28035
28047
|
}
|
|
28036
|
-
|
|
28037
|
-
|
|
28048
|
+
const decimalsFunctionSig = ethers.ethers.utils.id('decimals()').substring(0, 10);
|
|
28049
|
+
async function getTokenDecimals(tokenAddress, provider, nativeToken) {
|
|
28050
|
+
if (tokenAddress === 'native') {
|
|
28051
|
+
return nativeToken.decimals;
|
|
28052
|
+
}
|
|
28038
28053
|
try {
|
|
28039
28054
|
const decimalsResult = await provider.call({
|
|
28040
28055
|
to: tokenAddress,
|
|
@@ -28062,6 +28077,7 @@ function isValidNonZeroAddress(address) {
|
|
|
28062
28077
|
return false;
|
|
28063
28078
|
}
|
|
28064
28079
|
}
|
|
28080
|
+
const isValidTokenLiteral = (address) => address === 'native' ? true : isValidNonZeroAddress(address);
|
|
28065
28081
|
const erc20ToUniswapToken = (token) =>
|
|
28066
28082
|
// eslint-disable-next-line implicit-arrow-linebreak
|
|
28067
28083
|
new Uniswap__namespace.Token(token.chainId, token.address, token.decimals, token.symbol, token.name);
|
|
@@ -28516,12 +28532,13 @@ const getUnsignedERC20ApproveTransaction = (ownerAddress, tokenAmount, spenderAd
|
|
|
28516
28532
|
from: ownerAddress,
|
|
28517
28533
|
};
|
|
28518
28534
|
};
|
|
28519
|
-
const prepareApproval = (tradeType,
|
|
28520
|
-
const
|
|
28521
|
-
|
|
28522
|
-
|
|
28523
|
-
|
|
28524
|
-
|
|
28535
|
+
const prepareApproval = (tradeType, userSpecifiedAmount, quotedAmountWithSlippage, contracts, secondaryFees) => {
|
|
28536
|
+
const amountInToApprove = tradeType === Uniswap.TradeType.EXACT_INPUT ? userSpecifiedAmount : quotedAmountWithSlippage;
|
|
28537
|
+
if (!isERC20Amount(amountInToApprove)) {
|
|
28538
|
+
return null;
|
|
28539
|
+
}
|
|
28540
|
+
const spender = secondaryFees.length === 0 ? contracts.routerAddress : contracts.secondaryFeeAddress;
|
|
28541
|
+
return { spender, amount: amountInToApprove };
|
|
28525
28542
|
};
|
|
28526
28543
|
/**
|
|
28527
28544
|
* Get an unsigned approval transaction if needed
|
|
@@ -28566,6 +28583,38 @@ const getApproval = async (provider, ownerAddress, preparedApproval, gasPrice) =
|
|
|
28566
28583
|
};
|
|
28567
28584
|
};
|
|
28568
28585
|
|
|
28586
|
+
const canUnwrapToken = (token) => token.type === 'native';
|
|
28587
|
+
class NativeTokenService {
|
|
28588
|
+
nativeToken;
|
|
28589
|
+
wrappedToken;
|
|
28590
|
+
constructor(nativeToken, wrappedToken) {
|
|
28591
|
+
this.nativeToken = nativeToken;
|
|
28592
|
+
this.wrappedToken = wrappedToken;
|
|
28593
|
+
}
|
|
28594
|
+
wrapAmount(amount) {
|
|
28595
|
+
if (!canUnwrapToken(amount.token)) {
|
|
28596
|
+
throw new Error(`cannot wrap non-native token: ${amount.token.address}`);
|
|
28597
|
+
}
|
|
28598
|
+
return newAmount(amount.value, this.wrappedToken);
|
|
28599
|
+
}
|
|
28600
|
+
unwrapAmount(amount) {
|
|
28601
|
+
const isWrappedToken = amount.token.address.toLowerCase() !== this.wrappedToken.address.toLowerCase();
|
|
28602
|
+
if (isWrappedToken) {
|
|
28603
|
+
throw new Error(`cannot unwrap non-wrapped token ${amount.token.address}`);
|
|
28604
|
+
}
|
|
28605
|
+
return newAmount(amount.value, this.nativeToken);
|
|
28606
|
+
}
|
|
28607
|
+
maybeWrapToken(token) {
|
|
28608
|
+
if (canUnwrapToken(token)) {
|
|
28609
|
+
return this.wrappedToken;
|
|
28610
|
+
}
|
|
28611
|
+
return token;
|
|
28612
|
+
}
|
|
28613
|
+
maybeWrapAmount(amount) {
|
|
28614
|
+
return newAmount(amount.value, this.maybeWrapToken(amount.token));
|
|
28615
|
+
}
|
|
28616
|
+
}
|
|
28617
|
+
|
|
28569
28618
|
// slippageToPercent takes the slippage as a percentage (e.g. 0.1) and
|
|
28570
28619
|
// converts it to the Uniswap equivalent type
|
|
28571
28620
|
const slippageToFraction = (slippage) => {
|
|
@@ -28585,11 +28634,11 @@ const slippageToFraction = (slippage) => {
|
|
|
28585
28634
|
return new Uniswap.Percent(numerator, denominator);
|
|
28586
28635
|
};
|
|
28587
28636
|
|
|
28588
|
-
function getQuoteAmountFromTradeType(
|
|
28589
|
-
if (
|
|
28590
|
-
return
|
|
28637
|
+
function getQuoteAmountFromTradeType(routerQuote) {
|
|
28638
|
+
if (routerQuote.tradeType === Uniswap.TradeType.EXACT_INPUT) {
|
|
28639
|
+
return routerQuote.amountOut;
|
|
28591
28640
|
}
|
|
28592
|
-
return
|
|
28641
|
+
return routerQuote.amountIn;
|
|
28593
28642
|
}
|
|
28594
28643
|
function applySlippage(tradeType, amount, slippage) {
|
|
28595
28644
|
const slippageTolerance = slippageToFraction(slippage);
|
|
@@ -28598,6 +28647,18 @@ function applySlippage(tradeType, amount, slippage) {
|
|
|
28598
28647
|
const amountWithSlippage = maybeInverted.multiply(amount.toString()).quotient;
|
|
28599
28648
|
return ethers.ethers.BigNumber.from(amountWithSlippage.toString());
|
|
28600
28649
|
}
|
|
28650
|
+
const prepareUserQuote = (nativeTokenService, routerQuote, slippage, tokenOfQuotedAmount) => {
|
|
28651
|
+
const erc20QuoteAmount = getQuoteAmountFromTradeType(routerQuote);
|
|
28652
|
+
// If the quote amount is the native token, we need to unwrap it if the user originally specified the native token
|
|
28653
|
+
const quotedAmount = canUnwrapToken(tokenOfQuotedAmount)
|
|
28654
|
+
? nativeTokenService.unwrapAmount(erc20QuoteAmount)
|
|
28655
|
+
: erc20QuoteAmount;
|
|
28656
|
+
const quotedAmountWithMaxSlippage = newAmount(applySlippage(routerQuote.tradeType, quotedAmount.value, slippage), tokenOfQuotedAmount);
|
|
28657
|
+
return {
|
|
28658
|
+
quotedAmount,
|
|
28659
|
+
quotedAmountWithMaxSlippage,
|
|
28660
|
+
};
|
|
28661
|
+
};
|
|
28601
28662
|
function getOurQuoteReqAmount(amountSpecified, // the amount specified by the user, either exactIn or exactOut
|
|
28602
28663
|
fees, tradeType, nativeTokenService) {
|
|
28603
28664
|
if (tradeType === Uniswap.TradeType.EXACT_OUTPUT) {
|
|
@@ -28665,39 +28726,6 @@ class Fees {
|
|
|
28665
28726
|
}
|
|
28666
28727
|
}
|
|
28667
28728
|
|
|
28668
|
-
class NativeTokenService {
|
|
28669
|
-
nativeToken;
|
|
28670
|
-
wrappedToken;
|
|
28671
|
-
constructor(nativeToken, wrappedToken) {
|
|
28672
|
-
this.nativeToken = nativeToken;
|
|
28673
|
-
this.wrappedToken = wrappedToken;
|
|
28674
|
-
}
|
|
28675
|
-
wrapAmount(amount) {
|
|
28676
|
-
if (!this.isNativeToken(amount.token)) {
|
|
28677
|
-
throw new Error(`cannot wrap non-native token: ${amount.token.address}`);
|
|
28678
|
-
}
|
|
28679
|
-
return newAmount(amount.value, this.wrappedToken);
|
|
28680
|
-
}
|
|
28681
|
-
unwrapAmount(amount) {
|
|
28682
|
-
if (amount.token !== this.wrappedToken) {
|
|
28683
|
-
throw new Error(`cannot unwrap non-wrapped token ${amount.token.address}`);
|
|
28684
|
-
}
|
|
28685
|
-
return newAmount(amount.value, this.nativeToken);
|
|
28686
|
-
}
|
|
28687
|
-
maybeWrapToken(token) {
|
|
28688
|
-
if (this.isNativeToken(token)) {
|
|
28689
|
-
return this.wrappedToken;
|
|
28690
|
-
}
|
|
28691
|
-
return token;
|
|
28692
|
-
}
|
|
28693
|
-
maybeWrapAmount(amount) {
|
|
28694
|
-
return newAmount(amount.value, this.maybeWrapToken(amount.token));
|
|
28695
|
-
}
|
|
28696
|
-
isNativeToken(token) {
|
|
28697
|
-
return token === this.nativeToken;
|
|
28698
|
-
}
|
|
28699
|
-
}
|
|
28700
|
-
|
|
28701
28729
|
const IMMUTABLE_TESTNET_RPC_URL = 'https://rpc.testnet.immutable.com';
|
|
28702
28730
|
const IMMUTABLE_TESTNET_CHAIN_ID = 13472;
|
|
28703
28731
|
const TIMX_IMMUTABLE_TESTNET = {
|
|
@@ -28729,7 +28757,9 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
|
|
|
28729
28757
|
recipient: fee.recipient,
|
|
28730
28758
|
}));
|
|
28731
28759
|
if (trade.tradeType === Uniswap.TradeType.EXACT_INPUT) {
|
|
28732
|
-
return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [
|
|
28760
|
+
return secondaryFeeContract.encodeFunctionData('exactInputSingleWithSecondaryFee', [
|
|
28761
|
+
secondaryFeeValues,
|
|
28762
|
+
{
|
|
28733
28763
|
tokenIn: route.tokenPath[0].address,
|
|
28734
28764
|
tokenOut: route.tokenPath[1].address,
|
|
28735
28765
|
fee: route.pools[0].fee,
|
|
@@ -28737,9 +28767,12 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
|
|
|
28737
28767
|
amountIn,
|
|
28738
28768
|
amountOutMinimum: amountOut,
|
|
28739
28769
|
sqrtPriceLimitX96: 0,
|
|
28740
|
-
}
|
|
28770
|
+
},
|
|
28771
|
+
]);
|
|
28741
28772
|
}
|
|
28742
|
-
return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [
|
|
28773
|
+
return secondaryFeeContract.encodeFunctionData('exactOutputSingleWithSecondaryFee', [
|
|
28774
|
+
secondaryFeeValues,
|
|
28775
|
+
{
|
|
28743
28776
|
tokenIn: route.tokenPath[0].address,
|
|
28744
28777
|
tokenOut: route.tokenPath[1].address,
|
|
28745
28778
|
fee: route.pools[0].fee,
|
|
@@ -28747,7 +28780,8 @@ function buildSwapParametersForSinglePoolSwap(fromAddress, trade, route, amountI
|
|
|
28747
28780
|
amountInMaximum: amountIn,
|
|
28748
28781
|
amountOut,
|
|
28749
28782
|
sqrtPriceLimitX96: 0,
|
|
28750
|
-
}
|
|
28783
|
+
},
|
|
28784
|
+
]);
|
|
28751
28785
|
}
|
|
28752
28786
|
function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn, amountOut, secondaryFees, secondaryFeeContract) {
|
|
28753
28787
|
const path = v3Sdk.encodeRouteToPath(route, trade.tradeType === Uniswap.TradeType.EXACT_OUTPUT);
|
|
@@ -28756,19 +28790,25 @@ function buildSwapParametersForMultiPoolSwap(fromAddress, trade, route, amountIn
|
|
|
28756
28790
|
recipient: fee.recipient,
|
|
28757
28791
|
}));
|
|
28758
28792
|
if (trade.tradeType === Uniswap.TradeType.EXACT_INPUT) {
|
|
28759
|
-
return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [
|
|
28793
|
+
return secondaryFeeContract.encodeFunctionData('exactInputWithSecondaryFee', [
|
|
28794
|
+
secondaryFeeValues,
|
|
28795
|
+
{
|
|
28760
28796
|
path,
|
|
28761
28797
|
recipient: fromAddress,
|
|
28762
28798
|
amountIn,
|
|
28763
28799
|
amountOutMinimum: amountOut,
|
|
28764
|
-
}
|
|
28800
|
+
},
|
|
28801
|
+
]);
|
|
28765
28802
|
}
|
|
28766
|
-
return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [
|
|
28803
|
+
return secondaryFeeContract.encodeFunctionData('exactOutputWithSecondaryFee', [
|
|
28804
|
+
secondaryFeeValues,
|
|
28805
|
+
{
|
|
28767
28806
|
path,
|
|
28768
28807
|
recipient: fromAddress,
|
|
28769
28808
|
amountInMaximum: amountIn,
|
|
28770
28809
|
amountOut,
|
|
28771
|
-
}
|
|
28810
|
+
},
|
|
28811
|
+
]);
|
|
28772
28812
|
}
|
|
28773
28813
|
/**
|
|
28774
28814
|
* Builds swap parameters
|
|
@@ -28793,7 +28833,10 @@ function buildSwapParameters(fromAddress, trade, options, secondaryFees, seconda
|
|
|
28793
28833
|
function createSwapCallParametersWithFees(trade, fromAddress, swapOptions, secondaryFees) {
|
|
28794
28834
|
const secondaryFeeContract = SecondaryFee__factory.createInterface();
|
|
28795
28835
|
const swapWithFeesCalldata = buildSwapParameters(fromAddress, trade, swapOptions, secondaryFees, secondaryFeeContract);
|
|
28796
|
-
return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [
|
|
28836
|
+
return secondaryFeeContract.encodeFunctionData(multicallWithDeadlineFunctionSignature, [
|
|
28837
|
+
swapOptions.deadlineOrPreviousBlockhash,
|
|
28838
|
+
[swapWithFeesCalldata],
|
|
28839
|
+
]);
|
|
28797
28840
|
}
|
|
28798
28841
|
function createSwapParameters(adjustedQuote, fromAddress, slippage, deadline, secondaryFees) {
|
|
28799
28842
|
// Create an unchecked trade to be used in generating swap parameters.
|
|
@@ -28833,7 +28876,7 @@ function getSwap(adjustedQuote, fromAddress, slippage, deadline, peripheryRouter
|
|
|
28833
28876
|
const adjustAmountIn = (ourQuote, amountSpecified, fees, nativeTokenService) => {
|
|
28834
28877
|
if (ourQuote.tradeType === Uniswap.TradeType.EXACT_OUTPUT) {
|
|
28835
28878
|
// when doing exact output, calculate the fees based on the amountIn
|
|
28836
|
-
const amountToAdd =
|
|
28879
|
+
const amountToAdd = canUnwrapToken(fees.token)
|
|
28837
28880
|
? nativeTokenService.unwrapAmount(ourQuote.amountIn)
|
|
28838
28881
|
: ourQuote.amountIn;
|
|
28839
28882
|
fees.addAmount(amountToAdd);
|
|
@@ -28950,8 +28993,8 @@ class ExchangeConfiguration {
|
|
|
28950
28993
|
}
|
|
28951
28994
|
|
|
28952
28995
|
const toPublicQuote = (amount, amountWithMaxSlippage, slippage, fees) => ({
|
|
28953
|
-
amount,
|
|
28954
|
-
amountWithMaxSlippage,
|
|
28996
|
+
amount: toPublicAmount(amount),
|
|
28997
|
+
amountWithMaxSlippage: toPublicAmount(amountWithMaxSlippage),
|
|
28955
28998
|
slippage,
|
|
28956
28999
|
fees: fees.withAmounts().map((fee) => ({
|
|
28957
29000
|
...fee,
|
|
@@ -28986,8 +29029,8 @@ class Exchange {
|
|
|
28986
29029
|
}
|
|
28987
29030
|
static validate(tokenInAddress, tokenOutAddress, maxHops, slippagePercent, fromAddress) {
|
|
28988
29031
|
assert(isValidNonZeroAddress(fromAddress), new InvalidAddressError('invalid from address'));
|
|
28989
|
-
assert(
|
|
28990
|
-
assert(
|
|
29032
|
+
assert(isValidTokenLiteral(tokenInAddress), new InvalidAddressError('invalid token in address'));
|
|
29033
|
+
assert(isValidTokenLiteral(tokenOutAddress), new InvalidAddressError('invalid token out address'));
|
|
28991
29034
|
assert(tokenInAddress.toLocaleLowerCase() !== tokenOutAddress.toLocaleLowerCase(), new DuplicateAddressesError());
|
|
28992
29035
|
assert(maxHops <= MAX_MAX_HOPS, new InvalidMaxHopsError('max hops must be less than or equal to 10'));
|
|
28993
29036
|
assert(maxHops >= MIN_MAX_HOPS, new InvalidMaxHopsError('max hops must be greater than or equal to 1'));
|
|
@@ -29005,61 +29048,63 @@ class Exchange {
|
|
|
29005
29048
|
}
|
|
29006
29049
|
return this.secondaryFees;
|
|
29007
29050
|
}
|
|
29008
|
-
|
|
29009
|
-
|
|
29051
|
+
parseTokenLiteral(tokenLiteral, decimals) {
|
|
29052
|
+
if (tokenLiteral === 'native') {
|
|
29053
|
+
return this.nativeToken;
|
|
29054
|
+
}
|
|
29055
|
+
return {
|
|
29056
|
+
type: 'erc20',
|
|
29057
|
+
address: tokenLiteral,
|
|
29058
|
+
chainId: this.chainId,
|
|
29059
|
+
decimals,
|
|
29060
|
+
};
|
|
29061
|
+
}
|
|
29062
|
+
async getUnsignedSwapTx(fromAddress, tokenInLiteral, tokenOutLiteral, amount, slippagePercent, maxHops, deadline, tradeType) {
|
|
29063
|
+
Exchange.validate(tokenInLiteral, tokenOutLiteral, maxHops, slippagePercent, fromAddress);
|
|
29010
29064
|
// get the decimals of the tokens that will be swapped
|
|
29011
29065
|
const [tokenInDecimals, tokenOutDecimals, secondaryFees] = await Promise.all([
|
|
29012
|
-
|
|
29013
|
-
|
|
29066
|
+
getTokenDecimals(tokenInLiteral, this.provider, this.nativeToken),
|
|
29067
|
+
getTokenDecimals(tokenOutLiteral, this.provider, this.nativeToken),
|
|
29014
29068
|
this.getSecondaryFees(),
|
|
29015
29069
|
]);
|
|
29016
|
-
const tokenIn =
|
|
29017
|
-
|
|
29018
|
-
address: tokenInAddress,
|
|
29019
|
-
chainId: this.chainId,
|
|
29020
|
-
decimals: tokenInDecimals,
|
|
29021
|
-
};
|
|
29022
|
-
const tokenOut = {
|
|
29023
|
-
type: 'erc20',
|
|
29024
|
-
address: tokenOutAddress,
|
|
29025
|
-
chainId: this.chainId,
|
|
29026
|
-
decimals: tokenOutDecimals,
|
|
29027
|
-
};
|
|
29070
|
+
const tokenIn = this.parseTokenLiteral(tokenInLiteral, tokenInDecimals);
|
|
29071
|
+
const tokenOut = this.parseTokenLiteral(tokenOutLiteral, tokenOutDecimals);
|
|
29028
29072
|
// determine which amount was specified for the swap from the TradeType
|
|
29029
29073
|
const [tokenSpecified, otherToken] = tradeType === Uniswap.TradeType.EXACT_INPUT ? [tokenIn, tokenOut] : [tokenOut, tokenIn];
|
|
29030
29074
|
const amountSpecified = newAmount(amount, tokenSpecified);
|
|
29031
29075
|
const fees = new Fees(secondaryFees, tokenIn);
|
|
29032
29076
|
const ourQuoteReqAmount = getOurQuoteReqAmount(amountSpecified, fees, tradeType, this.nativeTokenService);
|
|
29033
|
-
//
|
|
29077
|
+
// Quotes will always use ERC20s. If the user-specified token is Native, we use the Wrapped Native Token pool
|
|
29034
29078
|
const [ourQuote, gasPrice] = await Promise.all([
|
|
29035
|
-
this.router.findOptimalRoute(ourQuoteReqAmount, otherToken, tradeType, maxHops),
|
|
29079
|
+
this.router.findOptimalRoute(ourQuoteReqAmount, this.nativeTokenService.maybeWrapToken(otherToken), tradeType, maxHops),
|
|
29036
29080
|
fetchGasPrice(this.provider, this.nativeToken),
|
|
29037
29081
|
]);
|
|
29038
29082
|
const adjustedQuote = adjustQuoteWithFees(ourQuote, amountSpecified, fees, this.nativeTokenService);
|
|
29039
29083
|
const swap = getSwap(adjustedQuote, fromAddress, slippagePercent, deadline, this.routerContractAddress, this.secondaryFeeContractAddress, gasPrice, secondaryFees, this.nativeTokenService);
|
|
29040
|
-
const quotedAmount =
|
|
29041
|
-
const
|
|
29042
|
-
const preparedApproval = prepareApproval(tradeType, amountSpecified, amountWithMaxSlippage, {
|
|
29084
|
+
const { quotedAmount, quotedAmountWithMaxSlippage } = prepareUserQuote(this.nativeTokenService, adjustedQuote, slippagePercent, otherToken);
|
|
29085
|
+
const preparedApproval = prepareApproval(tradeType, amountSpecified, quotedAmountWithMaxSlippage, {
|
|
29043
29086
|
routerAddress: this.routerContractAddress,
|
|
29044
29087
|
secondaryFeeAddress: this.secondaryFeeContractAddress,
|
|
29045
29088
|
}, secondaryFees);
|
|
29046
29089
|
// preparedApproval always uses the tokenIn address because we are always selling the tokenIn
|
|
29047
|
-
const approval =
|
|
29048
|
-
|
|
29090
|
+
const approval = preparedApproval
|
|
29091
|
+
? await getApproval(this.provider, fromAddress, preparedApproval, gasPrice)
|
|
29092
|
+
: null;
|
|
29093
|
+
const quote = toPublicQuote(quotedAmount, quotedAmountWithMaxSlippage, slippagePercent, fees);
|
|
29049
29094
|
return { quote, approval, swap };
|
|
29050
29095
|
}
|
|
29051
29096
|
/**
|
|
29052
29097
|
* Get the unsigned swap transaction given the amount to sell.
|
|
29053
29098
|
* Includes quote details for the swap.
|
|
29054
29099
|
*
|
|
29055
|
-
* @param {string} fromAddress The public address that will sign and submit the transaction
|
|
29056
|
-
* @param {string} tokenInAddress Token address to sell
|
|
29057
|
-
* @param {string} tokenOutAddress Token address to buy
|
|
29058
|
-
* @param {ethers.BigNumberish} amountIn Amount to sell
|
|
29059
|
-
* @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
|
|
29060
|
-
* @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
|
|
29061
|
-
* @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
|
|
29062
|
-
* @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
|
|
29100
|
+
* @param {string} fromAddress The public address that will sign and submit the transaction
|
|
29101
|
+
* @param {string} tokenInAddress Token address or 'native' to sell
|
|
29102
|
+
* @param {string} tokenOutAddress Token address or 'native' to buy
|
|
29103
|
+
* @param {ethers.BigNumberish} amountIn Amount to sell in the smallest unit of the token-in
|
|
29104
|
+
* @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
|
|
29105
|
+
* @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
|
|
29106
|
+
* @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
|
|
29107
|
+
* @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
|
|
29063
29108
|
*/
|
|
29064
29109
|
async getUnsignedSwapTxFromAmountIn(fromAddress, tokenInAddress, tokenOutAddress, amountIn, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
|
|
29065
29110
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.ethers.BigNumber.from(amountIn), slippagePercent, maxHops, deadline, Uniswap.TradeType.EXACT_INPUT);
|
|
@@ -29068,14 +29113,14 @@ class Exchange {
|
|
|
29068
29113
|
* Get the unsigned swap transaction given the amount to buy.
|
|
29069
29114
|
* Includes quote details for the swap.
|
|
29070
29115
|
*
|
|
29071
|
-
* @param {string} fromAddress The public address that will sign and submit the transaction
|
|
29072
|
-
* @param {string} tokenInAddress
|
|
29073
|
-
* @param {string} tokenOutAddress
|
|
29074
|
-
* @param {ethers.BigNumberish} amountOut Amount to buy
|
|
29075
|
-
* @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
|
|
29076
|
-
* @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
|
|
29077
|
-
* @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
|
|
29078
|
-
* @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
|
|
29116
|
+
* @param {string} fromAddress The public address that will sign and submit the transaction
|
|
29117
|
+
* @param {string} tokenInAddress ERC20 contract address or 'native' to sell
|
|
29118
|
+
* @param {string} tokenOutAddress ERC20 contract address or 'native' to buy
|
|
29119
|
+
* @param {ethers.BigNumberish} amountOut Amount to buy in the smallest unit of the token-out
|
|
29120
|
+
* @param {number} slippagePercent (optional) The percentage of slippage tolerance. Default = 0.1. Max = 50. Min = 0
|
|
29121
|
+
* @param {number} maxHops (optional) Maximum hops allowed in optimal route. Default is 2
|
|
29122
|
+
* @param {number} deadline (optional) Latest time swap can execute. Default is 15 minutes
|
|
29123
|
+
* @return {TransactionResponse} The result containing the unsigned transaction and details of the swap
|
|
29079
29124
|
*/
|
|
29080
29125
|
async getUnsignedSwapTxFromAmountOut(fromAddress, tokenInAddress, tokenOutAddress, amountOut, slippagePercent = DEFAULT_SLIPPAGE, maxHops = DEFAULT_MAX_HOPS, deadline = DEFAULT_DEADLINE) {
|
|
29081
29126
|
return await this.getUnsignedSwapTx(fromAddress, tokenInAddress, tokenOutAddress, ethers.ethers.BigNumber.from(amountOut), slippagePercent, maxHops, deadline, Uniswap.TradeType.EXACT_OUTPUT);
|
|
@@ -29319,6 +29364,14 @@ const $d85ad1457a3f1a83$export$fc55ed5a42b458ba = {
|
|
|
29319
29364
|
[($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET]: {
|
|
29320
29365
|
url: "https://explorer.mainnet.immutable.com",
|
|
29321
29366
|
nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_MAINNET).nativeCurrency
|
|
29367
|
+
},
|
|
29368
|
+
[($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA]: {
|
|
29369
|
+
url: "https://eth-sepolia.blockscout.com",
|
|
29370
|
+
nativeToken: $d85ad1457a3f1a83$export$3e81fc0987227f10.get(($0472f23319457bfb$export$c06e1e7429de6283).SEPOLIA).nativeCurrency
|
|
29371
|
+
},
|
|
29372
|
+
[($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM]: {
|
|
29373
|
+
url: "https://eth.blockscout.com/",
|
|
29374
|
+
nativeToken: $d85ad1457a3f1a83$export$6f24f3cef7d501c4.get(($0472f23319457bfb$export$c06e1e7429de6283).ETHEREUM).nativeCurrency
|
|
29322
29375
|
}
|
|
29323
29376
|
};
|
|
29324
29377
|
const $d85ad1457a3f1a83$export$db5daa1b5156ccfe = [
|
|
@@ -29918,6 +29971,7 @@ const $efe60cea83bfc4e8$export$473cec51305fdae8 = async (config, { type: type =
|
|
|
29918
29971
|
|
|
29919
29972
|
|
|
29920
29973
|
|
|
29974
|
+
|
|
29921
29975
|
const $fd8a8472dcc3ec2b$var$CACHE_DATA_TTL = 60; // seconds
|
|
29922
29976
|
class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
|
|
29923
29977
|
url;
|
|
@@ -30051,6 +30105,20 @@ class $fd8a8472dcc3ec2b$export$ef140a6b05dfc786 {
|
|
|
30051
30105
|
|
|
30052
30106
|
|
|
30053
30107
|
|
|
30108
|
+
const $458d407830d66110$export$e6a390ea6399b7d8 = (config, debugString, seconds)=>{
|
|
30109
|
+
// eslint-disable-next-line no-console
|
|
30110
|
+
if (!config.isProduction) console.debug(debugString, seconds);
|
|
30111
|
+
};
|
|
30112
|
+
const $458d407830d66110$export$5280dbcb91c8b391 = async (config, debugString, promise)=>{
|
|
30113
|
+
const startTime = performance.now();
|
|
30114
|
+
const result = await promise;
|
|
30115
|
+
const endTime = performance.now();
|
|
30116
|
+
const elapsedTimeInSeconds = (endTime - startTime) / 1000;
|
|
30117
|
+
$458d407830d66110$export$e6a390ea6399b7d8(config, debugString, elapsedTimeInSeconds);
|
|
30118
|
+
return result;
|
|
30119
|
+
};
|
|
30120
|
+
|
|
30121
|
+
|
|
30054
30122
|
const $1564e43dde50bb61$export$df96cd8d56be0ab1 = async (config, web3Provider, walletAddress)=>await ($a8bc256d81a5e2c1$export$bacc563de539c6c3)(async ()=>{
|
|
30055
30123
|
const networkInfo = await ($de192de6ef100f9f$export$79f13b4cfaaf0d09)(config, web3Provider);
|
|
30056
30124
|
if (!networkInfo.isSupported) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(`Chain:${networkInfo.chainId} is not a supported chain`, ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CHAIN_NOT_SUPPORTED_ERROR, {
|
|
@@ -30090,18 +30158,23 @@ async function $1564e43dde50bb61$export$60e0fe116a0e6ed0(web3Provider, walletAdd
|
|
|
30090
30158
|
type: ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_ERC20_BALANCE_ERROR
|
|
30091
30159
|
});
|
|
30092
30160
|
}
|
|
30093
|
-
// Blockscout client singleton
|
|
30094
|
-
|
|
30095
|
-
const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
30161
|
+
// Blockscout client singleton per chain id
|
|
30162
|
+
const $1564e43dde50bb61$var$blockscoutClientMap = new Map();
|
|
30163
|
+
const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId, filterTokens)=>{
|
|
30096
30164
|
// Shuffle the mapping of the tokens configuration so it is a hashmap
|
|
30097
30165
|
// for faster access to tokens config objects.
|
|
30098
|
-
const
|
|
30166
|
+
const shouldFilter = filterTokens.length > 0;
|
|
30167
|
+
const mapFilterTokens = Object.assign({}, ...filterTokens.map((t)=>({
|
|
30099
30168
|
[t.address || ""]: t
|
|
30100
30169
|
})));
|
|
30101
|
-
//
|
|
30102
|
-
|
|
30103
|
-
|
|
30104
|
-
|
|
30170
|
+
// Get blockscout client for the given chain
|
|
30171
|
+
let blockscoutClient = $1564e43dde50bb61$var$blockscoutClientMap.get(chainId);
|
|
30172
|
+
if (!blockscoutClient) {
|
|
30173
|
+
blockscoutClient = new ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786)({
|
|
30174
|
+
chainId: chainId
|
|
30175
|
+
});
|
|
30176
|
+
$1564e43dde50bb61$var$blockscoutClientMap.set(chainId, blockscoutClient);
|
|
30177
|
+
}
|
|
30105
30178
|
// Hold the items in an array for post-fetching processing
|
|
30106
30179
|
const items = [];
|
|
30107
30180
|
const tokenType = ($887a00f8f72d61f0$export$5bd1ea2b3d18210).ERC20;
|
|
@@ -30111,7 +30184,7 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
|
30111
30184
|
try {
|
|
30112
30185
|
do {
|
|
30113
30186
|
// eslint-disable-next-line no-await-in-loop
|
|
30114
|
-
resp = await
|
|
30187
|
+
resp = await blockscoutClient.getTokensByWalletAddress({
|
|
30115
30188
|
walletAddress: walletAddress,
|
|
30116
30189
|
tokenType: tokenType,
|
|
30117
30190
|
nextPage: resp?.next_page_params
|
|
@@ -30129,7 +30202,7 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
|
30129
30202
|
if (err?.code !== (globalAxios$1.HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getTokensByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30130
30203
|
}
|
|
30131
30204
|
try {
|
|
30132
|
-
const respNative = await
|
|
30205
|
+
const respNative = await blockscoutClient.getNativeTokenByWalletAddress({
|
|
30133
30206
|
walletAddress: walletAddress
|
|
30134
30207
|
});
|
|
30135
30208
|
items.push(respNative);
|
|
@@ -30143,24 +30216,26 @@ const $1564e43dde50bb61$export$8c978679845804d4 = async (walletAddress, chainId,
|
|
|
30143
30216
|
// or simply an incorrect wallet address was provided.
|
|
30144
30217
|
if (err?.code !== (globalAxios$1.HttpStatusCode).NotFound) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)(err.message || "InternalServerError | getNativeTokenByWalletAddress", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).GET_INDEXER_BALANCE_ERROR, err);
|
|
30145
30218
|
}
|
|
30219
|
+
const balances = [];
|
|
30220
|
+
items.forEach((item)=>{
|
|
30221
|
+
if (shouldFilter && !mapFilterTokens[item.token.address]) return;
|
|
30222
|
+
const tokenData = item.token || {};
|
|
30223
|
+
const balance = (ethers.BigNumber).from(item.value);
|
|
30224
|
+
let decimals = parseInt(tokenData.decimals, 10);
|
|
30225
|
+
if (Number.isNaN(decimals)) decimals = ($d85ad1457a3f1a83$export$903389470ba9433c);
|
|
30226
|
+
const token = {
|
|
30227
|
+
...tokenData,
|
|
30228
|
+
decimals: decimals
|
|
30229
|
+
};
|
|
30230
|
+
const formattedBalance = (ethers.utils).formatUnits(item.value, token.decimals);
|
|
30231
|
+
balances.push({
|
|
30232
|
+
balance: balance,
|
|
30233
|
+
formattedBalance: formattedBalance,
|
|
30234
|
+
token: token
|
|
30235
|
+
});
|
|
30236
|
+
});
|
|
30146
30237
|
return {
|
|
30147
|
-
balances:
|
|
30148
|
-
const tokenData = item.token || {};
|
|
30149
|
-
const balance = (ethers.BigNumber).from(item.value);
|
|
30150
|
-
const renamed = mapRename[tokenData.address] || {};
|
|
30151
|
-
const token = {
|
|
30152
|
-
...tokenData,
|
|
30153
|
-
name: renamed.name ?? tokenData.name,
|
|
30154
|
-
symbol: renamed.symbol ?? tokenData.symbol,
|
|
30155
|
-
decimals: parseInt(tokenData.decimals, 10)
|
|
30156
|
-
};
|
|
30157
|
-
const formattedBalance = (ethers.utils).formatUnits(item.value, token.decimals);
|
|
30158
|
-
return {
|
|
30159
|
-
balance: balance,
|
|
30160
|
-
formattedBalance: formattedBalance,
|
|
30161
|
-
token: token
|
|
30162
|
-
};
|
|
30163
|
-
})
|
|
30238
|
+
balances: balances
|
|
30164
30239
|
};
|
|
30165
30240
|
};
|
|
30166
30241
|
const $1564e43dde50bb61$export$a3238cee431627c6 = async (config, web3Provider, walletAddress, tokens)=>{
|
|
@@ -30191,11 +30266,19 @@ const $1564e43dde50bb61$export$fee49741664a4d7e = async (config, web3Provider, w
|
|
|
30191
30266
|
// eslint-disable-next-line no-console
|
|
30192
30267
|
console.error(err);
|
|
30193
30268
|
}
|
|
30194
|
-
if (flag && ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786).isChainSupported(chainId))
|
|
30269
|
+
if (flag && ($fd8a8472dcc3ec2b$export$ef140a6b05dfc786).isChainSupported(chainId)) {
|
|
30270
|
+
// This is a hack because the widgets are still using the tokens symbol
|
|
30271
|
+
// to drive the conversions. If we remove all the token symbols from e.g. zkevm
|
|
30272
|
+
// then we would not have fiat conversions.
|
|
30273
|
+
// Please remove this hack once https://immutable.atlassian.net/browse/WT-1710
|
|
30274
|
+
// is done.
|
|
30275
|
+
const isL1Chain = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config) === chainId;
|
|
30276
|
+
return ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using blockscout for ${chainId}`, $1564e43dde50bb61$export$8c978679845804d4(walletAddress, chainId, isL1Chain ? tokens : []));
|
|
30277
|
+
}
|
|
30195
30278
|
// This fallback to use ERC20s calls which is a best effort solution
|
|
30196
30279
|
// Fails in fetching data from the RCP calls might result in some
|
|
30197
30280
|
// missing data.
|
|
30198
|
-
return await $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens);
|
|
30281
|
+
return await ($458d407830d66110$export$5280dbcb91c8b391)(config, `Time to fetch balances using RPC for ${chainId}`, $1564e43dde50bb61$export$a3238cee431627c6(config, web3Provider, walletAddress, tokens));
|
|
30199
30282
|
};
|
|
30200
30283
|
|
|
30201
30284
|
|
|
@@ -30436,7 +30519,7 @@ async function $67fc622a2b913d5f$export$7cf6178417769841(chainId, config) {
|
|
|
30436
30519
|
overrides: dexConfig?.overrides
|
|
30437
30520
|
});
|
|
30438
30521
|
}
|
|
30439
|
-
|
|
30522
|
+
function $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config) {
|
|
30440
30523
|
return new (Orderbook)({
|
|
30441
30524
|
baseConfig: {
|
|
30442
30525
|
environment: config.environment
|
|
@@ -31237,8 +31320,8 @@ const $5e9bcae98dc8ff19$export$1165ca270f090a66 = (isDevelopment, isProduction)=
|
|
|
31237
31320
|
|
|
31238
31321
|
|
|
31239
31322
|
|
|
31240
|
-
const $1fda5c40669a566d$export$
|
|
31241
|
-
const $1fda5c40669a566d$export$
|
|
31323
|
+
const $1fda5c40669a566d$export$5d79dcabf4595ae0 = async ()=>true;
|
|
31324
|
+
const $1fda5c40669a566d$export$2c2bcd6e0d9a9969 = async (config)=>{
|
|
31242
31325
|
const availability = ($5e9bcae98dc8ff19$export$1165ca270f090a66)(config.isDevelopment, config.isProduction);
|
|
31243
31326
|
try {
|
|
31244
31327
|
return await availability.checkDexAvailability();
|
|
@@ -31259,18 +31342,18 @@ const $7f2e17f026d4fc8d$export$86d9f998ddda013e = async (config, provider)=>{
|
|
|
31259
31342
|
const geoBlockingChecks = [];
|
|
31260
31343
|
if (availableRoutingOptions.onRamp) geoBlockingChecks.push({
|
|
31261
31344
|
id: "onRamp",
|
|
31262
|
-
promise: ($1fda5c40669a566d$export$
|
|
31345
|
+
promise: ($1fda5c40669a566d$export$5d79dcabf4595ae0)()
|
|
31263
31346
|
});
|
|
31264
31347
|
if (availableRoutingOptions.swap) geoBlockingChecks.push({
|
|
31265
31348
|
id: "swap",
|
|
31266
|
-
promise: ($1fda5c40669a566d$export$
|
|
31349
|
+
promise: ($1fda5c40669a566d$export$2c2bcd6e0d9a9969)(config)
|
|
31267
31350
|
});
|
|
31268
31351
|
if (geoBlockingChecks.length > 0) {
|
|
31269
31352
|
const promises = geoBlockingChecks.map((geoBlockingCheck)=>geoBlockingCheck.promise);
|
|
31270
31353
|
const geoBlockingStatus = await Promise.allSettled(promises);
|
|
31271
31354
|
geoBlockingStatus.forEach((result, index)=>{
|
|
31272
31355
|
const statusId = geoBlockingChecks[index].id;
|
|
31273
|
-
availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" &&
|
|
31356
|
+
availableRoutingOptions[statusId] = availableRoutingOptions[statusId] && result.status === "fulfilled" && result.value;
|
|
31274
31357
|
});
|
|
31275
31358
|
}
|
|
31276
31359
|
// Bridge not available if passport provider
|
|
@@ -31377,7 +31460,7 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
|
|
|
31377
31460
|
}
|
|
31378
31461
|
// Resolve all the quotes and link them back to the swappable token
|
|
31379
31462
|
// The swappable token array is in the same position in the array as the quote in the promise array
|
|
31380
|
-
const dexTransactionResponse = await Promise.allSettled(dexTransactionResponsePromises);
|
|
31463
|
+
const dexTransactionResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve swap quotes from the dex", Promise.allSettled(dexTransactionResponsePromises));
|
|
31381
31464
|
dexTransactionResponse.forEach((response, index)=>{
|
|
31382
31465
|
if (response.status === "rejected") return; // Ignore any requests to dex that failed to resolve
|
|
31383
31466
|
const swappableToken = fromToken[index];
|
|
@@ -31394,15 +31477,6 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
|
|
|
31394
31477
|
};
|
|
31395
31478
|
|
|
31396
31479
|
|
|
31397
|
-
const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache, walletAddress, requiredToken, swappableTokens)=>{
|
|
31398
|
-
const dexQuotes = dexQuoteCache.get(requiredToken.address);
|
|
31399
|
-
if (dexQuotes && dexQuotes.size > 0) return dexQuotes;
|
|
31400
|
-
const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
|
|
31401
|
-
dexQuoteCache.set(requiredToken.address, quotes);
|
|
31402
|
-
return quotes;
|
|
31403
|
-
};
|
|
31404
|
-
|
|
31405
|
-
|
|
31406
31480
|
const $91807edfd7057288$var$constructFees = (approvalGasFees, swapGasFees, swapFees)=>{
|
|
31407
31481
|
let approvalGasFeeAmount = (ethers.BigNumber).from(0);
|
|
31408
31482
|
let approvalGasFeeFormatted = "0";
|
|
@@ -31530,11 +31604,17 @@ const $91807edfd7057288$export$7b6318fc1a8067b3 = (l2Balances, approval)=>{
|
|
|
31530
31604
|
approvalGasTokenAddress: approvalGasTokenAddress
|
|
31531
31605
|
};
|
|
31532
31606
|
};
|
|
31533
|
-
const $91807edfd7057288$export$38077235fe748d40 = (l2Balances,
|
|
31607
|
+
const $91807edfd7057288$export$38077235fe748d40 = (l2Balances, approvalFees, swapGasFees, swapFees, tokenBeingSwapped)=>{
|
|
31534
31608
|
// Set up a map of token addresses to amounts for each of the swap fees
|
|
31535
31609
|
const feeMap = new Map();
|
|
31536
31610
|
// Add the approval fee to list of fees
|
|
31537
31611
|
if (approvalFees.approvalGasTokenAddress !== "") feeMap.set(approvalFees.approvalGasTokenAddress, approvalFees.approvalGasFee);
|
|
31612
|
+
// Add the swap gas fee to list of fees
|
|
31613
|
+
if (swapGasFees) {
|
|
31614
|
+
const fee = feeMap.get(swapGasFees.token.address);
|
|
31615
|
+
if (fee) feeMap.set(swapGasFees.token.address, fee.add(swapGasFees.value));
|
|
31616
|
+
else feeMap.set(swapGasFees.token.address, swapGasFees.value);
|
|
31617
|
+
}
|
|
31538
31618
|
// Add the token being swapped to list of fees to ensure the user can cover the fee + the token swap
|
|
31539
31619
|
if (tokenBeingSwapped) {
|
|
31540
31620
|
const fee = feeMap.get(tokenBeingSwapped.address);
|
|
@@ -31583,7 +31663,7 @@ const $91807edfd7057288$export$567a0c83c08c514b = (l2balance, balanceRequirement
|
|
|
31583
31663
|
// that is going to be swapped from another item requirement then return true
|
|
31584
31664
|
return remainingBalance.gte(amountBeingSwapped);
|
|
31585
31665
|
};
|
|
31586
|
-
const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions,
|
|
31666
|
+
const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutingOptions, walletAddress, balanceRequirement, tokenBalanceResults, swappableTokens, balanceRequirements)=>{
|
|
31587
31667
|
const fundingSteps = [];
|
|
31588
31668
|
if (!availableRoutingOptions.swap) return fundingSteps;
|
|
31589
31669
|
if (swappableTokens.length === 0) return fundingSteps;
|
|
@@ -31594,7 +31674,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
31594
31674
|
if (!l2TokenBalanceResult) return fundingSteps;
|
|
31595
31675
|
const l2Balances = l2TokenBalanceResult.balances;
|
|
31596
31676
|
if (l2Balances.length === 0) return fundingSteps;
|
|
31597
|
-
const quotes = await ($
|
|
31677
|
+
const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
|
|
31598
31678
|
const quoteTokenAddresses = Array.from(quotes.keys());
|
|
31599
31679
|
for (const quoteTokenAddress of quoteTokenAddresses){
|
|
31600
31680
|
const quote = quotes.get(quoteTokenAddress);
|
|
@@ -31611,7 +31691,7 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
31611
31691
|
// If user does not have enough to cover approval fees then continue
|
|
31612
31692
|
if (!approvalFees.sufficient) continue;
|
|
31613
31693
|
// If user does not have enough to cover swap fees then continue
|
|
31614
|
-
if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, quote.quote.fees,
|
|
31694
|
+
if (!$91807edfd7057288$export$38077235fe748d40(l2Balances, approvalFees, quote.swap, quote.quote.fees, {
|
|
31615
31695
|
amount: amountOfQuoteTokenRequired.value,
|
|
31616
31696
|
address: quoteTokenAddress
|
|
31617
31697
|
})) continue;
|
|
@@ -32016,13 +32096,14 @@ const $7500587317643fc8$export$c3e193fd573f1a94 = async (config, swappableTokens
|
|
|
32016
32096
|
|
|
32017
32097
|
|
|
32018
32098
|
|
|
32019
|
-
|
|
32099
|
+
|
|
32100
|
+
const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
|
|
32020
32101
|
const filteredSwappableTokensAddresses = [];
|
|
32021
32102
|
for (const token of filteredSwappableTokens){
|
|
32022
32103
|
if (!token.address) continue;
|
|
32023
32104
|
filteredSwappableTokensAddresses.push(token.address);
|
|
32024
32105
|
}
|
|
32025
|
-
const dexQuotes = await ($
|
|
32106
|
+
const dexQuotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), ownerAddress, {
|
|
32026
32107
|
address: requiredTokenAddress,
|
|
32027
32108
|
amount: insufficientRequirement.delta.balance
|
|
32028
32109
|
}, filteredSwappableTokensAddresses);
|
|
@@ -32132,7 +32213,7 @@ const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundi
|
|
|
32132
32213
|
}
|
|
32133
32214
|
return bridgeAndSwapRoutes;
|
|
32134
32215
|
};
|
|
32135
|
-
const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement,
|
|
32216
|
+
const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
|
|
32136
32217
|
const { l1balances: l1balances, l2balances: l2balances } = ($7bb5af1d8b5d9127$export$8280985cc3da7882)(config, tokenBalances);
|
|
32137
32218
|
const requiredTokenAddress = insufficientRequirement.required.token.address;
|
|
32138
32219
|
if ($afd57acae9471ac5$export$b94e88f4f8805f71(bridgeableTokens, swappableTokens, l1balances, l2balances, availableRoutingOptions, requiredTokenAddress)) return [];
|
|
@@ -32143,7 +32224,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
|
|
|
32143
32224
|
const filteredSwappableTokens = $afd57acae9471ac5$export$ed7c59bd8d1bb5a7(requiredTokenAddress, bridgeableTokens, swappableTokens, l1tol2Addresses);
|
|
32144
32225
|
if (filteredSwappableTokens.length === 0) return [];
|
|
32145
32226
|
// Fetch all the dex quotes from the list of swappable tokens
|
|
32146
|
-
const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config,
|
|
32227
|
+
const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
|
|
32147
32228
|
// Construct bridge requirements based on L2 balances, slippage and swap fees
|
|
32148
32229
|
const bridgeRequirements = ($62e968a3dd87940e$export$df667c749c93b110)(dexQuotes, l1balances, l2balances, l1tol2Addresses, balanceRequirements);
|
|
32149
32230
|
if (bridgeRequirements.length === 0) return [];
|
|
@@ -32186,7 +32267,7 @@ const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProvide
|
|
|
32186
32267
|
// Modify the users L2 balance to include the amount as if the user successfully bridged
|
|
32187
32268
|
const modifiedTokenBalances = $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount(config, tokenBalances, l2balances, bridgedTokens, swappableTokens);
|
|
32188
32269
|
// Call the swap route with the faked bridged balances
|
|
32189
|
-
const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions,
|
|
32270
|
+
const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging, balanceRequirements);
|
|
32190
32271
|
if (!swapRoutes) return [];
|
|
32191
32272
|
const originalBalanceSwapRoutes = $afd57acae9471ac5$export$1fc63300bde5e690(tokenBalances, swapRoutes);
|
|
32192
32273
|
return $afd57acae9471ac5$export$d9b96654eebdaf2a(bridgeResults, originalBalanceSwapRoutes, l1tol2Addresses);
|
|
@@ -32228,6 +32309,7 @@ const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutin
|
|
|
32228
32309
|
|
|
32229
32310
|
|
|
32230
32311
|
|
|
32312
|
+
|
|
32231
32313
|
const $c16168a9c28ae4fd$var$hasAvailableRoutingOptions = (availableRoutingOptions)=>availableRoutingOptions.bridge || availableRoutingOptions.swap || availableRoutingOptions.onRamp;
|
|
32232
32314
|
const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
|
|
32233
32315
|
let insufficientBalanceCount = 0;
|
|
@@ -32251,7 +32333,7 @@ const $c16168a9c28ae4fd$export$ab86023c267660 = async (config, readOnlyProviders
|
|
|
32251
32333
|
if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, bridgeRequirement, tokenBalances, feeEstimates);
|
|
32252
32334
|
return bridgeFundingStep;
|
|
32253
32335
|
};
|
|
32254
|
-
const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement,
|
|
32336
|
+
const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, swapTokenAllowList, balanceRequirements)=>{
|
|
32255
32337
|
const fundingSteps = [];
|
|
32256
32338
|
if (!availableRoutingOptions.swap) return fundingSteps;
|
|
32257
32339
|
if (insufficientRequirement === undefined) return fundingSteps;
|
|
@@ -32262,9 +32344,9 @@ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutin
|
|
|
32262
32344
|
if (swapTokenAllowList.length === 0) return fundingSteps;
|
|
32263
32345
|
const swappableTokens = swapTokenAllowList.filter((token)=>token.address).map((token)=>token.address);
|
|
32264
32346
|
if (swappableTokens.length === 0) return fundingSteps;
|
|
32265
|
-
return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions,
|
|
32347
|
+
return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens, balanceRequirements);
|
|
32266
32348
|
};
|
|
32267
|
-
const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement,
|
|
32349
|
+
const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
|
|
32268
32350
|
if (!insufficientRequirement) return [];
|
|
32269
32351
|
const l1balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
32270
32352
|
const l2balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
@@ -32282,7 +32364,7 @@ const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProvide
|
|
|
32282
32364
|
});
|
|
32283
32365
|
const swapTokenAllowList = tokenAllowList?.swap ?? [];
|
|
32284
32366
|
if (insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE && insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return [];
|
|
32285
|
-
const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement,
|
|
32367
|
+
const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
|
|
32286
32368
|
return routes;
|
|
32287
32369
|
};
|
|
32288
32370
|
const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutingOptions, insufficientRequirement)=>{
|
|
@@ -32304,20 +32386,18 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
32304
32386
|
message: err.message
|
|
32305
32387
|
});
|
|
32306
32388
|
}
|
|
32307
|
-
const tokenBalances = await ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions);
|
|
32308
|
-
const allowList = await ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions);
|
|
32309
|
-
//
|
|
32389
|
+
const tokenBalances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get token balances inside router", ($33acec7b4a26c053$export$23ddeb2642d2f9d)(config, readOnlyProviders, ownerAddress, availableRoutingOptions));
|
|
32390
|
+
const allowList = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get routing allowlist", ($5a5ccedc98d53d25$export$1ad29657d49c5440)(config, tokenBalances, availableRoutingOptions));
|
|
32391
|
+
// Fee estimate cache
|
|
32310
32392
|
const feeEstimates = new Map();
|
|
32311
|
-
// Dex quotes cache
|
|
32312
|
-
const dexQuoteCache = new Map();
|
|
32313
32393
|
// Ensures only 1 balance requirement is insufficient
|
|
32314
32394
|
const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
|
|
32315
32395
|
const routePromises = [];
|
|
32316
32396
|
routePromises.push($c16168a9c28ae4fd$export$ab86023c267660(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, feeEstimates));
|
|
32317
|
-
routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement,
|
|
32397
|
+
routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList.swap, balanceRequirements));
|
|
32318
32398
|
routePromises.push($c16168a9c28ae4fd$export$e1b6e4d22d0365ee(config, availableRoutingOptions, insufficientRequirement));
|
|
32319
|
-
routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement,
|
|
32320
|
-
const resolved = await Promise.all(routePromises);
|
|
32399
|
+
routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
|
|
32400
|
+
const resolved = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to resolve all routes", Promise.all(routePromises));
|
|
32321
32401
|
let bridgeFundingStep;
|
|
32322
32402
|
let swapFundingSteps = [];
|
|
32323
32403
|
let onRampFundingStep;
|
|
@@ -32384,26 +32464,31 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
32384
32464
|
};
|
|
32385
32465
|
|
|
32386
32466
|
|
|
32467
|
+
|
|
32387
32468
|
const $0e7419077c373b24$export$9e073f9ada8c81e6 = async (config, provider, itemRequirements, transactionOrGasAmount)=>{
|
|
32388
32469
|
const ownerAddress = await provider.getSigner().getAddress();
|
|
32389
32470
|
let aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(itemRequirements);
|
|
32390
|
-
const
|
|
32391
|
-
const
|
|
32392
|
-
const
|
|
32393
|
-
|
|
32471
|
+
const erc20AllowancePromise = ($fc8b338399d890f3$export$d93c00812189e36)(provider, ownerAddress, aggregatedItems);
|
|
32472
|
+
const erc721AllowancePromise = ($35c3fc7013888ba5$export$be546c525d418988)(provider, ownerAddress, aggregatedItems);
|
|
32473
|
+
const resolvedAllowances = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to calculate token allowances", Promise.all([
|
|
32474
|
+
erc20AllowancePromise,
|
|
32475
|
+
erc721AllowancePromise
|
|
32476
|
+
]));
|
|
32477
|
+
const aggregatedAllowances = ($ddc6bcd0896481e5$export$2fbfa41a4de56a89)(resolvedAllowances[0], resolvedAllowances[1]);
|
|
32478
|
+
const gasItem = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run gas calculator", ($7d1bfafb81e64d74$export$3a4140bd9e983e4e)(provider, aggregatedAllowances, transactionOrGasAmount));
|
|
32394
32479
|
if (gasItem !== null) {
|
|
32395
32480
|
aggregatedItems.push(gasItem);
|
|
32396
32481
|
aggregatedItems = ($074f75878f618031$export$c804c9ade5c28607)(aggregatedItems);
|
|
32397
32482
|
}
|
|
32398
|
-
const balanceCheckResult = await ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems);
|
|
32483
|
+
const balanceCheckResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to run balance checks", ($beb896e098e41faf$export$ddfc885f43c3cb6e)(config, provider, ownerAddress, aggregatedItems));
|
|
32399
32484
|
const { sufficient: sufficient } = balanceCheckResult;
|
|
32400
32485
|
const transactionRequirements = balanceCheckResult.balanceRequirements;
|
|
32401
32486
|
if (sufficient) return {
|
|
32402
32487
|
sufficient: sufficient,
|
|
32403
32488
|
transactionRequirements: transactionRequirements
|
|
32404
32489
|
};
|
|
32405
|
-
const availableRoutingOptions = await ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider);
|
|
32406
|
-
const routingOutcome = await ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions);
|
|
32490
|
+
const availableRoutingOptions = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch available routing options", ($7f2e17f026d4fc8d$export$86d9f998ddda013e)(config, provider));
|
|
32491
|
+
const routingOutcome = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time to run the routing calculator", ($c16168a9c28ae4fd$export$92606e71d0a264ff)(config, ownerAddress, balanceCheckResult, availableRoutingOptions));
|
|
32407
32492
|
return {
|
|
32408
32493
|
sufficient: sufficient,
|
|
32409
32494
|
transactionRequirements: transactionRequirements,
|
|
@@ -32586,6 +32671,7 @@ const $9051cee080948594$export$1e69c9cfc42e28d8 = (orderFees, weiAmount, decimal
|
|
|
32586
32671
|
};
|
|
32587
32672
|
|
|
32588
32673
|
|
|
32674
|
+
|
|
32589
32675
|
const $64863c39386de592$export$4249179755829904 = (type, contractAddress, amount, spenderAddress)=>{
|
|
32590
32676
|
switch(type){
|
|
32591
32677
|
case ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20:
|
|
@@ -32624,8 +32710,8 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
32624
32710
|
if (orders.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orders were provided to the orders array. Please provide at least one order.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).FULFILL_ORDER_LISTING_ERROR);
|
|
32625
32711
|
const { id: id, takerFees: takerFees } = orders[0];
|
|
32626
32712
|
try {
|
|
32627
|
-
orderbook =
|
|
32628
|
-
order = await orderbook.getListing(id);
|
|
32713
|
+
orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
32714
|
+
order = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to fetch the listing from the orderbook", orderbook.getListing(id));
|
|
32629
32715
|
const { seaportContractAddress: seaportContractAddress } = orderbook.config();
|
|
32630
32716
|
spenderAddress = seaportContractAddress;
|
|
32631
32717
|
} catch (err) {
|
|
@@ -32642,23 +32728,26 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
32642
32728
|
let decimals = 18;
|
|
32643
32729
|
if (order.result.buy[0].type === "ERC20") {
|
|
32644
32730
|
const tokenContract = $06a6c5c23f7f2479$export$fbbc17f6e6e58544(order.result.buy[0].contractAddress, ($d85ad1457a3f1a83$export$db5daa1b5156ccfe), provider);
|
|
32645
|
-
decimals = await tokenContract.decimals();
|
|
32731
|
+
decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", tokenContract.decimals());
|
|
32646
32732
|
}
|
|
32647
32733
|
let fees = [];
|
|
32648
32734
|
if (takerFees && takerFees.length > 0) fees = ($9051cee080948594$export$1e69c9cfc42e28d8)(takerFees, buyToken.amount, decimals);
|
|
32649
32735
|
let unsignedApprovalTransactions = [];
|
|
32650
32736
|
let unsignedFulfillmentTransactions = [];
|
|
32651
32737
|
let orderActions = [];
|
|
32738
|
+
const fulfillOrderStartTime = new Date().getTime();
|
|
32652
32739
|
try {
|
|
32653
|
-
const fulfillerAddress = await provider.getSigner().getAddress();
|
|
32654
|
-
const { actions: actions } = await orderbook.fulfillOrder(id, fulfillerAddress, fees);
|
|
32740
|
+
const fulfillerAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
|
|
32741
|
+
const { actions: actions } = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to call fulfillOrder from the orderbook", orderbook.fulfillOrder(id, fulfillerAddress, fees));
|
|
32655
32742
|
orderActions = actions;
|
|
32656
|
-
unsignedApprovalTransactions = await (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions);
|
|
32657
|
-
} catch
|
|
32658
|
-
|
|
32743
|
+
unsignedApprovalTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned approval transactions", (0, $a7367d01c6e76b1c$export$f64a20a30eb98855)(actions));
|
|
32744
|
+
} catch (err) {
|
|
32745
|
+
// Silently ignore error as this is usually thrown if user does not have enough balance
|
|
32746
|
+
const elapsedTimeInSeconds = (new Date().getTime() - fulfillOrderStartTime) / 1000;
|
|
32747
|
+
($458d407830d66110$export$e6a390ea6399b7d8)(config, "Time to call fulfillOrder from the orderbook", elapsedTimeInSeconds);
|
|
32659
32748
|
}
|
|
32660
32749
|
try {
|
|
32661
|
-
unsignedFulfillmentTransactions = await (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions);
|
|
32750
|
+
unsignedFulfillmentTransactions = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to construct the unsigned fulfillment transactions", (0, $a7367d01c6e76b1c$export$396bd6ce7d3ab533)(orderActions));
|
|
32662
32751
|
} catch {
|
|
32663
32752
|
// if cannot estimate gas then silently continue and use gas limit in smartCheckout
|
|
32664
32753
|
// but get the fulfillment transactions after they have approved the spending
|
|
@@ -32690,7 +32779,7 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
32690
32779
|
const itemRequirements = [
|
|
32691
32780
|
$64863c39386de592$export$4249179755829904(type, contractAddress, amount, spenderAddress)
|
|
32692
32781
|
];
|
|
32693
|
-
const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions));
|
|
32782
|
+
const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, $64863c39386de592$export$8f2ff92ab8657f0b(gasLimit, unsignedFulfillmentTransactions)));
|
|
32694
32783
|
if (smartCheckoutResult.sufficient) {
|
|
32695
32784
|
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedApprovalTransactions);
|
|
32696
32785
|
if (approvalResult.type === ($d855a5ba32004345$export$f51b97f3aaf2d5a8).FAILED) return {
|
|
@@ -32732,15 +32821,16 @@ const $64863c39386de592$export$7f8e2b98eca5a7f0 = async (config, provider, order
|
|
|
32732
32821
|
|
|
32733
32822
|
|
|
32734
32823
|
|
|
32824
|
+
|
|
32735
32825
|
const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, orderIds)=>{
|
|
32736
32826
|
let unsignedCancelOrderTransaction;
|
|
32737
32827
|
if (orderIds.length === 0) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No orderIds were provided to the orderIds array. Please provide at least one orderId.", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR);
|
|
32738
32828
|
// Update this when bulk cancel is supported
|
|
32739
32829
|
const orderId = orderIds[0];
|
|
32740
32830
|
try {
|
|
32741
|
-
const offererAddress = await provider.getSigner().getAddress();
|
|
32742
|
-
const orderbook =
|
|
32743
|
-
const cancelOrderResponse = await orderbook.cancelOrder(orderId, offererAddress);
|
|
32831
|
+
const offererAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
|
|
32832
|
+
const orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
32833
|
+
const cancelOrderResponse = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the cancel order from the orderbook", orderbook.cancelOrder(orderId, offererAddress));
|
|
32744
32834
|
unsignedCancelOrderTransaction = cancelOrderResponse.unsignedCancelOrderTransaction;
|
|
32745
32835
|
} catch (err) {
|
|
32746
32836
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while cancelling the order listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).CANCEL_ORDER_LISTING_ERROR, {
|
|
@@ -32773,6 +32863,7 @@ const $9c3db1bb9c8b69d3$export$70b61ad426ddbe54 = async (config, provider, order
|
|
|
32773
32863
|
|
|
32774
32864
|
|
|
32775
32865
|
|
|
32866
|
+
|
|
32776
32867
|
const $9085b221b72ac69e$export$af768ccdf17d5c04 = (id, contractAddress, spenderAddress)=>({
|
|
32777
32868
|
type: ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC721,
|
|
32778
32869
|
id: id,
|
|
@@ -32801,15 +32892,15 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
32801
32892
|
if (buyToken.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
|
|
32802
32893
|
// get this from the allowed list
|
|
32803
32894
|
const buyTokenContract = new (ethers.Contract)(buyToken.contractAddress, JSON.stringify(($d85ad1457a3f1a83$export$db5daa1b5156ccfe)), provider);
|
|
32804
|
-
decimals = await buyTokenContract.decimals();
|
|
32895
|
+
decimals = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get decimals of token contract for the buy token", buyTokenContract.decimals());
|
|
32805
32896
|
}
|
|
32806
32897
|
const buyTokenOrNative = $9085b221b72ac69e$export$586d02673c66d423(buyToken, decimals);
|
|
32807
32898
|
try {
|
|
32808
|
-
const walletAddress = await provider.getSigner().getAddress();
|
|
32809
|
-
orderbook =
|
|
32899
|
+
const walletAddress = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to get the address from the provider", provider.getSigner().getAddress());
|
|
32900
|
+
orderbook = $67fc622a2b913d5f$export$c60ce6c6a92bc2ff(config);
|
|
32810
32901
|
const { seaportContractAddress: seaportContractAddress } = orderbook.config();
|
|
32811
32902
|
spenderAddress = seaportContractAddress;
|
|
32812
|
-
listing = await orderbook.prepareListing({
|
|
32903
|
+
listing = await (0, $458d407830d66110$export$5280dbcb91c8b391)(config, "Time to prepare the listing from the orderbook", orderbook.prepareListing({
|
|
32813
32904
|
makerAddress: walletAddress,
|
|
32814
32905
|
buy: buyTokenOrNative,
|
|
32815
32906
|
sell: {
|
|
@@ -32817,7 +32908,7 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
32817
32908
|
contractAddress: sellToken.collectionAddress,
|
|
32818
32909
|
tokenId: sellToken.id
|
|
32819
32910
|
}
|
|
32820
|
-
});
|
|
32911
|
+
}));
|
|
32821
32912
|
} catch (err) {
|
|
32822
32913
|
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("An error occurred while preparing the listing", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PREPARE_ORDER_LISTING_ERROR, {
|
|
32823
32914
|
message: err.message,
|
|
@@ -32828,13 +32919,13 @@ const $9085b221b72ac69e$export$e761f9e0703de895 = async (config, provider, order
|
|
|
32828
32919
|
const itemRequirements = [
|
|
32829
32920
|
$9085b221b72ac69e$export$af768ccdf17d5c04(sellToken.id, sellToken.collectionAddress, spenderAddress)
|
|
32830
32921
|
];
|
|
32831
|
-
const smartCheckoutResult = await ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
|
|
32922
|
+
const smartCheckoutResult = await ($458d407830d66110$export$5280dbcb91c8b391)(config, "Total time running smart checkout", ($0e7419077c373b24$export$9e073f9ada8c81e6)(config, provider, itemRequirements, {
|
|
32832
32923
|
type: ($4b58188d47aafe8d$export$65c64e46348ee3c1).GAS,
|
|
32833
32924
|
gasToken: {
|
|
32834
32925
|
type: ($4b58188d47aafe8d$export$537fa3efd10ed435).NATIVE,
|
|
32835
32926
|
limit: (ethers.BigNumber).from((constants).estimatedFulfillmentGasGwei)
|
|
32836
32927
|
}
|
|
32837
|
-
});
|
|
32928
|
+
}));
|
|
32838
32929
|
if (smartCheckoutResult.sufficient) {
|
|
32839
32930
|
const unsignedTransactions = await ($a7367d01c6e76b1c$export$c5b3365853cb6159)(listing.actions);
|
|
32840
32931
|
const approvalResult = await ($25ac589234c10b67$export$19693ca396db083e)(provider, unsignedTransactions.approvalTransactions);
|
|
@@ -33165,7 +33256,7 @@ class $a8cb37a3fc8eb863$export$1f60ba4ec72508a0 {
|
|
|
33165
33256
|
const tokenList = await $efe60cea83bfc4e8$export$473cec51305fdae8(this.config, {
|
|
33166
33257
|
type: ($08d5ddc39acd6833$export$fd9b17d87f4121d2).ONRAMP
|
|
33167
33258
|
});
|
|
33168
|
-
const token = tokenList.tokens
|
|
33259
|
+
const token = tokenList.tokens?.find((t)=>t.address?.toLowerCase() === params.tokenAddress?.toLowerCase());
|
|
33169
33260
|
if (token) {
|
|
33170
33261
|
tokenAmount = params.tokenAmount;
|
|
33171
33262
|
tokenSymbol = token.symbol;
|
|
@@ -33238,7 +33329,7 @@ var $045213b18e9f1f94$export$75be0f6af9650f2c;
|
|
|
33238
33329
|
})($045213b18e9f1f94$export$75be0f6af9650f2c || ($045213b18e9f1f94$export$75be0f6af9650f2c = {}));
|
|
33239
33330
|
|
|
33240
33331
|
|
|
33241
|
-
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.
|
|
33332
|
+
const $d663162fd5a0853f$export$38a083d9fb5551ca = "0.27.12";
|
|
33242
33333
|
const $d663162fd5a0853f$export$83bf90b30cdfd29f = ()=>false;
|
|
33243
33334
|
const $d663162fd5a0853f$export$1169f5475725171b = ()=>$d663162fd5a0853f$export$38a083d9fb5551ca;
|
|
33244
33335
|
|
|
@@ -33372,7 +33463,7 @@ var $207ed853f11d19d5$export$5a0ace85cae72d45;
|
|
|
33372
33463
|
IMTBLWidgetEvents["IMTBL_SWAP_WIDGET_EVENT"] = "imtbl-swap-widget";
|
|
33373
33464
|
IMTBLWidgetEvents["IMTBL_BRIDGE_WIDGET_EVENT"] = "imtbl-bridge-widget";
|
|
33374
33465
|
IMTBLWidgetEvents["IMTBL_ONRAMP_WIDGET_EVENT"] = "imtbl-onramp-widget";
|
|
33375
|
-
IMTBLWidgetEvents["
|
|
33466
|
+
IMTBLWidgetEvents["IMTBL_SALE_WIDGET_EVENT"] = "imtbl-sale-widget";
|
|
33376
33467
|
})($207ed853f11d19d5$export$5a0ace85cae72d45 || ($207ed853f11d19d5$export$5a0ace85cae72d45 = {}));
|
|
33377
33468
|
|
|
33378
33469
|
|