@imtbl/sdk 0.21.0 → 0.22.0-alpha.1
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 +580 -224
- package/dist/checkout_widgets.js +1 -1
- package/dist/immutablex_client.js +1 -1
- package/dist/index.browser.js +13 -13
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +624 -4098
- package/dist/index.d.ts +30 -703
- package/dist/index.js +625 -4096
- package/dist/orderbook.d.ts +21 -7
- package/dist/orderbook.js +7 -4
- package/dist/passport.js +2 -2
- package/package.json +2 -20
- package/dist/erc20.d.ts +0 -296
- package/dist/erc20.js +0 -371
- package/dist/erc721.d.ts +0 -592
- package/dist/erc721.js +0 -1790
- package/dist/erc721_mint_by_id.d.ts +0 -521
- package/dist/erc721_mint_by_id.js +0 -1660
package/dist/checkout_sdk.js
CHANGED
|
@@ -16922,11 +16922,14 @@ class Orderbook {
|
|
|
16922
16922
|
})),
|
|
16923
16923
|
},
|
|
16924
16924
|
]);
|
|
16925
|
-
if (fulfillmentDataRes.result.length
|
|
16926
|
-
throw new Error(
|
|
16925
|
+
if (fulfillmentDataRes.result.unfulfillable_orders?.length > 0) {
|
|
16926
|
+
throw new Error(`Unable to prepare fulfillment date: ${fulfillmentDataRes.result.unfulfillable_orders[0].reason}`);
|
|
16927
16927
|
}
|
|
16928
|
-
|
|
16929
|
-
|
|
16928
|
+
else if (fulfillmentDataRes.result.fulfillable_orders?.length !== 1) {
|
|
16929
|
+
throw new Error('unexpected fulfillable order result length');
|
|
16930
|
+
}
|
|
16931
|
+
const extraData = fulfillmentDataRes.result.fulfillable_orders[0].extra_data;
|
|
16932
|
+
const orderResult = fulfillmentDataRes.result.fulfillable_orders[0].order;
|
|
16930
16933
|
if (orderResult.status !== OrderStatus$1.ACTIVE) {
|
|
16931
16934
|
throw new Error(`Cannot fulfil order that is not active. Current status: ${orderResult.status}`);
|
|
16932
16935
|
}
|
|
@@ -19813,7 +19816,7 @@ class APIError extends Error {
|
|
|
19813
19816
|
|
|
19814
19817
|
/* eslint-disable implicit-arrow-linebreak */
|
|
19815
19818
|
const defaultHeaders = {
|
|
19816
|
-
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.
|
|
19819
|
+
sdkVersion: 'ts-immutable-sdk-multi-rollup-api-client-0.22.0-alpha.1',
|
|
19817
19820
|
};
|
|
19818
19821
|
/**
|
|
19819
19822
|
* createAPIConfiguration to create a custom Configuration
|
|
@@ -22244,6 +22247,7 @@ const $7f2e17f026d4fc8d$export$f1ca3744c025ab81 = async (config, provider)=>{
|
|
|
22244
22247
|
|
|
22245
22248
|
|
|
22246
22249
|
|
|
22250
|
+
|
|
22247
22251
|
var $b23305044c0e096a$export$3057de18ac0c076;
|
|
22248
22252
|
(function(RouteCalculatorType) {
|
|
22249
22253
|
RouteCalculatorType["ROUTES_FOUND"] = "ROUTES_FOUND";
|
|
@@ -22305,214 +22309,6 @@ const $33acec7b4a26c053$export$23ddeb2642d2f9d = async (config, readOnlyProvider
|
|
|
22305
22309
|
};
|
|
22306
22310
|
|
|
22307
22311
|
|
|
22308
|
-
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
22309
|
-
|
|
22310
|
-
|
|
22311
|
-
|
|
22312
|
-
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
22313
|
-
for (const balance of balances.balances){
|
|
22314
|
-
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
22315
|
-
}
|
|
22316
|
-
return (BigNumber$1).from(0);
|
|
22317
|
-
};
|
|
22318
|
-
|
|
22319
|
-
|
|
22320
|
-
|
|
22321
|
-
|
|
22322
|
-
|
|
22323
|
-
|
|
22324
|
-
const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProviders)=>{
|
|
22325
|
-
try {
|
|
22326
|
-
const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
|
|
22327
|
-
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
22328
|
-
isSpendingCapApprovalRequired: false
|
|
22329
|
-
}, readOnlyProviders, config);
|
|
22330
|
-
const gasEstimate = estimate.gasFee.estimatedAmount;
|
|
22331
|
-
const bridgeFee = estimate.bridgeFee.estimatedAmount;
|
|
22332
|
-
let totalFees = (0, BigNumber$1).from(0);
|
|
22333
|
-
if (gasEstimate) totalFees = totalFees.add(gasEstimate);
|
|
22334
|
-
if (bridgeFee) totalFees = totalFees.add(bridgeFee);
|
|
22335
|
-
return totalFees;
|
|
22336
|
-
} catch (err) {
|
|
22337
|
-
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
22338
|
-
message: err.message
|
|
22339
|
-
});
|
|
22340
|
-
}
|
|
22341
|
-
};
|
|
22342
|
-
|
|
22343
|
-
|
|
22344
|
-
|
|
22345
|
-
const $823db9fb0ca4bc15$export$c37d8687c27b9660 = "0x0000000000000000000000000000000000000001";
|
|
22346
|
-
const $823db9fb0ca4bc15$export$1430626eec86fce9 = (chainId)=>{
|
|
22347
|
-
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET) return "imtbl-zkevm-testnet";
|
|
22348
|
-
return "";
|
|
22349
|
-
};
|
|
22350
|
-
const $823db9fb0ca4bc15$export$53e663abd9b77fc1 = async (chainId, config)=>{
|
|
22351
|
-
const imxMappingConfig = await config.remote.getConfig("imxAddressMapping");
|
|
22352
|
-
return imxMappingConfig[chainId] ?? "";
|
|
22353
|
-
};
|
|
22354
|
-
|
|
22355
|
-
|
|
22356
|
-
|
|
22357
|
-
|
|
22358
|
-
|
|
22359
|
-
|
|
22360
|
-
|
|
22361
|
-
const $07ac9c0576988336$export$7847f5f5cce25dfa = async (config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, token, depositAmount)=>{
|
|
22362
|
-
try {
|
|
22363
|
-
const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config);
|
|
22364
|
-
const { unsignedTx: unsignedTx } = await tokenBridge.getUnsignedApproveDepositBridgeTx({
|
|
22365
|
-
depositorAddress: depositorAddress,
|
|
22366
|
-
token: token,
|
|
22367
|
-
depositAmount: depositAmount
|
|
22368
|
-
});
|
|
22369
|
-
if (unsignedTx === null) return (0, BigNumber$1).from(0);
|
|
22370
|
-
return await l1provider.estimateGas(unsignedTx);
|
|
22371
|
-
} catch (err) {
|
|
22372
|
-
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while attempting ot estimate gas for approval transaction", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
22373
|
-
message: err.message
|
|
22374
|
-
});
|
|
22375
|
-
}
|
|
22376
|
-
};
|
|
22377
|
-
const $07ac9c0576988336$export$a3dd181de896b7c7 = async (config, readOnlyProviders, l1provider, depositorAddress, l1Address, delta)=>{
|
|
22378
|
-
if (l1Address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) return (BigNumber$1).from(0); // Native ETH does not require approval
|
|
22379
|
-
const fromChainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
22380
|
-
const toChainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
|
|
22381
|
-
return await $07ac9c0576988336$export$7847f5f5cce25dfa(config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, l1Address, delta);
|
|
22382
|
-
};
|
|
22383
|
-
|
|
22384
|
-
|
|
22385
|
-
|
|
22386
|
-
|
|
22387
|
-
const $5a5ccedc98d53d25$var$filterTokens = (allowedTokens, balances)=>{
|
|
22388
|
-
if (balances && balances.success) return allowedTokens.filter((token)=>{
|
|
22389
|
-
if ("address" in token) return balances.balances.find((balance)=>balance.token.address === token.address && balance.balance.gt(0));
|
|
22390
|
-
return balances.balances.find((balance)=>!("address" in balance.token) && balance.balance.gt(0));
|
|
22391
|
-
});
|
|
22392
|
-
return [];
|
|
22393
|
-
};
|
|
22394
|
-
const $5a5ccedc98d53d25$export$9ec9fc71f3ce62c4 = async (config, availableRoutingOptions)=>{
|
|
22395
|
-
if (availableRoutingOptions.onRamp) {
|
|
22396
|
-
const onRampOptions = await config.remote.getConfig("onramp");
|
|
22397
|
-
const onRampAllowList = {};
|
|
22398
|
-
Object.entries(onRampOptions).forEach(([onRampProvider, onRampProviderConfig])=>{
|
|
22399
|
-
// Allowed list per onRamp provider
|
|
22400
|
-
onRampAllowList[onRampProvider] = onRampProviderConfig.tokens ?? [];
|
|
22401
|
-
});
|
|
22402
|
-
return onRampAllowList;
|
|
22403
|
-
}
|
|
22404
|
-
return {};
|
|
22405
|
-
};
|
|
22406
|
-
const $5a5ccedc98d53d25$export$d744af9f1c0712bc = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
22407
|
-
if (availableRoutingOptions.bridge) {
|
|
22408
|
-
const allowedTokens = (await config.remote.getConfig("bridge"))?.tokens ?? [];
|
|
22409
|
-
const balances = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
22410
|
-
return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
|
|
22411
|
-
}
|
|
22412
|
-
return [];
|
|
22413
|
-
};
|
|
22414
|
-
const $5a5ccedc98d53d25$export$87ed7f956d73690 = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
22415
|
-
if (availableRoutingOptions.swap) {
|
|
22416
|
-
const allowedTokens = (await config.remote.getConfig("dex"))?.tokens ?? [];
|
|
22417
|
-
const balances = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
22418
|
-
return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
|
|
22419
|
-
}
|
|
22420
|
-
return [];
|
|
22421
|
-
};
|
|
22422
|
-
const $5a5ccedc98d53d25$export$1ad29657d49c5440 = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
22423
|
-
const tokenAllowList = {};
|
|
22424
|
-
tokenAllowList.swap = await $5a5ccedc98d53d25$export$87ed7f956d73690(config, tokenBalances, availableRoutingOptions);
|
|
22425
|
-
tokenAllowList.bridge = await $5a5ccedc98d53d25$export$d744af9f1c0712bc(config, tokenBalances, availableRoutingOptions);
|
|
22426
|
-
tokenAllowList.onRamp = await $5a5ccedc98d53d25$export$9ec9fc71f3ce62c4(config, availableRoutingOptions);
|
|
22427
|
-
return tokenAllowList;
|
|
22428
|
-
};
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (balances, totalFees)=>{
|
|
22432
|
-
const balance = ($f730af3b727f04ac$export$22fea095b15361de)(balances);
|
|
22433
|
-
return balance.gte(totalFees);
|
|
22434
|
-
};
|
|
22435
|
-
const $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f = (balanceRequirement)=>{
|
|
22436
|
-
if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE) return $d85ad1457a3f1a83$export$b80040cb173ba6e9;
|
|
22437
|
-
if (balanceRequirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return balanceRequirement.required.token.address ?? "";
|
|
22438
|
-
return "";
|
|
22439
|
-
};
|
|
22440
|
-
const $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6 = async (config, balanceRequirement)=>{
|
|
22441
|
-
const l2address = $fa9ac5bfdbbf9dfa$export$97330fab5f794e7f(balanceRequirement);
|
|
22442
|
-
if (l2address === "") return "";
|
|
22443
|
-
if (l2address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) return await ($823db9fb0ca4bc15$export$53e663abd9b77fc1)(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config), config);
|
|
22444
|
-
const chainName = ($823db9fb0ca4bc15$export$1430626eec86fce9)(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
22445
|
-
if (chainName === "") return ""; // Chain name not a valid indexer chain name
|
|
22446
|
-
const blockchainData = ($67fc622a2b913d5f$export$436dd76f23f463ff)(config);
|
|
22447
|
-
const tokenData = await blockchainData.getToken({
|
|
22448
|
-
chainName: chainName,
|
|
22449
|
-
contractAddress: l2address
|
|
22450
|
-
});
|
|
22451
|
-
const l1address = tokenData.result.root_contract_address;
|
|
22452
|
-
if (l1address === null) return ""; // No L1 representation of this token
|
|
22453
|
-
return l1address;
|
|
22454
|
-
};
|
|
22455
|
-
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
22456
|
-
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE);
|
|
22457
|
-
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
22458
|
-
bridgeFeeEstimate = await ($8a49d1a3783a2640$export$3aff971444a4f244)(config, readOnlyProviders);
|
|
22459
|
-
feeEstimates.set(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE, bridgeFeeEstimate);
|
|
22460
|
-
return bridgeFeeEstimate;
|
|
22461
|
-
};
|
|
22462
|
-
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
22463
|
-
type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE,
|
|
22464
|
-
chainId: chainId,
|
|
22465
|
-
asset: {
|
|
22466
|
-
balance: balance.balance,
|
|
22467
|
-
formattedBalance: balance.formattedBalance,
|
|
22468
|
-
token: {
|
|
22469
|
-
name: balance.token.name,
|
|
22470
|
-
symbol: balance.token.symbol,
|
|
22471
|
-
address: balance.token.address,
|
|
22472
|
-
decimals: balance.token.decimals
|
|
22473
|
-
}
|
|
22474
|
-
}
|
|
22475
|
-
});
|
|
22476
|
-
const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
|
|
22477
|
-
if (!address || address === "") return true;
|
|
22478
|
-
return false;
|
|
22479
|
-
};
|
|
22480
|
-
const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProviders, depositorAddress, availableRoutingOptions, balanceRequirement, balances, feeEstimates)=>{
|
|
22481
|
-
if (!availableRoutingOptions.bridge) return undefined;
|
|
22482
|
-
const chainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
22483
|
-
const tokenBalanceResult = balances.get(chainId);
|
|
22484
|
-
const l1provider = readOnlyProviders.get(chainId);
|
|
22485
|
-
if (!l1provider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
|
|
22486
|
-
chainId: chainId.toString()
|
|
22487
|
-
});
|
|
22488
|
-
// If no balances on layer 1 then Bridge cannot be an option
|
|
22489
|
-
if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) return undefined;
|
|
22490
|
-
const allowedTokenList = await ($5a5ccedc98d53d25$export$d744af9f1c0712bc)(config, balances, availableRoutingOptions);
|
|
22491
|
-
if (allowedTokenList.length === 0) return undefined;
|
|
22492
|
-
const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
|
|
22493
|
-
// If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
|
|
22494
|
-
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
|
|
22495
|
-
const l1address = await $fa9ac5bfdbbf9dfa$export$952cdf461a00a8c6(config, balanceRequirement);
|
|
22496
|
-
if (l1address === "") return undefined;
|
|
22497
|
-
// Ensure l1address is in the allowed token list
|
|
22498
|
-
if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
|
|
22499
|
-
if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
|
|
22500
|
-
} else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
|
|
22501
|
-
const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, balanceRequirement.delta.balance);
|
|
22502
|
-
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
|
|
22503
|
-
// If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
|
|
22504
|
-
if (l1address === ($823db9fb0ca4bc15$export$c37d8687c27b9660)) {
|
|
22505
|
-
const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
|
|
22506
|
-
if (nativeETHBalance && nativeETHBalance.balance.gte(balanceRequirement.delta.balance.add(bridgeFeeEstimate))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance);
|
|
22507
|
-
return undefined;
|
|
22508
|
-
}
|
|
22509
|
-
// Find the balance of the L1 representation of the token and check if the balance covers the delta
|
|
22510
|
-
const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
|
|
22511
|
-
if (erc20balance && erc20balance.balance.gte(balanceRequirement.delta.balance)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
|
|
22512
|
-
return undefined;
|
|
22513
|
-
};
|
|
22514
|
-
|
|
22515
|
-
|
|
22516
22312
|
|
|
22517
22313
|
|
|
22518
22314
|
|
|
@@ -22541,11 +22337,13 @@ async function $0e0060cb42e136d2$export$339cb2be73677b30(config, existingReadOnl
|
|
|
22541
22337
|
|
|
22542
22338
|
const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, walletAddress, requiredToken, swappableTokens)=>{
|
|
22543
22339
|
const dexQuotes = new Map();
|
|
22340
|
+
// Apply a small slippage percent as a buffer to cover price fluctuations between token pairs
|
|
22341
|
+
const slippagePercent = 1;
|
|
22544
22342
|
try {
|
|
22545
22343
|
const exchange = await $67fc622a2b913d5f$export$7cf6178417769841(chainId, config);
|
|
22546
22344
|
const dexTransactionResponsePromises = [];
|
|
22547
22345
|
// Create a quote for each swappable token
|
|
22548
|
-
for (const swappableToken of swappableTokens)dexTransactionResponsePromises.push(exchange.getUnsignedSwapTxFromAmountOut(walletAddress, swappableToken, requiredToken.address, requiredToken.amount));
|
|
22346
|
+
for (const swappableToken of swappableTokens)dexTransactionResponsePromises.push(exchange.getUnsignedSwapTxFromAmountOut(walletAddress, swappableToken, requiredToken.address, requiredToken.amount, slippagePercent));
|
|
22549
22347
|
// Resolve all the quotes and link them back to the swappable token
|
|
22550
22348
|
// The swappable token array is in the same position in the array as the quote in the promise array
|
|
22551
22349
|
const dexTransactionResponse = await Promise.all(dexTransactionResponsePromises);
|
|
@@ -22566,7 +22364,7 @@ const $049bba630af05555$export$6946a1f17c2bbf26 = async (config, chainId, wallet
|
|
|
22566
22364
|
|
|
22567
22365
|
const $3ee85f12225c19f3$export$fb80fe94a81a3132 = async (config, dexQuoteCache, walletAddress, requiredToken, swappableTokens)=>{
|
|
22568
22366
|
const dexQuotes = dexQuoteCache.get(requiredToken.address);
|
|
22569
|
-
if (dexQuotes) return dexQuotes;
|
|
22367
|
+
if (dexQuotes && dexQuotes.size > 0) return dexQuotes;
|
|
22570
22368
|
const quotes = await ($049bba630af05555$export$6946a1f17c2bbf26)(config, ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), walletAddress, requiredToken, swappableTokens);
|
|
22571
22369
|
dexQuoteCache.set(requiredToken.address, quotes);
|
|
22572
22370
|
return quotes;
|
|
@@ -22703,6 +22501,506 @@ const $91807edfd7057288$export$8e03ea04d59f2402 = async (config, availableRoutin
|
|
|
22703
22501
|
|
|
22704
22502
|
|
|
22705
22503
|
|
|
22504
|
+
const $5a5ccedc98d53d25$var$filterTokens = (allowedTokens, balances)=>{
|
|
22505
|
+
if (balances && balances.success) return allowedTokens.filter((token)=>{
|
|
22506
|
+
if ("address" in token) return balances.balances.find((balance)=>balance.token.address === token.address && balance.balance.gt(0));
|
|
22507
|
+
return balances.balances.find((balance)=>!("address" in balance.token) && balance.balance.gt(0));
|
|
22508
|
+
});
|
|
22509
|
+
return [];
|
|
22510
|
+
};
|
|
22511
|
+
const $5a5ccedc98d53d25$export$9ec9fc71f3ce62c4 = async (config, availableRoutingOptions)=>{
|
|
22512
|
+
if (availableRoutingOptions.onRamp) {
|
|
22513
|
+
const onRampOptions = await config.remote.getConfig("onramp");
|
|
22514
|
+
const onRampAllowList = {};
|
|
22515
|
+
Object.entries(onRampOptions).forEach(([onRampProvider, onRampProviderConfig])=>{
|
|
22516
|
+
// Allowed list per onRamp provider
|
|
22517
|
+
onRampAllowList[onRampProvider] = onRampProviderConfig.tokens ?? [];
|
|
22518
|
+
});
|
|
22519
|
+
return onRampAllowList;
|
|
22520
|
+
}
|
|
22521
|
+
return {};
|
|
22522
|
+
};
|
|
22523
|
+
const $5a5ccedc98d53d25$export$d744af9f1c0712bc = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
22524
|
+
if (availableRoutingOptions.bridge) {
|
|
22525
|
+
const allowedTokens = (await config.remote.getConfig("bridge"))?.tokens ?? [];
|
|
22526
|
+
const balances = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
22527
|
+
return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
|
|
22528
|
+
}
|
|
22529
|
+
return [];
|
|
22530
|
+
};
|
|
22531
|
+
const $5a5ccedc98d53d25$export$87ed7f956d73690 = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
22532
|
+
if (availableRoutingOptions.swap) {
|
|
22533
|
+
const allowedTokens = (await config.remote.getConfig("dex"))?.tokens ?? [];
|
|
22534
|
+
const balances = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
22535
|
+
return $5a5ccedc98d53d25$var$filterTokens(allowedTokens, balances);
|
|
22536
|
+
}
|
|
22537
|
+
return [];
|
|
22538
|
+
};
|
|
22539
|
+
const $5a5ccedc98d53d25$export$1ad29657d49c5440 = async (config, tokenBalances, availableRoutingOptions)=>{
|
|
22540
|
+
const tokenAllowList = {};
|
|
22541
|
+
tokenAllowList.swap = await $5a5ccedc98d53d25$export$87ed7f956d73690(config, tokenBalances, availableRoutingOptions);
|
|
22542
|
+
tokenAllowList.bridge = await $5a5ccedc98d53d25$export$d744af9f1c0712bc(config, tokenBalances, availableRoutingOptions);
|
|
22543
|
+
tokenAllowList.onRamp = await $5a5ccedc98d53d25$export$9ec9fc71f3ce62c4(config, availableRoutingOptions);
|
|
22544
|
+
return tokenAllowList;
|
|
22545
|
+
};
|
|
22546
|
+
|
|
22547
|
+
|
|
22548
|
+
|
|
22549
|
+
|
|
22550
|
+
|
|
22551
|
+
|
|
22552
|
+
|
|
22553
|
+
|
|
22554
|
+
|
|
22555
|
+
const $f730af3b727f04ac$export$22fea095b15361de = (balances)=>{
|
|
22556
|
+
for (const balance of balances.balances){
|
|
22557
|
+
if (!balance.token.address || balance.token.address === "") return balance.balance;
|
|
22558
|
+
}
|
|
22559
|
+
return (BigNumber$1).from(0);
|
|
22560
|
+
};
|
|
22561
|
+
|
|
22562
|
+
|
|
22563
|
+
|
|
22564
|
+
|
|
22565
|
+
|
|
22566
|
+
|
|
22567
|
+
const $8a49d1a3783a2640$export$3aff971444a4f244 = async (config, readOnlyProviders)=>{
|
|
22568
|
+
try {
|
|
22569
|
+
const estimate = await (0, $2e7bf45a7c9a9570$export$942c8de7174809fc)({
|
|
22570
|
+
gasEstimateType: (0, $de275b98d2b651c3$export$788b1fd17f3dad84).BRIDGE_TO_L2,
|
|
22571
|
+
isSpendingCapApprovalRequired: false
|
|
22572
|
+
}, readOnlyProviders, config);
|
|
22573
|
+
const gasEstimate = estimate.gasFee.estimatedAmount;
|
|
22574
|
+
const bridgeFee = estimate.bridgeFee.estimatedAmount;
|
|
22575
|
+
let totalFees = (0, BigNumber$1).from(0);
|
|
22576
|
+
if (gasEstimate) totalFees = totalFees.add(gasEstimate);
|
|
22577
|
+
if (bridgeFee) totalFees = totalFees.add(bridgeFee);
|
|
22578
|
+
return totalFees;
|
|
22579
|
+
} catch (err) {
|
|
22580
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error estimating gas for bridge", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
22581
|
+
message: err.message
|
|
22582
|
+
});
|
|
22583
|
+
}
|
|
22584
|
+
};
|
|
22585
|
+
|
|
22586
|
+
|
|
22587
|
+
|
|
22588
|
+
|
|
22589
|
+
|
|
22590
|
+
|
|
22591
|
+
|
|
22592
|
+
|
|
22593
|
+
|
|
22594
|
+
const $887d24b47765b1c0$export$c37d8687c27b9660 = "0x0000000000000000000000000000000000000001";
|
|
22595
|
+
const $887d24b47765b1c0$export$1430626eec86fce9 = (chainId)=>{
|
|
22596
|
+
if (chainId === ($0472f23319457bfb$export$c06e1e7429de6283).IMTBL_ZKEVM_TESTNET) return "imtbl-zkevm-testnet";
|
|
22597
|
+
return "";
|
|
22598
|
+
};
|
|
22599
|
+
const $887d24b47765b1c0$export$53e663abd9b77fc1 = async (chainId, config)=>{
|
|
22600
|
+
const imxMappingConfig = await config.remote.getConfig("imxAddressMapping");
|
|
22601
|
+
return imxMappingConfig[chainId] ?? "";
|
|
22602
|
+
};
|
|
22603
|
+
const $887d24b47765b1c0$export$952cdf461a00a8c6 = async (config, l2address)=>{
|
|
22604
|
+
if (l2address === "") return {
|
|
22605
|
+
l1address: "",
|
|
22606
|
+
l2address: l2address
|
|
22607
|
+
};
|
|
22608
|
+
if (l2address === ($d85ad1457a3f1a83$export$b80040cb173ba6e9)) return {
|
|
22609
|
+
l1address: await $887d24b47765b1c0$export$53e663abd9b77fc1(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config), config),
|
|
22610
|
+
l2address: ($d85ad1457a3f1a83$export$b80040cb173ba6e9)
|
|
22611
|
+
};
|
|
22612
|
+
const chainName = $887d24b47765b1c0$export$1430626eec86fce9(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
22613
|
+
if (chainName === "") return {
|
|
22614
|
+
l1address: "",
|
|
22615
|
+
l2address: l2address
|
|
22616
|
+
}; // Chain name not a valid indexer chain name
|
|
22617
|
+
const blockchainData = ($67fc622a2b913d5f$export$436dd76f23f463ff)(config);
|
|
22618
|
+
const tokenData = await blockchainData.getToken({
|
|
22619
|
+
chainName: chainName,
|
|
22620
|
+
contractAddress: l2address
|
|
22621
|
+
});
|
|
22622
|
+
const l1address = tokenData.result.root_contract_address;
|
|
22623
|
+
if (l1address === null) return {
|
|
22624
|
+
l1address: "",
|
|
22625
|
+
l2address: l2address
|
|
22626
|
+
}; // No L1 representation of this token
|
|
22627
|
+
return {
|
|
22628
|
+
l1address: l1address,
|
|
22629
|
+
l2address: l2address
|
|
22630
|
+
};
|
|
22631
|
+
};
|
|
22632
|
+
|
|
22633
|
+
|
|
22634
|
+
const $07ac9c0576988336$export$7847f5f5cce25dfa = async (config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, token, depositAmount)=>{
|
|
22635
|
+
try {
|
|
22636
|
+
const tokenBridge = await $67fc622a2b913d5f$export$989eefe1274a439c(fromChainId, toChainId, readOnlyProviders, config);
|
|
22637
|
+
const { unsignedTx: unsignedTx } = await tokenBridge.getUnsignedApproveDepositBridgeTx({
|
|
22638
|
+
depositorAddress: depositorAddress,
|
|
22639
|
+
token: token,
|
|
22640
|
+
depositAmount: depositAmount
|
|
22641
|
+
});
|
|
22642
|
+
if (unsignedTx === null) return (0, BigNumber$1).from(0);
|
|
22643
|
+
return await l1provider.estimateGas(unsignedTx);
|
|
22644
|
+
} catch (err) {
|
|
22645
|
+
throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("Error occurred while attempting ot estimate gas for approval transaction", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).BRIDGE_GAS_ESTIMATE_ERROR, {
|
|
22646
|
+
message: err.message
|
|
22647
|
+
});
|
|
22648
|
+
}
|
|
22649
|
+
};
|
|
22650
|
+
const $07ac9c0576988336$export$a3dd181de896b7c7 = async (config, readOnlyProviders, l1provider, depositorAddress, l1Address, delta)=>{
|
|
22651
|
+
if (l1Address === ($887d24b47765b1c0$export$c37d8687c27b9660)) return (BigNumber$1).from(0); // Native ETH does not require approval
|
|
22652
|
+
const fromChainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
22653
|
+
const toChainId = ($4013c5c91bb535f6$export$c9af4e4b001c6476)(config);
|
|
22654
|
+
return await $07ac9c0576988336$export$7847f5f5cce25dfa(config, readOnlyProviders, l1provider, depositorAddress, fromChainId, toChainId, l1Address, delta);
|
|
22655
|
+
};
|
|
22656
|
+
|
|
22657
|
+
|
|
22658
|
+
|
|
22659
|
+
|
|
22660
|
+
|
|
22661
|
+
const $fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665 = (tokenBalanceResult, totalFees)=>{
|
|
22662
|
+
const balance = ($f730af3b727f04ac$export$22fea095b15361de)(tokenBalanceResult);
|
|
22663
|
+
return balance.gte(totalFees);
|
|
22664
|
+
};
|
|
22665
|
+
const $fa9ac5bfdbbf9dfa$export$da05aed50d75046 = async (config, readOnlyProviders, feeEstimates)=>{
|
|
22666
|
+
let bridgeFeeEstimate = feeEstimates.get(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE);
|
|
22667
|
+
if (bridgeFeeEstimate) return bridgeFeeEstimate;
|
|
22668
|
+
bridgeFeeEstimate = await ($8a49d1a3783a2640$export$3aff971444a4f244)(config, readOnlyProviders);
|
|
22669
|
+
feeEstimates.set(($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE, bridgeFeeEstimate);
|
|
22670
|
+
return bridgeFeeEstimate;
|
|
22671
|
+
};
|
|
22672
|
+
const $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute = (chainId, balance)=>({
|
|
22673
|
+
type: ($4b58188d47aafe8d$export$3af78bb3e8650ee6).BRIDGE,
|
|
22674
|
+
chainId: chainId,
|
|
22675
|
+
asset: {
|
|
22676
|
+
balance: balance.balance,
|
|
22677
|
+
formattedBalance: balance.formattedBalance,
|
|
22678
|
+
token: {
|
|
22679
|
+
name: balance.token.name,
|
|
22680
|
+
symbol: balance.token.symbol,
|
|
22681
|
+
address: balance.token.address,
|
|
22682
|
+
decimals: balance.token.decimals
|
|
22683
|
+
}
|
|
22684
|
+
}
|
|
22685
|
+
});
|
|
22686
|
+
const $fa9ac5bfdbbf9dfa$export$3139474685e4dedd = (address)=>{
|
|
22687
|
+
if (!address || address === "") return true;
|
|
22688
|
+
return false;
|
|
22689
|
+
};
|
|
22690
|
+
const $fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa = async (config, readOnlyProviders, depositorAddress, availableRoutingOptions, bridgeRequirement, tokenBalanceResults, feeEstimates)=>{
|
|
22691
|
+
if (!availableRoutingOptions.bridge) return undefined;
|
|
22692
|
+
if (bridgeRequirement.l2address === undefined || bridgeRequirement.l2address === "") return undefined;
|
|
22693
|
+
const chainId = ($4013c5c91bb535f6$export$9b794d067cdd1af6)(config);
|
|
22694
|
+
const tokenBalanceResult = tokenBalanceResults.get(chainId);
|
|
22695
|
+
const l1provider = readOnlyProviders.get(chainId);
|
|
22696
|
+
if (!l1provider) throw new ($a8bc256d81a5e2c1$export$b722478a3cbfa3bc)("No L1 provider available", ($a8bc256d81a5e2c1$export$e3dc0620abde7f5a).PROVIDER_ERROR, {
|
|
22697
|
+
chainId: chainId.toString()
|
|
22698
|
+
});
|
|
22699
|
+
// If no balances on layer 1 then Bridge cannot be an option
|
|
22700
|
+
if (tokenBalanceResult === undefined || tokenBalanceResult.success === false) return undefined;
|
|
22701
|
+
const allowedTokenList = await ($5a5ccedc98d53d25$export$d744af9f1c0712bc)(config, tokenBalanceResults, availableRoutingOptions);
|
|
22702
|
+
if (allowedTokenList.length === 0) return undefined;
|
|
22703
|
+
const bridgeFeeEstimate = await $fa9ac5bfdbbf9dfa$export$da05aed50d75046(config, readOnlyProviders, feeEstimates);
|
|
22704
|
+
// If the user has no ETH to cover the bridge fees or approval fees then bridge cannot be an option
|
|
22705
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, bridgeFeeEstimate)) return undefined;
|
|
22706
|
+
const l1RepresentationResult = await ($887d24b47765b1c0$export$952cdf461a00a8c6)(config, bridgeRequirement.l2address);
|
|
22707
|
+
// No mapping on L1 for this token
|
|
22708
|
+
const { l1address: l1address } = l1RepresentationResult;
|
|
22709
|
+
if (l1address === "") return undefined;
|
|
22710
|
+
// Ensure l1address is in the allowed token list
|
|
22711
|
+
if (l1address === ($887d24b47765b1c0$export$c37d8687c27b9660)) {
|
|
22712
|
+
if (!allowedTokenList.find((token)=>!("address" in token))) return undefined;
|
|
22713
|
+
} else if (!allowedTokenList.find((token)=>token.address === l1address)) return undefined;
|
|
22714
|
+
const gasForApproval = await ($07ac9c0576988336$export$a3dd181de896b7c7)(config, readOnlyProviders, l1provider, depositorAddress, l1address, bridgeRequirement.amount);
|
|
22715
|
+
if (!$fa9ac5bfdbbf9dfa$export$9994ad18c2f0e665(tokenBalanceResult, gasForApproval.add(bridgeFeeEstimate))) return undefined;
|
|
22716
|
+
// If the L1 representation of the requirement is ETH then find the ETH balance and check if the balance covers the delta
|
|
22717
|
+
if (l1address === ($887d24b47765b1c0$export$c37d8687c27b9660)) {
|
|
22718
|
+
const nativeETHBalance = tokenBalanceResult.balances.find((balance)=>$fa9ac5bfdbbf9dfa$export$3139474685e4dedd(balance.token.address));
|
|
22719
|
+
if (nativeETHBalance && nativeETHBalance.balance.gte(bridgeRequirement.amount.add(bridgeFeeEstimate))) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, nativeETHBalance);
|
|
22720
|
+
return undefined;
|
|
22721
|
+
}
|
|
22722
|
+
// Find the balance of the L1 representation of the token and check if the balance covers the delta
|
|
22723
|
+
const erc20balance = tokenBalanceResult.balances.find((balance)=>balance.token.address === l1address);
|
|
22724
|
+
if (erc20balance && erc20balance.balance.gte(bridgeRequirement.amount)) return $fa9ac5bfdbbf9dfa$var$constructBridgeFundingRoute(chainId, erc20balance);
|
|
22725
|
+
return undefined;
|
|
22726
|
+
};
|
|
22727
|
+
|
|
22728
|
+
|
|
22729
|
+
|
|
22730
|
+
|
|
22731
|
+
const $7bb5af1d8b5d9127$export$8280985cc3da7882 = (config, tokenBalances)=>{
|
|
22732
|
+
const balances = {
|
|
22733
|
+
l1balances: [],
|
|
22734
|
+
l2balances: []
|
|
22735
|
+
};
|
|
22736
|
+
const l1balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
22737
|
+
const l2balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
22738
|
+
// If there are no l1 balance then cannot bridge
|
|
22739
|
+
if (!l1balancesResult) return balances;
|
|
22740
|
+
if (l1balancesResult.error !== undefined) return balances;
|
|
22741
|
+
if (!l1balancesResult.success) return balances;
|
|
22742
|
+
// If there are no l2 balance then cannot swap
|
|
22743
|
+
if (!l2balancesResult) return balances;
|
|
22744
|
+
if (l2balancesResult.error !== undefined) return balances;
|
|
22745
|
+
if (!l2balancesResult.success) return balances;
|
|
22746
|
+
const l1balances = l1balancesResult.balances;
|
|
22747
|
+
const l2balances = l2balancesResult.balances;
|
|
22748
|
+
return {
|
|
22749
|
+
l1balances: l1balances,
|
|
22750
|
+
l2balances: l2balances
|
|
22751
|
+
};
|
|
22752
|
+
};
|
|
22753
|
+
|
|
22754
|
+
|
|
22755
|
+
|
|
22756
|
+
|
|
22757
|
+
|
|
22758
|
+
const $62e968a3dd87940e$export$8059963805b7876c = (dexQuote, tokenAddress)=>{
|
|
22759
|
+
let fees = (BigNumber$1).from(0);
|
|
22760
|
+
dexQuote.quote.fees.forEach((fee)=>{
|
|
22761
|
+
if (fee.amount.token.address === tokenAddress) fees = fees.add(fee.amount.value);
|
|
22762
|
+
});
|
|
22763
|
+
if (dexQuote.approval) {
|
|
22764
|
+
if (dexQuote.approval.token.address === tokenAddress) fees = fees.add(dexQuote.approval.value);
|
|
22765
|
+
}
|
|
22766
|
+
return fees;
|
|
22767
|
+
};
|
|
22768
|
+
// The token that is being bridged may also be a balance requirement
|
|
22769
|
+
// Since this token is going to be swapped after bridging then get the
|
|
22770
|
+
// balance requirement amount so this can be considered when bridging
|
|
22771
|
+
// enough of the token across
|
|
22772
|
+
const $62e968a3dd87940e$var$getAmountFromBalanceRequirement = (balanceRequirements, tokenAddress)=>{
|
|
22773
|
+
let amount = (BigNumber$1).from(0);
|
|
22774
|
+
balanceRequirements.balanceRequirements.forEach((requirement)=>{
|
|
22775
|
+
if (requirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE || requirement.type === ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) {
|
|
22776
|
+
if (requirement.required.token.address === tokenAddress) amount = amount.add(requirement.required.balance);
|
|
22777
|
+
}
|
|
22778
|
+
});
|
|
22779
|
+
return amount;
|
|
22780
|
+
};
|
|
22781
|
+
const $62e968a3dd87940e$export$df667c749c93b110 = (dexQuotes, l1balances, l2balances, l1tol2addresses, balanceRequirements)=>{
|
|
22782
|
+
const bridgeRequirements = [];
|
|
22783
|
+
for (const [tokenAddress, quote] of dexQuotes){
|
|
22784
|
+
// Get the L2 balance for the token address
|
|
22785
|
+
const l2balance = l2balances.find((balance)=>balance.token.address === tokenAddress);
|
|
22786
|
+
const l1tol2TokenMapping = l1tol2addresses.find((token)=>token.l2address === tokenAddress);
|
|
22787
|
+
if (!l1tol2TokenMapping) continue;
|
|
22788
|
+
const { l1address: l1address, l2address: l2address } = l1tol2TokenMapping;
|
|
22789
|
+
if (!l1address) continue;
|
|
22790
|
+
// If the user does not have any L1 balance for this token then cannot bridge
|
|
22791
|
+
const l1balance = l1balances.find((balance)=>{
|
|
22792
|
+
if (balance.token.address === undefined && l1address === ($887d24b47765b1c0$export$c37d8687c27b9660)) return true;
|
|
22793
|
+
return balance.token.address === l1address;
|
|
22794
|
+
});
|
|
22795
|
+
if (!l1balance) continue;
|
|
22796
|
+
// Get the total amount using slippage to ensure a small buffer is added to cover price fluctuations
|
|
22797
|
+
const quotedAmount = quote.quote.amountWithMaxSlippage.value;
|
|
22798
|
+
// Add fees to the quoted amount if the fees are in the same token as the token being swapped
|
|
22799
|
+
const fees = $62e968a3dd87940e$export$8059963805b7876c(quote, tokenAddress);
|
|
22800
|
+
// If the token being bridged is a balance requirement then add this to the total
|
|
22801
|
+
// to ensure when its swapped the balance requirement can still be fulfilled
|
|
22802
|
+
const balanceRequirementAmount = $62e968a3dd87940e$var$getAmountFromBalanceRequirement(balanceRequirements, tokenAddress);
|
|
22803
|
+
// Add all the amounts together
|
|
22804
|
+
const totalAmount = quotedAmount.add(fees).add(balanceRequirementAmount);
|
|
22805
|
+
// Subtract any L2 balance from the total amount to only bridge the necessary amount
|
|
22806
|
+
const amountToBridge = l2balance ? totalAmount.sub(l2balance.balance) : totalAmount;
|
|
22807
|
+
if (amountToBridge.lte(0)) continue;
|
|
22808
|
+
if (amountToBridge.gt(l1balance.balance)) continue;
|
|
22809
|
+
bridgeRequirements.push({
|
|
22810
|
+
amount: amountToBridge,
|
|
22811
|
+
formattedAmount: (utils).formatUnits(amountToBridge, l1balance.token.decimals),
|
|
22812
|
+
l2address: // L2 address is used for the bridge requirement as the bridge route uses the indexer to find L1 address
|
|
22813
|
+
l2address
|
|
22814
|
+
});
|
|
22815
|
+
}
|
|
22816
|
+
return bridgeRequirements;
|
|
22817
|
+
};
|
|
22818
|
+
|
|
22819
|
+
|
|
22820
|
+
|
|
22821
|
+
const $7500587317643fc8$export$c3e193fd573f1a94 = async (config, swappableTokens)=>{
|
|
22822
|
+
const l1tol2addressMappingPromises = swappableTokens.map((token)=>($887d24b47765b1c0$export$952cdf461a00a8c6)(config, token.address ?? ""));
|
|
22823
|
+
return await Promise.all(l1tol2addressMappingPromises);
|
|
22824
|
+
};
|
|
22825
|
+
|
|
22826
|
+
|
|
22827
|
+
|
|
22828
|
+
|
|
22829
|
+
const $d54df4a884f14123$export$d46f2133747ffd93 = async (config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens)=>{
|
|
22830
|
+
const filteredSwappableTokensAddresses = [];
|
|
22831
|
+
for (const token of filteredSwappableTokens){
|
|
22832
|
+
if (!token.address) continue;
|
|
22833
|
+
filteredSwappableTokensAddresses.push(token.address);
|
|
22834
|
+
}
|
|
22835
|
+
const dexQuotes = await ($3ee85f12225c19f3$export$fb80fe94a81a3132)(config, dexQuoteCache, ownerAddress, {
|
|
22836
|
+
address: requiredTokenAddress,
|
|
22837
|
+
amount: insufficientRequirement.delta.balance
|
|
22838
|
+
}, filteredSwappableTokensAddresses);
|
|
22839
|
+
return dexQuotes;
|
|
22840
|
+
};
|
|
22841
|
+
|
|
22842
|
+
|
|
22843
|
+
const $afd57acae9471ac5$export$b94e88f4f8805f71 = (bridgeableTokens, swappableTokens, l1balances, l2balances, availableRoutingOptions, requiredTokenAddress)=>{
|
|
22844
|
+
if (bridgeableTokens.length === 0) return true;
|
|
22845
|
+
if (swappableTokens.length === 0) return true;
|
|
22846
|
+
if (l1balances.length === 0) return true;
|
|
22847
|
+
if (l2balances.length === 0) return true;
|
|
22848
|
+
if (!availableRoutingOptions.bridge) return true;
|
|
22849
|
+
if (!availableRoutingOptions.swap) return true;
|
|
22850
|
+
if (requiredTokenAddress === undefined) return true;
|
|
22851
|
+
if (requiredTokenAddress === "") return true;
|
|
22852
|
+
return false;
|
|
22853
|
+
};
|
|
22854
|
+
const $afd57acae9471ac5$export$ed7c59bd8d1bb5a7 = (requiredTokenAddress, bridgeableTokens, swappableTokens, l1tol2Addresses)=>{
|
|
22855
|
+
const filteredSwappableTokens = [];
|
|
22856
|
+
for (const addresses of l1tol2Addresses){
|
|
22857
|
+
if (addresses.l1address === "") continue;
|
|
22858
|
+
if (addresses.l2address === "") continue;
|
|
22859
|
+
if (!bridgeableTokens.includes(addresses.l1address)) continue;
|
|
22860
|
+
// Filter out the token that is required from the swappable tokens list
|
|
22861
|
+
if (addresses.l2address === requiredTokenAddress) continue;
|
|
22862
|
+
const tokenInfo = swappableTokens.find((token)=>token.address === addresses.l2address);
|
|
22863
|
+
if (!tokenInfo) continue;
|
|
22864
|
+
filteredSwappableTokens.push(tokenInfo);
|
|
22865
|
+
}
|
|
22866
|
+
return filteredSwappableTokens;
|
|
22867
|
+
};
|
|
22868
|
+
// Modifies a users balance to include the amount as if the user successfully bridged
|
|
22869
|
+
// This is so the swap route can check against the balance once the user has performed a bridge
|
|
22870
|
+
const $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount = (config, tokenBalances, l2balances, bridgedTokens, swappableTokens)=>{
|
|
22871
|
+
const modifiedTokenBalances = new Map();
|
|
22872
|
+
for (const [chainId, tokenBalance] of tokenBalances)modifiedTokenBalances.set(chainId, {
|
|
22873
|
+
success: tokenBalance.success,
|
|
22874
|
+
balances: tokenBalance.balances
|
|
22875
|
+
});
|
|
22876
|
+
// Construct a map of balances to the L2 token address to make
|
|
22877
|
+
// it easier to adjust the balances for the tokens that can be bridged
|
|
22878
|
+
const balanceMap = new Map();
|
|
22879
|
+
for (const balance of l2balances){
|
|
22880
|
+
if (!balance.token.address) continue;
|
|
22881
|
+
balanceMap.set(balance.token.address, balance);
|
|
22882
|
+
}
|
|
22883
|
+
// Go through each of the tokens that can be bridged
|
|
22884
|
+
// and adjust the balances to fake the bridge
|
|
22885
|
+
for (const bridgedToken of bridgedTokens){
|
|
22886
|
+
const { amount: amount, l2address: l2address } = bridgedToken;
|
|
22887
|
+
if (l2address === "") continue;
|
|
22888
|
+
let l2balance = (BigNumber$1).from(0);
|
|
22889
|
+
// Find the current balance of this token
|
|
22890
|
+
const currentBalance = balanceMap.get(l2address);
|
|
22891
|
+
if (currentBalance) l2balance = currentBalance.balance;
|
|
22892
|
+
const newBalance = l2balance.add(amount);
|
|
22893
|
+
const tokenInfo = swappableTokens.find((token)=>token.address === l2address);
|
|
22894
|
+
balanceMap.set(l2address, {
|
|
22895
|
+
balance: newBalance,
|
|
22896
|
+
formattedBalance: (utils).formatUnits(newBalance, tokenInfo.decimals),
|
|
22897
|
+
token: tokenInfo
|
|
22898
|
+
});
|
|
22899
|
+
}
|
|
22900
|
+
const updatedBalances = Array.from(balanceMap.values());
|
|
22901
|
+
modifiedTokenBalances.set(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config), {
|
|
22902
|
+
success: true,
|
|
22903
|
+
balances: updatedBalances
|
|
22904
|
+
});
|
|
22905
|
+
return modifiedTokenBalances;
|
|
22906
|
+
};
|
|
22907
|
+
const $afd57acae9471ac5$export$1fc63300bde5e690 = (tokenBalances, swapRoutes)=>{
|
|
22908
|
+
const originalSwapSteps = [];
|
|
22909
|
+
for (const route of swapRoutes){
|
|
22910
|
+
const { chainId: chainId, asset: asset } = route;
|
|
22911
|
+
const tokenBalance = tokenBalances.get(chainId);
|
|
22912
|
+
if (!tokenBalance) continue;
|
|
22913
|
+
let originalBalance = (BigNumber$1).from(0);
|
|
22914
|
+
let originalFormattedBalance = "0";
|
|
22915
|
+
const l2balance = tokenBalance.balances.find((balance)=>balance.token.address === asset.token.address);
|
|
22916
|
+
if (l2balance) {
|
|
22917
|
+
originalBalance = l2balance.balance;
|
|
22918
|
+
originalFormattedBalance = l2balance.formattedBalance;
|
|
22919
|
+
}
|
|
22920
|
+
route.asset.balance = originalBalance;
|
|
22921
|
+
route.asset.formattedBalance = originalFormattedBalance;
|
|
22922
|
+
originalSwapSteps.push(route);
|
|
22923
|
+
}
|
|
22924
|
+
return originalSwapSteps;
|
|
22925
|
+
};
|
|
22926
|
+
const $afd57acae9471ac5$export$d9b96654eebdaf2a = (bridgeFundingSteps, swapFundingSteps, l1tol2Addresses)=>{
|
|
22927
|
+
const bridgeAndSwapRoutes = [];
|
|
22928
|
+
for (const bridgeFundingStep of bridgeFundingSteps){
|
|
22929
|
+
if (!bridgeFundingStep) continue;
|
|
22930
|
+
const mapping = l1tol2Addresses.find((addresses)=>{
|
|
22931
|
+
if (bridgeFundingStep.asset.token.address === undefined) return addresses.l1address === ($887d24b47765b1c0$export$c37d8687c27b9660) && addresses.l2address;
|
|
22932
|
+
return addresses.l1address === bridgeFundingStep.asset.token.address && addresses.l2address;
|
|
22933
|
+
});
|
|
22934
|
+
if (!mapping) continue;
|
|
22935
|
+
const swapFundingStep = swapFundingSteps.find((step)=>step.asset.token.address === mapping.l2address);
|
|
22936
|
+
if (!swapFundingStep) continue;
|
|
22937
|
+
bridgeAndSwapRoutes.push({
|
|
22938
|
+
bridgeFundingStep: bridgeFundingStep,
|
|
22939
|
+
swapFundingStep: swapFundingStep
|
|
22940
|
+
});
|
|
22941
|
+
}
|
|
22942
|
+
return bridgeAndSwapRoutes;
|
|
22943
|
+
};
|
|
22944
|
+
const $afd57acae9471ac5$export$f95ed27e871fe308 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableTokens, swappableTokens, balanceRequirements)=>{
|
|
22945
|
+
const { l1balances: l1balances, l2balances: l2balances } = ($7bb5af1d8b5d9127$export$8280985cc3da7882)(config, tokenBalances);
|
|
22946
|
+
const requiredTokenAddress = insufficientRequirement.required.token.address;
|
|
22947
|
+
if ($afd57acae9471ac5$export$b94e88f4f8805f71(bridgeableTokens, swappableTokens, l1balances, l2balances, availableRoutingOptions, requiredTokenAddress)) return [];
|
|
22948
|
+
// Fetch L2 to L1 address mapping and based on the L1 address existing then
|
|
22949
|
+
// filter the bridgeable and swappable tokens list further to only include
|
|
22950
|
+
// tokens that can be both swapped and bridged
|
|
22951
|
+
const l1tol2Addresses = await ($7500587317643fc8$export$c3e193fd573f1a94)(config, swappableTokens);
|
|
22952
|
+
const filteredSwappableTokens = $afd57acae9471ac5$export$ed7c59bd8d1bb5a7(requiredTokenAddress, bridgeableTokens, swappableTokens, l1tol2Addresses);
|
|
22953
|
+
if (filteredSwappableTokens.length === 0) return [];
|
|
22954
|
+
// Fetch all the dex quotes from the list of swappable tokens
|
|
22955
|
+
const dexQuotes = await ($d54df4a884f14123$export$d46f2133747ffd93)(config, dexQuoteCache, ownerAddress, requiredTokenAddress, insufficientRequirement, filteredSwappableTokens);
|
|
22956
|
+
// Construct bridge requirements based on L2 balances, slippage and swap fees
|
|
22957
|
+
const bridgeRequirements = ($62e968a3dd87940e$export$df667c749c93b110)(dexQuotes, l1balances, l2balances, l1tol2Addresses, balanceRequirements);
|
|
22958
|
+
if (bridgeRequirements.length === 0) return [];
|
|
22959
|
+
// Create a mapping of bridge routes to L2 addresses
|
|
22960
|
+
const bridgePromises = new Map();
|
|
22961
|
+
// Create map of bridgeable tokens to make it easier to get the amount that was bridged when modifying the users balance later
|
|
22962
|
+
const bridgeableRequirementsMap = new Map();
|
|
22963
|
+
const bridgedTokens = [];
|
|
22964
|
+
for (const bridgeRequirement of bridgeRequirements){
|
|
22965
|
+
if (!bridgeRequirement.l2address) continue;
|
|
22966
|
+
bridgePromises.set(bridgeRequirement.l2address, ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, bridgeRequirement, tokenBalances, feeEstimates));
|
|
22967
|
+
bridgeableRequirementsMap.set(bridgeRequirement.l2address, {
|
|
22968
|
+
amount: bridgeRequirement.amount,
|
|
22969
|
+
formattedAmount: bridgeRequirement.formattedAmount,
|
|
22970
|
+
l2address: bridgeRequirement.l2address
|
|
22971
|
+
});
|
|
22972
|
+
}
|
|
22973
|
+
const bridgeResults = await Promise.all(bridgePromises.values());
|
|
22974
|
+
const bridgeKeys = Array.from(bridgePromises.keys());
|
|
22975
|
+
// Create an array to store all the tokens that are able to be bridged
|
|
22976
|
+
const swappableTokensAfterBridging = [];
|
|
22977
|
+
// Iterate through all the bridge route results
|
|
22978
|
+
// If a bridge route result was successful then add this token to the
|
|
22979
|
+
// list of tokens that should be checked with the swap route
|
|
22980
|
+
bridgeResults.forEach((result, index)=>{
|
|
22981
|
+
const key = bridgeKeys[index];
|
|
22982
|
+
if (result === undefined) return;
|
|
22983
|
+
swappableTokensAfterBridging.push(key);
|
|
22984
|
+
const bridgedToken = bridgeableRequirementsMap.get(key);
|
|
22985
|
+
if (!bridgedToken) return;
|
|
22986
|
+
bridgedTokens.push({
|
|
22987
|
+
amount: bridgedToken.amount,
|
|
22988
|
+
formattedAmount: bridgedToken.formattedAmount,
|
|
22989
|
+
l2address: bridgedToken.l2address
|
|
22990
|
+
});
|
|
22991
|
+
});
|
|
22992
|
+
// Bridge route determined that no tokens could be bridged
|
|
22993
|
+
if (swappableTokensAfterBridging.length === 0) return [];
|
|
22994
|
+
if (bridgedTokens.length === 0) return []; // No tokens were bridged
|
|
22995
|
+
// Modify the users L2 balance to include the amount as if the user successfully bridged
|
|
22996
|
+
const modifiedTokenBalances = $afd57acae9471ac5$var$modifyTokenBalancesWithBridgedAmount(config, tokenBalances, l2balances, bridgedTokens, swappableTokens);
|
|
22997
|
+
// Call the swap route with the faked bridged balances
|
|
22998
|
+
const swapRoutes = await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, modifiedTokenBalances, swappableTokensAfterBridging);
|
|
22999
|
+
if (!swapRoutes) return [];
|
|
23000
|
+
const originalBalanceSwapRoutes = $afd57acae9471ac5$export$1fc63300bde5e690(tokenBalances, swapRoutes);
|
|
23001
|
+
return $afd57acae9471ac5$export$d9b96654eebdaf2a(bridgeResults, originalBalanceSwapRoutes, l1tol2Addresses);
|
|
23002
|
+
};
|
|
23003
|
+
|
|
22706
23004
|
|
|
22707
23005
|
|
|
22708
23006
|
|
|
@@ -22733,6 +23031,7 @@ const $5649bc8af91da370$export$1fb2bd867f4a9be3 = async (config, availableRoutin
|
|
|
22733
23031
|
|
|
22734
23032
|
|
|
22735
23033
|
|
|
23034
|
+
|
|
22736
23035
|
const $c16168a9c28ae4fd$var$hasAvailableRoutingOptions = (availableRoutingOptions)=>availableRoutingOptions.bridge || availableRoutingOptions.swap || availableRoutingOptions.onRamp;
|
|
22737
23036
|
const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
|
|
22738
23037
|
let insufficientBalanceCount = 0;
|
|
@@ -22744,6 +23043,18 @@ const $c16168a9c28ae4fd$export$31ce7ba1a2956195 = (balanceRequirements)=>{
|
|
|
22744
23043
|
if (insufficientBalanceCount === 1) return insufficientRequirement;
|
|
22745
23044
|
return undefined;
|
|
22746
23045
|
};
|
|
23046
|
+
const $c16168a9c28ae4fd$export$ab86023c267660 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, feeEstimates)=>{
|
|
23047
|
+
let bridgeFundingStep;
|
|
23048
|
+
if (insufficientRequirement === undefined) return undefined;
|
|
23049
|
+
if (insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE && insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return undefined;
|
|
23050
|
+
const bridgeRequirement = {
|
|
23051
|
+
amount: insufficientRequirement.delta.balance,
|
|
23052
|
+
formattedAmount: insufficientRequirement.delta.formattedBalance,
|
|
23053
|
+
l2address: insufficientRequirement.required.token.address ?? ""
|
|
23054
|
+
};
|
|
23055
|
+
if (availableRoutingOptions.bridge && insufficientRequirement) bridgeFundingStep = await ($fa9ac5bfdbbf9dfa$export$ddc7ba2b57d7c5fa)(config, readOnlyProviders, ownerAddress, availableRoutingOptions, bridgeRequirement, tokenBalances, feeEstimates);
|
|
23056
|
+
return bridgeFundingStep;
|
|
23057
|
+
};
|
|
22747
23058
|
const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, swapTokenAllowList)=>{
|
|
22748
23059
|
const fundingSteps = [];
|
|
22749
23060
|
if (!availableRoutingOptions.swap) return fundingSteps;
|
|
@@ -22757,6 +23068,27 @@ const $c16168a9c28ae4fd$export$814624e957fa0f11 = async (config, availableRoutin
|
|
|
22757
23068
|
if (swappableTokens.length === 0) return fundingSteps;
|
|
22758
23069
|
return await ($91807edfd7057288$export$8e03ea04d59f2402)(config, availableRoutingOptions, dexQuoteCache, ownerAddress, insufficientRequirement, tokenBalances, swappableTokens);
|
|
22759
23070
|
};
|
|
23071
|
+
const $c16168a9c28ae4fd$export$2becd43da9d21f73 = async (config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, tokenAllowList, feeEstimates, balanceRequirements)=>{
|
|
23072
|
+
if (!insufficientRequirement) return [];
|
|
23073
|
+
const l1balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$9b794d067cdd1af6)(config));
|
|
23074
|
+
const l2balancesResult = tokenBalances.get(($4013c5c91bb535f6$export$c9af4e4b001c6476)(config));
|
|
23075
|
+
// If there are no l1 balance then cannot bridge
|
|
23076
|
+
if (!l1balancesResult) return [];
|
|
23077
|
+
if (l1balancesResult.error !== undefined || !l1balancesResult.success) return [];
|
|
23078
|
+
// If there are no l2 balance then cannot swap
|
|
23079
|
+
if (!l2balancesResult) return [];
|
|
23080
|
+
if (l2balancesResult.error !== undefined || !l2balancesResult.success) return [];
|
|
23081
|
+
// Get a list of all the swappable tokens
|
|
23082
|
+
const bridgeTokenAllowList = tokenAllowList?.bridge ?? [];
|
|
23083
|
+
const bridgeableL1Addresses = bridgeTokenAllowList.map((token)=>{
|
|
23084
|
+
if (token.address === undefined) return $887d24b47765b1c0$export$c37d8687c27b9660;
|
|
23085
|
+
return token.address;
|
|
23086
|
+
});
|
|
23087
|
+
const swapTokenAllowList = tokenAllowList?.swap ?? [];
|
|
23088
|
+
if (insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).NATIVE && insufficientRequirement.type !== ($4b58188d47aafe8d$export$1fc8f52ad1810e52).ERC20) return [];
|
|
23089
|
+
const routes = await ($afd57acae9471ac5$export$f95ed27e871fe308)(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, feeEstimates, tokenBalances, bridgeableL1Addresses, swapTokenAllowList, balanceRequirements);
|
|
23090
|
+
return routes;
|
|
23091
|
+
};
|
|
22760
23092
|
const $c16168a9c28ae4fd$export$e1b6e4d22d0365ee = async (config, availableRoutingOptions, insufficientRequirement)=>{
|
|
22761
23093
|
if (!availableRoutingOptions.onRamp) return undefined;
|
|
22762
23094
|
if (insufficientRequirement === undefined) return undefined;
|
|
@@ -22785,16 +23117,24 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
22785
23117
|
const feeEstimates = new Map();
|
|
22786
23118
|
// Dex quotes cache
|
|
22787
23119
|
const dexQuoteCache = new Map();
|
|
22788
|
-
// Ensures only 1 balance requirement is insufficient
|
|
23120
|
+
// Ensures only 1 balance requirement is insufficient
|
|
22789
23121
|
const insufficientRequirement = $c16168a9c28ae4fd$export$31ce7ba1a2956195(balanceRequirements);
|
|
23122
|
+
const routePromises = [];
|
|
23123
|
+
routePromises.push($c16168a9c28ae4fd$export$ab86023c267660(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, ownerAddress, tokenBalances, feeEstimates));
|
|
23124
|
+
routePromises.push($c16168a9c28ae4fd$export$814624e957fa0f11(config, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList.swap));
|
|
23125
|
+
routePromises.push($c16168a9c28ae4fd$export$e1b6e4d22d0365ee(config, availableRoutingOptions, insufficientRequirement));
|
|
23126
|
+
routePromises.push($c16168a9c28ae4fd$export$2becd43da9d21f73(config, readOnlyProviders, availableRoutingOptions, insufficientRequirement, dexQuoteCache, ownerAddress, tokenBalances, allowList, feeEstimates, balanceRequirements));
|
|
23127
|
+
const resolved = await Promise.all(routePromises);
|
|
22790
23128
|
let bridgeFundingStep;
|
|
22791
|
-
|
|
22792
|
-
|
|
22793
|
-
|
|
22794
|
-
|
|
22795
|
-
|
|
22796
|
-
|
|
22797
|
-
|
|
23129
|
+
let swapFundingSteps = [];
|
|
23130
|
+
let onRampFundingStep;
|
|
23131
|
+
let bridgeAndSwapFundingSteps = [];
|
|
23132
|
+
resolved.forEach((result, index)=>{
|
|
23133
|
+
if (index === 0) bridgeFundingStep = result;
|
|
23134
|
+
if (index === 1) swapFundingSteps = result;
|
|
23135
|
+
if (index === 2) onRampFundingStep = result;
|
|
23136
|
+
if (index === 3) bridgeAndSwapFundingSteps = result;
|
|
23137
|
+
});
|
|
22798
23138
|
const response = {
|
|
22799
23139
|
response: {
|
|
22800
23140
|
type: ($b23305044c0e096a$export$3057de18ac0c076).NO_ROUTES,
|
|
@@ -22803,7 +23143,7 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
22803
23143
|
fundingRoutes: []
|
|
22804
23144
|
};
|
|
22805
23145
|
let priority = 0;
|
|
22806
|
-
if (bridgeFundingStep || swapFundingSteps.length > 0 || onRampFundingStep) {
|
|
23146
|
+
if (bridgeFundingStep || swapFundingSteps.length > 0 || onRampFundingStep || bridgeAndSwapFundingSteps.length > 0) {
|
|
22807
23147
|
response.response.type = ($b23305044c0e096a$export$3057de18ac0c076).ROUTES_FOUND;
|
|
22808
23148
|
response.response.message = "Routes found";
|
|
22809
23149
|
}
|
|
@@ -22836,6 +23176,22 @@ const $c16168a9c28ae4fd$export$92606e71d0a264ff = async (config, ownerAddress, b
|
|
|
22836
23176
|
]
|
|
22837
23177
|
});
|
|
22838
23178
|
}
|
|
23179
|
+
if (bridgeAndSwapFundingSteps) {
|
|
23180
|
+
priority++;
|
|
23181
|
+
bridgeAndSwapFundingSteps.forEach((bridgeAndSwapFundingStep)=>{
|
|
23182
|
+
const bridgeStep = bridgeAndSwapFundingStep.bridgeFundingStep;
|
|
23183
|
+
const swapStep = bridgeAndSwapFundingStep.swapFundingStep;
|
|
23184
|
+
response.fundingRoutes.push({
|
|
23185
|
+
priority: priority,
|
|
23186
|
+
steps: [
|
|
23187
|
+
bridgeStep,
|
|
23188
|
+
swapStep
|
|
23189
|
+
]
|
|
23190
|
+
});
|
|
23191
|
+
});
|
|
23192
|
+
}
|
|
23193
|
+
// eslint-disable-next-line no-console
|
|
23194
|
+
console.log("** response", response);
|
|
22839
23195
|
return response;
|
|
22840
23196
|
};
|
|
22841
23197
|
|