@cowprotocol/sdk-bridging 0.1.0-monorepo.4 → 0.1.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/README.md CHANGED
@@ -85,7 +85,7 @@ if (confirm(`You will get at least: ${buyAmount}, ok?`)) {
85
85
  }
86
86
  ```
87
87
 
88
- ### Usage with Umbrella SDK
88
+ ### Usage with CoW SDK
89
89
 
90
90
  ```typescript
91
91
  import {
@@ -132,7 +132,6 @@ const parameters: QuoteBridgeRequest = {
132
132
  appCode: 'YOUR_APP_CODE',
133
133
  }
134
134
 
135
- // Access bridging through the umbrella SDK
136
135
  const quoteResult = await sdk.bridging.getQuote(parameters)
137
136
  assertIsBridgeQuoteAndPost(quoteResult)
138
137
  const { swap, bridge, postSwapOrderFromQuote } = quoteResult
package/dist/index.d.mts CHANGED
@@ -107,6 +107,10 @@ interface BuyTokensParams {
107
107
  sellChainId?: SupportedChainId;
108
108
  sellTokenAddress?: string;
109
109
  }
110
+ interface GetProviderBuyTokens {
111
+ tokens: TokenInfo[];
112
+ isRouteAvailable: boolean;
113
+ }
110
114
  /**
111
115
  * A bridge deposit. It includes the provideer information, sell amount and the minimum buy amount.
112
116
  *
@@ -127,7 +131,7 @@ interface BridgeProvider<Q extends BridgeQuoteResult> {
127
131
  /**
128
132
  * Get supported tokens for a chain
129
133
  */
130
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
134
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
131
135
  /**
132
136
  * Get intermediate tokens given a quote request.
133
137
  *
@@ -162,8 +166,14 @@ interface BridgeProvider<Q extends BridgeQuoteResult> {
162
166
  * 2. The final amount could affect hook gas costs
163
167
  *
164
168
  * By estimating gas costs independently, we can resolve this dependency cycle.
169
+ * For some providers, the `extraGas` parameter adds additional gas‐unit buffer to the hook
170
+ * and `extraGasProxyCreation` parameter adds additional gas‐unit buffer for the proxy creation
171
+ * (see DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION and DEFAULT_EXTRA_GAS_PROXY_CREATION).
165
172
  */
166
- getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'>): Promise<number>;
173
+ getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'> & {
174
+ extraGas?: number;
175
+ extraGasProxyCreation?: number;
176
+ }): Promise<number>;
167
177
  /**
168
178
  * Get a pre-authorized hook for initiating a bridge.
169
179
  *
@@ -390,7 +400,7 @@ type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging'>>;
390
400
  declare class BridgingSdk {
391
401
  readonly options: BridgingSdkOptions;
392
402
  protected config: BridgingSdkConfig;
393
- constructor(options: BridgingSdkOptions);
403
+ constructor(options: BridgingSdkOptions, adapter?: AbstractProviderAdapter);
394
404
  private get provider();
395
405
  /**
396
406
  * Get the providers for the bridging.
@@ -409,7 +419,7 @@ declare class BridgingSdk {
409
419
 
410
420
  * @param params
411
421
  */
412
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
422
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
413
423
  /**
414
424
  * Get quote details, including a callback function to post the order on-chain.
415
425
  *
@@ -433,7 +443,9 @@ declare class BridgingSdk {
433
443
 
434
444
  declare const RAW_PROVIDERS_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main/src/bridging/providers";
435
445
  declare const DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 240000;
446
+ declare const DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION = 200000;
436
447
  declare const COW_SHED_PROXY_CREATION_GAS = 360000;
448
+ declare const DEFAULT_EXTRA_GAS_PROXY_CREATION = 400000;
437
449
  declare const HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
438
450
 
439
451
  interface GetCrossChainOrderParams {
@@ -709,7 +721,7 @@ declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteResult>
709
721
  constructor(options?: AcrossBridgeProviderOptions, _adapter?: AbstractProviderAdapter);
710
722
  info: BridgeProviderInfo;
711
723
  getNetworks(): Promise<ChainInfo[]>;
712
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
724
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
713
725
  getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
714
726
  getQuote(request: QuoteBridgeRequest): Promise<AcrossQuoteResult>;
715
727
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: AcrossQuoteResult): Promise<EvmCall>;
@@ -727,7 +739,7 @@ declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteResult>
727
739
  private getSupportedTokensState;
728
740
  }
729
741
 
730
- type SupportedBridge = 'across' | 'cctp';
742
+ type SupportedBridge = 'across' | 'cctp' | 'gnosis-native-bridge';
731
743
  interface BungeeQuoteAPIRequest {
732
744
  userAddress: string;
733
745
  originChainId: string;
@@ -834,7 +846,8 @@ interface BungeeQuoteAPIResponse {
834
846
  }
835
847
  declare enum BungeeBridge {
836
848
  'Across' = "across",
837
- 'CircleCCTP' = "cctp"
849
+ 'CircleCCTP' = "cctp",
850
+ 'GnosisNative' = "gnosis-native-bridge"
838
851
  }
839
852
  interface BungeeQuote {
840
853
  originChainId: number;
@@ -943,6 +956,7 @@ interface BungeeApiOptions {
943
956
  eventsApiBaseUrl?: string;
944
957
  acrossApiBaseUrl?: string;
945
958
  includeBridges?: SupportedBridge[];
959
+ affiliate?: string;
946
960
  }
947
961
  interface IntermediateTokensParams {
948
962
  fromChainId: SupportedChainId;
@@ -997,6 +1011,7 @@ declare class BungeeApi {
997
1011
  }): Promise<BungeeEvent[]>;
998
1012
  getAcrossStatus(depositTxHash: string): Promise<AcrossStatus>;
999
1013
  private getSupportedBridges;
1014
+ private shouldAddAffiliate;
1000
1015
  private makeApiCall;
1001
1016
  }
1002
1017
 
@@ -1015,7 +1030,7 @@ declare class BungeeBridgeProvider implements BridgeProvider<BungeeQuoteResult>
1015
1030
  constructor(options: BungeeBridgeProviderOptions, _adapter?: AbstractProviderAdapter);
1016
1031
  info: BridgeProviderInfo;
1017
1032
  getNetworks(): Promise<ChainInfo[]>;
1018
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
1033
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
1019
1034
  getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
1020
1035
  getQuote(request: QuoteBridgeRequest): Promise<BungeeQuoteResult>;
1021
1036
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: BungeeQuoteResult): Promise<EvmCall>;
@@ -1030,6 +1045,7 @@ declare class BungeeBridgeProvider implements BridgeProvider<BungeeQuoteResult>
1030
1045
  getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
1031
1046
  getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
1032
1047
  getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
1048
+ private isExtraGasRequired;
1033
1049
  }
1034
1050
 
1035
- export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, type BridgingSdkConfig, type BridgingSdkOptions, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type GetOrderParams, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isQuoteAndPost };
1051
+ export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, type BridgingSdkConfig, type BridgingSdkOptions, 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 GetOrderParams, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isQuoteAndPost };
package/dist/index.d.ts CHANGED
@@ -107,6 +107,10 @@ interface BuyTokensParams {
107
107
  sellChainId?: SupportedChainId;
108
108
  sellTokenAddress?: string;
109
109
  }
110
+ interface GetProviderBuyTokens {
111
+ tokens: TokenInfo[];
112
+ isRouteAvailable: boolean;
113
+ }
110
114
  /**
111
115
  * A bridge deposit. It includes the provideer information, sell amount and the minimum buy amount.
112
116
  *
@@ -127,7 +131,7 @@ interface BridgeProvider<Q extends BridgeQuoteResult> {
127
131
  /**
128
132
  * Get supported tokens for a chain
129
133
  */
