@cowprotocol/cow-sdk 6.0.0-RC.7 → 6.0.0-RC.9

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.
@@ -49,7 +49,13 @@ export declare class BridgingSdk {
49
49
  *
50
50
  * This method support both, cross-chain swaps and single-chain swap.
51
51
  *
52
- * The return type will be either `QuoteAndPost` or `BridgeQuoteAndPost`. To safely assert the type in Typescript, you can use `isBridgeQuoteAndPost(result)` utility.
52
+ * The return type will be either `QuoteAndPost` or `BridgeQuoteAndPost`.
53
+ *
54
+ * To safely assert the type in Typescript, you can use:
55
+ * - `isBridgeQuoteAndPost(result)` utility.
56
+ * - `isQuoteAndPost(result)` utility.
57
+ * - `assertIsBridgeQuoteAndPost(result)` assertion.
58
+ * - `assertIsQuoteAndPost(result)` assertion.
53
59
  *
54
60
  * @throws Error if no path is found
55
61
  */
@@ -9,29 +9,28 @@ export interface BridgeProviderInfo {
9
9
  name: string;
10
10
  logoUrl: string;
11
11
  }
12
- export interface WithSellToken {
12
+ export interface GetBuyTokensParams extends Partial<WithSellToken> {
13
+ targetChainId: TargetChainId;
14
+ }
15
+ interface WithSellToken {
13
16
  sellTokenChainId: SupportedChainId;
14
17
  sellTokenAddress: Address;
15
18
  sellTokenDecimals: number;
16
19
  }
17
- export interface WithBuyToken {
20
+ interface WithBuyToken {
18
21
  buyTokenChainId: TargetChainId;
19
22
  buyTokenAddress: Address;
20
23
  buyTokenDecimals: number;
21
24
  }
22
- export interface GetBuyTokensParams extends Partial<WithSellToken> {
23
- targetChainId: TargetChainId;
24
- }
25
+ type WithQuoter = Omit<QuoterParameters, 'chainId'>;
26
+ type WithTrader = Pick<TraderParameters, 'signer'>;
25
27
  /**
26
28
  * Parameters for getting a bridge quote
27
29
  */
28
- export interface QuoteBridgeRequest extends WithSellToken, WithBuyToken, TradeOptionalParameters, Omit<QuoterParameters, 'chainId'>, Pick<TraderParameters, 'signer'> {
30
+ export type QuoteBridgeRequest = {
29
31
  kind: OrderKind.SELL;
30
32
  amount: bigint;
31
- recipient?: string;
32
- feeBps?: number;
33
- feeRecipient?: string;
34
- }
33
+ } & WithSellToken & WithBuyToken & WithQuoter & WithTrader & TradeOptionalParameters;
35
34
  export type QuoteBridgeRequestWithoutAmount = Omit<QuoteBridgeRequest, 'amount'>;
36
35
  export interface BridgeQuoteResult {
37
36
  /**
@@ -199,7 +198,6 @@ export interface BridgeCosts<T = bigint> {
199
198
  amountInSellCurrency: T;
200
199
  amountInBuyCurrency: T;
201
200
  };
202
- slippageBps: number;
203
201
  }
204
202
  export interface BridgeQuoteAmountsAndCosts<T = bigint> {
205
203
  /**
@@ -220,6 +218,10 @@ export interface BridgeQuoteAmountsAndCosts<T = bigint> {
220
218
  * It includes the fees and the slippage tolerance, so its the minimum amount that the user will receive.
221
219
  */
222
220
  afterSlippage: Amounts<T>;
221
+ /**
222
+ * The slippage tolerance in basis points.
223
+ */
224
+ slippageBps: number;
223
225
  }
224
226
  export interface BridgeQuoteResults extends BridgeQuoteResult {
225
227
  /**
@@ -227,17 +229,23 @@ export interface BridgeQuoteResults extends BridgeQuoteResult {
227
229
  */
228
230
  providerInfo: BridgeProviderInfo;
229
231
  /**
230
- * Unsigned call to initiate the bridge. This call should be executed in the context of user's cow-shed account.
232
+ * Trade parameters
231
233
  */
232
- unsignedBridgeCall: EvmCall;
234
+ tradeParameters: QuoteBridgeRequest;
233
235
  /**
234
- * Pre-authorized hook to initiate the bridge. This hook has been signed, and is ready to be executed by the
235
- * CoW Protocol Trampoline contract after settling the swap order that buys the intermediate token.
236
+ * Bridge call details
236
237
  */
237
- preAuthorizedBridgingHook: BridgeHook;
238
- /**
239
- * Information about the quote response from the order book API.
240
- */
241
- quoteResponse: BridgeQuoteResult;
238
+ bridgeCallDetails: {
239
+ /**
240
+ * Unsigned call to initiate the bridge. This call should be executed in the context of user's cow-shed account.
241
+ */
242
+ unsignedBridgeCall: EvmCall;
243
+ /**
244
+ * Pre-authorized hook to initiate the bridge. This hook has been signed, and is ready to be executed by the
245
+ * CoW Protocol Trampoline contract after settling the swap order that buys the intermediate token.
246
+ */
247
+ preAuthorizedBridgingHook: BridgeHook;
248
+ };
242
249
  }
243
250
  export type GetErc20Decimals = (chainId: TargetChainId, tokenAddress: string) => Promise<number>;
251
+ export {};
@@ -1,2 +1,6 @@
1
+ import { QuoteAndPost } from '../trading';
1
2
  import { BridgeQuoteAndPost, CrossChainQuoteAndPost } from './types';
2
3
  export declare function isBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): quote is BridgeQuoteAndPost;
4
+ export declare function isQuoteAndPost(quote: CrossChainQuoteAndPost): quote is QuoteAndPost;
5
+ export declare function assertIsBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is BridgeQuoteAndPost;
6
+ export declare function assertIsQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is QuoteAndPost;