@cowprotocol/sdk-bridging 0.10.1 → 0.12.0
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/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +280 -108
- package/dist/index.mjs +242 -71
- package/package.json +10 -10
package/dist/index.d.mts
CHANGED
|
@@ -428,7 +428,7 @@ interface BestQuoteProviderContext extends MultiQuoteContext {
|
|
|
428
428
|
bestResult: {
|
|
429
429
|
current: MultiQuoteResult | null;
|
|
430
430
|
};
|
|
431
|
-
|
|
431
|
+
bestError: {
|
|
432
432
|
current: MultiQuoteResult | null;
|
|
433
433
|
};
|
|
434
434
|
}
|
|
@@ -443,8 +443,10 @@ declare enum BridgeQuoteErrors {
|
|
|
443
443
|
QUOTE_ERROR = "QUOTE_ERROR",
|
|
444
444
|
NO_ROUTES = "NO_ROUTES",
|
|
445
445
|
INVALID_BRIDGE = "INVALID_BRIDGE",
|
|
446
|
-
QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"
|
|
446
|
+
QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS",
|
|
447
|
+
SELL_AMOUNT_TOO_SMALL = "SELL_AMOUNT_TOO_SMALL"
|
|
447
448
|
}
|
|
449
|
+
declare const BridgeQuoteErrorPriorities: Record<BridgeQuoteErrors, number>;
|
|
448
450
|
declare class BridgeProviderQuoteError extends Error {
|
|
449
451
|
readonly context?: unknown | undefined;
|
|
450
452
|
constructor(message: BridgeQuoteErrors, context?: unknown | undefined);
|
|
@@ -1294,4 +1296,4 @@ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider
|
|
|
1294
1296
|
} | null>;
|
|
1295
1297
|
}
|
|
1296
1298
|
|
|
1297
|
-
export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
|
|
1299
|
+
export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrorPriorities, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
|
package/dist/index.d.ts
CHANGED
|
@@ -428,7 +428,7 @@ interface BestQuoteProviderContext extends MultiQuoteContext {
|
|
|
428
428
|
bestResult: {
|
|
429
429
|
current: MultiQuoteResult | null;
|
|
430
430
|
};
|
|
431
|
-
|
|
431
|
+
bestError: {
|
|
432
432
|
current: MultiQuoteResult | null;
|
|
433
433
|
};
|
|
434
434
|
}
|
|
@@ -443,8 +443,10 @@ declare enum BridgeQuoteErrors {
|
|
|
443
443
|
QUOTE_ERROR = "QUOTE_ERROR",
|
|
444
444
|
NO_ROUTES = "NO_ROUTES",
|
|
445
445
|
INVALID_BRIDGE = "INVALID_BRIDGE",
|
|
446
|
-
QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"
|
|
446
|
+
QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS",
|
|
447
|
+
SELL_AMOUNT_TOO_SMALL = "SELL_AMOUNT_TOO_SMALL"
|
|
447
448
|
}
|
|
449
|
+
declare const BridgeQuoteErrorPriorities: Record<BridgeQuoteErrors, number>;
|
|
448
450
|
declare class BridgeProviderQuoteError extends Error {
|
|
449
451
|
readonly context?: unknown | undefined;
|
|
450
452
|
constructor(message: BridgeQuoteErrors, context?: unknown | undefined);
|
|
@@ -1294,4 +1296,4 @@ declare class NearIntentsBridgeProvider implements ReceiverAccountBridgeProvider
|
|
|
1294
1296
|
} | null>;
|
|
1295
1297
|
}
|
|
1296
1298
|
|
|
1297
|
-
export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
|
|
1299
|
+
export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BestQuoteProgressCallback, type BestQuoteProviderContext, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeProviderType, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrorPriorities, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION, DEFAULT_EXTRA_GAS_PROXY_CREATION, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type DefaultBridgeProvider, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type HookBridgeProvider, type MultiQuoteOptions, type MultiQuoteProgressCallback, type MultiQuoteRequest, type MultiQuoteResult, NearIntentsBridgeProvider, type NearIntentsBridgeProviderOptions, type NearIntentsQuoteResult, type ProviderQuoteContext, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, type ReceiverAccountBridgeProvider, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isHookBridgeProvider, isQuoteAndPost, isReceiverAccountBridgeProvider };
|
package/dist/index.js
CHANGED
|
@@ -34,6 +34,7 @@ __export(src_exports, {
|
|
|
34
34
|
BridgeOrderParsingError: () => BridgeOrderParsingError,
|
|
35
35
|
BridgeProviderError: () => BridgeProviderError,
|
|
36
36
|
BridgeProviderQuoteError: () => BridgeProviderQuoteError,
|
|
37
|
+
BridgeQuoteErrorPriorities: () => BridgeQuoteErrorPriorities,
|
|
37
38
|
BridgeQuoteErrors: () => BridgeQuoteErrors,
|
|
38
39
|
BridgeStatus: () => BridgeStatus,
|
|
39
40
|
BridgingSdk: () => BridgingSdk,
|
|
@@ -78,8 +79,21 @@ var BridgeQuoteErrors = /* @__PURE__ */ ((BridgeQuoteErrors2) => {
|
|
|
78
79
|
BridgeQuoteErrors2["NO_ROUTES"] = "NO_ROUTES";
|
|
79
80
|
BridgeQuoteErrors2["INVALID_BRIDGE"] = "INVALID_BRIDGE";
|
|
80
81
|
BridgeQuoteErrors2["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"] = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS";
|
|
82
|
+
BridgeQuoteErrors2["SELL_AMOUNT_TOO_SMALL"] = "SELL_AMOUNT_TOO_SMALL";
|
|
81
83
|
return BridgeQuoteErrors2;
|
|
82
84
|
})(BridgeQuoteErrors || {});
|
|
85
|
+
var BridgeQuoteErrorPriorities = {
|
|
86
|
+
["SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */]: 10,
|
|
87
|
+
["ONLY_SELL_ORDER_SUPPORTED" /* ONLY_SELL_ORDER_SUPPORTED */]: 9,
|
|
88
|
+
["NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */]: 1,
|
|
89
|
+
["API_ERROR" /* API_ERROR */]: 1,
|
|
90
|
+
["INVALID_API_JSON_RESPONSE" /* INVALID_API_JSON_RESPONSE */]: 1,
|
|
91
|
+
["TX_BUILD_ERROR" /* TX_BUILD_ERROR */]: 1,
|
|
92
|
+
["QUOTE_ERROR" /* QUOTE_ERROR */]: 1,
|
|
93
|
+
["NO_ROUTES" /* NO_ROUTES */]: 1,
|
|
94
|
+
["INVALID_BRIDGE" /* INVALID_BRIDGE */]: 1,
|
|
95
|
+
["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS" /* QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS */]: 1
|
|
96
|
+
};
|
|
83
97
|
var BridgeProviderQuoteError = class extends Error {
|
|
84
98
|
constructor(message, context) {
|
|
85
99
|
super(message);
|
|
@@ -220,7 +234,7 @@ async function getCrossChainOrder(params) {
|
|
|
220
234
|
// src/BridgingSdk/BridgingSdk.ts
|
|
221
235
|
var import_sdk_trading2 = require("@cowprotocol/sdk-trading");
|
|
222
236
|
var import_sdk_order_book2 = require("@cowprotocol/sdk-order-book");
|
|
223
|
-
var
|
|
237
|
+
var import_sdk_config3 = require("@cowprotocol/sdk-config");
|
|
224
238
|
var import_sdk_common5 = require("@cowprotocol/sdk-common");
|
|
225
239
|
|
|
226
240
|
// src/BridgingSdk/helpers.ts
|
|
@@ -293,6 +307,128 @@ function getHookMockForCostEstimation(gasLimit) {
|
|
|
293
307
|
|
|
294
308
|
// src/BridgingSdk/getIntermediateSwapResult.ts
|
|
295
309
|
var import_sdk_common3 = require("@cowprotocol/sdk-common");
|
|
310
|
+
|
|
311
|
+
// src/BridgingSdk/tokenPriority.ts
|
|
312
|
+
var import_sdk_config2 = require("@cowprotocol/sdk-config");
|
|
313
|
+
var PRIORITY_STABLECOIN_TOKENS = {
|
|
314
|
+
[import_sdk_config2.SupportedChainId.MAINNET]: /* @__PURE__ */ new Set([
|
|
315
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
316
|
+
// USDC
|
|
317
|
+
"0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
318
|
+
// USDT
|
|
319
|
+
]),
|
|
320
|
+
[import_sdk_config2.SupportedChainId.BNB]: /* @__PURE__ */ new Set([
|
|
321
|
+
"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
322
|
+
// USDC
|
|
323
|
+
"0x55d398326f99059ff775485246999027b3197955"
|
|
324
|
+
// USDT
|
|
325
|
+
]),
|
|
326
|
+
[import_sdk_config2.SupportedChainId.GNOSIS_CHAIN]: /* @__PURE__ */ new Set([
|
|
327
|
+
"0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
|
|
328
|
+
// USDC
|
|
329
|
+
"0x2a22f9c3b484c3629090feed35f17ff8f88f76f0",
|
|
330
|
+
// USDC.e
|
|
331
|
+
"0x4ecaba5870353805a9f068101a40e0f32ed605c6"
|
|
332
|
+
// USDT
|
|
333
|
+
]),
|
|
334
|
+
[import_sdk_config2.SupportedChainId.POLYGON]: /* @__PURE__ */ new Set([
|
|
335
|
+
"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
|
|
336
|
+
// USDC
|
|
337
|
+
"0xc2132d05d31c914a87c6611c10748aeb04b58e8f"
|
|
338
|
+
// USDT
|
|
339
|
+
]),
|
|
340
|
+
[import_sdk_config2.SupportedChainId.BASE]: /* @__PURE__ */ new Set([
|
|
341
|
+
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
342
|
+
// USDC
|
|
343
|
+
"0xfde4c96c8593536e31f229ea8f37b2ada2699bb2"
|
|
344
|
+
// USDT
|
|
345
|
+
]),
|
|
346
|
+
[import_sdk_config2.SupportedChainId.ARBITRUM_ONE]: /* @__PURE__ */ new Set([
|
|
347
|
+
"0xaf88d065e77c8cc2239327c5edb3a432268e5831",
|
|
348
|
+
// USDC
|
|
349
|
+
"0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
|
|
350
|
+
// USDT
|
|
351
|
+
]),
|
|
352
|
+
[import_sdk_config2.SupportedChainId.AVALANCHE]: /* @__PURE__ */ new Set([
|
|
353
|
+
"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
|
|
354
|
+
// USDC
|
|
355
|
+
"0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7"
|
|
356
|
+
// USDT
|
|
357
|
+
]),
|
|
358
|
+
[import_sdk_config2.SupportedChainId.LINEA]: /* @__PURE__ */ new Set([
|
|
359
|
+
"0x176211869ca2b568f2a7d4ee941e073a821ee1ff",
|
|
360
|
+
// USDC
|
|
361
|
+
"0xA219439258ca9da29E9Cc4cE5596924745e12B93"
|
|
362
|
+
// USDT
|
|
363
|
+
]),
|
|
364
|
+
[import_sdk_config2.SupportedChainId.SEPOLIA]: /* @__PURE__ */ new Set([
|
|
365
|
+
"0x1c7d4b196cb0c7b01d743fbc6116a902379c7238"
|
|
366
|
+
// USDC
|
|
367
|
+
])
|
|
368
|
+
};
|
|
369
|
+
function isStablecoinPriorityToken(chainId, tokenAddress) {
|
|
370
|
+
const chainTokens = PRIORITY_STABLECOIN_TOKENS[chainId];
|
|
371
|
+
if (!chainTokens)
|
|
372
|
+
return false;
|
|
373
|
+
return chainTokens.has(tokenAddress.toLowerCase());
|
|
374
|
+
}
|
|
375
|
+
function isCorrelatedToken(tokenAddress, correlatedTokens) {
|
|
376
|
+
return correlatedTokens.has(tokenAddress.toLowerCase());
|
|
377
|
+
}
|
|
378
|
+
function isNativeToken(tokenAddress) {
|
|
379
|
+
return tokenAddress.toLowerCase() === import_sdk_config2.NATIVE_CURRENCY_ADDRESS.toLowerCase();
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// src/BridgingSdk/determineIntermediateToken.ts
|
|
383
|
+
async function determineIntermediateToken(sourceChainId, intermediateTokens, getCorrelatedTokens) {
|
|
384
|
+
const firstToken = intermediateTokens[0];
|
|
385
|
+
if (intermediateTokens.length === 0 || !firstToken) {
|
|
386
|
+
throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
|
|
387
|
+
}
|
|
388
|
+
if (intermediateTokens.length === 1) {
|
|
389
|
+
return firstToken;
|
|
390
|
+
}
|
|
391
|
+
const correlatedTokens = await resolveCorrelatedTokens(sourceChainId, getCorrelatedTokens);
|
|
392
|
+
const tokensWithPriority = intermediateTokens.map((token) => {
|
|
393
|
+
if (isStablecoinPriorityToken(token.chainId, token.address)) {
|
|
394
|
+
return { token, priority: 4 /* HIGHEST */ };
|
|
395
|
+
}
|
|
396
|
+
if (isCorrelatedToken(token.address, correlatedTokens)) {
|
|
397
|
+
return { token, priority: 3 /* HIGH */ };
|
|
398
|
+
}
|
|
399
|
+
if (isNativeToken(token.address)) {
|
|
400
|
+
return { token, priority: 2 /* MEDIUM */ };
|
|
401
|
+
}
|
|
402
|
+
return { token, priority: 1 /* LOW */ };
|
|
403
|
+
});
|
|
404
|
+
tokensWithPriority.sort((a, b) => {
|
|
405
|
+
if (a.priority !== b.priority) {
|
|
406
|
+
return b.priority - a.priority;
|
|
407
|
+
}
|
|
408
|
+
return intermediateTokens.indexOf(a.token) - intermediateTokens.indexOf(b.token);
|
|
409
|
+
});
|
|
410
|
+
const result = tokensWithPriority[0]?.token;
|
|
411
|
+
if (!result) {
|
|
412
|
+
throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
|
|
413
|
+
}
|
|
414
|
+
return result;
|
|
415
|
+
}
|
|
416
|
+
async function resolveCorrelatedTokens(sourceChainId, getCorrelatedTokens) {
|
|
417
|
+
if (getCorrelatedTokens) {
|
|
418
|
+
try {
|
|
419
|
+
const tokens = await getCorrelatedTokens(sourceChainId);
|
|
420
|
+
return new Set(tokens.map((t) => t.toLowerCase()));
|
|
421
|
+
} catch (error) {
|
|
422
|
+
console.warn(
|
|
423
|
+
"[determineIntermediateToken] Failed to fetch correlated tokens, falling back to basic priority",
|
|
424
|
+
error
|
|
425
|
+
);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
return /* @__PURE__ */ new Set();
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
// src/BridgingSdk/getIntermediateSwapResult.ts
|
|
296
432
|
async function getIntermediateSwapResult({
|
|
297
433
|
provider,
|
|
298
434
|
params,
|
|
@@ -318,11 +454,12 @@ async function getIntermediateSwapResult({
|
|
|
318
454
|
quoteBridgeRequest: swapAndBridgeRequest,
|
|
319
455
|
intermediateTokensCache: params.intermediateTokensCache
|
|
320
456
|
});
|
|
321
|
-
const intermediateToken =
|
|
457
|
+
const intermediateToken = await determineIntermediateToken(
|
|
458
|
+
sellTokenChainId,
|
|
459
|
+
intermediateTokens,
|
|
460
|
+
params.advancedSettings?.getCorrelatedTokens
|
|
461
|
+
);
|
|
322
462
|
(0, import_sdk_common3.log)(`Using ${intermediateToken?.name ?? intermediateToken?.address} as intermediate tokens`);
|
|
323
|
-
if (!intermediateToken) {
|
|
324
|
-
throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
|
|
325
|
-
}
|
|
326
463
|
const bridgeRequestWithoutAmount = {
|
|
327
464
|
...swapAndBridgeRequest,
|
|
328
465
|
sellTokenAddress: intermediateToken.address,
|
|
@@ -826,6 +963,25 @@ function resolveProvidersToQuery(providerDappIds, providers) {
|
|
|
826
963
|
return provider;
|
|
827
964
|
});
|
|
828
965
|
}
|
|
966
|
+
function getErrorPriority(error) {
|
|
967
|
+
if (!error)
|
|
968
|
+
return 0;
|
|
969
|
+
if (error instanceof BridgeProviderQuoteError) {
|
|
970
|
+
return BridgeQuoteErrorPriorities[error.message] ?? 0;
|
|
971
|
+
}
|
|
972
|
+
return 0;
|
|
973
|
+
}
|
|
974
|
+
function isBetterError(error1, error2) {
|
|
975
|
+
if (!error2 || !error2.error) {
|
|
976
|
+
return !!error1?.error;
|
|
977
|
+
}
|
|
978
|
+
if (!error1?.error) {
|
|
979
|
+
return false;
|
|
980
|
+
}
|
|
981
|
+
const priority1 = getErrorPriority(error1.error);
|
|
982
|
+
const priority2 = getErrorPriority(error2.error);
|
|
983
|
+
return priority1 > priority2;
|
|
984
|
+
}
|
|
829
985
|
|
|
830
986
|
// src/BridgingSdk/strategies/MultiQuoteStrategy.ts
|
|
831
987
|
var DEFAULT_TOTAL_TIMEOUT_MS = 4e4;
|
|
@@ -932,7 +1088,7 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
|
|
|
932
1088
|
providerTimeout = DEFAULT_PROVIDER_TIMEOUT_MS2
|
|
933
1089
|
} = options || {};
|
|
934
1090
|
const bestResult = { current: null };
|
|
935
|
-
const
|
|
1091
|
+
const bestError = { current: null };
|
|
936
1092
|
const promises = [];
|
|
937
1093
|
for (const provider of providersToQuery) {
|
|
938
1094
|
const context = {
|
|
@@ -942,16 +1098,16 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
|
|
|
942
1098
|
providerTimeout,
|
|
943
1099
|
onQuoteResult,
|
|
944
1100
|
bestResult,
|
|
945
|
-
|
|
1101
|
+
bestError
|
|
946
1102
|
};
|
|
947
1103
|
const promise = this.createBestQuoteProviderPromise(context, tradingSdk);
|
|
948
1104
|
promises.push(promise);
|
|
949
1105
|
}
|
|
950
1106
|
await executeProviderQuotes(promises, totalTimeout, providers);
|
|
951
|
-
return bestResult.current ||
|
|
1107
|
+
return bestResult.current || bestError.current;
|
|
952
1108
|
}
|
|
953
1109
|
createBestQuoteProviderPromise(context, tradingSdk) {
|
|
954
|
-
const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult,
|
|
1110
|
+
const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult, bestError } = context;
|
|
955
1111
|
return (async () => {
|
|
956
1112
|
try {
|
|
957
1113
|
const baseParams = {
|
|
@@ -984,8 +1140,8 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
|
|
|
984
1140
|
quote: null,
|
|
985
1141
|
error: error instanceof Error ? error : new BridgeProviderError(String(error), {})
|
|
986
1142
|
};
|
|
987
|
-
if (
|
|
988
|
-
|
|
1143
|
+
if (isBetterError(errorResult, bestError.current)) {
|
|
1144
|
+
bestError.current = errorResult;
|
|
989
1145
|
}
|
|
990
1146
|
}
|
|
991
1147
|
})();
|
|
@@ -1073,7 +1229,7 @@ var BridgingSdk = class {
|
|
|
1073
1229
|
* Get the available sources networks for the bridging.
|
|
1074
1230
|
*/
|
|
1075
1231
|
async getSourceNetworks() {
|
|
1076
|
-
return
|
|
1232
|
+
return import_sdk_config3.ALL_SUPPORTED_CHAINS;
|
|
1077
1233
|
}
|
|
1078
1234
|
/**
|
|
1079
1235
|
* Get the available target networks for the bridging.
|
|
@@ -1368,55 +1524,55 @@ var COW_TRADE_EVENT_INTERFACE = () => {
|
|
|
1368
1524
|
};
|
|
1369
1525
|
|
|
1370
1526
|
// src/providers/across/const/contracts.ts
|
|
1371
|
-
var
|
|
1527
|
+
var import_sdk_config4 = require("@cowprotocol/sdk-config");
|
|
1372
1528
|
var ACROSS_SPOOK_CONTRACT_ADDRESSES = {
|
|
1373
1529
|
// https://docs.across.to/reference/contract-addresses/mainnet-chain-id-1
|
|
1374
|
-
[
|
|
1530
|
+
[import_sdk_config4.SupportedChainId.MAINNET]: "0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5",
|
|
1375
1531
|
// https://docs.across.to/reference/contract-addresses/arbitrum-chain-id-42161-1
|
|
1376
|
-
[
|
|
1532
|
+
[import_sdk_config4.SupportedChainId.ARBITRUM_ONE]: "0xe35e9842fceaca96570b734083f4a58e8f7c5f2a",
|
|
1377
1533
|
// https://docs.across.to/reference/contract-addresses/base-chain-id-8453
|
|
1378
|
-
[
|
|
1534
|
+
[import_sdk_config4.SupportedChainId.BASE]: "0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64",
|
|
1379
1535
|
// // https://docs.across.to/reference/contract-addresses/mainnet-chain-id-1
|
|
1380
|
-
[
|
|
1536
|
+
[import_sdk_config4.SupportedChainId.SEPOLIA]: "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
|
|
1381
1537
|
// https://docs.across.to/reference/contract-addresses/polygon-chain-id-137
|
|
1382
|
-
[
|
|
1538
|
+
[import_sdk_config4.SupportedChainId.POLYGON]: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096",
|
|
1383
1539
|
// https://docs.across.to/reference/contract-addresses/lens-chain-id-232
|
|
1384
|
-
[
|
|
1540
|
+
[import_sdk_config4.SupportedChainId.LENS]: "0xe7cb3e167e7475dE1331Cf6E0CEb187654619E12",
|
|
1385
1541
|
// https://docs.across.to/reference/contract-addresses/bnb-smart-chain
|
|
1386
|
-
[
|
|
1542
|
+
[import_sdk_config4.SupportedChainId.BNB]: "0x4e8E101924eDE233C13e2D8622DC8aED2872d505",
|
|
1387
1543
|
// https://docs.across.to/reference/contract-addresses/linea-chain-id-59144
|
|
1388
|
-
[
|
|
1544
|
+
[import_sdk_config4.SupportedChainId.LINEA]: "0xE0BCff426509723B18D6b2f0D8F4602d143bE3e0",
|
|
1389
1545
|
// https://docs.across.to/reference/contract-addresses/plasma
|
|
1390
|
-
[
|
|
1546
|
+
[import_sdk_config4.SupportedChainId.PLASMA]: "0x50039fAEfebef707cFD94D6d462fE6D10B39207a",
|
|
1391
1547
|
// Not supported chains
|
|
1392
1548
|
// TODO: This first integration is a draft, some of this chains might be supported, so we will need to update here as we iterate on the provider
|
|
1393
|
-
[
|
|
1394
|
-
[
|
|
1395
|
-
[
|
|
1549
|
+
[import_sdk_config4.SupportedChainId.GNOSIS_CHAIN]: void 0,
|
|
1550
|
+
[import_sdk_config4.SupportedChainId.AVALANCHE]: void 0,
|
|
1551
|
+
[import_sdk_config4.AdditionalTargetChainId.OPTIMISM]: void 0
|
|
1396
1552
|
};
|
|
1397
1553
|
var ACROSS_MATH_CONTRACT_ADDRESSES = {
|
|
1398
|
-
[
|
|
1399
|
-
[
|
|
1400
|
-
[
|
|
1554
|
+
[import_sdk_config4.SupportedChainId.MAINNET]: "0xf2ae6728b6f146556977Af0A68bFbf5bADA22863",
|
|
1555
|
+
[import_sdk_config4.SupportedChainId.ARBITRUM_ONE]: "0x5771A4b4029832e79a75De7B485E5fBbec28848f",
|
|
1556
|
+
[import_sdk_config4.SupportedChainId.BASE]: "0xd4e943dc6ddc885f6229ce33c2e3dfe402a12c81",
|
|
1401
1557
|
// Not supported chains
|
|
1402
1558
|
// TODO: This first integration is a draft, some of this chains might be supported, so we will need to update here as we iterate on the provider
|
|
1403
|
-
[
|
|
1404
|
-
[
|
|
1405
|
-
[
|
|
1406
|
-
[
|
|
1407
|
-
[
|
|
1408
|
-
[
|
|
1559
|
+
[import_sdk_config4.SupportedChainId.GNOSIS_CHAIN]: void 0,
|
|
1560
|
+
[import_sdk_config4.SupportedChainId.SEPOLIA]: void 0,
|
|
1561
|
+
[import_sdk_config4.SupportedChainId.POLYGON]: void 0,
|
|
1562
|
+
[import_sdk_config4.AdditionalTargetChainId.OPTIMISM]: void 0,
|
|
1563
|
+
[import_sdk_config4.SupportedChainId.AVALANCHE]: void 0,
|
|
1564
|
+
[import_sdk_config4.SupportedChainId.LENS]: void 0,
|
|
1409
1565
|
// TODO: confirm
|
|
1410
|
-
[
|
|
1566
|
+
[import_sdk_config4.SupportedChainId.BNB]: void 0,
|
|
1411
1567
|
// TODO: confirm
|
|
1412
|
-
[
|
|
1568
|
+
[import_sdk_config4.SupportedChainId.LINEA]: void 0,
|
|
1413
1569
|
// TODO: confirm
|
|
1414
|
-
[
|
|
1570
|
+
[import_sdk_config4.SupportedChainId.PLASMA]: void 0
|
|
1415
1571
|
// TODO: confirm
|
|
1416
1572
|
};
|
|
1417
1573
|
|
|
1418
1574
|
// src/providers/across/util.ts
|
|
1419
|
-
var
|
|
1575
|
+
var import_sdk_config5 = require("@cowprotocol/sdk-config");
|
|
1420
1576
|
var import_sdk_order_book3 = require("@cowprotocol/sdk-order-book");
|
|
1421
1577
|
var import_sdk_common8 = require("@cowprotocol/sdk-common");
|
|
1422
1578
|
var PCT_100_PERCENT = 10n ** 18n;
|
|
@@ -1553,7 +1709,7 @@ function getAcrossDepositEvents(chainId, logs) {
|
|
|
1553
1709
|
function getCowTradeEvents(chainId, logs) {
|
|
1554
1710
|
const COW_TRADE_EVENT_TOPIC = COW_TRADE_EVENT_INTERFACE().getEventTopic("Trade");
|
|
1555
1711
|
const cowTradeEvents = logs.filter((log7) => {
|
|
1556
|
-
return log7.address.toLowerCase() ===
|
|
1712
|
+
return log7.address.toLowerCase() === import_sdk_config5.COW_PROTOCOL_SETTLEMENT_CONTRACT_ADDRESS[chainId].toLowerCase() && log7.topics[0] === COW_TRADE_EVENT_TOPIC;
|
|
1557
1713
|
});
|
|
1558
1714
|
return cowTradeEvents.map((event) => {
|
|
1559
1715
|
const parsedLog = COW_TRADE_EVENT_INTERFACE().parseLog(event);
|
|
@@ -3481,11 +3637,11 @@ async function getGasLimitEstimationForHook({
|
|
|
3481
3637
|
|
|
3482
3638
|
// src/providers/across/AcrossBridgeProvider.ts
|
|
3483
3639
|
var import_sdk_common12 = require("@cowprotocol/sdk-common");
|
|
3484
|
-
var
|
|
3640
|
+
var import_sdk_config6 = require("@cowprotocol/sdk-config");
|
|
3485
3641
|
var import_sdk_cow_shed = require("@cowprotocol/sdk-cow-shed");
|
|
3486
3642
|
var import_sdk_order_book4 = require("@cowprotocol/sdk-order-book");
|
|
3487
3643
|
var ACROSS_HOOK_DAPP_ID = `${HOOK_DAPP_BRIDGE_PROVIDER_PREFIX}/across`;
|
|
3488
|
-
var ACROSS_SUPPORTED_NETWORKS = [
|
|
3644
|
+
var ACROSS_SUPPORTED_NETWORKS = [import_sdk_config6.mainnet, import_sdk_config6.polygon, import_sdk_config6.arbitrumOne, import_sdk_config6.base, import_sdk_config6.optimism];
|
|
3489
3645
|
var SLIPPAGE_TOLERANCE_BPS = 0;
|
|
3490
3646
|
var providerType = "HookBridgeProvider";
|
|
3491
3647
|
var AcrossBridgeProvider = class {
|
|
@@ -3854,63 +4010,63 @@ var getBungeeBridgeFromDisplayName = (displayName) => {
|
|
|
3854
4010
|
};
|
|
3855
4011
|
|
|
3856
4012
|
// src/providers/bungee/const/contracts.ts
|
|
3857
|
-
var
|
|
4013
|
+
var import_sdk_config7 = require("@cowprotocol/sdk-config");
|
|
3858
4014
|
var BUNGEE_COWSWAP_LIB_ADDRESS = "0x75b6ba5fcab20848ca00f132d253638fea82e598";
|
|
3859
4015
|
var BungeeCowswapLibAddresses = {
|
|
3860
|
-
[
|
|
3861
|
-
[
|
|
3862
|
-
[
|
|
3863
|
-
[
|
|
3864
|
-
[
|
|
3865
|
-
[
|
|
3866
|
-
[
|
|
4016
|
+
[import_sdk_config7.SupportedChainId.MAINNET]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
4017
|
+
[import_sdk_config7.SupportedChainId.GNOSIS_CHAIN]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
4018
|
+
[import_sdk_config7.SupportedChainId.ARBITRUM_ONE]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
4019
|
+
[import_sdk_config7.SupportedChainId.BASE]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
4020
|
+
[import_sdk_config7.SupportedChainId.AVALANCHE]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
4021
|
+
[import_sdk_config7.SupportedChainId.POLYGON]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
4022
|
+
[import_sdk_config7.SupportedChainId.LENS]: void 0,
|
|
3867
4023
|
// TODO: confirm
|
|
3868
|
-
[
|
|
4024
|
+
[import_sdk_config7.SupportedChainId.BNB]: void 0,
|
|
3869
4025
|
// TODO: confirm
|
|
3870
|
-
[
|
|
4026
|
+
[import_sdk_config7.SupportedChainId.LINEA]: void 0,
|
|
3871
4027
|
// TODO: confirm
|
|
3872
|
-
[
|
|
4028
|
+
[import_sdk_config7.SupportedChainId.PLASMA]: void 0,
|
|
3873
4029
|
// TODO: confirm
|
|
3874
|
-
[
|
|
3875
|
-
[
|
|
4030
|
+
[import_sdk_config7.SupportedChainId.SEPOLIA]: void 0,
|
|
4031
|
+
[import_sdk_config7.AdditionalTargetChainId.OPTIMISM]: BUNGEE_COWSWAP_LIB_ADDRESS
|
|
3876
4032
|
};
|
|
3877
4033
|
var SOCKET_VERIFIER_ADDRESS = "0xa27A3f5A96DF7D8Be26EE2790999860C00eb688D";
|
|
3878
4034
|
var SocketVerifierAddresses = {
|
|
3879
|
-
[
|
|
3880
|
-
[
|
|
3881
|
-
[
|
|
3882
|
-
[
|
|
3883
|
-
[
|
|
3884
|
-
[
|
|
3885
|
-
[
|
|
4035
|
+
[import_sdk_config7.SupportedChainId.MAINNET]: SOCKET_VERIFIER_ADDRESS,
|
|
4036
|
+
[import_sdk_config7.SupportedChainId.GNOSIS_CHAIN]: SOCKET_VERIFIER_ADDRESS,
|
|
4037
|
+
[import_sdk_config7.SupportedChainId.ARBITRUM_ONE]: SOCKET_VERIFIER_ADDRESS,
|
|
4038
|
+
[import_sdk_config7.SupportedChainId.BASE]: SOCKET_VERIFIER_ADDRESS,
|
|
4039
|
+
[import_sdk_config7.SupportedChainId.AVALANCHE]: SOCKET_VERIFIER_ADDRESS,
|
|
4040
|
+
[import_sdk_config7.SupportedChainId.POLYGON]: SOCKET_VERIFIER_ADDRESS,
|
|
4041
|
+
[import_sdk_config7.SupportedChainId.LENS]: void 0,
|
|
3886
4042
|
// TODO: confirm
|
|
3887
|
-
[
|
|
4043
|
+
[import_sdk_config7.SupportedChainId.BNB]: void 0,
|
|
3888
4044
|
// TODO: confirm
|
|
3889
|
-
[
|
|
4045
|
+
[import_sdk_config7.SupportedChainId.LINEA]: void 0,
|
|
3890
4046
|
// TODO: confirm
|
|
3891
|
-
[
|
|
4047
|
+
[import_sdk_config7.SupportedChainId.PLASMA]: void 0,
|
|
3892
4048
|
// TODO: confirm
|
|
3893
|
-
[
|
|
3894
|
-
[
|
|
4049
|
+
[import_sdk_config7.SupportedChainId.SEPOLIA]: void 0,
|
|
4050
|
+
[import_sdk_config7.AdditionalTargetChainId.OPTIMISM]: SOCKET_VERIFIER_ADDRESS
|
|
3895
4051
|
};
|
|
3896
4052
|
var BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS = "0xD06a673fe1fa27B1b9E5BA0be980AB15Dbce85cc";
|
|
3897
4053
|
var BungeeApproveAndBridgeV1Addresses = {
|
|
3898
|
-
[
|
|
3899
|
-
[
|
|
3900
|
-
[
|
|
3901
|
-
[
|
|
3902
|
-
[
|
|
3903
|
-
[
|
|
3904
|
-
[
|
|
4054
|
+
[import_sdk_config7.SupportedChainId.MAINNET]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4055
|
+
[import_sdk_config7.SupportedChainId.GNOSIS_CHAIN]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4056
|
+
[import_sdk_config7.SupportedChainId.ARBITRUM_ONE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4057
|
+
[import_sdk_config7.SupportedChainId.BASE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4058
|
+
[import_sdk_config7.SupportedChainId.AVALANCHE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4059
|
+
[import_sdk_config7.SupportedChainId.POLYGON]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4060
|
+
[import_sdk_config7.SupportedChainId.LENS]: void 0,
|
|
3905
4061
|
// TODO: confirm
|
|
3906
|
-
[
|
|
4062
|
+
[import_sdk_config7.SupportedChainId.BNB]: void 0,
|
|
3907
4063
|
// TODO: confirm
|
|
3908
|
-
[
|
|
4064
|
+
[import_sdk_config7.SupportedChainId.LINEA]: void 0,
|
|
3909
4065
|
// TODO: confirm
|
|
3910
|
-
[
|
|
4066
|
+
[import_sdk_config7.SupportedChainId.PLASMA]: void 0,
|
|
3911
4067
|
// TODO: confirm
|
|
3912
|
-
[
|
|
3913
|
-
[
|
|
4068
|
+
[import_sdk_config7.SupportedChainId.SEPOLIA]: void 0,
|
|
4069
|
+
[import_sdk_config7.AdditionalTargetChainId.OPTIMISM]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS
|
|
3914
4070
|
};
|
|
3915
4071
|
|
|
3916
4072
|
// src/providers/bungee/abi.ts
|
|
@@ -4550,7 +4706,7 @@ var BungeeApi = class {
|
|
|
4550
4706
|
};
|
|
4551
4707
|
|
|
4552
4708
|
// src/providers/bungee/createBungeeDepositCall.ts
|
|
4553
|
-
var
|
|
4709
|
+
var import_sdk_config8 = require("@cowprotocol/sdk-config");
|
|
4554
4710
|
var import_sdk_common14 = require("@cowprotocol/sdk-common");
|
|
4555
4711
|
async function createBungeeDepositCall(params) {
|
|
4556
4712
|
const adapter = (0, import_sdk_common14.getGlobalAdapter)();
|
|
@@ -4595,7 +4751,7 @@ async function createBungeeDepositCall(params) {
|
|
|
4595
4751
|
fullData
|
|
4596
4752
|
// data
|
|
4597
4753
|
]);
|
|
4598
|
-
const value = request.sellTokenAddress.toLowerCase() ===
|
|
4754
|
+
const value = request.sellTokenAddress.toLowerCase() === import_sdk_config8.ETH_ADDRESS.toLowerCase() ? BigInt(bridgeInputAmount) : 0n;
|
|
4599
4755
|
const finalValue = value + nativeTokenExtraFee;
|
|
4600
4756
|
const to = BungeeApproveAndBridgeV1Addresses[request.sellTokenChainId];
|
|
4601
4757
|
if (!to) {
|
|
@@ -4644,11 +4800,11 @@ async function getBridgingStatusFromEvents(events, getAcrossStatus) {
|
|
|
4644
4800
|
}
|
|
4645
4801
|
|
|
4646
4802
|
// src/providers/bungee/BungeeBridgeProvider.ts
|
|
4647
|
-
var
|
|
4803
|
+
var import_sdk_config9 = require("@cowprotocol/sdk-config");
|
|
4648
4804
|
var import_sdk_cow_shed2 = require("@cowprotocol/sdk-cow-shed");
|
|
4649
4805
|
var import_sdk_common15 = require("@cowprotocol/sdk-common");
|
|
4650
4806
|
var BUNGEE_HOOK_DAPP_ID = `${HOOK_DAPP_BRIDGE_PROVIDER_PREFIX2}/bungee`;
|
|
4651
|
-
var BUNGEE_SUPPORTED_NETWORKS = [
|
|
4807
|
+
var BUNGEE_SUPPORTED_NETWORKS = [import_sdk_config9.mainnet, import_sdk_config9.polygon, import_sdk_config9.arbitrumOne, import_sdk_config9.base, import_sdk_config9.optimism, import_sdk_config9.avalanche, import_sdk_config9.gnosisChain];
|
|
4652
4808
|
var SLIPPAGE_TOLERANCE_BPS2 = 0;
|
|
4653
4809
|
var providerType2 = "HookBridgeProvider";
|
|
4654
4810
|
var BungeeBridgeProvider = class {
|
|
@@ -4803,13 +4959,13 @@ var BungeeBridgeProvider = class {
|
|
|
4803
4959
|
}
|
|
4804
4960
|
isExtraGasRequired(request) {
|
|
4805
4961
|
const { sellTokenChainId, buyTokenChainId } = request;
|
|
4806
|
-
return sellTokenChainId ===
|
|
4962
|
+
return sellTokenChainId === import_sdk_config9.SupportedChainId.MAINNET && buyTokenChainId === import_sdk_config9.SupportedChainId.GNOSIS_CHAIN;
|
|
4807
4963
|
}
|
|
4808
4964
|
};
|
|
4809
4965
|
|
|
4810
4966
|
// src/providers/near-intents/NearIntentsBridgeProvider.ts
|
|
4811
4967
|
var import_sdk_common17 = require("@cowprotocol/sdk-common");
|
|
4812
|
-
var
|
|
4968
|
+
var import_sdk_config12 = require("@cowprotocol/sdk-config");
|
|
4813
4969
|
var import_sdk_cow_shed3 = require("@cowprotocol/sdk-cow-shed");
|
|
4814
4970
|
var import_sdk_order_book7 = require("@cowprotocol/sdk-order-book");
|
|
4815
4971
|
var import_one_click_sdk_typescript2 = require("@defuse-protocol/one-click-sdk-typescript");
|
|
@@ -4826,7 +4982,22 @@ var NearIntentsApi = class {
|
|
|
4826
4982
|
return this.cachedTokens;
|
|
4827
4983
|
}
|
|
4828
4984
|
async getQuote(request) {
|
|
4829
|
-
|
|
4985
|
+
try {
|
|
4986
|
+
return await import_one_click_sdk_typescript.OneClickService.getQuote(request);
|
|
4987
|
+
} catch (error) {
|
|
4988
|
+
if (error instanceof import_one_click_sdk_typescript.ApiError) {
|
|
4989
|
+
const message = error.body?.message;
|
|
4990
|
+
if (message && typeof message === "string" && message.toLowerCase().includes("amount is too low")) {
|
|
4991
|
+
const minAmountMatch = message.match(/try at least (\d+)/);
|
|
4992
|
+
const minAmount = minAmountMatch ? minAmountMatch[1] : void 0;
|
|
4993
|
+
throw new BridgeProviderQuoteError("SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */, {
|
|
4994
|
+
originalMessage: message,
|
|
4995
|
+
minAmount
|
|
4996
|
+
});
|
|
4997
|
+
}
|
|
4998
|
+
}
|
|
4999
|
+
throw error;
|
|
5000
|
+
}
|
|
4830
5001
|
}
|
|
4831
5002
|
async getStatus(depositAddress) {
|
|
4832
5003
|
return await import_one_click_sdk_typescript.OneClickService.getExecutionStatus(depositAddress);
|
|
@@ -4847,27 +5018,27 @@ var NearIntentsApi = class {
|
|
|
4847
5018
|
};
|
|
4848
5019
|
|
|
4849
5020
|
// src/providers/near-intents/const/index.ts
|
|
4850
|
-
var
|
|
5021
|
+
var import_sdk_config10 = require("@cowprotocol/sdk-config");
|
|
4851
5022
|
var NEAR_INTENTS_HOOK_DAPP_ID = `${HOOK_DAPP_BRIDGE_PROVIDER_PREFIX}/near-intents`;
|
|
4852
5023
|
var NEAR_INTENTS_SUPPORTED_NETWORKS = [
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
|
|
4856
|
-
|
|
4857
|
-
|
|
4858
|
-
|
|
4859
|
-
|
|
4860
|
-
|
|
5024
|
+
import_sdk_config10.arbitrumOne,
|
|
5025
|
+
import_sdk_config10.avalanche,
|
|
5026
|
+
import_sdk_config10.base,
|
|
5027
|
+
import_sdk_config10.bnb,
|
|
5028
|
+
import_sdk_config10.gnosisChain,
|
|
5029
|
+
import_sdk_config10.mainnet,
|
|
5030
|
+
import_sdk_config10.optimism,
|
|
5031
|
+
import_sdk_config10.polygon
|
|
4861
5032
|
];
|
|
4862
5033
|
var NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS = {
|
|
4863
|
-
arb:
|
|
4864
|
-
avax:
|
|
4865
|
-
base:
|
|
4866
|
-
bsc:
|
|
4867
|
-
eth:
|
|
4868
|
-
gnosis:
|
|
4869
|
-
op:
|
|
4870
|
-
pol:
|
|
5034
|
+
arb: import_sdk_config10.arbitrumOne.id,
|
|
5035
|
+
avax: import_sdk_config10.avalanche.id,
|
|
5036
|
+
base: import_sdk_config10.base.id,
|
|
5037
|
+
bsc: import_sdk_config10.bnb.id,
|
|
5038
|
+
eth: import_sdk_config10.mainnet.id,
|
|
5039
|
+
gnosis: import_sdk_config10.gnosisChain.id,
|
|
5040
|
+
op: import_sdk_config10.optimism.id,
|
|
5041
|
+
pol: import_sdk_config10.polygon.id
|
|
4871
5042
|
};
|
|
4872
5043
|
var NEAR_INTENTS_STATUS_TO_COW_STATUS = {
|
|
4873
5044
|
KNOWN_DEPOSIT_TX: "in_progress" /* IN_PROGRESS */,
|
|
@@ -4885,7 +5056,7 @@ var ATTESTATOR_ADDRESS = "0x0073DD100b51C555E41B2a452E5933ef76F42790";
|
|
|
4885
5056
|
// src/providers/near-intents/util.ts
|
|
4886
5057
|
var import_json_stable_stringify = __toESM(require("json-stable-stringify"));
|
|
4887
5058
|
var import_sdk_common16 = require("@cowprotocol/sdk-common");
|
|
4888
|
-
var
|
|
5059
|
+
var import_sdk_config11 = require("@cowprotocol/sdk-config");
|
|
4889
5060
|
var calculateDeadline = (seconds) => {
|
|
4890
5061
|
const secs = Number(seconds);
|
|
4891
5062
|
if (!Number.isFinite(secs)) {
|
|
@@ -4898,7 +5069,7 @@ var adaptToken = (token) => {
|
|
|
4898
5069
|
const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
|
|
4899
5070
|
if (!chainId)
|
|
4900
5071
|
return null;
|
|
4901
|
-
const tokenAddress = token.contractAddress ||
|
|
5072
|
+
const tokenAddress = token.contractAddress || import_sdk_config11.ETH_ADDRESS;
|
|
4902
5073
|
if (!tokenAddress)
|
|
4903
5074
|
return null;
|
|
4904
5075
|
return {
|
|
@@ -4922,10 +5093,10 @@ var getTokenByAddressAndChainId = (tokens, targetTokenAddress, targetTokenChainI
|
|
|
4922
5093
|
const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
|
|
4923
5094
|
if (!chainId)
|
|
4924
5095
|
return false;
|
|
4925
|
-
if (targetTokenAddress.toLowerCase() ===
|
|
5096
|
+
if (targetTokenAddress.toLowerCase() === import_sdk_config11.ETH_ADDRESS.toLowerCase()) {
|
|
4926
5097
|
return chainId === targetTokenChainId && !token.contractAddress;
|
|
4927
5098
|
}
|
|
4928
|
-
const tokenAddress = token.contractAddress ||
|
|
5099
|
+
const tokenAddress = token.contractAddress || import_sdk_config11.ETH_ADDRESS;
|
|
4929
5100
|
return tokenAddress?.toLowerCase() === targetTokenAddress.toLowerCase() && chainId === targetTokenChainId;
|
|
4930
5101
|
});
|
|
4931
5102
|
};
|
|
@@ -5149,8 +5320,8 @@ var NearIntentsBridgeProvider = class {
|
|
|
5149
5320
|
fillTxHash: status.swapDetails?.destinationChainTxHashes?.[0]?.hash
|
|
5150
5321
|
},
|
|
5151
5322
|
params: {
|
|
5152
|
-
inputTokenAddress: inputToken.contractAddress ??
|
|
5153
|
-
outputTokenAddress: outputToken.contractAddress ??
|
|
5323
|
+
inputTokenAddress: inputToken.contractAddress ?? import_sdk_config12.ETH_ADDRESS,
|
|
5324
|
+
outputTokenAddress: outputToken.contractAddress ?? import_sdk_config12.ETH_ADDRESS,
|
|
5154
5325
|
inputAmount: BigInt(quote.amountIn),
|
|
5155
5326
|
outputAmount: swapDetails.amountOut ? BigInt(swapDetails.amountOut) : BigInt(quote.amountOut),
|
|
5156
5327
|
owner: order.owner,
|
|
@@ -5222,6 +5393,7 @@ var NearIntentsBridgeProvider = class {
|
|
|
5222
5393
|
BridgeOrderParsingError,
|
|
5223
5394
|
BridgeProviderError,
|
|
5224
5395
|
BridgeProviderQuoteError,
|
|
5396
|
+
BridgeQuoteErrorPriorities,
|
|
5225
5397
|
BridgeQuoteErrors,
|
|
5226
5398
|
BridgeStatus,
|
|
5227
5399
|
BridgingSdk,
|
package/dist/index.mjs
CHANGED
|
@@ -19,8 +19,21 @@ var BridgeQuoteErrors = /* @__PURE__ */ ((BridgeQuoteErrors2) => {
|
|
|
19
19
|
BridgeQuoteErrors2["NO_ROUTES"] = "NO_ROUTES";
|
|
20
20
|
BridgeQuoteErrors2["INVALID_BRIDGE"] = "INVALID_BRIDGE";
|
|
21
21
|
BridgeQuoteErrors2["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS"] = "QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS";
|
|
22
|
+
BridgeQuoteErrors2["SELL_AMOUNT_TOO_SMALL"] = "SELL_AMOUNT_TOO_SMALL";
|
|
22
23
|
return BridgeQuoteErrors2;
|
|
23
24
|
})(BridgeQuoteErrors || {});
|
|
25
|
+
var BridgeQuoteErrorPriorities = {
|
|
26
|
+
["SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */]: 10,
|
|
27
|
+
["ONLY_SELL_ORDER_SUPPORTED" /* ONLY_SELL_ORDER_SUPPORTED */]: 9,
|
|
28
|
+
["NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */]: 1,
|
|
29
|
+
["API_ERROR" /* API_ERROR */]: 1,
|
|
30
|
+
["INVALID_API_JSON_RESPONSE" /* INVALID_API_JSON_RESPONSE */]: 1,
|
|
31
|
+
["TX_BUILD_ERROR" /* TX_BUILD_ERROR */]: 1,
|
|
32
|
+
["QUOTE_ERROR" /* QUOTE_ERROR */]: 1,
|
|
33
|
+
["NO_ROUTES" /* NO_ROUTES */]: 1,
|
|
34
|
+
["INVALID_BRIDGE" /* INVALID_BRIDGE */]: 1,
|
|
35
|
+
["QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS" /* QUOTE_DOES_NOT_MATCH_DEPOSIT_ADDRESS */]: 1
|
|
36
|
+
};
|
|
24
37
|
var BridgeProviderQuoteError = class extends Error {
|
|
25
38
|
constructor(message, context) {
|
|
26
39
|
super(message);
|
|
@@ -238,6 +251,128 @@ function getHookMockForCostEstimation(gasLimit) {
|
|
|
238
251
|
|
|
239
252
|
// src/BridgingSdk/getIntermediateSwapResult.ts
|
|
240
253
|
import { getGlobalAdapter as getGlobalAdapter2, jsonWithBigintReplacer as jsonWithBigintReplacer2, log as log2 } from "@cowprotocol/sdk-common";
|
|
254
|
+
|
|
255
|
+
// src/BridgingSdk/tokenPriority.ts
|
|
256
|
+
import { NATIVE_CURRENCY_ADDRESS, SupportedChainId } from "@cowprotocol/sdk-config";
|
|
257
|
+
var PRIORITY_STABLECOIN_TOKENS = {
|
|
258
|
+
[SupportedChainId.MAINNET]: /* @__PURE__ */ new Set([
|
|
259
|
+
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
|
|
260
|
+
// USDC
|
|
261
|
+
"0xdac17f958d2ee523a2206206994597c13d831ec7"
|
|
262
|
+
// USDT
|
|
263
|
+
]),
|
|
264
|
+
[SupportedChainId.BNB]: /* @__PURE__ */ new Set([
|
|
265
|
+
"0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
266
|
+
// USDC
|
|
267
|
+
"0x55d398326f99059ff775485246999027b3197955"
|
|
268
|
+
// USDT
|
|
269
|
+
]),
|
|
270
|
+
[SupportedChainId.GNOSIS_CHAIN]: /* @__PURE__ */ new Set([
|
|
271
|
+
"0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
|
|
272
|
+
// USDC
|
|
273
|
+
"0x2a22f9c3b484c3629090feed35f17ff8f88f76f0",
|
|
274
|
+
// USDC.e
|
|
275
|
+
"0x4ecaba5870353805a9f068101a40e0f32ed605c6"
|
|
276
|
+
// USDT
|
|
277
|
+
]),
|
|
278
|
+
[SupportedChainId.POLYGON]: /* @__PURE__ */ new Set([
|
|
279
|
+
"0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
|
|
280
|
+
// USDC
|
|
281
|
+
"0xc2132d05d31c914a87c6611c10748aeb04b58e8f"
|
|
282
|
+
// USDT
|
|
283
|
+
]),
|
|
284
|
+
[SupportedChainId.BASE]: /* @__PURE__ */ new Set([
|
|
285
|
+
"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
286
|
+
// USDC
|
|
287
|
+
"0xfde4c96c8593536e31f229ea8f37b2ada2699bb2"
|
|
288
|
+
// USDT
|
|
289
|
+
]),
|
|
290
|
+
[SupportedChainId.ARBITRUM_ONE]: /* @__PURE__ */ new Set([
|
|
291
|
+
"0xaf88d065e77c8cc2239327c5edb3a432268e5831",
|
|
292
|
+
// USDC
|
|
293
|
+
"0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
|
|
294
|
+
// USDT
|
|
295
|
+
]),
|
|
296
|
+
[SupportedChainId.AVALANCHE]: /* @__PURE__ */ new Set([
|
|
297
|
+
"0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
|
|
298
|
+
// USDC
|
|
299
|
+
"0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7"
|
|
300
|
+
// USDT
|
|
301
|
+
]),
|
|
302
|
+
[SupportedChainId.LINEA]: /* @__PURE__ */ new Set([
|
|
303
|
+
"0x176211869ca2b568f2a7d4ee941e073a821ee1ff",
|
|
304
|
+
// USDC
|
|
305
|
+
"0xA219439258ca9da29E9Cc4cE5596924745e12B93"
|
|
306
|
+
// USDT
|
|
307
|
+
]),
|
|
308
|
+
[SupportedChainId.SEPOLIA]: /* @__PURE__ */ new Set([
|
|
309
|
+
"0x1c7d4b196cb0c7b01d743fbc6116a902379c7238"
|
|
310
|
+
// USDC
|
|
311
|
+
])
|
|
312
|
+
};
|
|
313
|
+
function isStablecoinPriorityToken(chainId, tokenAddress) {
|
|
314
|
+
const chainTokens = PRIORITY_STABLECOIN_TOKENS[chainId];
|
|
315
|
+
if (!chainTokens)
|
|
316
|
+
return false;
|
|
317
|
+
return chainTokens.has(tokenAddress.toLowerCase());
|
|
318
|
+
}
|
|
319
|
+
function isCorrelatedToken(tokenAddress, correlatedTokens) {
|
|
320
|
+
return correlatedTokens.has(tokenAddress.toLowerCase());
|
|
321
|
+
}
|
|
322
|
+
function isNativeToken(tokenAddress) {
|
|
323
|
+
return tokenAddress.toLowerCase() === NATIVE_CURRENCY_ADDRESS.toLowerCase();
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
// src/BridgingSdk/determineIntermediateToken.ts
|
|
327
|
+
async function determineIntermediateToken(sourceChainId, intermediateTokens, getCorrelatedTokens) {
|
|
328
|
+
const firstToken = intermediateTokens[0];
|
|
329
|
+
if (intermediateTokens.length === 0 || !firstToken) {
|
|
330
|
+
throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
|
|
331
|
+
}
|
|
332
|
+
if (intermediateTokens.length === 1) {
|
|
333
|
+
return firstToken;
|
|
334
|
+
}
|
|
335
|
+
const correlatedTokens = await resolveCorrelatedTokens(sourceChainId, getCorrelatedTokens);
|
|
336
|
+
const tokensWithPriority = intermediateTokens.map((token) => {
|
|
337
|
+
if (isStablecoinPriorityToken(token.chainId, token.address)) {
|
|
338
|
+
return { token, priority: 4 /* HIGHEST */ };
|
|
339
|
+
}
|
|
340
|
+
if (isCorrelatedToken(token.address, correlatedTokens)) {
|
|
341
|
+
return { token, priority: 3 /* HIGH */ };
|
|
342
|
+
}
|
|
343
|
+
if (isNativeToken(token.address)) {
|
|
344
|
+
return { token, priority: 2 /* MEDIUM */ };
|
|
345
|
+
}
|
|
346
|
+
return { token, priority: 1 /* LOW */ };
|
|
347
|
+
});
|
|
348
|
+
tokensWithPriority.sort((a, b) => {
|
|
349
|
+
if (a.priority !== b.priority) {
|
|
350
|
+
return b.priority - a.priority;
|
|
351
|
+
}
|
|
352
|
+
return intermediateTokens.indexOf(a.token) - intermediateTokens.indexOf(b.token);
|
|
353
|
+
});
|
|
354
|
+
const result = tokensWithPriority[0]?.token;
|
|
355
|
+
if (!result) {
|
|
356
|
+
throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
|
|
357
|
+
}
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
async function resolveCorrelatedTokens(sourceChainId, getCorrelatedTokens) {
|
|
361
|
+
if (getCorrelatedTokens) {
|
|
362
|
+
try {
|
|
363
|
+
const tokens = await getCorrelatedTokens(sourceChainId);
|
|
364
|
+
return new Set(tokens.map((t) => t.toLowerCase()));
|
|
365
|
+
} catch (error) {
|
|
366
|
+
console.warn(
|
|
367
|
+
"[determineIntermediateToken] Failed to fetch correlated tokens, falling back to basic priority",
|
|
368
|
+
error
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return /* @__PURE__ */ new Set();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// src/BridgingSdk/getIntermediateSwapResult.ts
|
|
241
376
|
async function getIntermediateSwapResult({
|
|
242
377
|
provider,
|
|
243
378
|
params,
|
|
@@ -263,11 +398,12 @@ async function getIntermediateSwapResult({
|
|
|
263
398
|
quoteBridgeRequest: swapAndBridgeRequest,
|
|
264
399
|
intermediateTokensCache: params.intermediateTokensCache
|
|
265
400
|
});
|
|
266
|
-
const intermediateToken =
|
|
401
|
+
const intermediateToken = await determineIntermediateToken(
|
|
402
|
+
sellTokenChainId,
|
|
403
|
+
intermediateTokens,
|
|
404
|
+
params.advancedSettings?.getCorrelatedTokens
|
|
405
|
+
);
|
|
267
406
|
log2(`Using ${intermediateToken?.name ?? intermediateToken?.address} as intermediate tokens`);
|
|
268
|
-
if (!intermediateToken) {
|
|
269
|
-
throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
|
|
270
|
-
}
|
|
271
407
|
const bridgeRequestWithoutAmount = {
|
|
272
408
|
...swapAndBridgeRequest,
|
|
273
409
|
sellTokenAddress: intermediateToken.address,
|
|
@@ -771,6 +907,25 @@ function resolveProvidersToQuery(providerDappIds, providers) {
|
|
|
771
907
|
return provider;
|
|
772
908
|
});
|
|
773
909
|
}
|
|
910
|
+
function getErrorPriority(error) {
|
|
911
|
+
if (!error)
|
|
912
|
+
return 0;
|
|
913
|
+
if (error instanceof BridgeProviderQuoteError) {
|
|
914
|
+
return BridgeQuoteErrorPriorities[error.message] ?? 0;
|
|
915
|
+
}
|
|
916
|
+
return 0;
|
|
917
|
+
}
|
|
918
|
+
function isBetterError(error1, error2) {
|
|
919
|
+
if (!error2 || !error2.error) {
|
|
920
|
+
return !!error1?.error;
|
|
921
|
+
}
|
|
922
|
+
if (!error1?.error) {
|
|
923
|
+
return false;
|
|
924
|
+
}
|
|
925
|
+
const priority1 = getErrorPriority(error1.error);
|
|
926
|
+
const priority2 = getErrorPriority(error2.error);
|
|
927
|
+
return priority1 > priority2;
|
|
928
|
+
}
|
|
774
929
|
|
|
775
930
|
// src/BridgingSdk/strategies/MultiQuoteStrategy.ts
|
|
776
931
|
var DEFAULT_TOTAL_TIMEOUT_MS = 4e4;
|
|
@@ -877,7 +1032,7 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
|
|
|
877
1032
|
providerTimeout = DEFAULT_PROVIDER_TIMEOUT_MS2
|
|
878
1033
|
} = options || {};
|
|
879
1034
|
const bestResult = { current: null };
|
|
880
|
-
const
|
|
1035
|
+
const bestError = { current: null };
|
|
881
1036
|
const promises = [];
|
|
882
1037
|
for (const provider of providersToQuery) {
|
|
883
1038
|
const context = {
|
|
@@ -887,16 +1042,16 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
|
|
|
887
1042
|
providerTimeout,
|
|
888
1043
|
onQuoteResult,
|
|
889
1044
|
bestResult,
|
|
890
|
-
|
|
1045
|
+
bestError
|
|
891
1046
|
};
|
|
892
1047
|
const promise = this.createBestQuoteProviderPromise(context, tradingSdk);
|
|
893
1048
|
promises.push(promise);
|
|
894
1049
|
}
|
|
895
1050
|
await executeProviderQuotes(promises, totalTimeout, providers);
|
|
896
|
-
return bestResult.current ||
|
|
1051
|
+
return bestResult.current || bestError.current;
|
|
897
1052
|
}
|
|
898
1053
|
createBestQuoteProviderPromise(context, tradingSdk) {
|
|
899
|
-
const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult,
|
|
1054
|
+
const { provider, quoteBridgeRequest, advancedSettings, providerTimeout, onQuoteResult, bestResult, bestError } = context;
|
|
900
1055
|
return (async () => {
|
|
901
1056
|
try {
|
|
902
1057
|
const baseParams = {
|
|
@@ -929,8 +1084,8 @@ var BestQuoteStrategy = class extends BaseBestQuoteStrategy {
|
|
|
929
1084
|
quote: null,
|
|
930
1085
|
error: error instanceof Error ? error : new BridgeProviderError(String(error), {})
|
|
931
1086
|
};
|
|
932
|
-
if (
|
|
933
|
-
|
|
1087
|
+
if (isBetterError(errorResult, bestError.current)) {
|
|
1088
|
+
bestError.current = errorResult;
|
|
934
1089
|
}
|
|
935
1090
|
}
|
|
936
1091
|
})();
|
|
@@ -1313,50 +1468,50 @@ var COW_TRADE_EVENT_INTERFACE = () => {
|
|
|
1313
1468
|
};
|
|
1314
1469
|
|
|
1315
1470
|
// src/providers/across/const/contracts.ts
|
|
1316
|
-
import { AdditionalTargetChainId, SupportedChainId } from "@cowprotocol/sdk-config";
|
|
1471
|
+
import { AdditionalTargetChainId, SupportedChainId as SupportedChainId2 } from "@cowprotocol/sdk-config";
|
|
1317
1472
|
var ACROSS_SPOOK_CONTRACT_ADDRESSES = {
|
|
1318
1473
|
// https://docs.across.to/reference/contract-addresses/mainnet-chain-id-1
|
|
1319
|
-
[
|
|
1474
|
+
[SupportedChainId2.MAINNET]: "0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5",
|
|
1320
1475
|
// https://docs.across.to/reference/contract-addresses/arbitrum-chain-id-42161-1
|
|
1321
|
-
[
|
|
1476
|
+
[SupportedChainId2.ARBITRUM_ONE]: "0xe35e9842fceaca96570b734083f4a58e8f7c5f2a",
|
|
1322
1477
|
// https://docs.across.to/reference/contract-addresses/base-chain-id-8453
|
|
1323
|
-
[
|
|
1478
|
+
[SupportedChainId2.BASE]: "0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64",
|
|
1324
1479
|
// // https://docs.across.to/reference/contract-addresses/mainnet-chain-id-1
|
|
1325
|
-
[
|
|
1480
|
+
[SupportedChainId2.SEPOLIA]: "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
|
|
1326
1481
|
// https://docs.across.to/reference/contract-addresses/polygon-chain-id-137
|
|
1327
|
-
[
|
|
1482
|
+
[SupportedChainId2.POLYGON]: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096",
|
|
1328
1483
|
// https://docs.across.to/reference/contract-addresses/lens-chain-id-232
|
|
1329
|
-
[
|
|
1484
|
+
[SupportedChainId2.LENS]: "0xe7cb3e167e7475dE1331Cf6E0CEb187654619E12",
|
|
1330
1485
|
// https://docs.across.to/reference/contract-addresses/bnb-smart-chain
|
|
1331
|
-
[
|
|
1486
|
+
[SupportedChainId2.BNB]: "0x4e8E101924eDE233C13e2D8622DC8aED2872d505",
|
|
1332
1487
|
// https://docs.across.to/reference/contract-addresses/linea-chain-id-59144
|
|
1333
|
-
[
|
|
1488
|
+
[SupportedChainId2.LINEA]: "0xE0BCff426509723B18D6b2f0D8F4602d143bE3e0",
|
|
1334
1489
|
// https://docs.across.to/reference/contract-addresses/plasma
|
|
1335
|
-
[
|
|
1490
|
+
[SupportedChainId2.PLASMA]: "0x50039fAEfebef707cFD94D6d462fE6D10B39207a",
|
|
1336
1491
|
// Not supported chains
|
|
1337
1492
|
// TODO: This first integration is a draft, some of this chains might be supported, so we will need to update here as we iterate on the provider
|
|
1338
|
-
[
|
|
1339
|
-
[
|
|
1493
|
+
[SupportedChainId2.GNOSIS_CHAIN]: void 0,
|
|
1494
|
+
[SupportedChainId2.AVALANCHE]: void 0,
|
|
1340
1495
|
[AdditionalTargetChainId.OPTIMISM]: void 0
|
|
1341
1496
|
};
|
|
1342
1497
|
var ACROSS_MATH_CONTRACT_ADDRESSES = {
|
|
1343
|
-
[
|
|
1344
|
-
[
|
|
1345
|
-
[
|
|
1498
|
+
[SupportedChainId2.MAINNET]: "0xf2ae6728b6f146556977Af0A68bFbf5bADA22863",
|
|
1499
|
+
[SupportedChainId2.ARBITRUM_ONE]: "0x5771A4b4029832e79a75De7B485E5fBbec28848f",
|
|
1500
|
+
[SupportedChainId2.BASE]: "0xd4e943dc6ddc885f6229ce33c2e3dfe402a12c81",
|
|
1346
1501
|
// Not supported chains
|
|
1347
1502
|
// TODO: This first integration is a draft, some of this chains might be supported, so we will need to update here as we iterate on the provider
|
|
1348
|
-
[
|
|
1349
|
-
[
|
|
1350
|
-
[
|
|
1503
|
+
[SupportedChainId2.GNOSIS_CHAIN]: void 0,
|
|
1504
|
+
[SupportedChainId2.SEPOLIA]: void 0,
|
|
1505
|
+
[SupportedChainId2.POLYGON]: void 0,
|
|
1351
1506
|
[AdditionalTargetChainId.OPTIMISM]: void 0,
|
|
1352
|
-
[
|
|
1353
|
-
[
|
|
1507
|
+
[SupportedChainId2.AVALANCHE]: void 0,
|
|
1508
|
+
[SupportedChainId2.LENS]: void 0,
|
|
1354
1509
|
// TODO: confirm
|
|
1355
|
-
[
|
|
1510
|
+
[SupportedChainId2.BNB]: void 0,
|
|
1356
1511
|
// TODO: confirm
|
|
1357
|
-
[
|
|
1512
|
+
[SupportedChainId2.LINEA]: void 0,
|
|
1358
1513
|
// TODO: confirm
|
|
1359
|
-
[
|
|
1514
|
+
[SupportedChainId2.PLASMA]: void 0
|
|
1360
1515
|
// TODO: confirm
|
|
1361
1516
|
};
|
|
1362
1517
|
|
|
@@ -3805,62 +3960,62 @@ var getBungeeBridgeFromDisplayName = (displayName) => {
|
|
|
3805
3960
|
};
|
|
3806
3961
|
|
|
3807
3962
|
// src/providers/bungee/const/contracts.ts
|
|
3808
|
-
import { AdditionalTargetChainId as AdditionalTargetChainId2, SupportedChainId as
|
|
3963
|
+
import { AdditionalTargetChainId as AdditionalTargetChainId2, SupportedChainId as SupportedChainId5 } from "@cowprotocol/sdk-config";
|
|
3809
3964
|
var BUNGEE_COWSWAP_LIB_ADDRESS = "0x75b6ba5fcab20848ca00f132d253638fea82e598";
|
|
3810
3965
|
var BungeeCowswapLibAddresses = {
|
|
3811
|
-
[
|
|
3812
|
-
[
|
|
3813
|
-
[
|
|
3814
|
-
[
|
|
3815
|
-
[
|
|
3816
|
-
[
|
|
3817
|
-
[
|
|
3966
|
+
[SupportedChainId5.MAINNET]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
3967
|
+
[SupportedChainId5.GNOSIS_CHAIN]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
3968
|
+
[SupportedChainId5.ARBITRUM_ONE]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
3969
|
+
[SupportedChainId5.BASE]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
3970
|
+
[SupportedChainId5.AVALANCHE]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
3971
|
+
[SupportedChainId5.POLYGON]: BUNGEE_COWSWAP_LIB_ADDRESS,
|
|
3972
|
+
[SupportedChainId5.LENS]: void 0,
|
|
3818
3973
|
// TODO: confirm
|
|
3819
|
-
[
|
|
3974
|
+
[SupportedChainId5.BNB]: void 0,
|
|
3820
3975
|
// TODO: confirm
|
|
3821
|
-
[
|
|
3976
|
+
[SupportedChainId5.LINEA]: void 0,
|
|
3822
3977
|
// TODO: confirm
|
|
3823
|
-
[
|
|
3978
|
+
[SupportedChainId5.PLASMA]: void 0,
|
|
3824
3979
|
// TODO: confirm
|
|
3825
|
-
[
|
|
3980
|
+
[SupportedChainId5.SEPOLIA]: void 0,
|
|
3826
3981
|
[AdditionalTargetChainId2.OPTIMISM]: BUNGEE_COWSWAP_LIB_ADDRESS
|
|
3827
3982
|
};
|
|
3828
3983
|
var SOCKET_VERIFIER_ADDRESS = "0xa27A3f5A96DF7D8Be26EE2790999860C00eb688D";
|
|
3829
3984
|
var SocketVerifierAddresses = {
|
|
3830
|
-
[
|
|
3831
|
-
[
|
|
3832
|
-
[
|
|
3833
|
-
[
|
|
3834
|
-
[
|
|
3835
|
-
[
|
|
3836
|
-
[
|
|
3985
|
+
[SupportedChainId5.MAINNET]: SOCKET_VERIFIER_ADDRESS,
|
|
3986
|
+
[SupportedChainId5.GNOSIS_CHAIN]: SOCKET_VERIFIER_ADDRESS,
|
|
3987
|
+
[SupportedChainId5.ARBITRUM_ONE]: SOCKET_VERIFIER_ADDRESS,
|
|
3988
|
+
[SupportedChainId5.BASE]: SOCKET_VERIFIER_ADDRESS,
|
|
3989
|
+
[SupportedChainId5.AVALANCHE]: SOCKET_VERIFIER_ADDRESS,
|
|
3990
|
+
[SupportedChainId5.POLYGON]: SOCKET_VERIFIER_ADDRESS,
|
|
3991
|
+
[SupportedChainId5.LENS]: void 0,
|
|
3837
3992
|
// TODO: confirm
|
|
3838
|
-
[
|
|
3993
|
+
[SupportedChainId5.BNB]: void 0,
|
|
3839
3994
|
// TODO: confirm
|
|
3840
|
-
[
|
|
3995
|
+
[SupportedChainId5.LINEA]: void 0,
|
|
3841
3996
|
// TODO: confirm
|
|
3842
|
-
[
|
|
3997
|
+
[SupportedChainId5.PLASMA]: void 0,
|
|
3843
3998
|
// TODO: confirm
|
|
3844
|
-
[
|
|
3999
|
+
[SupportedChainId5.SEPOLIA]: void 0,
|
|
3845
4000
|
[AdditionalTargetChainId2.OPTIMISM]: SOCKET_VERIFIER_ADDRESS
|
|
3846
4001
|
};
|
|
3847
4002
|
var BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS = "0xD06a673fe1fa27B1b9E5BA0be980AB15Dbce85cc";
|
|
3848
4003
|
var BungeeApproveAndBridgeV1Addresses = {
|
|
3849
|
-
[
|
|
3850
|
-
[
|
|
3851
|
-
[
|
|
3852
|
-
[
|
|
3853
|
-
[
|
|
3854
|
-
[
|
|
3855
|
-
[
|
|
4004
|
+
[SupportedChainId5.MAINNET]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4005
|
+
[SupportedChainId5.GNOSIS_CHAIN]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4006
|
+
[SupportedChainId5.ARBITRUM_ONE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4007
|
+
[SupportedChainId5.BASE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4008
|
+
[SupportedChainId5.AVALANCHE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4009
|
+
[SupportedChainId5.POLYGON]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
|
|
4010
|
+
[SupportedChainId5.LENS]: void 0,
|
|
3856
4011
|
// TODO: confirm
|
|
3857
|
-
[
|
|
4012
|
+
[SupportedChainId5.BNB]: void 0,
|
|
3858
4013
|
// TODO: confirm
|
|
3859
|
-
[
|
|
4014
|
+
[SupportedChainId5.LINEA]: void 0,
|
|
3860
4015
|
// TODO: confirm
|
|
3861
|
-
[
|
|
4016
|
+
[SupportedChainId5.PLASMA]: void 0,
|
|
3862
4017
|
// TODO: confirm
|
|
3863
|
-
[
|
|
4018
|
+
[SupportedChainId5.SEPOLIA]: void 0,
|
|
3864
4019
|
[AdditionalTargetChainId2.OPTIMISM]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS
|
|
3865
4020
|
};
|
|
3866
4021
|
|
|
@@ -4603,7 +4758,7 @@ import {
|
|
|
4603
4758
|
mainnet as mainnet2,
|
|
4604
4759
|
optimism as optimism2,
|
|
4605
4760
|
polygon as polygon2,
|
|
4606
|
-
SupportedChainId as
|
|
4761
|
+
SupportedChainId as SupportedChainId6
|
|
4607
4762
|
} from "@cowprotocol/sdk-config";
|
|
4608
4763
|
import { CowShedSdk as CowShedSdk2 } from "@cowprotocol/sdk-cow-shed";
|
|
4609
4764
|
import { setGlobalAdapter as setGlobalAdapter3 } from "@cowprotocol/sdk-common";
|
|
@@ -4763,7 +4918,7 @@ var BungeeBridgeProvider = class {
|
|
|
4763
4918
|
}
|
|
4764
4919
|
isExtraGasRequired(request) {
|
|
4765
4920
|
const { sellTokenChainId, buyTokenChainId } = request;
|
|
4766
|
-
return sellTokenChainId ===
|
|
4921
|
+
return sellTokenChainId === SupportedChainId6.MAINNET && buyTokenChainId === SupportedChainId6.GNOSIS_CHAIN;
|
|
4767
4922
|
}
|
|
4768
4923
|
};
|
|
4769
4924
|
|
|
@@ -4775,7 +4930,7 @@ import { OrderKind as OrderKind6 } from "@cowprotocol/sdk-order-book";
|
|
|
4775
4930
|
import { QuoteRequest } from "@defuse-protocol/one-click-sdk-typescript";
|
|
4776
4931
|
|
|
4777
4932
|
// src/providers/near-intents/NearIntentsApi.ts
|
|
4778
|
-
import { OneClickService, OpenAPI } from "@defuse-protocol/one-click-sdk-typescript";
|
|
4933
|
+
import { ApiError, OneClickService, OpenAPI } from "@defuse-protocol/one-click-sdk-typescript";
|
|
4779
4934
|
var NearIntentsApi = class {
|
|
4780
4935
|
cachedTokens = [];
|
|
4781
4936
|
async getTokens() {
|
|
@@ -4786,7 +4941,22 @@ var NearIntentsApi = class {
|
|
|
4786
4941
|
return this.cachedTokens;
|
|
4787
4942
|
}
|
|
4788
4943
|
async getQuote(request) {
|
|
4789
|
-
|
|
4944
|
+
try {
|
|
4945
|
+
return await OneClickService.getQuote(request);
|
|
4946
|
+
} catch (error) {
|
|
4947
|
+
if (error instanceof ApiError) {
|
|
4948
|
+
const message = error.body?.message;
|
|
4949
|
+
if (message && typeof message === "string" && message.toLowerCase().includes("amount is too low")) {
|
|
4950
|
+
const minAmountMatch = message.match(/try at least (\d+)/);
|
|
4951
|
+
const minAmount = minAmountMatch ? minAmountMatch[1] : void 0;
|
|
4952
|
+
throw new BridgeProviderQuoteError("SELL_AMOUNT_TOO_SMALL" /* SELL_AMOUNT_TOO_SMALL */, {
|
|
4953
|
+
originalMessage: message,
|
|
4954
|
+
minAmount
|
|
4955
|
+
});
|
|
4956
|
+
}
|
|
4957
|
+
}
|
|
4958
|
+
throw error;
|
|
4959
|
+
}
|
|
4790
4960
|
}
|
|
4791
4961
|
async getStatus(depositAddress) {
|
|
4792
4962
|
return await OneClickService.getExecutionStatus(depositAddress);
|
|
@@ -5181,6 +5351,7 @@ export {
|
|
|
5181
5351
|
BridgeOrderParsingError,
|
|
5182
5352
|
BridgeProviderError,
|
|
5183
5353
|
BridgeProviderQuoteError,
|
|
5354
|
+
BridgeQuoteErrorPriorities,
|
|
5184
5355
|
BridgeQuoteErrors,
|
|
5185
5356
|
BridgeStatus,
|
|
5186
5357
|
BridgingSdk,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/sdk-bridging",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"description": "Bridging for CoW Protocol",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@defuse-protocol/one-click-sdk-typescript": "0.1.1-0.2",
|
|
18
18
|
"json-stable-stringify": "^1.3.0",
|
|
19
|
-
"@cowprotocol/sdk-
|
|
19
|
+
"@cowprotocol/sdk-app-data": "4.3.6",
|
|
20
20
|
"@cowprotocol/sdk-common": "0.4.0",
|
|
21
|
-
"@cowprotocol/sdk-contracts-ts": "0.
|
|
22
|
-
"@cowprotocol/sdk-
|
|
23
|
-
"@cowprotocol/sdk-order-book": "0.4.
|
|
24
|
-
"@cowprotocol/sdk-trading": "0.
|
|
25
|
-
"@cowprotocol/sdk-
|
|
26
|
-
"@cowprotocol/sdk-
|
|
21
|
+
"@cowprotocol/sdk-contracts-ts": "0.8.1",
|
|
22
|
+
"@cowprotocol/sdk-config": "0.6.2",
|
|
23
|
+
"@cowprotocol/sdk-order-book": "0.4.4",
|
|
24
|
+
"@cowprotocol/sdk-trading": "0.7.1",
|
|
25
|
+
"@cowprotocol/sdk-cow-shed": "0.2.8",
|
|
26
|
+
"@cowprotocol/sdk-weiroll": "0.1.11"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"@types/jest": "^29.4.0",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"@cow-sdk/typescript-config": "0.0.0-beta.0",
|
|
42
42
|
"@cowprotocol/sdk-ethers-v5-adapter": "0.3.0",
|
|
43
43
|
"@cowprotocol/sdk-ethers-v6-adapter": "0.3.0",
|
|
44
|
-
"@cowprotocol/sdk-
|
|
45
|
-
"@cowprotocol/sdk-
|
|
44
|
+
"@cowprotocol/sdk-order-signing": "0.1.21",
|
|
45
|
+
"@cowprotocol/sdk-viem-adapter": "0.3.0"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|