130
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
134
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
131
135
  /**
132
136
  * Get intermediate tokens given a quote request.
133
137
  *
@@ -162,8 +166,14 @@ interface BridgeProvider<Q extends BridgeQuoteResult> {
162
166
  * 2. The final amount could affect hook gas costs
163
167
  *
164
168
  * By estimating gas costs independently, we can resolve this dependency cycle.
169
+ * For some providers, the `extraGas` parameter adds additional gas‐unit buffer to the hook
170
+ * and `extraGasProxyCreation` parameter adds additional gas‐unit buffer for the proxy creation
171
+ * (see DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION and DEFAULT_EXTRA_GAS_PROXY_CREATION).
165
172
  */
166
- getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'>): Promise<number>;
173
+ getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'> & {
174
+ extraGas?: number;
175
+ extraGasProxyCreation?: number;
176
+ }): Promise<number>;
167
177
  /**
168
178
  * Get a pre-authorized hook for initiating a bridge.
169
179
  *
@@ -390,7 +400,7 @@ type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging'>>;
390
400
  declare class BridgingSdk {
391
401
  readonly options: BridgingSdkOptions;
392
402
  protected config: BridgingSdkConfig;
393
- constructor(options: BridgingSdkOptions);
403
+ constructor(options: BridgingSdkOptions, adapter?: AbstractProviderAdapter);
394
404
  private get provider();
395
405
  /**
396
406
  * Get the providers for the bridging.
@@ -409,7 +419,7 @@ declare class BridgingSdk {
409
419
 
410
420
  * @param params
411
421
  */
