@cowprotocol/cow-sdk 6.0.0-RC.66 → 6.0.0-RC.68

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.
@@ -2,7 +2,6 @@ import { SwapAdvancedSettings, TradingSdk } from '../../trading';
2
2
  import { BridgeProvider, BridgeQuoteResult, BridgeStatusResult, CrossChainOrder, CrossChainQuoteAndPost, QuoteBridgeRequest } from '../types';
3
3
  import { CowEnv, TokenInfo } from '../../common';
4
4
  import { ChainInfo, SupportedChainId, TargetChainId } from '../../chains';
5
- import { JsonRpcProvider } from '@ethersproject/providers';
6
5
  import { OrderBookApi } from '../../order-book';
7
6
  export interface BridgingSdkOptions {
8
7
  /**
@@ -34,10 +33,6 @@ export interface GetOrderParams {
34
33
  * The unique identifier of the order.
35
34
  */
36
35
  orderId: string;
37
- /**
38
- * RPC provider to get order transactions details
39
- */
40
- rpcProvider: JsonRpcProvider;
41
36
  /**
42
37
  * The environment of the order
43
38
  */
@@ -1,7 +1,7 @@
1
1
  import { EvmCall } from '../../common';
2
2
  import { BridgeHook, BridgeQuoteResult, QuoteBridgeRequest } from '../types';
3
3
  import { BridgeResultContext } from './types';
4
- export declare function getBridgeSignedHook(bridgeRequest: QuoteBridgeRequest, { provider, signer, defaultGasLimit, swapResult, validToOverride }: BridgeResultContext): Promise<{
4
+ export declare function getBridgeSignedHook(bridgeRequest: QuoteBridgeRequest, { provider, signer, hookGasLimit, swapResult, validToOverride }: BridgeResultContext): Promise<{
5
5
  hook: BridgeHook;
6
6
  unsignedBridgeCall: EvmCall;
7
7
  bridgingQuote: BridgeQuoteResult;
@@ -1,12 +1,10 @@
1
1
  import { BridgeProvider, BridgeQuoteResult, CrossChainOrder } from '../types';
2
2
  import { CowEnv } from '../../common';
3
- import { JsonRpcProvider } from '@ethersproject/providers';
4
3
  import { SupportedChainId } from '../../chains';
5
4
  import { OrderBookApi } from '../../order-book';
6
5
  interface GetCrossChainOrderParams {
7
6
  chainId: SupportedChainId;
8
7
  orderId: string;
9
- rpcProvider: JsonRpcProvider;
10
8
  orderBookApi: OrderBookApi;
11
9
  providers: BridgeProvider<BridgeQuoteResult>[];
12
10
  env: CowEnv;
@@ -39,7 +39,7 @@ export interface BridgeResultContext<T extends BridgeQuoteResult = BridgeQuoteRe
39
39
  provider: BridgeProvider<T>;
40
40
  signer: Signer;
41
41
  mockedHook: latest.CoWHook;
42
+ hookGasLimit: number;
42
43
  validToOverride?: number;
43
44
  appDataOverride?: SwapAdvancedSettings['appData'];
44
- defaultGasLimit?: bigint;
45
45
  }
@@ -1,3 +1,4 @@
1
1
  export declare const RAW_PROVIDERS_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main/src/bridging/providers";
2
- export declare const DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 200000;
2
+ export declare const DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 240000;
3
+ export declare const COW_SHED_PROXY_CREATION_GAS = 260000;
3
4
  export declare const HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
@@ -10,6 +10,7 @@ import { JsonRpcProvider } from '@ethersproject/providers';
10
10
  export declare const ACROSS_HOOK_DAPP_ID = "cow-sdk://bridging/providers/across";
11
11
  export declare const ACROSS_SUPPORTED_NETWORKS: ChainInfo[];
12
12
  export interface AcrossBridgeProviderOptions {
13
+ getRpcProvider(chainId: SupportedChainId): JsonRpcProvider;
13
14
  apiOptions?: AcrossApiOptions;
14
15
  cowShedOptions?: CowShedSdkOptions;
15
16
  }
@@ -19,18 +20,19 @@ export interface AcrossQuoteResult extends BridgeQuoteResult {
19
20
  export declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteResult> {
20
21
  protected api: AcrossApi;
21
22
  protected cowShedSdk: CowShedSdk;
23
+ getRpcProvider: (chainId: SupportedChainId) => JsonRpcProvider;
22
24
  private supportedTokens;
23
- constructor(options?: AcrossBridgeProviderOptions);
25
+ constructor(options: AcrossBridgeProviderOptions);
24
26
  info: BridgeProviderInfo;
25
27
  getNetworks(): Promise<ChainInfo[]>;
26
28
  getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
27
29
  getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
28
30
  getQuote(request: QuoteBridgeRequest): Promise<AcrossQuoteResult>;
29
31
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: AcrossQuoteResult): Promise<EvmCall>;
30
- getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
31
- getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, bridgeHookNonce: string, deadline: bigint, defaultGasLimit?: bigint): Promise<BridgeHook>;
32
+ getGasLimitEstimationForHook(request: QuoteBridgeRequest): Promise<number>;
33
+ getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number): Promise<BridgeHook>;
32
34
  decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
33
- getBridgingParams(chainId: ChainId, provider: JsonRpcProvider, orderUid: string, txHash: string): Promise<BridgingDepositParams | null>;
35
+ getBridgingParams(chainId: ChainId, orderUid: string, txHash: string): Promise<BridgingDepositParams | null>;
34
36
  getExplorerUrl(bridgingId: string): string;
35
37
  getStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
36
38
  getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
@@ -10,6 +10,7 @@ import { BungeeBuildTx, BungeeQuote } from './types';
10
10
  export declare const BUNGEE_HOOK_DAPP_ID = "cow-sdk://bridging/providers/bungee";
11
11
  export declare const BUNGEE_SUPPORTED_NETWORKS: ChainInfo[];
12
12
  export interface BungeeBridgeProviderOptions {
13
+ getRpcProvider(chainId: SupportedChainId): JsonRpcProvider;
13
14
  apiOptions?: BungeeApiOptions;
14
15
  cowShedOptions?: CowShedSdkOptions;
15
16
  }
@@ -21,16 +22,17 @@ export declare class BungeeBridgeProvider implements BridgeProvider<BungeeQuoteR
21
22
  private options;
22
23
  protected api: BungeeApi;
23
24
  protected cowShedSdk: CowShedSdk;
24
- constructor(options?: BungeeBridgeProviderOptions);
25
+ getRpcProvider: (chainId: SupportedChainId) => JsonRpcProvider;
26
+ constructor(options: BungeeBridgeProviderOptions);
25
27
  info: BridgeProviderInfo;
26
28
  getNetworks(): Promise<ChainInfo[]>;
27
29
  getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
28
30
  getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
29
31
  getQuote(request: QuoteBridgeRequest): Promise<BungeeQuoteResult>;
30
32
  getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: BungeeQuoteResult): Promise<EvmCall>;
31
- getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
32
- getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, bridgeHookNonce: string, deadline: bigint, defaultGasLimit?: bigint): Promise<BridgeHook>;
33
- getBridgingParams(_chainId: ChainId, _provider: JsonRpcProvider, orderId: string, _txHash: string): Promise<BridgingDepositParams | null>;
33
+ getGasLimitEstimationForHook(request: QuoteBridgeRequest): Promise<number>;
34
+ getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number): Promise<BridgeHook>;
35
+ getBridgingParams(_chainId: ChainId, orderId: string, _txHash: string): Promise<BridgingDepositParams | null>;
34
36
  decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
