@cowprotocol/cow-sdk 6.0.0-RC.46 → 6.0.0-RC.47

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 (31) hide show
  1. package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +14 -8
  2. package/dist/bridging/BridgingSdk/findBridgeProviderFromHook.d.ts +2 -0
  3. package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +12 -8
  4. package/dist/bridging/const.d.ts +1 -0
  5. package/dist/bridging/errors.d.ts +4 -0
  6. package/dist/bridging/providers/across/AcrossApi.d.ts +2 -1
  7. package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +5 -4
  8. package/dist/bridging/providers/across/const/interfaces.d.ts +3 -0
  9. package/dist/bridging/providers/across/const/misc.d.ts +2 -1
  10. package/dist/bridging/providers/across/getDepositParams.d.ts +4 -0
  11. package/dist/bridging/providers/across/types.d.ts +73 -0
  12. package/dist/bridging/providers/across/util.d.ts +7 -3
  13. package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +4 -3
  14. package/dist/bridging/types.d.ts +26 -9
  15. package/dist/index-4e45cdb3.js +29 -0
  16. package/dist/index-4e45cdb3.js.map +1 -0
  17. package/dist/index.js +4 -4
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.modern.mjs +1 -1
  20. package/dist/index.module.js +4 -4
  21. package/dist/index.module.js.map +1 -1
  22. package/dist/package.json +1 -1
  23. package/dist/{utils-588822c5.js → utils-2c641bba.js} +1 -1
  24. package/dist/{utils-588822c5.js.map → utils-2c641bba.js.map} +1 -1
  25. package/dist/{utils-cdcbdaa9.js → utils-a4bdf15a.js} +1 -1
  26. package/dist/{utils-cdcbdaa9.js.map → utils-a4bdf15a.js.map} +1 -1
  27. package/dist/{utils-26ed0fa2.js → utils-c1446f6a.js} +2 -2
  28. package/dist/{utils-26ed0fa2.js.map → utils-c1446f6a.js.map} +1 -1
  29. package/package.json +1 -1
  30. package/dist/index-d020641c.js +0 -29
  31. package/dist/index-d020641c.js.map +0 -1
@@ -1,8 +1,9 @@
1
1
  import { SwapAdvancedSettings, TradingSdk } from '../../trading';