412
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
422
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
413
423
  /**
414
424
  * Get quote details, including a callback function to post the order on-chain.
415
425
  *
@@ -433,7 +443,9 @@ declare class BridgingSdk {
433
443
 
434
444
  declare const RAW_PROVIDERS_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main/src/bridging/providers";
435
445
  declare const DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 240000;
446
+ declare const DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION = 200000;
436
447
  declare const COW_SHED_PROXY_CREATION_GAS = 360000;
448
+ declare const DEFAULT_EXTRA_GAS_PROXY_CREATION = 400000;
437
449
  declare const HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
438
450
 
439
451
  interface GetCrossChainOrderParams {
@@ -709,7 +721,7 @@ declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteResult>
709
721
  constructor(options?: AcrossBridgeProviderOptions, _adapter?: AbstractProviderAdapter);
710
722
  info: BridgeProviderInfo;
711
723
  getNetworks(): Promise<ChainInfo[]>;
712
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
724
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
713
725
  getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
714
726
  getQuote(request: QuoteBridgeRequest): Promise<AcrossQuoteResult>;
715
727
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: AcrossQuoteResult): Promise<EvmCall>;
@@ -727,7 +739,7 @@ declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteResult>
727
739
  private getSupportedTokensState;
728
740
  }
729
741
 
730
- type SupportedBridge = 'across' | 'cctp';
742
+ type SupportedBridge = 'across' | 'cctp' | 'gnosis-native-bridge';
731
743
  interface BungeeQuoteAPIRequest {
732
744
  userAddress: string;
733
745
  originChainId: string;
@@ -834,7 +846,8 @@ interface BungeeQuoteAPIResponse {
834
846
  }
835
847
  declare enum BungeeBridge {
836
848
  'Across' = "across",
837
- 'CircleCCTP' = "cctp"
849
+ 'CircleCCTP' = "cctp",
850
+ 'GnosisNative' = "gnosis-native-bridge"
838
851
  }
839
852
  interface BungeeQuote {
840
853
  originChainId: number;
@@ -943,6 +956,7 @@ interface BungeeApiOptions {
943
956
  eventsApiBaseUrl?: string;
944
957
  acrossApiBaseUrl?: string;
945
958
  includeBridges?: SupportedBridge[];
959
+ affiliate?: string;
946
960
  }
947
961
  interface IntermediateTokensParams {
948
962
  fromChainId: SupportedChainId;
@@ -997,6 +1011,7 @@ declare class BungeeApi {
997
1011
  }): Promise<BungeeEvent[]>;
998
1012
  getAcrossStatus(depositTxHash: string): Promise<AcrossStatus>;
999
1013
  private getSupportedBridges;
1014
+ private shouldAddAffiliate;
1000
1015
  private makeApiCall;
1001
1016
  }
1002
1017
 
@@ -1015,7 +1030,7 @@ declare class BungeeBridgeProvider implements BridgeProvider<BungeeQuoteResult>
1015
1030
  constructor(options: BungeeBridgeProviderOptions, _adapter?: AbstractProviderAdapter);
1016
1031
  info: BridgeProviderInfo;
1017
1032
  getNetworks(): Promise<ChainInfo[]>;
1018
- getBuyTokens(params: BuyTokensParams): Promise<TokenInfo[]>;
1033
+ getBuyTokens(params: BuyTokensParams): Promise<GetProviderBuyTokens>;
1019
1034
  getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
1020
1035
  getQuote(request: QuoteBridgeRequest): Promise<BungeeQuoteResult>;
1021
1036
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: BungeeQuoteResult): Promise<EvmCall>;
@@ -1030,6 +1045,7 @@ declare class BungeeBridgeProvider implements BridgeProvider<BungeeQuoteResult>
1030
1045
  getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
1031
1046
  getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
1032
1047
  getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
1048
+ private isExtraGasRequired;
1033
1049
  }
1034
1050
 
1035
- export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, type BridgingSdkConfig, type BridgingSdkOptions, BungeeBridgeProvider, type BungeeBridgeProviderOptions, type BungeeQuoteResult, type BuyTokensParams, COW_SHED_PROXY_CREATION_GAS, type CrossChainOrder, type CrossChainQuoteAndPost, DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION, type GetOrderParams, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isQuoteAndPost };
1051
+ export { AcrossBridgeProvider, type AcrossBridgeProviderOptions, type AcrossQuoteResult, type BridgeCallDetails, type BridgeCosts, type BridgeDeposit, type BridgeHook, BridgeOrderParsingError, type BridgeProvider, BridgeProviderError, type BridgeProviderInfo, BridgeProviderQuoteError, type BridgeQuoteAmountsAndCosts, type BridgeQuoteAndPost, BridgeQuoteErrors, type BridgeQuoteResult, type BridgeQuoteResults, BridgeStatus, type BridgeStatusResult, type BridgingDepositParams, BridgingSdk, type BridgingSdkConfig, type BridgingSdkOptions, 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 GetOrderParams, type GetProviderBuyTokens, HOOK_DAPP_BRIDGE_PROVIDER_PREFIX, type QuoteBridgeRequest, type QuoteBridgeRequestWithoutAmount, RAW_PROVIDERS_FILES_PATH, assertIsBridgeQuoteAndPost, assertIsQuoteAndPost, getCrossChainOrder, getPostHooks, isAppDoc, isBridgeQuoteAndPost, isQuoteAndPost };
package/dist/index.js CHANGED
@@ -29,6 +29,8 @@ __export(src_exports, {
29
29
  BridgingSdk: () => BridgingSdk,
30
30
  BungeeBridgeProvider: () => BungeeBridgeProvider,
31
31
  COW_SHED_PROXY_CREATION_GAS: () => COW_SHED_PROXY_CREATION_GAS,
32
+ DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION: () => DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION,
33
+ DEFAULT_EXTRA_GAS_PROXY_CREATION: () => DEFAULT_EXTRA_GAS_PROXY_CREATION,
32
34
  DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION: () => DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION,
33
35
  HOOK_DAPP_BRIDGE_PROVIDER_PREFIX: () => HOOK_DAPP_BRIDGE_PROVIDER_PREFIX,
34
36
  RAW_PROVIDERS_FILES_PATH: () => RAW_PROVIDERS_FILES_PATH,
@@ -146,7 +148,7 @@ async function getBridgeSignedHook(bridgeRequest, { provider, signer, hookGasLim
146
148
  const adapter = (0, import_sdk_common2.getGlobalAdapter)();
147
149
  const bridgingQuote = await provider.getQuote(bridgeRequest);
148
150
  const unsignedBridgeCall = await provider.getUnsignedBridgeCall(bridgeRequest, bridgingQuote);
149
- const deadline = BigInt(validToOverride || swapResult.orderToSign.validTo);
151
+ const deadline = BigInt(validToOverride ?? swapResult.orderToSign.validTo);
150
152
  const bridgeHookNonce = adapter.utils.solidityKeccak256(
151
153
  ["bytes", "uint256"],
152
154
  [unsignedBridgeCall.data, deadline]
@@ -170,7 +172,9 @@ async function getBridgeSignedHook(bridgeRequest, { provider, signer, hookGasLim
170
172
  var import_sdk_config = require("@cowprotocol/sdk-config");
171
173
  var RAW_PROVIDERS_FILES_PATH = `${import_sdk_config.RAW_FILES_PATH}/src/bridging/providers`;
172
174
  var DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 24e4;
175
+ var DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION = 2e5;
173
176
  var COW_SHED_PROXY_CREATION_GAS = 36e4;
177
+ var DEFAULT_EXTRA_GAS_PROXY_CREATION = 4e5;
174
178
  var HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
175
179
 
176
180
  // src/BridgingSdk/getQuoteWithBridge.ts
@@ -468,8 +472,11 @@ var import_sdk_order_book2 = require("@cowprotocol/sdk-order-book");
468
472
  var import_sdk_config2 = require("@cowprotocol/sdk-config");
469
473
  var import_sdk_common4 = require("@cowprotocol/sdk-common");
470
474
  var BridgingSdk = class {
471
- constructor(options) {
475
+ constructor(options, adapter) {
472
476
  this.options = options;
477
+ if (adapter) {
478
+ (0, import_sdk_common4.setGlobalAdapter)(adapter);
479
+ }
473
480
  const { providers, ...restOptions } = options;
474
481
  if (!providers || providers.length !== 1) {
475
482
  throw new Error("Current implementation only supports a single bridge provider");
@@ -2779,14 +2786,20 @@ async function getDepositParams(chainId, orderId, txReceipt) {
2779
2786
 
2780
2787
  // src/providers/utils/getGasLimitEstimationForHook.ts
2781
2788
  var import_sdk_common10 = require("@cowprotocol/sdk-common");
2782
- async function getGasLimitEstimationForHook(cowShedSdk, request) {
2789
+ async function getGasLimitEstimationForHook({
2790
+ cowShedSdk,
2791
+ request,
2792
+ extraGas,
2793
+ extraGasProxyCreation
2794
+ }) {
2783
2795
  const adapter = (0, import_sdk_common10.getGlobalAdapter)();
2784
2796
  const proxyAddress = cowShedSdk.getCowShedAccount(request.sellTokenChainId, request.owner || request.account);
2785
2797
  const proxyCode = await adapter.getCode(proxyAddress);
2786
2798
  if (!proxyCode || proxyCode === "0x") {
2787
- return DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION + COW_SHED_PROXY_CREATION_GAS;
2799
+ const baseGas = DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION + COW_SHED_PROXY_CREATION_GAS;
2800
+ return baseGas + (extraGasProxyCreation && extraGasProxyCreation > 0 ? extraGasProxyCreation : 0);
2788
2801
  }
2789
- return DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION;
2802
+ return DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION + (extraGas && extraGas > 0 ? extraGas : 0);
2790
2803
  }
2791
2804
 
2792
2805
  // src/providers/across/AcrossBridgeProvider.ts
@@ -2819,7 +2832,12 @@ var AcrossBridgeProvider = class {
2819
2832
  return ACROSS_SUPPORTED_NETWORKS;
2820
2833
  }
2821
2834
  async getBuyTokens(params) {
2822
- return Object.values((await this.getSupportedTokensState())[params.buyChainId] || {});
2835
+ const tokens = Object.values((await this.getSupportedTokensState())[params.buyChainId] || {});
2836
+ const isRouteAvailable = tokens.length > 0;
2837
+ return {
2838
+ tokens,
2839
+ isRouteAvailable
2840
+ };
2823
2841
  }
2824
2842
  async getIntermediateTokens(request) {
2825
2843
  if (request.kind !== import_sdk_order_book4.OrderKind.SELL) {
@@ -2856,7 +2874,10 @@ var AcrossBridgeProvider = class {
2856
2874
  });
2857
2875
  }
2858
2876
  async getGasLimitEstimationForHook(request) {
2859
- return getGasLimitEstimationForHook(this.cowShedSdk, request);
2877
+ return getGasLimitEstimationForHook({
2878
+ cowShedSdk: this.cowShedSdk,
2879
+ request
2880
+ });
2860
2881
  }
2861
2882
  async getSignedHook(chainId, unsignedCall, bridgeHookNonce, deadline, hookGasLimit, signer) {
2862
2883
  const { signedMulticall, cowShedAccount, gasLimit } = await this.cowShedSdk.signCalls({
@@ -3006,13 +3027,42 @@ var BungeeTxDataBytesIndices = {
3006
3027
  // 32 bytes = 64 chars for the amount
3007
3028
  }
3008
3029
  }
3030
+ },
3031
+ "gnosis-native-bridge": {
3032
+ // bridgeERC20To (amount is 5th param -> 8 + 4*32 = 136)
3033
+ ["0x3bf5c228".toLowerCase()]: {
3034
+ inputAmount: {
3035
+ bytes_startIndex: 136,
3036
+ // first 136 bytes are the routeId, followed by the function selector
3037
+ bytes_length: 32,
3038
+ // first 32 bytes of the params are the amount
3039
+ bytesString_startIndex: 2 + 8 * 2,
3040
+ // first two characters are 0x and 8 bytes = 16 chars for the amount
3041
+ bytesString_length: 32 * 2
3042
+ // 32 bytes = 64 chars for the amount
3043
+ }
3044
+ },
3045
+ // bridgeNativeTo (amount is 4th param -> 8 + 3*32 = 104)
3046
+ ["0xfcb23eb0".toLowerCase()]: {
3047
+ inputAmount: {
3048
+ bytes_startIndex: 104,
3049
+ // first 104 bytes are the routeId, followed by the function selector
3050
+ bytes_length: 32,
3051
+ // first 32 bytes of the params are the amount
3052
+ bytesString_startIndex: 2 + 8 * 2,
3053
+ // first two characters are 0x and 8 bytes = 16 chars for the amount
3054
+ bytesString_length: 32 * 2
3055
+ // 32 bytes = 64 chars for the amount
3056
+ }
3057
+ }
3009
3058
  }
3010
3059
  };
3011
3060
 
3012
3061
  // src/providers/bungee/types.ts
3013
3062
  var BungeeBridgeNames = {
3014
3063
  Across: "across" /* Across */,