35
37
  getBridgingId(_orderUid: string, _settlementTx: string, _logIndex: number): Promise<string>;
36
38
  getExplorerUrl(bridgingId: string): string;
@@ -6,15 +6,16 @@ import { Signer } from '@ethersproject/abstract-signer';
6
6
  import { JsonRpcProvider } from '@ethersproject/providers';
7
7
  export declare class MockBridgeProvider implements BridgeProvider<BridgeQuoteResult> {
8
8
  info: BridgeProviderInfo;
9
+ getRpcProvider(): JsonRpcProvider;
9
10
  getNetworks(): Promise<ChainInfo[]>;
10
11
  getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
11
12
  getIntermediateTokens({ sellTokenChainId }: QuoteBridgeRequest): Promise<TokenInfo[]>;
12
13
  getQuote(_request: QuoteBridgeRequest): Promise<BridgeQuoteResult>;
13
- getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
14
+ getGasLimitEstimationForHook(_request: QuoteBridgeRequest): Promise<number>;
14
15
  getUnsignedBridgeCall(_request: QuoteBridgeRequest, _quote: BridgeQuoteResult): Promise<EvmCall>;
15
16
  getSignedHook(_chainId: SupportedChainId, _unsignedCall: EvmCall, _signer: Signer): Promise<BridgeHook>;
16
17
  decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
17
- getBridgingParams(_chainId: ChainId, _provider: JsonRpcProvider, _orderUid: string, _txHash: string): Promise<BridgingDepositParams>;
18
+ getBridgingParams(_chainId: ChainId, _orderUid: string, _txHash: string): Promise<BridgingDepositParams>;
18
19
  getExplorerUrl(bridgingId: string): string;
19
20
  getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
20
21
  getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
@@ -0,0 +1,4 @@
1
+ import { QuoteBridgeRequest } from '../../types';
2
+ import type { JsonRpcProvider } from '@ethersproject/providers';
3
+ import { CowShedSdk } from '../../../cow-shed';
4
+ export declare function getGasLimitEstimationForHook(cowShedSdk: CowShedSdk, request: QuoteBridgeRequest, provider: JsonRpcProvider): Promise<number>;
@@ -113,6 +113,7 @@ export interface BridgeDeposit extends Omit<QuoteBridgeRequest, 'amount'> {
113
113
  }
114
114
  export interface BridgeProvider<Q extends BridgeQuoteResult> {
115
115
  info: BridgeProviderInfo;
116
+ getRpcProvider(chainId: SupportedChainId): JsonRpcProvider;
116
117
  /**
117
118
  * Get basic supported chains
118
119
  */
@@ -156,7 +157,7 @@ export interface BridgeProvider<Q extends BridgeQuoteResult> {
156
157
  *
157
158
  * By estimating gas costs independently, we can resolve this dependency cycle.
158
159
  */
159
- getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'>): number;
160
+ getGasLimitEstimationForHook(request: Omit<QuoteBridgeRequest, 'amount'>): Promise<number>;
160
161
  /**
161
162
  * Get a pre-authorized hook for initiating a bridge.
162
163
  *
@@ -169,7 +170,7 @@ export interface BridgeProvider<Q extends BridgeQuoteResult> {
169
170
  *
170
171
  * This hook will include the pre-authorization (signature) of the owner of the cow-shed account (the trader).
171
172
  */
172
- getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, bridgeHookNonce: string, deadline: bigint, defaultGasLimit?: bigint): Promise<BridgeHook>;
173
+ getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, bridgeHookNonce: string, deadline: bigint, hookGasLimit: number): Promise<BridgeHook>;
173
174
  /**
174
175
  * Decode a bridge hook into a bridge deposit information.
175
176
  *
@@ -182,11 +183,10 @@ export interface BridgeProvider<Q extends BridgeQuoteResult> {
182
183
  /**
183
184
  * Get the identifier of the bridging transaction from the settlement transaction.
184
185
  * @param chainId
185
- * @param provider - Provider is needed in order to get transaction details from blockchain.
186
186
  * @param orderUid - The unique identifier of the order
187
187
  * @param txHash - The hash of the settlement transaction in which the bridging post-hook was executed
188
188
  */
189
- getBridgingParams(chainId: ChainId, provider: JsonRpcProvider, orderUid: string, txHash: string): Promise<BridgingDepositParams | null>;
189
+ getBridgingParams(chainId: ChainId, orderUid: string, txHash: string): Promise<BridgingDepositParams | null>;
190
190
  /**
191
191
  * Get the explorer url for a bridging id.
192
192
  *
@@ -27,6 +27,10 @@ export interface SignAndEncodeTxArgs {
27
27
  * Deadline to use for the transaction. If not provided, the maximum uint256 will be used.
28
28
  */
29
29
  deadline: bigint;
30
+ /**
31
+ * If value is provided, gas won't be estimated and will use the value
32
+ */
33
+ gasLimit?: bigint;
30
34
  /**
31
35
  * Default gas limit to use for the transaction. If not provided, it will throw an error if the gas limit cannot be estimated.
32
36
  */
@@ -63,7 +67,7 @@ export declare class CowShedSdk {
63
67
  *
64
68
  * @returns pre-authorized multicall details
65
69
  */
66
- signCalls({ calls, signer: signerParam, chainId, nonce, deadline, defaultGasLimit, signingScheme, }: SignAndEncodeTxArgs): Promise<CowShedCall>;
70
+ signCalls({ calls, signer: signerParam, chainId, nonce, deadline, gasLimit, defaultGasLimit, signingScheme, }: SignAndEncodeTxArgs): Promise<CowShedCall>;
67
71
  protected getCowShedHooks(chainId: SupportedChainId, customOptions?: ICoWShedOptions): CowShedHooks;
68
72
  protected static getNonce(): string;
69
73
  }