@cowprotocol/sdk-bridging 4.1.2 → 4.2.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.mjs CHANGED
@@ -256,79 +256,169 @@ function getHookMockForCostEstimation(gasLimit) {
256
256
  import { getGlobalAdapter as getGlobalAdapter2, jsonWithBigintReplacer as jsonWithBigintReplacer2, log as log2 } from "@cowprotocol/sdk-common";
257
257
 
258
258
  // src/BridgingSdk/determineIntermediateToken.ts
259
- import { areAddressesEqual, getAddressKey as getAddressKey3, isNativeToken, isWrappedNativeToken } from "@cowprotocol/sdk-common";
259
+ import { isSupportedChain } from "@cowprotocol/sdk-config";
260
+ import { areAddressesEqual, getAddressKey as getAddressKey3, isNativeToken } from "@cowprotocol/sdk-common";
260
261
 
261
262
  // src/BridgingSdk/tokenPriority.ts
262
263
  import { SupportedChainId } from "@cowprotocol/sdk-config";
263
264
  import { getAddressKey as getAddressKey2 } from "@cowprotocol/sdk-common";
264
265
  var PRIORITY_STABLECOIN_TOKENS = {
265
266
  [SupportedChainId.MAINNET]: /* @__PURE__ */ new Set([
266
- "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
267
- // USDC
268
- "0xdac17f958d2ee523a2206206994597c13d831ec7"
269
- // USDT
267
+ {
268
+ chainId: SupportedChainId.MAINNET,
269
+ address: "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48",
270
+ decimals: 6,
271
+ symbol: "USDC"
272
+ },
273
+ {
274
+ chainId: SupportedChainId.MAINNET,
275
+ address: "0xdac17f958d2ee523a2206206994597c13d831ec7",
276
+ decimals: 6,
277
+ symbol: "USDT"
278
+ }
270
279
  ]),
271
280
  [SupportedChainId.BNB]: /* @__PURE__ */ new Set([
272
- "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
273
- // USDC
274
- "0x55d398326f99059ff775485246999027b3197955"
275
- // USDT
281
+ {
282
+ chainId: SupportedChainId.BNB,
283
+ address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
284
+ decimals: 18,
285
+ symbol: "USDC"
286
+ },
287
+ {
288
+ chainId: SupportedChainId.BNB,
289
+ address: "0x55d398326f99059ff775485246999027b3197955",
290
+ decimals: 18,
291
+ symbol: "USDT"
292
+ }
276
293
  ]),
277
294
  [SupportedChainId.GNOSIS_CHAIN]: /* @__PURE__ */ new Set([
278
- "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
279
- // USDC
280
- "0x2a22f9c3b484c3629090feed35f17ff8f88f76f0",
281
- // USDC.e
282
- "0x4ecaba5870353805a9f068101a40e0f32ed605c6"
283
- // USDT
295
+ {
296
+ chainId: SupportedChainId.GNOSIS_CHAIN,
297
+ address: "0xddafbb505ad214d7b80b1f830fccc89b60fb7a83",
298
+ decimals: 6,
299
+ symbol: "USDC"
300
+ },
301
+ {
302
+ chainId: SupportedChainId.GNOSIS_CHAIN,
303
+ address: "0x2a22f9c3b484c3629090feed35f17ff8f88f76f0",
304
+ decimals: 6,
305
+ symbol: "USDC.e"
306
+ },
307
+ {
308
+ chainId: SupportedChainId.GNOSIS_CHAIN,
309
+ address: "0x4ecaba5870353805a9f068101a40e0f32ed605c6",
310
+ decimals: 6,
311
+ symbol: "USDT"
312
+ }
284
313
  ]),
285
314
  [SupportedChainId.POLYGON]: /* @__PURE__ */ new Set([
286
- "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
287
- // USDC
288
- "0xc2132d05d31c914a87c6611c10748aeb04b58e8f"
289
- // USDT
315
+ {
316
+ chainId: SupportedChainId.POLYGON,
317
+ address: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
318
+ decimals: 6,
319
+ symbol: "USDC"
320
+ },
321
+ {
322
+ chainId: SupportedChainId.POLYGON,
323
+ address: "0xc2132d05d31c914a87c6611c10748aeb04b58e8f",
324
+ decimals: 6,
325
+ symbol: "USDT"
326
+ }
290
327
  ]),
291
328
  [SupportedChainId.BASE]: /* @__PURE__ */ new Set([
292
- "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
293
- // USDC
294
- "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2"
295
- // USDT
329
+ {
330
+ chainId: SupportedChainId.BASE,
331
+ address: "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
332
+ decimals: 6,
333
+ symbol: "USDC"
334
+ },
335
+ {
336
+ chainId: SupportedChainId.BASE,
337
+ address: "0xfde4c96c8593536e31f229ea8f37b2ada2699bb2",
338
+ decimals: 6,
339
+ symbol: "USDT"
340
+ }
296
341
  ]),
297
342
  [SupportedChainId.ARBITRUM_ONE]: /* @__PURE__ */ new Set([
298
- "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
299
- // USDC
300
- "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
301
- // USDT
343
+ {
344
+ chainId: SupportedChainId.ARBITRUM_ONE,
345
+ address: "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
346
+ decimals: 6,
347
+ symbol: "USDC"
348
+ },
349
+ {
350
+ chainId: SupportedChainId.ARBITRUM_ONE,
351
+ address: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
352
+ decimals: 6,
353
+ symbol: "USDT"
354
+ }
302
355
  ]),
303
356
  [SupportedChainId.AVALANCHE]: /* @__PURE__ */ new Set([
304
- "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
305
- // USDC
306
- "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7"
307
- // USDT
357
+ {
358
+ chainId: SupportedChainId.AVALANCHE,
359
+ address: "0xb97ef9ef8734c71904d8002f8b6bc66dd9c48a6e",
360
+ decimals: 6,
361
+ symbol: "USDC"
362
+ },
363
+ {
364
+ chainId: SupportedChainId.AVALANCHE,
365
+ address: "0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7",
366
+ decimals: 6,
367
+ symbol: "USDT"
368
+ }
308
369
  ]),
309
370
  [SupportedChainId.LINEA]: /* @__PURE__ */ new Set([
310
- "0x176211869ca2b568f2a7d4ee941e073a821ee1ff",
311
- // USDC
312
- "0xa219439258ca9da29e9cc4ce5596924745e12b93"
313
- // USDT
371
+ {
372
+ chainId: SupportedChainId.LINEA,
373
+ address: "0x176211869ca2b568f2a7d4ee941e073a821ee1ff",
374
+ decimals: 6,
375
+ symbol: "USDC"
376
+ },
377
+ {
378
+ chainId: SupportedChainId.LINEA,
379
+ address: "0xa219439258ca9da29e9cc4ce5596924745e12b93",
380
+ decimals: 6,
381
+ symbol: "USDT"
382
+ }
314
383
  ]),
315
384
  [SupportedChainId.SEPOLIA]: /* @__PURE__ */ new Set([
316
- "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238"
317
- // USDC
385
+ {
386
+ chainId: SupportedChainId.SEPOLIA,
387
+ address: "0x1c7d4b196cb0c7b01d743fbc6116a902379c7238",
388
+ decimals: 6,
389
+ symbol: "USDC"
390
+ }
318
391
  ])
319
392
  };
320
- function isStablecoinPriorityToken(chainId, tokenAddress) {
393
+ function getStablecoinPriorityToken(chainId, tokenAddress) {
321
394
  const chainTokens = PRIORITY_STABLECOIN_TOKENS[chainId];
322
395
  if (!chainTokens)
323
- return false;
324
- return chainTokens.has(getAddressKey2(tokenAddress));
396
+ return void 0;
397
+ const key = getAddressKey2(tokenAddress);
398
+ for (const token of chainTokens) {
399
+ if (getAddressKey2(token.address) === key)
400
+ return token;
401
+ }
402
+ return void 0;
403
+ }
404
+ function isStablecoinPriorityToken(chainId, tokenAddress) {
405
+ return getStablecoinPriorityToken(chainId, tokenAddress) !== void 0;
325
406
  }
326
407
  function isCorrelatedToken(tokenAddress, correlatedTokens) {
327
408
  return correlatedTokens.has(getAddressKey2(tokenAddress));
328
409
  }
329
410
 
330
411
  // src/BridgingSdk/determineIntermediateToken.ts
331
- async function determineIntermediateToken(sourceChainId, sourceTokenAddress, intermediateTokens, getCorrelatedTokens, allowIntermediateEqSellToken) {
412
+ async function determineIntermediateToken(context) {
413
+ const {
414
+ sourceChainId,
415
+ sourceTokenAddress,
416
+ destinationChainId,
417
+ destinationTokenAddress,
418
+ intermediateTokens,
419
+ getCorrelatedTokens,
420
+ allowIntermediateEqSellToken
421
+ } = context;
332
422
  const firstToken = intermediateTokens[0];
333
423
  if (intermediateTokens.length === 0 || !firstToken) {
334
424
  throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
@@ -337,26 +427,29 @@ async function determineIntermediateToken(sourceChainId, sourceTokenAddress, int
337
427
  return firstToken;
338
428
  }
339
429
  const correlatedTokens = await resolveCorrelatedTokens(sourceChainId, getCorrelatedTokens);
340
- const sellTokenLike = { chainId: sourceChainId, address: sourceTokenAddress };
341
- const isSellNativeOrWrapped = isNativeToken(sellTokenLike) || isWrappedNativeToken(sellTokenLike);
342
430
  const filteredTokens = allowIntermediateEqSellToken ? intermediateTokens : intermediateTokens.filter((token) => !areAddressesEqual(token.address, sourceTokenAddress));
431
+ const destinationStableCoin = isSupportedChain(destinationChainId) ? getStablecoinPriorityToken(destinationChainId, destinationTokenAddress) : void 0;
343
432
  const tokensWithPriority = filteredTokens.map((token) => {
344
- const isNativeOrWrapped = isNativeToken(token) || isWrappedNativeToken(token);
345
- if (areAddressesEqual(token.address, sourceTokenAddress)) {
346
- if (!(isSellNativeOrWrapped && isNativeOrWrapped)) {
347
- return { token, priority: 5 /* HIGHEST */ };
433
+ const isStableCoin = isStablecoinPriorityToken(token.chainId, token.address);
434
+ if (destinationStableCoin && isStableCoin) {
435
+ const matchesDestinationTokenSymbol = !!token.symbol && token.symbol.toLowerCase() === destinationStableCoin?.symbol?.toLowerCase();
436
+ if (matchesDestinationTokenSymbol) {
437
+ return { token, priority: 6 /* STABLECOIN_MATCHES_DESTINATION */ };
348
438
  }
349
439
  }
350
- if (isStablecoinPriorityToken(token.chainId, token.address)) {
351
- return { token, priority: 4 /* HIGH */ };
440
+ if (areAddressesEqual(token.address, sourceTokenAddress)) {
441
+ return { token, priority: 5 /* MATCHES_SELL */ };
442
+ }
443
+ if (isStableCoin) {
444
+ return { token, priority: 4 /* STABLECOIN */ };
352
445
  }
353
446
  if (isCorrelatedToken(token.address, correlatedTokens)) {
354
- return { token, priority: 3 /* MEDIUM */ };
447
+ return { token, priority: 3 /* CORRELATED */ };
355
448
  }
356
- if (isNativeToken(token) && !isSellNativeOrWrapped) {
357
- return { token, priority: 2 /* LOW */ };
449
+ if (isNativeToken(token)) {
450
+ return { token, priority: 2 /* NATIVE */ };
358
451
  }
359
- return { token, priority: 1 /* LOWEST */ };
452
+ return { token, priority: 1 /* OTHER */ };
360
453
  });
361
454
  tokensWithPriority.sort((a, b) => {
362
455
  if (a.priority !== b.priority) {
@@ -411,13 +504,15 @@ async function getIntermediateSwapResult({
411
504
  quoteBridgeRequest: swapAndBridgeRequest,
412
505
  intermediateTokensCache: params.intermediateTokensCache
413
506
  });
414
- const intermediateToken = await determineIntermediateToken(
415
- sellTokenChainId,
416
- sellTokenAddress,
507
+ const intermediateToken = await determineIntermediateToken({
508
+ sourceChainId: sellTokenChainId,
509
+ sourceTokenAddress: sellTokenAddress,
510
+ destinationChainId: buyTokenChainId,
511
+ destinationTokenAddress: buyTokenAddress,
417
512
  intermediateTokens,
418
- params.advancedSettings?.getCorrelatedTokens,
513
+ getCorrelatedTokens: params.advancedSettings?.getCorrelatedTokens,
419
514
  allowIntermediateEqSellToken
420
- );
515
+ });
421
516
  log2(`Using ${intermediateToken?.name ?? intermediateToken?.address} as intermediate tokens`);
422
517
  const bridgeRequestWithoutAmount = {
423
518
  ...swapAndBridgeRequest,
@@ -1501,56 +1596,56 @@ var COW_TRADE_EVENT_INTERFACE = () => {
1501
1596
  };
1502
1597
 
1503
1598
  // src/providers/across/const/contracts.ts
1504
- import { AdditionalTargetChainId, SupportedChainId as SupportedChainId2 } from "@cowprotocol/sdk-config";
1599
+ import { AdditionalTargetChainId, SupportedChainId as SupportedChainId3 } from "@cowprotocol/sdk-config";
1505
1600
  var ACROSS_SPOOK_CONTRACT_ADDRESSES = {
1506
1601
  // https://docs.across.to/reference/contract-addresses/mainnet-chain-id-1
1507
- [SupportedChainId2.MAINNET]: "0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5",
1602
+ [SupportedChainId3.MAINNET]: "0x5c7BCd6E7De5423a257D81B442095A1a6ced35C5",
1508
1603
  // https://docs.across.to/reference/contract-addresses/arbitrum-chain-id-42161-1
1509
- [SupportedChainId2.ARBITRUM_ONE]: "0xe35e9842fceaca96570b734083f4a58e8f7c5f2a",
1604
+ [SupportedChainId3.ARBITRUM_ONE]: "0xe35e9842fceaca96570b734083f4a58e8f7c5f2a",
1510
1605
  // https://docs.across.to/reference/contract-addresses/base-chain-id-8453
1511
- [SupportedChainId2.BASE]: "0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64",
1606
+ [SupportedChainId3.BASE]: "0x09aea4b2242abC8bb4BB78D537A67a245A7bEC64",
1512
1607
  // // https://docs.across.to/reference/contract-addresses/mainnet-chain-id-1
1513
- [SupportedChainId2.SEPOLIA]: "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
1608
+ [SupportedChainId3.SEPOLIA]: "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
1514
1609
  // https://docs.across.to/reference/contract-addresses/polygon-chain-id-137
1515
- [SupportedChainId2.POLYGON]: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096",
1610
+ [SupportedChainId3.POLYGON]: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096",
1516
1611
  // https://docs.across.to/reference/contract-addresses/bnb-smart-chain
1517
- [SupportedChainId2.BNB]: "0x4e8E101924eDE233C13e2D8622DC8aED2872d505",
1612
+ [SupportedChainId3.BNB]: "0x4e8E101924eDE233C13e2D8622DC8aED2872d505",
1518
1613
  // https://docs.across.to/reference/contract-addresses/linea-chain-id-59144
1519
- [SupportedChainId2.LINEA]: "0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75",
1614
+ [SupportedChainId3.LINEA]: "0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75",
1520
1615
  // https://docs.across.to/reference/contract-addresses/plasma
1521
- [SupportedChainId2.PLASMA]: "0x50039fAEfebef707cFD94D6d462fE6D10B39207a",
1616
+ [SupportedChainId3.PLASMA]: "0x50039fAEfebef707cFD94D6d462fE6D10B39207a",
1522
1617
  // https://docs.across.to/reference/contract-addresses/ink-chain-id-57073
1523
- [SupportedChainId2.INK]: "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4",
1618
+ [SupportedChainId3.INK]: "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4",
1524
1619
  // https://docs.across.to/reference/contract-addresses/optimism-chain-id-10
1525
1620
  [AdditionalTargetChainId.OPTIMISM]: "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
1526
1621
  // Not supported chains
1527
1622
  // 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
1528
- [SupportedChainId2.GNOSIS_CHAIN]: void 0,
1529
- [SupportedChainId2.AVALANCHE]: void 0,
1623
+ [SupportedChainId3.GNOSIS_CHAIN]: void 0,
1624
+ [SupportedChainId3.AVALANCHE]: void 0,
1530
1625
  [AdditionalTargetChainId.BITCOIN]: void 0,
1531
- [SupportedChainId2.SOLANA]: void 0
1626
+ [SupportedChainId3.SOLANA]: void 0
1532
1627
  };
1533
1628
  var ACROSS_MATH_CONTRACT_ADDRESSES = {
1534
- [SupportedChainId2.MAINNET]: "0xf2ae6728b6f146556977Af0A68bFbf5bADA22863",
1535
- [SupportedChainId2.ARBITRUM_ONE]: "0x5771A4b4029832e79a75De7B485E5fBbec28848f",
1536
- [SupportedChainId2.BASE]: "0xd4e943dc6ddc885f6229ce33c2e3dfe402a12c81",
1629
+ [SupportedChainId3.MAINNET]: "0xf2ae6728b6f146556977Af0A68bFbf5bADA22863",
1630
+ [SupportedChainId3.ARBITRUM_ONE]: "0x5771A4b4029832e79a75De7B485E5fBbec28848f",
1631
+ [SupportedChainId3.BASE]: "0xd4e943dc6ddc885f6229ce33c2e3dfe402a12c81",
1537
1632
  // Not supported chains
1538
1633
  // 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
1539
- [SupportedChainId2.GNOSIS_CHAIN]: void 0,
1540
- [SupportedChainId2.SEPOLIA]: void 0,
1541
- [SupportedChainId2.POLYGON]: void 0,
1542
- [SupportedChainId2.AVALANCHE]: void 0,
1543
- [SupportedChainId2.BNB]: void 0,
1634
+ [SupportedChainId3.GNOSIS_CHAIN]: void 0,
1635
+ [SupportedChainId3.SEPOLIA]: void 0,
1636
+ [SupportedChainId3.POLYGON]: void 0,
1637
+ [SupportedChainId3.AVALANCHE]: void 0,
1638
+ [SupportedChainId3.BNB]: void 0,
1544
1639
  // TODO: confirm
1545
- [SupportedChainId2.LINEA]: void 0,
1640
+ [SupportedChainId3.LINEA]: void 0,
1546
1641
  // TODO: confirm
1547
- [SupportedChainId2.PLASMA]: void 0,
1642
+ [SupportedChainId3.PLASMA]: void 0,
1548
1643
  // TODO: confirm
1549
- [SupportedChainId2.INK]: void 0,
1644
+ [SupportedChainId3.INK]: void 0,
1550
1645
  // TODO: confirm
1551
1646
  [AdditionalTargetChainId.OPTIMISM]: void 0,
1552
1647
  [AdditionalTargetChainId.BITCOIN]: void 0,
1553
- [SupportedChainId2.SOLANA]: void 0
1648
+ [SupportedChainId3.SOLANA]: void 0
1554
1649
  };
1555
1650
 
1556
1651
  // src/providers/across/util.ts
@@ -3626,7 +3721,7 @@ import {
3626
3721
  mainnet,
3627
3722
  optimism,
3628
3723
  polygon,
3629
- isSupportedChain
3724
+ isSupportedChain as isSupportedChain2
3630
3725
  } from "@cowprotocol/sdk-config";
3631
3726
  import { CowShedSdk } from "@cowprotocol/sdk-cow-shed";
3632
3727
  import { OrderKind as OrderKind3 } from "@cowprotocol/sdk-order-book";
@@ -3738,7 +3833,7 @@ var AcrossBridgeProvider = class {
3738
3833
  throw new Error("Not implemented");
3739
3834
  }
3740
3835
  async getBridgingParams(chainId, order, txHash, settlementContractOverride) {
3741
- if (!isSupportedChain(chainId)) {
3836
+ if (!isSupportedChain2(chainId)) {
3742
3837
  return null;
3743
3838
  }
3744
3839
  const orderUid = order.uid;
@@ -3984,69 +4079,69 @@ var getBungeeBridgeFromDisplayName = (displayName) => {
3984
4079
  };
3985
4080
 
3986
4081
  // src/providers/bungee/const/contracts.ts
3987
- import { AdditionalTargetChainId as AdditionalTargetChainId2, SupportedChainId as SupportedChainId4 } from "@cowprotocol/sdk-config";
4082
+ import { AdditionalTargetChainId as AdditionalTargetChainId2, SupportedChainId as SupportedChainId5 } from "@cowprotocol/sdk-config";
3988
4083
  var BUNGEE_COWSWAP_LIB_ADDRESS = "0x75b6ba5fcab20848ca00f132d253638fea82e598";
3989
4084
  var BungeeCowswapLibAddresses = {
3990
- [SupportedChainId4.MAINNET]: BUNGEE_COWSWAP_LIB_ADDRESS,
3991
- [SupportedChainId4.GNOSIS_CHAIN]: BUNGEE_COWSWAP_LIB_ADDRESS,
3992
- [SupportedChainId4.ARBITRUM_ONE]: BUNGEE_COWSWAP_LIB_ADDRESS,
3993
- [SupportedChainId4.BASE]: BUNGEE_COWSWAP_LIB_ADDRESS,
3994
- [SupportedChainId4.AVALANCHE]: BUNGEE_COWSWAP_LIB_ADDRESS,
3995
- [SupportedChainId4.POLYGON]: BUNGEE_COWSWAP_LIB_ADDRESS,
3996
- [SupportedChainId4.BNB]: void 0,
4085
+ [SupportedChainId5.MAINNET]: BUNGEE_COWSWAP_LIB_ADDRESS,
4086
+ [SupportedChainId5.GNOSIS_CHAIN]: BUNGEE_COWSWAP_LIB_ADDRESS,
4087
+ [SupportedChainId5.ARBITRUM_ONE]: BUNGEE_COWSWAP_LIB_ADDRESS,
4088
+ [SupportedChainId5.BASE]: BUNGEE_COWSWAP_LIB_ADDRESS,
4089
+ [SupportedChainId5.AVALANCHE]: BUNGEE_COWSWAP_LIB_ADDRESS,
4090
+ [SupportedChainId5.POLYGON]: BUNGEE_COWSWAP_LIB_ADDRESS,
4091
+ [SupportedChainId5.BNB]: void 0,
3997
4092
  // TODO: confirm
3998
- [SupportedChainId4.LINEA]: void 0,
4093
+ [SupportedChainId5.LINEA]: void 0,
3999
4094
  // TODO: confirm
4000
- [SupportedChainId4.PLASMA]: void 0,
4095
+ [SupportedChainId5.PLASMA]: void 0,
4001
4096
  // TODO: confirm
4002
- [SupportedChainId4.INK]: void 0,
4097
+ [SupportedChainId5.INK]: void 0,
4003
4098
  // TODO: confirm
4004
- [SupportedChainId4.SEPOLIA]: void 0,
4099
+ [SupportedChainId5.SEPOLIA]: void 0,
4005
4100
  [AdditionalTargetChainId2.OPTIMISM]: BUNGEE_COWSWAP_LIB_ADDRESS,
4006
4101
  [AdditionalTargetChainId2.BITCOIN]: void 0,
4007
- [SupportedChainId4.SOLANA]: void 0
4102
+ [SupportedChainId5.SOLANA]: void 0
4008
4103
  };
4009
4104
  var SOCKET_VERIFIER_ADDRESS = "0xa27A3f5A96DF7D8Be26EE2790999860C00eb688D";
4010
4105
  var SocketVerifierAddresses = {
4011
- [SupportedChainId4.MAINNET]: SOCKET_VERIFIER_ADDRESS,
4012
- [SupportedChainId4.GNOSIS_CHAIN]: SOCKET_VERIFIER_ADDRESS,
4013
- [SupportedChainId4.ARBITRUM_ONE]: SOCKET_VERIFIER_ADDRESS,
4014
- [SupportedChainId4.BASE]: SOCKET_VERIFIER_ADDRESS,
4015
- [SupportedChainId4.AVALANCHE]: SOCKET_VERIFIER_ADDRESS,
4016
- [SupportedChainId4.POLYGON]: SOCKET_VERIFIER_ADDRESS,
4017
- [SupportedChainId4.BNB]: void 0,
4106
+ [SupportedChainId5.MAINNET]: SOCKET_VERIFIER_ADDRESS,
4107
+ [SupportedChainId5.GNOSIS_CHAIN]: SOCKET_VERIFIER_ADDRESS,
4108
+ [SupportedChainId5.ARBITRUM_ONE]: SOCKET_VERIFIER_ADDRESS,
4109
+ [SupportedChainId5.BASE]: SOCKET_VERIFIER_ADDRESS,
4110
+ [SupportedChainId5.AVALANCHE]: SOCKET_VERIFIER_ADDRESS,
4111
+ [SupportedChainId5.POLYGON]: SOCKET_VERIFIER_ADDRESS,
4112
+ [SupportedChainId5.BNB]: void 0,
4018
4113
  // TODO: confirm
4019
- [SupportedChainId4.LINEA]: void 0,
4114
+ [SupportedChainId5.LINEA]: void 0,
4020
4115
  // TODO: confirm
4021
- [SupportedChainId4.PLASMA]: void 0,
4116
+ [SupportedChainId5.PLASMA]: void 0,
4022
4117
  // TODO: confirm
4023
- [SupportedChainId4.INK]: void 0,
4118
+ [SupportedChainId5.INK]: void 0,
4024
4119
  // TODO: confirm
4025
- [SupportedChainId4.SEPOLIA]: void 0,
4120
+ [SupportedChainId5.SEPOLIA]: void 0,
4026
4121
  [AdditionalTargetChainId2.OPTIMISM]: SOCKET_VERIFIER_ADDRESS,
4027
4122
  [AdditionalTargetChainId2.BITCOIN]: void 0,
4028
- [SupportedChainId4.SOLANA]: void 0
4123
+ [SupportedChainId5.SOLANA]: void 0
4029
4124
  };
4030
4125
  var BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS = "0xD06a673fe1fa27B1b9E5BA0be980AB15Dbce85cc";
4031
4126
  var BungeeApproveAndBridgeV1Addresses = {
4032
- [SupportedChainId4.MAINNET]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4033
- [SupportedChainId4.GNOSIS_CHAIN]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4034
- [SupportedChainId4.ARBITRUM_ONE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4035
- [SupportedChainId4.BASE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4036
- [SupportedChainId4.AVALANCHE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4037
- [SupportedChainId4.POLYGON]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4038
- [SupportedChainId4.BNB]: void 0,
4127
+ [SupportedChainId5.MAINNET]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4128
+ [SupportedChainId5.GNOSIS_CHAIN]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4129
+ [SupportedChainId5.ARBITRUM_ONE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4130
+ [SupportedChainId5.BASE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4131
+ [SupportedChainId5.AVALANCHE]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4132
+ [SupportedChainId5.POLYGON]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4133
+ [SupportedChainId5.BNB]: void 0,
4039
4134
  // TODO: confirm
4040
- [SupportedChainId4.LINEA]: void 0,
4135
+ [SupportedChainId5.LINEA]: void 0,
4041
4136
  // TODO: confirm
4042
- [SupportedChainId4.PLASMA]: void 0,
4137
+ [SupportedChainId5.PLASMA]: void 0,
4043
4138
  // TODO: confirm
4044
- [SupportedChainId4.INK]: void 0,
4139
+ [SupportedChainId5.INK]: void 0,
4045
4140
  // TODO: confirm
4046
- [SupportedChainId4.SEPOLIA]: void 0,
4141
+ [SupportedChainId5.SEPOLIA]: void 0,
4047
4142
  [AdditionalTargetChainId2.OPTIMISM]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
4048
4143
  [AdditionalTargetChainId2.BITCOIN]: void 0,
4049
- [SupportedChainId4.SOLANA]: void 0
4144
+ [SupportedChainId5.SOLANA]: void 0
4050
4145
  };
4051
4146
 
4052
4147
  // src/providers/bungee/abi.ts
@@ -4785,7 +4880,7 @@ import {
4785
4880
  mainnet as mainnet2,
4786
4881
  optimism as optimism2,
4787
4882
  polygon as polygon2,
4788
- SupportedChainId as SupportedChainId5
4883
+ SupportedChainId as SupportedChainId6
4789
4884
  } from "@cowprotocol/sdk-config";
4790
4885
  import { CowShedSdk as CowShedSdk2 } from "@cowprotocol/sdk-cow-shed";
4791
4886
  import { setGlobalAdapter as setGlobalAdapter3 } from "@cowprotocol/sdk-common";
@@ -4945,7 +5040,7 @@ var BungeeBridgeProvider = class {
4945
5040
  }
4946
5041
  isExtraGasRequired(request) {
4947
5042
  const { sellTokenChainId, buyTokenChainId } = request;
4948
- return sellTokenChainId === SupportedChainId5.MAINNET && buyTokenChainId === SupportedChainId5.GNOSIS_CHAIN;
5043
+ return sellTokenChainId === SupportedChainId6.MAINNET && buyTokenChainId === SupportedChainId6.GNOSIS_CHAIN;
4949
5044
  }
4950
5045
  };
4951
5046
 
@@ -4958,7 +5053,17 @@ import { QuoteRequest } from "@defuse-protocol/one-click-sdk-typescript";
4958
5053
 
4959
5054
  // src/providers/near-intents/NearIntentsApi.ts
4960
5055
  import { ApiError, OneClickService, OpenAPI } from "@defuse-protocol/one-click-sdk-typescript";
4961
- var NearIntentsApi = class {
5056
+ var NearIntentsApi = class _NearIntentsApi {
5057
+ // Upstream /v0/tokens still lists deprecated assets the attestation service
5058
+ // no longer signs. They share `blockchain: 'btc'` with the live token and
5059
+ // both resolve to BTC_CURRENCY_ADDRESS, so without this filter `tokens.find()`
5060
+ // picks the deprecated entry (it appears first) and /v0/attestation fails
5061
+ // with "Invalid quote hash".
5062
+ static DEPRECATED_ASSET_IDS = /* @__PURE__ */ new Set([
5063
+ // POA BTC bridge, replaced by `1cs_v1:btc:native:coin` (Omni migration).
5064
+ // https://partners.near-intents.org/omni-migration
5065
+ "nep141:btc.omft.near"
5066
+ ]);
4962
5067
  cachedTokens = [];
4963
5068
  constructor(apiKey) {
4964
5069
  if (apiKey) {
@@ -4968,7 +5073,7 @@ var NearIntentsApi = class {
4968
5073
  async getTokens() {
4969
5074
  if (this.cachedTokens.length === 0) {
4970
5075
  const response = await OneClickService.getTokens();
4971
- this.cachedTokens = response;
5076
+ this.cachedTokens = response.filter((t) => !_NearIntentsApi.DEPRECATED_ASSET_IDS.has(t.assetId));
4972
5077
  }
4973
5078
  return this.cachedTokens;
4974
5079
  }
@@ -5083,11 +5188,23 @@ var calculateDeadline = (seconds) => {
5083
5188
  const d = new Date(Date.now() + secs * 1e3);
5084
5189
  return d.toISOString().replace(/\.\d{3}Z$/, "Z");
5085
5190
  };
5191
+ var resolveTokenAddress = (chainId, contractAddress) => {
5192
+ const isBtcNative = chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.btc && (!contractAddress || contractAddress === "coin");
5193
+ if (isBtcNative)
5194
+ return BTC_CURRENCY_ADDRESS;
5195
+ if (contractAddress)
5196
+ return contractAddress;
5197
+ if (chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.sol)
5198
+ return SOL_NATIVE_CURRENCY_ADDRESS;
5199
+ if (isEvmChain(chainId))
5200
+ return ETH_ADDRESS2;
5201
+ return null;
5202
+ };
5086
5203
  var adaptToken = (token) => {
5087
5204
  const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
5088
5205
  if (!chainId)
5089
5206
  return null;
5090
- const tokenAddress = token.contractAddress ?? (chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.btc ? BTC_CURRENCY_ADDRESS : chainId === NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS.sol ? SOL_NATIVE_CURRENCY_ADDRESS : ETH_ADDRESS2);
5207
+ const tokenAddress = resolveTokenAddress(chainId, token.contractAddress);
5091
5208
  if (!tokenAddress)
5092
5209
  return null;
5093
5210
  return {
@@ -5109,21 +5226,10 @@ var adaptTokens = (tokens) => tokens.reduce((acc, token) => {
5109
5226
  var getTokenByAddressAndChainId = (tokens, targetTokenAddress, targetTokenChainId) => {
5110
5227
  return tokens.find((token) => {
5111
5228
  const chainId = NEAR_INTENTS_BLOCKCHAIN_CHAIN_IDS[token.blockchain];
5112
- if (!chainId)
5113
- return false;
5114
- if (chainId !== targetTokenChainId)
5229
+ if (!chainId || chainId !== targetTokenChainId)
5115
5230
  return false;
5116
- if (!isEvmChain(targetTokenChainId)) {
5117
- if (!token.contractAddress) {
5118
- return areAddressesEqual4(targetTokenAddress, BTC_CURRENCY_ADDRESS) || areAddressesEqual4(targetTokenAddress, SOL_NATIVE_CURRENCY_ADDRESS);
5119
- }
5120
- return areAddressesEqual4(token.contractAddress, targetTokenAddress);
5121
- }
5122
- if (areAddressesEqual4(targetTokenAddress, ETH_ADDRESS2)) {
5123
- return !token.contractAddress;
5124
- }
5125
- const tokenAddress = token.contractAddress || ETH_ADDRESS2;
5126
- return areAddressesEqual4(tokenAddress, targetTokenAddress);
5231
+ const tokenAddress = resolveTokenAddress(chainId, token.contractAddress);
5232
+ return tokenAddress ? areAddressesEqual4(tokenAddress, targetTokenAddress) : false;
5127
5233
  });
5128
5234
  };
5129
5235
  var hashQuote = ({
@@ -5351,8 +5457,8 @@ var NearIntentsBridgeProvider = class {
5351
5457
  fillTxHash: status.swapDetails?.destinationChainTxHashes?.[0]?.hash
5352
5458
  },
5353
5459
  params: {
5354
- inputTokenAddress: inputToken.contractAddress ?? adaptedInput.address,
5355
- outputTokenAddress: outputToken.contractAddress ?? adaptedOutput.address,
5460
+ inputTokenAddress: adaptedInput.address,
5461
+ outputTokenAddress: adaptedOutput.address,
5356
5462
  inputAmount: BigInt(quote.amountIn),
5357
5463
  outputAmount: swapDetails.amountOut ? BigInt(swapDetails.amountOut) : BigInt(quote.amountOut),
5358
5464
  owner: order.owner,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-bridging",
3
- "version": "4.1.2",
3
+ "version": "4.2.0",
4
4
  "description": "Bridging for CoW Protocol",
5
5
  "repository": {
6
6
  "type": "git",
@@ -21,19 +21,18 @@
21
21
  "dependencies": {
22
22
  "@defuse-protocol/one-click-sdk-typescript": "0.1.1-0.2",
23
23
  "json-stable-stringify": "^1.3.0",
24
- "@cowprotocol/sdk-app-data": "5.2.0",
25
- "@cowprotocol/sdk-common": "0.11.2",
26
- "@cowprotocol/sdk-config": "2.3.0",
27
- "@cowprotocol/sdk-cow-shed": "0.3.13",
28
- "@cowprotocol/sdk-order-book": "3.2.2",
29
- "@cowprotocol/sdk-contracts-ts": "3.1.2",
30
- "@cowprotocol/sdk-trading": "2.1.2",
31
- "@cowprotocol/sdk-weiroll": "0.1.35"
24
+ "@cowprotocol/sdk-common": "0.12.0",
25
+ "@cowprotocol/sdk-app-data": "5.3.0",
26
+ "@cowprotocol/sdk-config": "2.3.1",
27
+ "@cowprotocol/sdk-contracts-ts": "3.2.0",
28
+ "@cowprotocol/sdk-cow-shed": "0.4.0",
29
+ "@cowprotocol/sdk-order-book": "4.0.0",
30
+ "@cowprotocol/sdk-trading": "2.2.0",
31
+ "@cowprotocol/sdk-weiroll": "0.2.0"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/jest": "^29.4.0",
35
35
  "@types/node": "^20.17.31",
36
- "coveralls": "^3.1.1",
37
36
  "ethers": "^5.7.2",
38
37
  "ethers-v5": "npm:ethers@^5.7.2",
39
38
  "ethers-v6": "npm:ethers@^6.13.7",
@@ -43,18 +42,19 @@
43
42
  "tsup": "^7.2.0",
44
43
  "typescript": "^5.2.2",
45
44
  "viem": "^2.28.4",
46
- "@cowprotocol/sdk-ethers-v5-adapter": "0.4.9",
45
+ "@cowprotocol/sdk-ethers-v5-adapter": "0.4.10",
47
46
  "@cow-sdk/typescript-config": "0.0.0-beta.0",
48
- "@cowprotocol/sdk-ethers-v6-adapter": "0.4.9",
49
- "@cowprotocol/sdk-order-signing": "1.0.6",
50
- "@cowprotocol/sdk-viem-adapter": "0.3.23"
47
+ "@cowprotocol/sdk-ethers-v6-adapter": "0.4.10",
48
+ "@cowprotocol/sdk-viem-adapter": "0.3.24",
49
+ "@cowprotocol/sdk-order-signing": "1.1.0"
51
50
  },
52
51
  "scripts": {
53
52
  "build": "tsup src/index.ts --format esm,cjs --dts",
54
53
  "lint": "eslint src/**/*.ts",
55
54
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
56
55
  "test": "jest",
57
- "test:coverage": "jest --coverage --json --outputFile=jest.results.json && npx coveralls < ./coverage/lcov.info",
56
+ "test:coverage": "jest --coverage",
57
+ "coverage:badges": "istanbul-badges-readme --exitCode=1",
58
58
  "test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
59
59
  "test:bungeeGnosisBridge": "jest --testPathPattern=BungeeGnosisBridge",
60
60
  "test:bungeeAcrossBridge": "jest --testPathPattern=BungeeAcrossBridge",