2
- import { BridgeProvider, BridgeQuoteResult, CrossChainOrder, CrossChainQuoteAndPost, QuoteBridgeRequest } from '../types';
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 { OrderBookApi } from 'src/order-book';
5
+ import { JsonRpcProvider } from '@ethersproject/providers';
6
+ import { OrderBookApi } from '../../order-book';
6
7
  export interface BridgingSdkOptions {
7
8
  /**
8
9
  * Providers for the bridging.
@@ -25,14 +26,18 @@ export interface BridgingSdkOptions {
25
26
  * Parameters for the `getOrder` method.
26
27
  */
27
28
  export interface GetOrderParams {
29
+ /**
30
+ * Id of a network where order was settled
31
+ */
32
+ chainId: SupportedChainId;
28
33
  /**
29
34
  * The unique identifier of the order.
30
35
  */
31
36
  orderId: string;
32
37
  /**
33
- * The chain ID of the order.
38
+ * RPC provider to get order transactions details
34
39
  */
35
- chainId: SupportedChainId;
40
+ rpcProvider: JsonRpcProvider;
36
41
  /**
37
42
  * The environment of the order
38
43
  */
@@ -61,9 +66,8 @@ export declare class BridgingSdk {
61
66
  getTargetNetworks(): Promise<ChainInfo[]>;
62
67
  /**
63
68
  * Get the available buy tokens for buying in a specific target chain
64
- *
65
- * @param param
66
- * @returns
69
+
70
+ * @param targetChainId
67
71
  */
68
72
  getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
69
73
  /**
@@ -82,5 +86,7 @@ export declare class BridgingSdk {
82
86
  * @throws Error if no path is found
83
87
  */
84
88
  getQuote(quoteBridgeRequest: QuoteBridgeRequest, advancedSettings?: SwapAdvancedSettings): Promise<CrossChainQuoteAndPost>;
85
- getOrder(params: GetOrderParams): Promise<CrossChainOrder>;
89
+ getOrder(params: GetOrderParams): Promise<CrossChainOrder | null>;
90
+ getOrderBridgingStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
91
+ getProviderFromAppData(fullAppData: string): BridgeProvider<BridgeQuoteResult> | undefined;
86
92
  }
@@ -0,0 +1,2 @@
1
+ import { BridgeProvider, BridgeQuoteResult } from '../types';
2
+ export declare function findBridgeProviderFromHook(fullAppData: string, providers: BridgeProvider<BridgeQuoteResult>[]): BridgeProvider<BridgeQuoteResult> | undefined;
@@ -1,14 +1,18 @@
1
1
  import { BridgeProvider, BridgeQuoteResult, CrossChainOrder } from '../types';
2
- import { SupportedChainId } from '../../chains';
3
- import { OrderBookApi } from 'src/order-book';
4
2
  import { CowEnv } from '../../common';
5
- /**
6
- * Fetch a cross-chain order and its status.
7
- */
8
- export declare function getCrossChainOrder(params: {
9
- orderId: string;
3
+ import { JsonRpcProvider } from '@ethersproject/providers';
4
+ import { SupportedChainId } from '../../chains';
5
+ import { OrderBookApi } from '../../order-book';
6
+ interface GetCrossChainOrderParams {
10
7
  chainId: SupportedChainId;
8
+ orderId: string;
9
+ rpcProvider: JsonRpcProvider;
11
10
  orderBookApi: OrderBookApi;
12
11
  providers: BridgeProvider<BridgeQuoteResult>[];
13
12
  env: CowEnv;
14
- }): Promise<CrossChainOrder>;
13
+ }
14
+ /**
15
+ * Fetch a cross-chain order and its status.
16
+ */
17
+ export declare function getCrossChainOrder(params: GetCrossChainOrderParams): Promise<CrossChainOrder | null>;
18
+ export {};
@@ -1,2 +1,3 @@
1
1
  export declare const RAW_PROVIDERS_FILES_PATH = "https://raw.githubusercontent.com/cowprotocol/cow-sdk/refs/heads/main/src/bridging/providers";
2
2
  export declare const DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 200000;
3
+ export declare const HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
@@ -2,3 +2,7 @@ export declare class BridgeProviderQuoteError extends Error {
2
2
  readonly context: unknown;
3
3
  constructor(message: string, context: unknown);
4
4
  }
5
+ export declare class BridgeOrderParsingError extends Error {
6
+ readonly context?: unknown | undefined;
7
+ constructor(message: string, context?: unknown | undefined);
8
+ }
@@ -1,4 +1,4 @@
1
- import { AvailableRoutesRequest, Route, SuggestedFeesRequest, SuggestedFeesResponse } from './types';
1
+ import { AvailableRoutesRequest, DepositStatusRequest, DepositStatusResponse, Route, SuggestedFeesRequest, SuggestedFeesResponse } from './types';
2
2
  import { TokenInfo } from '../../../common';
3
3
  export interface AcrossApiOptions {
4
4
  apiBaseUrl?: string;
@@ -25,5 +25,6 @@ export declare class AcrossApi {
25
25
  */
26
26
  getSuggestedFees(request: SuggestedFeesRequest): Promise<SuggestedFeesResponse>;
27
27
  getSupportedTokens(): Promise<TokenInfo[]>;
28
+ getDepositStatus(request: DepositStatusRequest): Promise<DepositStatusResponse>;
28
29
  protected fetchApi<T>(path: string, params: Record<string, string>, isValidResponse?: (response: unknown) => response is T): Promise<T>;
29
30
  }
@@ -1,11 +1,12 @@
1
1
  import { Signer } from 'ethers';
2
2
  import { latest as latestAppData } from '@cowprotocol/app-data';
3
- import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, QuoteBridgeRequest } from '../../types';
4
- import { ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
3
+ import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, BridgingDepositParams, QuoteBridgeRequest } from '../../types';
4
+ import { ChainId, ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
5
5
  import { EvmCall, TokenInfo } from '../../../common';
6
6
  import { AcrossApi, AcrossApiOptions } from './AcrossApi';
7
7
  import { CowShedSdk, CowShedSdkOptions } from '../../../cow-shed';
8
8
  import { SuggestedFeesResponse } from './types';
9
+ import { JsonRpcProvider } from '@ethersproject/providers';
9
10
  export declare const ACROSS_SUPPORTED_NETWORKS: ChainInfo[];
10
11
  export interface AcrossBridgeProviderOptions {
11
12
  apiOptions?: AcrossApiOptions;
@@ -28,9 +29,9 @@ export declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteR
28
29
  getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
29
30
  getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, defaultGasLimit?: bigint): Promise<BridgeHook>;
30
31
  decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
31
- getBridgingId(_orderUid: string, _settlementTx: string, _logIndex: number): Promise<string>;
32
+ getBridgingParams(chainId: ChainId, provider: JsonRpcProvider, orderUid: string, txHash: string): Promise<BridgingDepositParams | null>;
32
33
  getExplorerUrl(bridgingId: string): string;
33
- getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
34
+ getStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
34
35
  getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
35
36
  getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
36
37
  private getSupportedTokensState;
@@ -0,0 +1,3 @@
1
+ import { Interface } from 'ethers/lib/utils';
2
+ export declare const ACROSS_DEPOSIT_EVENT_INTERFACE: Interface;
3
+ export declare const COW_TRADE_EVENT_INTERFACE: Interface;
@@ -1 +1,2 @@
1
- export declare const HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
1
+ export declare const ACROSS_DEPOSIT_EVENT_TOPIC: string;
2
+ export declare const COW_TRADE_EVENT_TOPIC: string;
@@ -0,0 +1,4 @@
1
+ import { TransactionReceipt } from '@ethersproject/abstract-provider';
2
+ import { SupportedChainId } from '../../../chains';
3
+ import { BridgingDepositParams } from '../../types';
4
+ export declare function getDepositParams(chainId: SupportedChainId, orderId: string, txReceipt: TransactionReceipt): Promise<BridgingDepositParams | null>;
@@ -167,3 +167,76 @@ export interface PctFee {
167
167
  pct: string;
168
168
  total: string;
169
169
  }
170
+ export interface DepositStatusRequest {
171
+ originChainId: string;
172
+ depositId: string;
173
+ }
174
+ export interface DepositStatusResponse {
175
+ /**
176
+ * Status of the deposit:
177
+ * - filled: Deposit has been filled on destination chain (FilledV3Relay event emitted)
178
+ * - pending: Deposit not yet filled
179
+ * - expired: Deposit expired and will be refunded
180
+ * - refunded: Deposit expired and depositor refunded on originChain
181
+ * - slowFillRequested: Across' relayer fills without requiring another relayer to front capital
182
+ * (requires input token and output token to be the same asset)
183
+ */
184
+ status: 'filled' | 'pending' | 'expired' | 'refunded' | 'slowFillRequested';
185
+ /**
186
+ * Origin chain ID where the deposit was made.
187
+ */
188
+ originChainId: string;
189
+ /**
190
+ * Unique identifier of the deposit.
191
+ */
192
+ depositId: string;
193
+ /**
194
+ * Transaction hash of the deposit on the origin chain.
195
+ */
196
+ depositTxHash?: string;
197
+ /**
198
+ * Transaction hash of the fill on the destination chain.
199
+ * Only present when fillStatus is 'filled'.
200
+ */
201
+ fillTx?: string;
202
+ /**
203
+ * Destination chain ID where the fill transaction will occur.
204
+ */
205
+ destinationChainId?: string;
206
+ /**
207
+ * Transaction hash of the refund on the origin chain.
208
+ * Only present when fillStatus is 'refunded'.
209
+ */
210
+ depositRefundTxHash?: string;
211
+ /**
212
+ * Pagination information for the response.
213
+ */
214
+ pagination?: {
215
+ currentIndex: number;
216
+ maxIndex: number;
217
+ };
218
+ }
219
+ export interface AcrossDepositEvent {
220
+ inputToken: string;
221
+ outputToken: string;
222
+ inputAmount: string;
223
+ outputAmount: string;
224
+ destinationChainId: string;
225
+ depositId: string;
226
+ quoteTimestamp: string;
227
+ fillDeadline: string;
228
+ exclusivityDeadline: string;
229
+ depositor: string;
230
+ recipient: string;
231
+ exclusiveRelayer: string;
232
+ message: string;
233
+ }
234
+ export interface CowTradeEvent {
235
+ owner: string;
236
+ sellToken: string;
237
+ buyToken: string;
238
+ sellAmount: string;
239
+ buyAmount: string;
240
+ feeAmount: string;
241
+ orderUid: string;
242
+ }
@@ -1,8 +1,9 @@
1
- import { QuoteBridgeRequest } from '../../../bridging/types';
2
- import { TargetChainId } from '../../../chains';
1
+ import { Log } from '@ethersproject/providers';
2
+ import { BridgeStatus, QuoteBridgeRequest } from '../../types';
3
+ import { SupportedChainId, TargetChainId } from '../../../chains';
4
+ import { AcrossDepositEvent, CowTradeEvent, DepositStatusResponse, SuggestedFeesResponse } from './types';
3
5
  import { AcrossQuoteResult } from './AcrossBridgeProvider';
4
6
  import { AcrossChainConfig } from './const/tokens';
5
- import { SuggestedFeesResponse } from './types';
6
7
  /**
7
8
  * Return the chain configs
8
9
  *
@@ -37,3 +38,6 @@ export declare function pctToBps(pct: bigint): number;
37
38
  */
38
39
  export declare function applyPctFee(amount: bigint, pct: bigint): bigint;
39
40
  export declare function applyBps(amount: bigint, bps: number): bigint;
41
+ export declare function mapAcrossStatusToBridgeStatus(status: DepositStatusResponse['status']): BridgeStatus;
42
+ export declare function getAcrossDepositEvents(chainId: SupportedChainId, logs: Log[]): AcrossDepositEvent[];
43
+ export declare function getCowTradeEvents(chainId: SupportedChainId, logs: Log[]): CowTradeEvent[];
@@ -1,8 +1,9 @@
1
1
  import { latest as latestAppData } from '@cowprotocol/app-data';
2
- import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, QuoteBridgeRequest } from '../../types';
2
+ import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, BridgingDepositParams, QuoteBridgeRequest } from '../../types';
3
3
  import { EvmCall, TokenInfo } from '../../../common';
4
- import { ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
4
+ import { ChainId, ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
5
5
  import { Signer } from '@ethersproject/abstract-signer';
6
+ import { JsonRpcProvider } from '@ethersproject/providers';
6
7
  export declare class MockBridgeProvider implements BridgeProvider<BridgeQuoteResult> {
7
8
  info: BridgeProviderInfo;
8
9
  getNetworks(): Promise<ChainInfo[]>;
@@ -13,7 +14,7 @@ export declare class MockBridgeProvider implements BridgeProvider<BridgeQuoteRes
13
14
  getUnsignedBridgeCall(_request: QuoteBridgeRequest, _quote: BridgeQuoteResult): Promise<EvmCall>;
14
15
  getSignedHook(_chainId: SupportedChainId, _unsignedCall: EvmCall, _signer: Signer): Promise<BridgeHook>;
15
16
  decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
16
- getBridgingId(_orderUid: string, _settlementTx: string, _logIndex: number): Promise<string>;
17
+ getBridgingParams(_chainId: ChainId, _provider: JsonRpcProvider, _orderUid: string, _txHash: string): Promise<BridgingDepositParams>;
17
18
  getExplorerUrl(bridgingId: string): string;
18
19
  getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
19
20
  getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
@@ -1,14 +1,16 @@
1
1
  import { latest as latestAppData } from '@cowprotocol/app-data';
2
- import { ChainInfo, SupportedChainId, TargetChainId } from '../chains';
2
+ import { ChainId, ChainInfo, SupportedChainId, TargetChainId } from '../chains';
3
3
  import { TokenInfo } from '../common/types/tokens';
4
4
  import { Address, Amounts, EnrichedOrder, OrderKind } from '../order-book';
5
5
  import { EvmCall } from '../common/types/ethereum';
6
6
  import type { AccountAddress } from '../common/types/wallets';
7
7
  import { OrderPostingResult, QuoteAndPost, QuoteResults, QuoterParameters, SwapAdvancedSettings, TradeOptionalParameters, TraderParameters } from '../trading';
8
8
  import { Signer } from '@ethersproject/abstract-signer';
9
+ import { JsonRpcProvider } from '@ethersproject/providers';
9
10
  export interface BridgeProviderInfo {
10
11
  name: string;
11
12
  logoUrl: string;
13
+ dappId: string;
12
14
  }
13
15
  interface WithSellToken {
14
16
  sellTokenChainId: SupportedChainId;
@@ -78,11 +80,10 @@ export interface BridgeHook {
78
80
  recipient: string;
79
81
  }
80
82
  export declare enum BridgeStatus {
81
- NOT_INITIATED = "not_initiated",
82
83
  IN_PROGRESS = "in_progress",
83
84
  EXECUTED = "executed",
84
- FAILED = "failed",
85
- EXPIRED = "expired"
85
+ EXPIRED = "expired",
86
+ REFUND = "refund"
86
87
  }
87
88
  export interface BridgeStatusResult {
88
89
  status: BridgeStatus;
@@ -169,11 +170,12 @@ export interface BridgeProvider<Q extends BridgeQuoteResult> {
169
170
  decodeBridgeHook(hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
170
171
  /**
171
172
  * Get the identifier of the bridging transaction from the settlement transaction.
173
+ * @param chainId
174
+ * @param provider - Provider is needed in order to get transaction details from blockchain.
172
175
  * @param orderUid - The unique identifier of the order
173
- * @param settlementTx - The settlement transaction in which the bridging post-hook was executed
174
- * @param logIndex - The log index of the trade within the settlement transaction
176
+ * @param txHash - The hash of the settlement transaction in which the bridging post-hook was executed
175
177
  */
176
- getBridgingId(orderUid: string, settlementTx: string, logIndex: number): Promise<string>;
178
+ getBridgingParams(chainId: ChainId, provider: JsonRpcProvider, orderUid: string, txHash: string): Promise<BridgingDepositParams | null>;
177
179
  /**
178
180
  * Get the explorer url for a bridging id.
179
181
  *
@@ -184,8 +186,9 @@ export interface BridgeProvider<Q extends BridgeQuoteResult> {
184
186
  * Get the status of a bridging transaction.
185
187
  *
186
188
  * @param bridgingId - The bridging id
189
+ * @param originChainId - id of network where funds were deposited
187
190
  */
188
- getStatus(bridgingId: string): Promise<BridgeStatusResult>;
191
+ getStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
189
192
  getCancelBridgingTx(bridgingId: string): Promise<EvmCall>;
190
193
  getRefundBridgingTx(bridgingId: string): Promise<EvmCall>;
191
194
  }
@@ -272,11 +275,25 @@ export interface BridgeQuoteResults extends BridgeQuoteResult {
272
275
  */
273
276
  bridgeCallDetails: BridgeCallDetails;
274
277
  }
278
+ export interface BridgingDepositParams {
279
+ inputTokenAddress: Address;
280
+ outputTokenAddress: Address;
281
+ inputAmount: bigint;
282
+ outputAmount: bigint;
283
+ owner: Address;
284
+ quoteTimestamp: number;
285
+ fillDeadline: number;
286
+ recipient: Address;
287
+ sourceChainId: number;
288
+ destinationChainId: number;
289
+ bridgingId: string;
290
+ }
275
291
  export interface CrossChainOrder {
276
292
  chainId: SupportedChainId;
277
293
  order: EnrichedOrder;
278
294
  status: BridgeStatus;
279
- bridgingId?: string;
295
+ bridgingParams: BridgingDepositParams;
296
+ tradeTxHash: string;
280
297
  explorerUrl?: string;
281
298
  fillTimeInSeconds?: number;
282
299
  }