@cowprotocol/sdk-bridging 1.4.1 → 1.6.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.
Files changed (3) hide show
  1. package/dist/index.js +29 -14
  2. package/dist/index.mjs +29 -14
  3. package/package.json +13 -13
package/dist/index.js CHANGED
@@ -383,7 +383,7 @@ function isCorrelatedToken(tokenAddress, correlatedTokens) {
383
383
  }
384
384
 
385
385
  // src/BridgingSdk/determineIntermediateToken.ts
386
- async function determineIntermediateToken(sourceChainId, sourceTokenAddress, intermediateTokens, getCorrelatedTokens) {
386
+ async function determineIntermediateToken(sourceChainId, sourceTokenAddress, intermediateTokens, getCorrelatedTokens, allowIntermediateEqSellToken) {
387
387
  const firstToken = intermediateTokens[0];
388
388
  if (intermediateTokens.length === 0 || !firstToken) {
389
389
  throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
@@ -394,7 +394,8 @@ async function determineIntermediateToken(sourceChainId, sourceTokenAddress, int
394
394
  const correlatedTokens = await resolveCorrelatedTokens(sourceChainId, getCorrelatedTokens);
395
395
  const sellTokenLike = { chainId: sourceChainId, address: sourceTokenAddress };
396
396
  const isSellNativeOrWrapped = (0, import_sdk_common3.isNativeToken)(sellTokenLike) || (0, import_sdk_common3.isWrappedNativeToken)(sellTokenLike);
397
- const tokensWithPriority = intermediateTokens.map((token) => {
397
+ const filteredTokens = allowIntermediateEqSellToken ? intermediateTokens : intermediateTokens.filter((token) => !(0, import_sdk_common3.areAddressesEqual)(token.address, sourceTokenAddress));
398
+ const tokensWithPriority = filteredTokens.map((token) => {
398
399
  const isNativeOrWrapped = (0, import_sdk_common3.isNativeToken)(token) || (0, import_sdk_common3.isWrappedNativeToken)(token);
399
400
  if ((0, import_sdk_common3.areAddressesEqual)(token.address, sourceTokenAddress)) {
400
401
  if (!(isSellNativeOrWrapped && isNativeOrWrapped)) {
@@ -416,11 +417,11 @@ async function determineIntermediateToken(sourceChainId, sourceTokenAddress, int
416
417
  if (a.priority !== b.priority) {
417
418
  return b.priority - a.priority;
418
419
  }
419
- return intermediateTokens.indexOf(a.token) - intermediateTokens.indexOf(b.token);
420
+ return filteredTokens.indexOf(a.token) - filteredTokens.indexOf(b.token);
420
421
  });
421
422
  const result = tokensWithPriority[0]?.token;
422
423
  if (!result) {
423
- throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
424
+ throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens: filteredTokens });
424
425
  }
425
426
  return result;
426
427
  }
@@ -445,7 +446,7 @@ async function getIntermediateSwapResult({
445
446
  params,
446
447
  getBridgeHook
447
448
  }) {
448
- const { swapAndBridgeRequest, advancedSettings, tradingSdk } = params;
449
+ const { swapAndBridgeRequest, advancedSettings, tradingSdk, allowIntermediateEqSellToken } = params;
449
450
  const {
450
451
  kind,
451
452
  sellTokenChainId,
@@ -469,7 +470,8 @@ async function getIntermediateSwapResult({
469
470
  sellTokenChainId,
470
471
  sellTokenAddress,
471
472
  intermediateTokens,
472
- params.advancedSettings?.getCorrelatedTokens
473
+ params.advancedSettings?.getCorrelatedTokens,
474
+ allowIntermediateEqSellToken
473
475
  );
474
476
  (0, import_sdk_common4.log)(`Using ${intermediateToken?.name ?? intermediateToken?.address} as intermediate tokens`);
475
477
  const bridgeRequestWithoutAmount = {
@@ -885,7 +887,8 @@ var SingleQuoteStrategy = class extends BaseSingleQuoteStrategy {
885
887
  swapAndBridgeRequest: quoteBridgeRequest,
886
888
  advancedSettings,
887
889
  tradingSdk,
888
- quoteSigner: advancedSettings?.quoteSigner
890
+ quoteSigner: advancedSettings?.quoteSigner,
891
+ allowIntermediateEqSellToken: advancedSettings?.allowIntermediateEqSellToken
889
892
  };
890
893
  const request2 = this.intermediateTokensCache ? {
891
894
  ...baseParams,
@@ -1021,7 +1024,8 @@ async function fetchMultiQuote(context, tradingSdk, intermediateTokensCache) {
1021
1024
  swapAndBridgeRequest: quoteBridgeRequest,
1022
1025
  advancedSettings,
1023
1026
  tradingSdk,
1024
- quoteSigner: advancedSettings?.quoteSigner
1027
+ quoteSigner: advancedSettings?.quoteSigner,
1028
+ allowIntermediateEqSellToken: advancedSettings?.allowIntermediateEqSellToken
1025
1029
  };
1026
1030
  const request = intermediateTokensCache ? {
1027
1031
  ...baseParams,
@@ -1558,19 +1562,22 @@ var ACROSS_SPOOK_CONTRACT_ADDRESSES = {
1558
1562
  [import_sdk_config4.SupportedChainId.SEPOLIA]: "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
1559
1563
  // https://docs.across.to/reference/contract-addresses/polygon-chain-id-137
1560
1564
  [import_sdk_config4.SupportedChainId.POLYGON]: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096",
1561
- // https://docs.across.to/reference/contract-addresses/lens-chain-id-232
1562
- [import_sdk_config4.SupportedChainId.LENS]: "0xe7cb3e167e7475dE1331Cf6E0CEb187654619E12",
1565
+ // https://docs.across.to/reference/contract-addresses/lens-chain
1566
+ [import_sdk_config4.SupportedChainId.LENS]: "0xb234cA484866c811d0e6D3318866F583781ED045",
1563
1567
  // https://docs.across.to/reference/contract-addresses/bnb-smart-chain
1564
1568
  [import_sdk_config4.SupportedChainId.BNB]: "0x4e8E101924eDE233C13e2D8622DC8aED2872d505",
1565
1569
  // https://docs.across.to/reference/contract-addresses/linea-chain-id-59144
1566
- [import_sdk_config4.SupportedChainId.LINEA]: "0xE0BCff426509723B18D6b2f0D8F4602d143bE3e0",
1570
+ [import_sdk_config4.SupportedChainId.LINEA]: "0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75",
1567
1571
  // https://docs.across.to/reference/contract-addresses/plasma
1568
1572
  [import_sdk_config4.SupportedChainId.PLASMA]: "0x50039fAEfebef707cFD94D6d462fE6D10B39207a",
1573
+ // https://docs.across.to/reference/contract-addresses/ink-chain-id-57073
1574
+ [import_sdk_config4.SupportedChainId.INK]: "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4",
1575
+ // https://docs.across.to/reference/contract-addresses/optimism-chain-id-10
1576
+ [import_sdk_config4.AdditionalTargetChainId.OPTIMISM]: "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
1569
1577
  // Not supported chains
1570
1578
  // 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
1571
1579
  [import_sdk_config4.SupportedChainId.GNOSIS_CHAIN]: void 0,
1572
- [import_sdk_config4.SupportedChainId.AVALANCHE]: void 0,
1573
- [import_sdk_config4.AdditionalTargetChainId.OPTIMISM]: void 0
1580
+ [import_sdk_config4.SupportedChainId.AVALANCHE]: void 0
1574
1581
  };
1575
1582
  var ACROSS_MATH_CONTRACT_ADDRESSES = {
1576
1583
  [import_sdk_config4.SupportedChainId.MAINNET]: "0xf2ae6728b6f146556977Af0A68bFbf5bADA22863",
@@ -1589,7 +1596,9 @@ var ACROSS_MATH_CONTRACT_ADDRESSES = {
1589
1596
  // TODO: confirm
1590
1597
  [import_sdk_config4.SupportedChainId.LINEA]: void 0,
1591
1598
  // TODO: confirm
1592
- [import_sdk_config4.SupportedChainId.PLASMA]: void 0
1599
+ [import_sdk_config4.SupportedChainId.PLASMA]: void 0,
1600
+ // TODO: confirm
1601
+ [import_sdk_config4.SupportedChainId.INK]: void 0
1593
1602
  // TODO: confirm
1594
1603
  };
1595
1604
 
@@ -4033,6 +4042,8 @@ var BungeeCowswapLibAddresses = {
4033
4042
  // TODO: confirm
4034
4043
  [import_sdk_config7.SupportedChainId.PLASMA]: void 0,
4035
4044
  // TODO: confirm
4045
+ [import_sdk_config7.SupportedChainId.INK]: void 0,
4046
+ // TODO: confirm
4036
4047
  [import_sdk_config7.SupportedChainId.SEPOLIA]: void 0,
4037
4048
  [import_sdk_config7.AdditionalTargetChainId.OPTIMISM]: BUNGEE_COWSWAP_LIB_ADDRESS
4038
4049
  };
@@ -4052,6 +4063,8 @@ var SocketVerifierAddresses = {
4052
4063
  // TODO: confirm
4053
4064
  [import_sdk_config7.SupportedChainId.PLASMA]: void 0,
4054
4065
  // TODO: confirm
4066
+ [import_sdk_config7.SupportedChainId.INK]: void 0,
4067
+ // TODO: confirm
4055
4068
  [import_sdk_config7.SupportedChainId.SEPOLIA]: void 0,
4056
4069
  [import_sdk_config7.AdditionalTargetChainId.OPTIMISM]: SOCKET_VERIFIER_ADDRESS
4057
4070
  };
@@ -4071,6 +4084,8 @@ var BungeeApproveAndBridgeV1Addresses = {
4071
4084
  // TODO: confirm
4072
4085
  [import_sdk_config7.SupportedChainId.PLASMA]: void 0,
4073
4086
  // TODO: confirm
4087
+ [import_sdk_config7.SupportedChainId.INK]: void 0,
4088
+ // TODO: confirm
4074
4089
  [import_sdk_config7.SupportedChainId.SEPOLIA]: void 0,
4075
4090
  [import_sdk_config7.AdditionalTargetChainId.OPTIMISM]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS
4076
4091
  };
package/dist/index.mjs CHANGED
@@ -326,7 +326,7 @@ function isCorrelatedToken(tokenAddress, correlatedTokens) {
326
326
  }
327
327
 
328
328
  // src/BridgingSdk/determineIntermediateToken.ts
329
- async function determineIntermediateToken(sourceChainId, sourceTokenAddress, intermediateTokens, getCorrelatedTokens) {
329
+ async function determineIntermediateToken(sourceChainId, sourceTokenAddress, intermediateTokens, getCorrelatedTokens, allowIntermediateEqSellToken) {
330
330
  const firstToken = intermediateTokens[0];
331
331
  if (intermediateTokens.length === 0 || !firstToken) {
332
332
  throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
@@ -337,7 +337,8 @@ async function determineIntermediateToken(sourceChainId, sourceTokenAddress, int
337
337
  const correlatedTokens = await resolveCorrelatedTokens(sourceChainId, getCorrelatedTokens);
338
338
  const sellTokenLike = { chainId: sourceChainId, address: sourceTokenAddress };
339
339
  const isSellNativeOrWrapped = isNativeToken(sellTokenLike) || isWrappedNativeToken(sellTokenLike);
340
- const tokensWithPriority = intermediateTokens.map((token) => {
340
+ const filteredTokens = allowIntermediateEqSellToken ? intermediateTokens : intermediateTokens.filter((token) => !areAddressesEqual(token.address, sourceTokenAddress));
341
+ const tokensWithPriority = filteredTokens.map((token) => {
341
342
  const isNativeOrWrapped = isNativeToken(token) || isWrappedNativeToken(token);
342
343
  if (areAddressesEqual(token.address, sourceTokenAddress)) {
343
344
  if (!(isSellNativeOrWrapped && isNativeOrWrapped)) {
@@ -359,11 +360,11 @@ async function determineIntermediateToken(sourceChainId, sourceTokenAddress, int
359
360
  if (a.priority !== b.priority) {
360
361
  return b.priority - a.priority;
361
362
  }
362
- return intermediateTokens.indexOf(a.token) - intermediateTokens.indexOf(b.token);
363
+ return filteredTokens.indexOf(a.token) - filteredTokens.indexOf(b.token);
363
364
  });
364
365
  const result = tokensWithPriority[0]?.token;
365
366
  if (!result) {
366
- throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens });
367
+ throw new BridgeProviderQuoteError("NO_INTERMEDIATE_TOKENS" /* NO_INTERMEDIATE_TOKENS */, { intermediateTokens: filteredTokens });
367
368
  }
368
369
  return result;
369
370
  }
@@ -388,7 +389,7 @@ async function getIntermediateSwapResult({
388
389
  params,
389
390
  getBridgeHook
390
391
  }) {
391
- const { swapAndBridgeRequest, advancedSettings, tradingSdk } = params;
392
+ const { swapAndBridgeRequest, advancedSettings, tradingSdk, allowIntermediateEqSellToken } = params;
392
393
  const {
393
394
  kind,
394
395
  sellTokenChainId,
@@ -412,7 +413,8 @@ async function getIntermediateSwapResult({
412
413
  sellTokenChainId,
413
414
  sellTokenAddress,
414
415
  intermediateTokens,
415
- params.advancedSettings?.getCorrelatedTokens
416
+ params.advancedSettings?.getCorrelatedTokens,
417
+ allowIntermediateEqSellToken
416
418
  );
417
419
  log2(`Using ${intermediateToken?.name ?? intermediateToken?.address} as intermediate tokens`);
418
420
  const bridgeRequestWithoutAmount = {
@@ -828,7 +830,8 @@ var SingleQuoteStrategy = class extends BaseSingleQuoteStrategy {
828
830
  swapAndBridgeRequest: quoteBridgeRequest,
829
831
  advancedSettings,
830
832
  tradingSdk,
831
- quoteSigner: advancedSettings?.quoteSigner
833
+ quoteSigner: advancedSettings?.quoteSigner,
834
+ allowIntermediateEqSellToken: advancedSettings?.allowIntermediateEqSellToken
832
835
  };
833
836
  const request2 = this.intermediateTokensCache ? {
834
837
  ...baseParams,
@@ -964,7 +967,8 @@ async function fetchMultiQuote(context, tradingSdk, intermediateTokensCache) {
964
967
  swapAndBridgeRequest: quoteBridgeRequest,
965
968
  advancedSettings,
966
969
  tradingSdk,
967
- quoteSigner: advancedSettings?.quoteSigner
970
+ quoteSigner: advancedSettings?.quoteSigner,
971
+ allowIntermediateEqSellToken: advancedSettings?.allowIntermediateEqSellToken
968
972
  };
969
973
  const request = intermediateTokensCache ? {
970
974
  ...baseParams,
@@ -1501,19 +1505,22 @@ var ACROSS_SPOOK_CONTRACT_ADDRESSES = {
1501
1505
  [SupportedChainId2.SEPOLIA]: "0x5ef6C01E11889d86803e0B23e3cB3F9E9d97B662",
1502
1506
  // https://docs.across.to/reference/contract-addresses/polygon-chain-id-137
1503
1507
  [SupportedChainId2.POLYGON]: "0x9295ee1d8C5b022Be115A2AD3c30C72E34e7F096",
1504
- // https://docs.across.to/reference/contract-addresses/lens-chain-id-232
1505
- [SupportedChainId2.LENS]: "0xe7cb3e167e7475dE1331Cf6E0CEb187654619E12",
1508
+ // https://docs.across.to/reference/contract-addresses/lens-chain
1509
+ [SupportedChainId2.LENS]: "0xb234cA484866c811d0e6D3318866F583781ED045",
1506
1510
  // https://docs.across.to/reference/contract-addresses/bnb-smart-chain
1507
1511
  [SupportedChainId2.BNB]: "0x4e8E101924eDE233C13e2D8622DC8aED2872d505",
1508
1512
  // https://docs.across.to/reference/contract-addresses/linea-chain-id-59144
1509
- [SupportedChainId2.LINEA]: "0xE0BCff426509723B18D6b2f0D8F4602d143bE3e0",
1513
+ [SupportedChainId2.LINEA]: "0x7E63A5f1a8F0B4d0934B2f2327DAED3F6bb2ee75",
1510
1514
  // https://docs.across.to/reference/contract-addresses/plasma
1511
1515
  [SupportedChainId2.PLASMA]: "0x50039fAEfebef707cFD94D6d462fE6D10B39207a",
1516
+ // https://docs.across.to/reference/contract-addresses/ink-chain-id-57073
1517
+ [SupportedChainId2.INK]: "0xeF684C38F94F48775959ECf2012D7E864ffb9dd4",
1518
+ // https://docs.across.to/reference/contract-addresses/optimism-chain-id-10
1519
+ [AdditionalTargetChainId.OPTIMISM]: "0x6f26Bf09B1C792e3228e5467807a900A503c0281",
1512
1520
  // Not supported chains
1513
1521
  // 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
1514
1522
  [SupportedChainId2.GNOSIS_CHAIN]: void 0,
1515
- [SupportedChainId2.AVALANCHE]: void 0,
1516
- [AdditionalTargetChainId.OPTIMISM]: void 0
1523
+ [SupportedChainId2.AVALANCHE]: void 0
1517
1524
  };
1518
1525
  var ACROSS_MATH_CONTRACT_ADDRESSES = {
1519
1526
  [SupportedChainId2.MAINNET]: "0xf2ae6728b6f146556977Af0A68bFbf5bADA22863",
@@ -1532,7 +1539,9 @@ var ACROSS_MATH_CONTRACT_ADDRESSES = {
1532
1539
  // TODO: confirm
1533
1540
  [SupportedChainId2.LINEA]: void 0,
1534
1541
  // TODO: confirm
1535
- [SupportedChainId2.PLASMA]: void 0
1542
+ [SupportedChainId2.PLASMA]: void 0,
1543
+ // TODO: confirm
1544
+ [SupportedChainId2.INK]: void 0
1536
1545
  // TODO: confirm
1537
1546
  };
1538
1547
 
@@ -3982,6 +3991,8 @@ var BungeeCowswapLibAddresses = {
3982
3991
  // TODO: confirm
3983
3992
  [SupportedChainId5.PLASMA]: void 0,
3984
3993
  // TODO: confirm
3994
+ [SupportedChainId5.INK]: void 0,
3995
+ // TODO: confirm
3985
3996
  [SupportedChainId5.SEPOLIA]: void 0,
3986
3997
  [AdditionalTargetChainId2.OPTIMISM]: BUNGEE_COWSWAP_LIB_ADDRESS
3987
3998
  };
@@ -4001,6 +4012,8 @@ var SocketVerifierAddresses = {
4001
4012
  // TODO: confirm
4002
4013
  [SupportedChainId5.PLASMA]: void 0,
4003
4014
  // TODO: confirm
4015
+ [SupportedChainId5.INK]: void 0,
4016
+ // TODO: confirm
4004
4017
  [SupportedChainId5.SEPOLIA]: void 0,
4005
4018
  [AdditionalTargetChainId2.OPTIMISM]: SOCKET_VERIFIER_ADDRESS
4006
4019
  };
@@ -4020,6 +4033,8 @@ var BungeeApproveAndBridgeV1Addresses = {
4020
4033
  // TODO: confirm
4021
4034
  [SupportedChainId5.PLASMA]: void 0,
4022
4035
  // TODO: confirm
4036
+ [SupportedChainId5.INK]: void 0,
4037
+ // TODO: confirm
4023
4038
  [SupportedChainId5.SEPOLIA]: void 0,
4024
4039
  [AdditionalTargetChainId2.OPTIMISM]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS
4025
4040
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-bridging",
3
- "version": "1.4.1",
3
+ "version": "1.6.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-app-data": "4.5.1",
20
- "@cowprotocol/sdk-common": "0.5.0",
21
- "@cowprotocol/sdk-config": "0.6.3",
22
- "@cowprotocol/sdk-contracts-ts": "1.1.1",
23
- "@cowprotocol/sdk-order-book": "0.5.1",
24
- "@cowprotocol/sdk-trading": "0.8.2",
25
- "@cowprotocol/sdk-weiroll": "0.1.12",
26
- "@cowprotocol/sdk-cow-shed": "0.2.11"
19
+ "@cowprotocol/sdk-app-data": "4.5.2",
20
+ "@cowprotocol/sdk-common": "0.5.1",
21
+ "@cowprotocol/sdk-config": "0.7.0",
22
+ "@cowprotocol/sdk-contracts-ts": "1.3.0",
23
+ "@cowprotocol/sdk-cow-shed": "0.2.13",
24
+ "@cowprotocol/sdk-trading": "0.9.1",
25
+ "@cowprotocol/sdk-weiroll": "0.1.13",
26
+ "@cowprotocol/sdk-order-book": "0.6.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/jest": "^29.4.0",
@@ -39,10 +39,10 @@
39
39
  "typescript": "^5.2.2",
40
40
  "viem": "^2.28.4",
41
41
  "@cow-sdk/typescript-config": "0.0.0-beta.0",
42
- "@cowprotocol/sdk-ethers-v5-adapter": "0.3.1",
43
- "@cowprotocol/sdk-ethers-v6-adapter": "0.3.1",
44
- "@cowprotocol/sdk-order-signing": "0.1.25",
45
- "@cowprotocol/sdk-viem-adapter": "0.3.1"
42
+ "@cowprotocol/sdk-ethers-v6-adapter": "0.3.2",
43
+ "@cowprotocol/sdk-order-signing": "0.1.27",
44
+ "@cowprotocol/sdk-ethers-v5-adapter": "0.3.2",
45
+ "@cowprotocol/sdk-viem-adapter": "0.3.2"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "tsup src/index.ts --format esm,cjs --dts",