3015
- "Circle CCTP": "cctp" /* CircleCCTP */
3064
+ "Circle CCTP": "cctp" /* CircleCCTP */,
3065
+ "Gnosis Native": "gnosis-native-bridge" /* GnosisNative */
3016
3066
  };
3017
3067
 
3018
3068
  // src/providers/bungee/util.ts
@@ -3153,7 +3203,7 @@ var SocketVerifierAddresses = {
3153
3203
  [import_sdk_config6.SupportedChainId.SEPOLIA]: void 0,
3154
3204
  [import_sdk_config6.AdditionalTargetChainId.OPTIMISM]: SOCKET_VERIFIER_ADDRESS
3155
3205
  };
3156
- var BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS = "0x936fa1cfd96849329B18b915773E176718A64b95";
3206
+ var BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS = "0xD06a673fe1fa27B1b9E5BA0be980AB15Dbce85cc";
3157
3207
  var BungeeApproveAndBridgeV1Addresses = {
3158
3208
  [import_sdk_config6.SupportedChainId.MAINNET]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
3159
3209
  [import_sdk_config6.SupportedChainId.GNOSIS_CHAIN]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
@@ -3381,11 +3431,12 @@ var BUNGEE_APPROVE_AND_BRIDGE_V1_ABI = [
3381
3431
 
3382
3432
  // src/providers/bungee/BungeeApi.ts
3383
3433
  var import_sdk_common12 = require("@cowprotocol/sdk-common");
3384
- var BUNGEE_API_URL = "https://public-backend.bungee.exchange/api/v1/bungee";
3385
- var BUNGEE_MANUAL_API_URL = "https://public-backend.bungee.exchange/api/v1/bungee-manual";
3434
+ var BUNGEE_BASE_URL = "https://public-backend.bungee.exchange";
3435
+ var BUNGEE_API_URL = `${BUNGEE_BASE_URL}/api/v1/bungee`;
3436
+ var BUNGEE_MANUAL_API_URL = `${BUNGEE_BASE_URL}/api/v1/bungee-manual`;
3386
3437
  var BUNGEE_EVENTS_API_URL = "https://microservices.socket.tech/loki";
3387
3438
  var ACROSS_API_URL2 = "https://app.across.to/api";
3388
- var SUPPORTED_BRIDGES = ["across", "cctp"];
3439
+ var SUPPORTED_BRIDGES = ["across", "cctp", "gnosis-native-bridge"];
3389
3440
  var errorMessageMap = {
3390
3441
  bungee: "Bungee Api Error",
3391
3442
  events: "Bungee Events Api Error",
@@ -3629,6 +3680,10 @@ var BungeeApi = class {
3629
3680
  getSupportedBridges(bridges) {
3630
3681
  return bridges ?? this.options.includeBridges ?? SUPPORTED_BRIDGES;
3631
3682
  }
3683
+ shouldAddAffiliate(apiType, baseUrl) {
3684
+ const isBungeeApi = apiType === "bungee" || apiType === "bungee-manual";
3685
+ return !baseUrl.includes(BUNGEE_BASE_URL) && isBungeeApi;
3686
+ }
3632
3687
  async makeApiCall(apiType, path, params, isValidResponse) {
3633
3688
  const baseUrlMap = {
3634
3689
  bungee: this.options.apiBaseUrl || BUNGEE_API_URL,
@@ -3638,8 +3693,12 @@ var BungeeApi = class {
3638
3693
  };
3639
3694
  const baseUrl = baseUrlMap[apiType];
3640
3695
  const url = `${baseUrl}${path}?${new URLSearchParams(params).toString()}`;
3696
+ const headers = {};
3697
+ if (this.shouldAddAffiliate(apiType, baseUrl) && this.options.affiliate) {
3698
+ headers["affiliate"] = this.options.affiliate;
3699
+ }
3641
3700
  (0, import_sdk_common12.log)(`Fetching ${apiType} API: GET ${url}. Params: ${JSON.stringify(params)}`);
3642
- const response = await fetch(url, { method: "GET" });
3701
+ const response = await fetch(url, { method: "GET", headers });
3643
3702
  if (!response.ok) {
3644
3703
  const errorBody = await response.json();
3645
3704
  throw new BridgeProviderQuoteError("API_ERROR" /* API_ERROR */, { errorBody, type: errorMessageMap[apiType] });
@@ -3701,7 +3760,8 @@ function isValidBungeeEventsResponse(response) {
3701
3760
  return false;
3702
3761
  }
3703
3762
  const e = event;
3704
- return "identifier" in e && "bridgeName" in e && "fromChainId" in e && "isCowswapTrade" in e && "orderId" in e && "recipient" in e && "sender" in e && "srcTxStatus" in e && "destTxStatus" in e;
3763
+ return "identifier" in e && "bridgeName" in e && "fromChainId" in e && "isCowswapTrade" in e && "orderId" in e && // 'recipient' in e &&
3764
+ "sender" in e && "srcTxStatus" in e && "destTxStatus" in e;
3705
3765
  });
3706
3766
  }
3707
3767
  function isValidAcrossStatusResponse(response) {
@@ -3776,7 +3836,7 @@ async function createBungeeDepositCall(params) {
3776
3836
 
3777
3837
  // src/providers/bungee/getBridgingStatusFromEvents.ts
3778
3838
  async function getBridgingStatusFromEvents(events, getAcrossStatus) {
3779
- if (!events?.length) {
3839
+ if (!events?.length || !events?.[0]) {
3780
3840
  return { status: "unknown" /* UNKNOWN */ };
3781
3841
  }
3782
3842
  const event = events[0];
@@ -3814,7 +3874,7 @@ var import_sdk_config8 = require("@cowprotocol/sdk-config");
3814
3874
  var import_sdk_cow_shed2 = require("@cowprotocol/sdk-cow-shed");
3815
3875
  var import_sdk_common14 = require("@cowprotocol/sdk-common");
3816
3876
  var BUNGEE_HOOK_DAPP_ID = `${HOOK_DAPP_BRIDGE_PROVIDER_PREFIX2}/bungee`;
3817
- var BUNGEE_SUPPORTED_NETWORKS = [import_sdk_config8.mainnet, import_sdk_config8.polygon, import_sdk_config8.arbitrumOne, import_sdk_config8.base, import_sdk_config8.optimism, import_sdk_config8.avalanche];
3877
+ var BUNGEE_SUPPORTED_NETWORKS = [import_sdk_config8.mainnet, import_sdk_config8.polygon, import_sdk_config8.arbitrumOne, import_sdk_config8.base, import_sdk_config8.optimism, import_sdk_config8.avalanche, import_sdk_config8.gnosisChain];
3818
3878
  var SLIPPAGE_TOLERANCE_BPS2 = 0;
3819
3879
  var BungeeBridgeProvider = class {
3820
3880
  constructor(options, _adapter) {
@@ -3838,7 +3898,12 @@ var BungeeBridgeProvider = class {
3838
3898
  return BUNGEE_SUPPORTED_NETWORKS;
3839
3899
  }
3840
3900
  async getBuyTokens(params) {
3841
- return this.api.getBuyTokens(params);
3901
+ const tokens = await this.api.getBuyTokens(params);
3902
+ const isRouteAvailable = tokens.length > 0;
3903
+ return {
3904
+ tokens,
3905
+ isRouteAvailable
3906
+ };
3842
3907
  }
3843
3908
  async getIntermediateTokens(request) {
3844
3909
  if (request.kind !== import_sdk_order_book6.OrderKind.SELL) {
@@ -3883,7 +3948,15 @@ var BungeeBridgeProvider = class {
3883
3948
  });
3884
3949
  }
3885
3950
  async getGasLimitEstimationForHook(request) {
3886
- return getGasLimitEstimationForHook(this.cowShedSdk, request);
3951
+ const isExtraGasRequired = this.isExtraGasRequired(request);
3952
+ const extraGas = isExtraGasRequired ? DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION : void 0;
3953
+ const extraGasProxyCreation = isExtraGasRequired ? DEFAULT_EXTRA_GAS_PROXY_CREATION : void 0;
3954
+ return getGasLimitEstimationForHook({
3955
+ cowShedSdk: this.cowShedSdk,
3956
+ request,
3957
+ extraGas,
3958
+ extraGasProxyCreation
3959
+ });
3887
3960
  }
3888
3961
  async getSignedHook(chainId, unsignedCall, bridgeHookNonce, deadline, hookGasLimit, signer) {
3889
3962
  const { signedMulticall, cowShedAccount, gasLimit } = await this.cowShedSdk.signCalls({
@@ -3915,7 +3988,7 @@ var BungeeBridgeProvider = class {
3915
3988
  }
3916
3989
  async getBridgingParams(_chainId, orderId, _txHash) {
3917
3990
  const events = await this.api.getEvents({ orderId });
3918
- const event = events[0];
3991
+ const event = events?.[0];
3919
3992
  if (!event)
3920
3993
  return null;
3921
3994
  const status = await getBridgingStatusFromEvents(events, (orderId2) => this.api.getAcrossStatus(orderId2));
@@ -3950,6 +4023,10 @@ var BungeeBridgeProvider = class {
3950
4023
  async getRefundBridgingTx(_bridgingId) {
3951
4024
  throw new Error("Not implemented");
3952
4025
  }
4026
+ isExtraGasRequired(request) {
4027
+ const { sellTokenChainId, buyTokenChainId } = request;
4028
+ return sellTokenChainId === import_sdk_config8.SupportedChainId.MAINNET && buyTokenChainId === import_sdk_config8.SupportedChainId.GNOSIS_CHAIN;
4029
+ }
3953
4030
  };
3954
4031
  // Annotate the CommonJS export names for ESM import in node:
3955
4032
  0 && (module.exports = {
@@ -3962,6 +4039,8 @@ var BungeeBridgeProvider = class {
3962
4039
  BridgingSdk,
3963
4040
  BungeeBridgeProvider,
3964
4041
  COW_SHED_PROXY_CREATION_GAS,
4042
+ DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION,
4043
+ DEFAULT_EXTRA_GAS_PROXY_CREATION,
3965
4044
  DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION,
3966
4045
  HOOK_DAPP_BRIDGE_PROVIDER_PREFIX,
3967
4046
  RAW_PROVIDERS_FILES_PATH,
package/dist/index.mjs CHANGED
@@ -106,7 +106,7 @@ async function getBridgeSignedHook(bridgeRequest, { provider, signer, hookGasLim
106
106
  const adapter = getGlobalAdapter();
107
107
  const bridgingQuote = await provider.getQuote(bridgeRequest);
108
108
  const unsignedBridgeCall = await provider.getUnsignedBridgeCall(bridgeRequest, bridgingQuote);
109
- const deadline = BigInt(validToOverride || swapResult.orderToSign.validTo);
109
+ const deadline = BigInt(validToOverride ?? swapResult.orderToSign.validTo);
110
110
  const bridgeHookNonce = adapter.utils.solidityKeccak256(
111
111
  ["bytes", "uint256"],
112
112
  [unsignedBridgeCall.data, deadline]
@@ -130,7 +130,9 @@ async function getBridgeSignedHook(bridgeRequest, { provider, signer, hookGasLim
130
130
  import { RAW_FILES_PATH } from "@cowprotocol/sdk-config";
131
131
  var RAW_PROVIDERS_FILES_PATH = `${RAW_FILES_PATH}/src/bridging/providers`;
132
132
  var DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 24e4;
133
+ var DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION = 2e5;
133
134
  var COW_SHED_PROXY_CREATION_GAS = 36e4;
135
+ var DEFAULT_EXTRA_GAS_PROXY_CREATION = 4e5;
134
136
  var HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
135
137
 
136
138
  // src/BridgingSdk/getQuoteWithBridge.ts
@@ -426,10 +428,13 @@ async function getCrossChainOrder(params) {
426
428
  import { TradingSdk } from "@cowprotocol/sdk-trading";
427
429
  import { OrderBookApi } from "@cowprotocol/sdk-order-book";
428
430
  import { ALL_SUPPORTED_CHAINS } from "@cowprotocol/sdk-config";
429
- import { enableLogging } from "@cowprotocol/sdk-common";
431
+ import { enableLogging, setGlobalAdapter } from "@cowprotocol/sdk-common";
430
432
  var BridgingSdk = class {
431
- constructor(options) {
433
+ constructor(options, adapter) {
432
434
  this.options = options;
435
+ if (adapter) {
436
+ setGlobalAdapter(adapter);
437
+ }
433
438
  const { providers, ...restOptions } = options;
434
439
  if (!providers || providers.length !== 1) {
435
440
  throw new Error("Current implementation only supports a single bridge provider");
@@ -2739,18 +2744,24 @@ async function getDepositParams(chainId, orderId, txReceipt) {
2739
2744
 
2740
2745
  // src/providers/utils/getGasLimitEstimationForHook.ts
2741
2746
  import { getGlobalAdapter as getGlobalAdapter6 } from "@cowprotocol/sdk-common";
2742
- async function getGasLimitEstimationForHook(cowShedSdk, request) {
2747
+ async function getGasLimitEstimationForHook({
2748
+ cowShedSdk,
2749
+ request,
2750
+ extraGas,
2751
+ extraGasProxyCreation
2752
+ }) {
2743
2753
  const adapter = getGlobalAdapter6();
2744
2754
  const proxyAddress = cowShedSdk.getCowShedAccount(request.sellTokenChainId, request.owner || request.account);
2745
2755
  const proxyCode = await adapter.getCode(proxyAddress);
2746
2756
  if (!proxyCode || proxyCode === "0x") {
2747
- return DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION + COW_SHED_PROXY_CREATION_GAS;
2757
+ const baseGas = DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION + COW_SHED_PROXY_CREATION_GAS;
2758
+ return baseGas + (extraGasProxyCreation && extraGasProxyCreation > 0 ? extraGasProxyCreation : 0);
2748
2759
  }
2749
- return DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION;
2760
+ return DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION + (extraGas && extraGas > 0 ? extraGas : 0);
2750
2761
  }
2751
2762
 
2752
2763
  // src/providers/across/AcrossBridgeProvider.ts
2753
- import { getGlobalAdapter as getGlobalAdapter7, setGlobalAdapter } from "@cowprotocol/sdk-common";
2764
+ import { getGlobalAdapter as getGlobalAdapter7, setGlobalAdapter as setGlobalAdapter2 } from "@cowprotocol/sdk-common";
2754
2765
  import {
2755
2766
  arbitrumOne,
2756
2767
  base,
@@ -2770,7 +2781,7 @@ var AcrossBridgeProvider = class {
2770
2781
  constructor(options = {}, _adapter) {
2771
2782
  const adapter = _adapter || options.cowShedOptions?.adapter;
2772
2783
  if (adapter) {
2773
- setGlobalAdapter(adapter);
2784
+ setGlobalAdapter2(adapter);
2774
2785
  }
2775
2786
  this.api = new AcrossApi(options.apiOptions);
2776
2787
  this.cowShedSdk = new CowShedSdk(adapter, options.cowShedOptions?.factoryOptions);
@@ -2785,7 +2796,12 @@ var AcrossBridgeProvider = class {
2785
2796
  return ACROSS_SUPPORTED_NETWORKS;
2786
2797
  }
2787
2798
  async getBuyTokens(params) {
2788
- return Object.values((await this.getSupportedTokensState())[params.buyChainId] || {});
2799
+ const tokens = Object.values((await this.getSupportedTokensState())[params.buyChainId] || {});
2800
+ const isRouteAvailable = tokens.length > 0;
2801
+ return {
2802
+ tokens,
2803
+ isRouteAvailable
2804
+ };
2789
2805
  }
2790
2806
  async getIntermediateTokens(request) {
2791
2807
  if (request.kind !== OrderKind3.SELL) {
@@ -2822,7 +2838,10 @@ var AcrossBridgeProvider = class {
2822
2838
  });
2823
2839
  }
2824
2840
  async getGasLimitEstimationForHook(request) {
2825
- return getGasLimitEstimationForHook(this.cowShedSdk, request);
2841
+ return getGasLimitEstimationForHook({
2842
+ cowShedSdk: this.cowShedSdk,
2843
+ request
2844
+ });
2826
2845
  }
2827
2846
  async getSignedHook(chainId, unsignedCall, bridgeHookNonce, deadline, hookGasLimit, signer) {
2828
2847
  const { signedMulticall, cowShedAccount, gasLimit } = await this.cowShedSdk.signCalls({
@@ -2972,13 +2991,42 @@ var BungeeTxDataBytesIndices = {
2972
2991
  // 32 bytes = 64 chars for the amount
2973
2992
  }
2974
2993
  }
2994
+ },
2995
+ "gnosis-native-bridge": {
2996
+ // bridgeERC20To (amount is 5th param -> 8 + 4*32 = 136)
2997
+ ["0x3bf5c228".toLowerCase()]: {
2998
+ inputAmount: {
2999
+ bytes_startIndex: 136,
3000
+ // first 136 bytes are the routeId, followed by the function selector
3001
+ bytes_length: 32,
3002
+ // first 32 bytes of the params are the amount
3003
+ bytesString_startIndex: 2 + 8 * 2,
3004
+ // first two characters are 0x and 8 bytes = 16 chars for the amount
3005
+ bytesString_length: 32 * 2
3006
+ // 32 bytes = 64 chars for the amount
3007
+ }
3008
+ },
3009
+ // bridgeNativeTo (amount is 4th param -> 8 + 3*32 = 104)
3010
+ ["0xfcb23eb0".toLowerCase()]: {
3011
+ inputAmount: {
3012
+ bytes_startIndex: 104,
3013
+ // first 104 bytes are the routeId, followed by the function selector
3014
+ bytes_length: 32,
3015
+ // first 32 bytes of the params are the amount
3016
+ bytesString_startIndex: 2 + 8 * 2,
3017
+ // first two characters are 0x and 8 bytes = 16 chars for the amount
3018
+ bytesString_length: 32 * 2
3019
+ // 32 bytes = 64 chars for the amount
3020
+ }
3021
+ }
2975
3022
  }
2976
3023
  };
2977
3024
 
2978
3025
  // src/providers/bungee/types.ts
2979
3026
  var BungeeBridgeNames = {
2980
3027
  Across: "across" /* Across */,
2981
- "Circle CCTP": "cctp" /* CircleCCTP */
3028
+ "Circle CCTP": "cctp" /* CircleCCTP */,
3029
+ "Gnosis Native": "gnosis-native-bridge" /* GnosisNative */
2982
3030
  };
2983
3031
 
2984
3032
  // src/providers/bungee/util.ts
@@ -3119,7 +3167,7 @@ var SocketVerifierAddresses = {
3119
3167
  [SupportedChainId5.SEPOLIA]: void 0,
3120
3168
  [AdditionalTargetChainId2.OPTIMISM]: SOCKET_VERIFIER_ADDRESS
3121
3169
  };
3122
- var BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS = "0x936fa1cfd96849329B18b915773E176718A64b95";
3170
+ var BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS = "0xD06a673fe1fa27B1b9E5BA0be980AB15Dbce85cc";
3123
3171
  var BungeeApproveAndBridgeV1Addresses = {
3124
3172
  [SupportedChainId5.MAINNET]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
3125
3173
  [SupportedChainId5.GNOSIS_CHAIN]: BUNGEE_APPROVE_AND_BRIDGE_V1_ADDRESS,
@@ -3347,11 +3395,12 @@ var BUNGEE_APPROVE_AND_BRIDGE_V1_ABI = [
3347
3395
 
3348
3396
  // src/providers/bungee/BungeeApi.ts
3349
3397
  import { getGlobalAdapter as getGlobalAdapter8, log as log5 } from "@cowprotocol/sdk-common";
3350
- var BUNGEE_API_URL = "https://public-backend.bungee.exchange/api/v1/bungee";
3351
- var BUNGEE_MANUAL_API_URL = "https://public-backend.bungee.exchange/api/v1/bungee-manual";
3398
+ var BUNGEE_BASE_URL = "https://public-backend.bungee.exchange";
3399
+ var BUNGEE_API_URL = `${BUNGEE_BASE_URL}/api/v1/bungee`;
3400
+ var BUNGEE_MANUAL_API_URL = `${BUNGEE_BASE_URL}/api/v1/bungee-manual`;
3352
3401
  var BUNGEE_EVENTS_API_URL = "https://microservices.socket.tech/loki";
3353
3402
  var ACROSS_API_URL2 = "https://app.across.to/api";
3354
- var SUPPORTED_BRIDGES = ["across", "cctp"];
3403
+ var SUPPORTED_BRIDGES = ["across", "cctp", "gnosis-native-bridge"];
3355
3404
  var errorMessageMap = {
3356
3405
  bungee: "Bungee Api Error",
3357
3406
  events: "Bungee Events Api Error",
@@ -3595,6 +3644,10 @@ var BungeeApi = class {
3595
3644
  getSupportedBridges(bridges) {
3596
3645
  return bridges ?? this.options.includeBridges ?? SUPPORTED_BRIDGES;
3597
3646
  }
3647
+ shouldAddAffiliate(apiType, baseUrl) {
3648
+ const isBungeeApi = apiType === "bungee" || apiType === "bungee-manual";
3649
+ return !baseUrl.includes(BUNGEE_BASE_URL) && isBungeeApi;
3650
+ }
3598
3651
  async makeApiCall(apiType, path, params, isValidResponse) {
3599
3652
  const baseUrlMap = {
3600
3653
  bungee: this.options.apiBaseUrl || BUNGEE_API_URL,
@@ -3604,8 +3657,12 @@ var BungeeApi = class {
3604
3657
  };
3605
3658
  const baseUrl = baseUrlMap[apiType];
3606
3659
  const url = `${baseUrl}${path}?${new URLSearchParams(params).toString()}`;
3660
+ const headers = {};
3661
+ if (this.shouldAddAffiliate(apiType, baseUrl) && this.options.affiliate) {
3662
+ headers["affiliate"] = this.options.affiliate;
3663
+ }
3607
3664
  log5(`Fetching ${apiType} API: GET ${url}. Params: ${JSON.stringify(params)}`);
3608
- const response = await fetch(url, { method: "GET" });
3665
+ const response = await fetch(url, { method: "GET", headers });
3609
3666
  if (!response.ok) {
3610
3667
  const errorBody = await response.json();
3611
3668
  throw new BridgeProviderQuoteError("API_ERROR" /* API_ERROR */, { errorBody, type: errorMessageMap[apiType] });
@@ -3667,7 +3724,8 @@ function isValidBungeeEventsResponse(response) {
3667
3724
  return false;
3668
3725
  }
3669
3726
  const e = event;
3670
- return "identifier" in e && "bridgeName" in e && "fromChainId" in e && "isCowswapTrade" in e && "orderId" in e && "recipient" in e && "sender" in e && "srcTxStatus" in e && "destTxStatus" in e;
3727
+ return "identifier" in e && "bridgeName" in e && "fromChainId" in e && "isCowswapTrade" in e && "orderId" in e && // 'recipient' in e &&
3728
+ "sender" in e && "srcTxStatus" in e && "destTxStatus" in e;
3671
3729
  });
3672
3730
  }
3673
3731
  function isValidAcrossStatusResponse(response) {
@@ -3742,7 +3800,7 @@ async function createBungeeDepositCall(params) {
3742
3800
 
3743
3801
  // src/providers/bungee/getBridgingStatusFromEvents.ts
3744
3802
  async function getBridgingStatusFromEvents(events, getAcrossStatus) {
3745
- if (!events?.length) {
3803
+ if (!events?.length || !events?.[0]) {
3746
3804
  return { status: "unknown" /* UNKNOWN */ };
3747
3805
  }
3748
3806
  const event = events[0];
@@ -3780,21 +3838,23 @@ import {
3780
3838
  arbitrumOne as arbitrumOne2,
3781
3839
  avalanche,
3782
3840
  base as base2,
3841
+ gnosisChain,
3783
3842
  mainnet as mainnet2,
3784
3843
  optimism as optimism2,
3785
- polygon as polygon2
3844
+ polygon as polygon2,
3845
+ SupportedChainId as SupportedChainId6
3786
3846
  } from "@cowprotocol/sdk-config";
3787
3847
  import { CowShedSdk as CowShedSdk2 } from "@cowprotocol/sdk-cow-shed";
3788
- import { setGlobalAdapter as setGlobalAdapter2 } from "@cowprotocol/sdk-common";
3848
+ import { setGlobalAdapter as setGlobalAdapter3 } from "@cowprotocol/sdk-common";
3789
3849
  var BUNGEE_HOOK_DAPP_ID = `${HOOK_DAPP_BRIDGE_PROVIDER_PREFIX2}/bungee`;
3790
- var BUNGEE_SUPPORTED_NETWORKS = [mainnet2, polygon2, arbitrumOne2, base2, optimism2, avalanche];
3850
+ var BUNGEE_SUPPORTED_NETWORKS = [mainnet2, polygon2, arbitrumOne2, base2, optimism2, avalanche, gnosisChain];
3791
3851
  var SLIPPAGE_TOLERANCE_BPS2 = 0;
3792
3852
  var BungeeBridgeProvider = class {
3793
3853
  constructor(options, _adapter) {
3794
3854
  this.options = options;
3795
3855
  const adapter = _adapter || options.cowShedOptions?.adapter;
3796
3856
  if (adapter) {
3797
- setGlobalAdapter2(adapter);
3857
+ setGlobalAdapter3(adapter);
3798
3858
  }
3799
3859
  this.api = new BungeeApi(options.apiOptions);
3800
3860
  this.cowShedSdk = new CowShedSdk2(adapter, options.cowShedOptions?.factoryOptions);
@@ -3811,7 +3871,12 @@ var BungeeBridgeProvider = class {
3811
3871
  return BUNGEE_SUPPORTED_NETWORKS;
3812
3872
  }
3813
3873
  async getBuyTokens(params) {
3814
- return this.api.getBuyTokens(params);
3874
+ const tokens = await this.api.getBuyTokens(params);
3875
+ const isRouteAvailable = tokens.length > 0;
3876
+ return {
3877
+ tokens,
3878
+ isRouteAvailable
3879
+ };
3815
3880
  }
3816
3881
  async getIntermediateTokens(request) {
3817
3882
  if (request.kind !== OrderKind5.SELL) {
@@ -3856,7 +3921,15 @@ var BungeeBridgeProvider = class {
3856
3921
  });
3857
3922
  }
3858
3923
  async getGasLimitEstimationForHook(request) {
3859
- return getGasLimitEstimationForHook(this.cowShedSdk, request);
3924
+ const isExtraGasRequired = this.isExtraGasRequired(request);
3925
+ const extraGas = isExtraGasRequired ? DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION : void 0;
3926
+ const extraGasProxyCreation = isExtraGasRequired ? DEFAULT_EXTRA_GAS_PROXY_CREATION : void 0;
3927
+ return getGasLimitEstimationForHook({
3928
+ cowShedSdk: this.cowShedSdk,
3929
+ request,
3930
+ extraGas,
3931
+ extraGasProxyCreation
3932
+ });
3860
3933
  }
3861
3934
  async getSignedHook(chainId, unsignedCall, bridgeHookNonce, deadline, hookGasLimit, signer) {
3862
3935
  const { signedMulticall, cowShedAccount, gasLimit } = await this.cowShedSdk.signCalls({
@@ -3888,7 +3961,7 @@ var BungeeBridgeProvider = class {
3888
3961
  }
3889
3962
  async getBridgingParams(_chainId, orderId, _txHash) {
3890
3963
  const events = await this.api.getEvents({ orderId });
3891
- const event = events[0];
3964
+ const event = events?.[0];
3892
3965
  if (!event)
3893
3966
  return null;
3894
3967
  const status = await getBridgingStatusFromEvents(events, (orderId2) => this.api.getAcrossStatus(orderId2));
@@ -3923,6 +3996,10 @@ var BungeeBridgeProvider = class {
3923
3996
  async getRefundBridgingTx(_bridgingId) {
3924
3997
  throw new Error("Not implemented");
3925
3998
  }
3999
+ isExtraGasRequired(request) {
4000
+ const { sellTokenChainId, buyTokenChainId } = request;
4001
+ return sellTokenChainId === SupportedChainId6.MAINNET && buyTokenChainId === SupportedChainId6.GNOSIS_CHAIN;
4002
+ }
3926
4003
  };
3927
4004
  export {
3928
4005
  AcrossBridgeProvider,
@@ -3934,6 +4011,8 @@ export {
3934
4011
  BridgingSdk,
3935
4012
  BungeeBridgeProvider,
3936
4013
  COW_SHED_PROXY_CREATION_GAS,
4014
+ DEFAULT_EXTRA_GAS_FOR_HOOK_ESTIMATION,
4015
+ DEFAULT_EXTRA_GAS_PROXY_CREATION,
3937
4016
  DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION,
3938
4017
  HOOK_DAPP_BRIDGE_PROVIDER_PREFIX,
3939
4018
  RAW_PROVIDERS_FILES_PATH,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cowprotocol/sdk-bridging",
3
- "version": "0.1.0-monorepo.4",
3
+ "version": "0.1.0",
4
4
  "description": "Bridging for CoW Protocol",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -13,33 +13,17 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "scripts": {
17
- "build": "tsup src/index.ts --format esm,cjs --dts",
18
- "lint": "eslint src/**/*.ts",
19
- "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
20
- "test": "jest",
21
- "test:coverage": "jest --coverage --json --outputFile=jest.results.json && npx coveralls < ./coverage/lcov.info",
22
- "test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
23
- "typecheck": "tsc --noEmit",
24
- "publish": "npm publish --access public",
25
- "prepublishOnly": "npm run build"
26
- },
27
16
  "dependencies": {
28
- "@cowprotocol/sdk-app-data": "workspace:*",
29
- "@cowprotocol/sdk-common": "workspace:*",
30
- "@cowprotocol/sdk-config": "workspace:*",
31
- "@cowprotocol/sdk-contracts-ts": "workspace:*",
32
- "@cowprotocol/sdk-cow-shed": "workspace:*",
33
- "@cowprotocol/sdk-order-book": "workspace:*",
34
- "@cowprotocol/sdk-trading": "workspace:*",
35
- "@cowprotocol/sdk-weiroll": "workspace:*"
17
+ "@cowprotocol/sdk-app-data": "4.0.0",
18
+ "@cowprotocol/sdk-common": "0.1.0",
19
+ "@cowprotocol/sdk-config": "0.1.0",
20
+ "@cowprotocol/sdk-cow-shed": "0.1.0",
21
+ "@cowprotocol/sdk-contracts-ts": "0.1.0",
22
+ "@cowprotocol/sdk-order-book": "0.1.0",
23
+ "@cowprotocol/sdk-trading": "0.1.0",
24
+ "@cowprotocol/sdk-weiroll": "0.1.0"
36
25
  },
37
26
  "devDependencies": {
38
- "@cowprotocol/sdk-order-signing": "workspace:*",
39
- "@cow-sdk/typescript-config": "workspace:*",
40
- "@cowprotocol/sdk-ethers-v5-adapter": "workspace:*",
41
- "@cowprotocol/sdk-ethers-v6-adapter": "workspace:*",
42
- "@cowprotocol/sdk-viem-adapter": "workspace:*",
43
27
  "ethers-v5": "npm:ethers@^5.7.2",
44
28
  "ethers-v6": "npm:ethers@^6.13.7",
45
29
  "@types/jest": "^29.4.0",
@@ -51,6 +35,21 @@
51
35
  "jest-fetch-mock": "^3.0.3",
52
36
  "ts-jest": "^29.0.0",
53
37
  "ethers": "^5.7.2",
54
- "viem": "^2.28.4"
38
+ "viem": "^2.28.4",
39
+ "@cowprotocol/sdk-order-signing": "0.1.0",
40
+ "@cowprotocol/sdk-ethers-v5-adapter": "0.1.0",
41
+ "@cow-sdk/typescript-config": "0.0.0-beta.0",
42
+ "@cowprotocol/sdk-viem-adapter": "0.1.0",
43
+ "@cowprotocol/sdk-ethers-v6-adapter": "0.1.0"
44
+ },
45
+ "scripts": {
46
+ "build": "tsup src/index.ts --format esm,cjs --dts",
47
+ "lint": "eslint src/**/*.ts",
48
+ "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
49
+ "test": "jest",
50
+ "test:coverage": "jest --coverage --json --outputFile=jest.results.json && npx coveralls < ./coverage/lcov.info",
51
+ "test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
52
+ "test:bungeeGnosisBridge": "yarn test --testPathPattern=BungeeGnosisBridge",
53
+ "typecheck": "tsc --noEmit"
55
54
  }
56
- }
55
+ }