@cowprotocol/cow-sdk 6.0.0-RC.44 → 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.
- package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +15 -13
- package/dist/bridging/BridgingSdk/findBridgeProviderFromHook.d.ts +2 -0
- package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +12 -8
- package/dist/bridging/BridgingSdk/getQuoteWithBridge.d.ts +1 -5
- package/dist/bridging/const.d.ts +1 -0
- package/dist/bridging/errors.d.ts +4 -0
- package/dist/bridging/index.d.ts +0 -1
- package/dist/bridging/providers/across/AcrossApi.d.ts +4 -1
- package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +7 -12
- package/dist/bridging/providers/across/const/interfaces.d.ts +3 -0
- package/dist/bridging/providers/across/const/misc.d.ts +2 -1
- package/dist/bridging/providers/across/getDepositParams.d.ts +4 -0
- package/dist/bridging/providers/across/types.d.ts +73 -0
- package/dist/bridging/providers/across/util.d.ts +7 -3
- package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +5 -4
- package/dist/bridging/types.d.ts +27 -11
- package/dist/index-4e45cdb3.js +29 -0
- package/dist/index-4e45cdb3.js.map +1 -0
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/dist/index.modern.mjs +1 -1
- package/dist/index.module.js +4 -4
- package/dist/index.module.js.map +1 -1
- package/dist/package.json +1 -1
- package/dist/trading/consts.d.ts +0 -3
- package/dist/trading/getOrderToSign.d.ts +4 -1
- package/dist/trading/getQuote.d.ts +1 -0
- package/dist/trading/suggestSlippageBps.d.ts +1 -0
- package/dist/trading/utils/misc.d.ts +0 -7
- package/dist/trading/utils/slippage.d.ts +3 -0
- package/dist/{utils-84b5bba2.js → utils-2c641bba.js} +1 -1
- package/dist/{utils-84b5bba2.js.map → utils-2c641bba.js.map} +1 -1
- package/dist/{utils-834caecd.js → utils-a4bdf15a.js} +1 -1
- package/dist/{utils-834caecd.js.map → utils-a4bdf15a.js.map} +1 -1
- package/dist/{utils-979cfae5.js → utils-c1446f6a.js} +2 -2
- package/dist/{utils-979cfae5.js.map → utils-c1446f6a.js.map} +1 -1
- package/package.json +1 -1
- package/dist/bridging/BridgingSdk/getErc20Decimals.d.ts +0 -4
- package/dist/index-ceb19ab3.js +0 -29
- package/dist/index-ceb19ab3.js.map +0 -1
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { SwapAdvancedSettings, TradingSdk } from '../../trading';
|
|
2
|
-
import { BridgeProvider, BridgeQuoteResult, CrossChainOrder, CrossChainQuoteAndPost,
|
|
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 {
|
|
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.
|
|
9
10
|
*/
|
|
10
11
|
providers: BridgeProvider<BridgeQuoteResult>[];
|
|
11
|
-
/**
|
|
12
|
-
* Function to get the decimals of the ERC20 tokens
|
|
13
|
-
*/
|
|
14
|
-
getErc20Decimals?: GetErc20Decimals;
|
|
15
12
|
/**
|
|
16
13
|
* Trading SDK.
|
|
17
14
|
*/
|
|
@@ -29,20 +26,24 @@ export interface BridgingSdkOptions {
|
|
|
29
26
|
* Parameters for the `getOrder` method.
|
|
30
27
|
*/
|
|
31
28
|
export interface GetOrderParams {
|
|
29
|
+
/**
|
|
30
|
+
* Id of a network where order was settled
|
|
31
|
+
*/
|
|
32
|
+
chainId: SupportedChainId;
|
|
32
33
|
/**
|
|
33
34
|
* The unique identifier of the order.
|
|
34
35
|
*/
|
|
35
36
|
orderId: string;
|
|
36
37
|
/**
|
|
37
|
-
*
|
|
38
|
+
* RPC provider to get order transactions details
|
|
38
39
|
*/
|
|
39
|
-
|
|
40
|
+
rpcProvider: JsonRpcProvider;
|
|
40
41
|
/**
|
|
41
42
|
* The environment of the order
|
|
42
43
|
*/
|
|
43
44
|
env?: CowEnv;
|
|
44
45
|
}
|
|
45
|
-
export type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging'
|
|
46
|
+
export type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging'>>;
|
|
46
47
|
/**
|
|
47
48
|
* SDK for bridging for swapping tokens between different chains.
|
|
48
49
|
*/
|
|
@@ -65,9 +66,8 @@ export declare class BridgingSdk {
|
|
|
65
66
|
getTargetNetworks(): Promise<ChainInfo[]>;
|
|
66
67
|
/**
|
|
67
68
|
* Get the available buy tokens for buying in a specific target chain
|
|
68
|
-
|
|
69
|
-
* @param
|
|
70
|
-
* @returns
|
|
69
|
+
|
|
70
|
+
* @param targetChainId
|
|
71
71
|
*/
|
|
72
72
|
getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
|
|
73
73
|
/**
|
|
@@ -86,5 +86,7 @@ export declare class BridgingSdk {
|
|
|
86
86
|
* @throws Error if no path is found
|
|
87
87
|
*/
|
|
88
88
|
getQuote(quoteBridgeRequest: QuoteBridgeRequest, advancedSettings?: SwapAdvancedSettings): Promise<CrossChainQuoteAndPost>;
|
|
89
|
-
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;
|
|
90
92
|
}
|
|
@@ -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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
}
|
|
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,5 +1,5 @@
|
|
|
1
1
|
import { SwapAdvancedSettings, TradingSdk } from '../../trading';
|
|
2
|
-
import { BridgeProvider, BridgeQuoteAndPost, BridgeQuoteResult,
|
|
2
|
+
import { BridgeProvider, BridgeQuoteAndPost, BridgeQuoteResult, QuoteBridgeRequest } from '../types';
|
|
3
3
|
import { SignerLike } from '../../common';
|
|
4
4
|
type GetQuoteWithBridgeParams<T extends BridgeQuoteResult> = {
|
|
5
5
|
/**
|
|
@@ -18,10 +18,6 @@ type GetQuoteWithBridgeParams<T extends BridgeQuoteResult> = {
|
|
|
18
18
|
* Trading SDK.
|
|
19
19
|
*/
|
|
20
20
|
tradingSdk: TradingSdk;
|
|
21
|
-
/**
|
|
22
|
-
* Function to get the decimals of the ERC20 tokens.
|
|
23
|
-
*/
|
|
24
|
-
getErc20Decimals: GetErc20Decimals;
|
|
25
21
|
/**
|
|
26
22
|
* For quote fetching we have to sign bridging hooks.
|
|
27
23
|
* But we won't do that using users wallet and will use some static PK.
|
package/dist/bridging/const.d.ts
CHANGED
|
@@ -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
|
+
}
|
package/dist/bridging/index.d.ts
CHANGED
|
@@ -2,5 +2,4 @@ export * from './types';
|
|
|
2
2
|
export * from './errors';
|
|
3
3
|
export * from './utils';
|
|
4
4
|
export * from './BridgingSdk/BridgingSdk';
|
|
5
|
-
export { MockBridgeProvider } from './providers/mock/MockBridgeProvider';
|
|
6
5
|
export { AcrossBridgeProvider, AcrossQuoteResult, AcrossBridgeProviderOptions, } from './providers/across/AcrossBridgeProvider';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AvailableRoutesRequest, Route, SuggestedFeesRequest, SuggestedFeesResponse } from './types';
|
|
1
|
+
import { AvailableRoutesRequest, DepositStatusRequest, DepositStatusResponse, Route, SuggestedFeesRequest, SuggestedFeesResponse } from './types';
|
|
2
|
+
import { TokenInfo } from '../../../common';
|
|
2
3
|
export interface AcrossApiOptions {
|
|
3
4
|
apiBaseUrl?: string;
|
|
4
5
|
}
|
|
@@ -23,5 +24,7 @@ export declare class AcrossApi {
|
|
|
23
24
|
* * See https://docs.across.to/reference/api-reference#suggested-fees
|
|
24
25
|
*/
|
|
25
26
|
getSuggestedFees(request: SuggestedFeesRequest): Promise<SuggestedFeesResponse>;
|
|
27
|
+
getSupportedTokens(): Promise<TokenInfo[]>;
|
|
28
|
+
getDepositStatus(request: DepositStatusRequest): Promise<DepositStatusResponse>;
|
|
26
29
|
protected fetchApi<T>(path: string, params: Record<string, string>, isValidResponse?: (response: unknown) => response is T): Promise<T>;
|
|
27
30
|
}
|
|
@@ -1,20 +1,14 @@
|
|
|
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';
|
|
3
|
+
import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, BridgingDepositParams, QuoteBridgeRequest } from '../../types';
|
|
4
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
|
-
* Token info provider
|
|
13
|
-
* @param chainId - The chain ID
|
|
14
|
-
* @param addresses - The addresses of the tokens to get the info for
|
|
15
|
-
* @returns The token infos
|
|
16
|
-
*/
|
|
17
|
-
getTokenInfos?: (chainId: ChainId, addresses: string[]) => Promise<TokenInfo[]>;
|
|
18
12
|
apiOptions?: AcrossApiOptions;
|
|
19
13
|
cowShedOptions?: CowShedSdkOptions;
|
|
20
14
|
}
|
|
@@ -22,22 +16,23 @@ export interface AcrossQuoteResult extends BridgeQuoteResult {
|
|
|
22
16
|
suggestedFees: SuggestedFeesResponse;
|
|
23
17
|
}
|
|
24
18
|
export declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteResult> {
|
|
25
|
-
private options;
|
|
26
19
|
protected api: AcrossApi;
|
|
27
20
|
protected cowShedSdk: CowShedSdk;
|
|
21
|
+
private supportedTokens;
|
|
28
22
|
constructor(options?: AcrossBridgeProviderOptions);
|
|
29
23
|
info: BridgeProviderInfo;
|
|
30
24
|
getNetworks(): Promise<ChainInfo[]>;
|
|
31
25
|
getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
|
|
32
|
-
getIntermediateTokens(request: QuoteBridgeRequest): Promise<
|
|
26
|
+
getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
|
|
33
27
|
getQuote(request: QuoteBridgeRequest): Promise<AcrossQuoteResult>;
|
|
34
28
|
getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: AcrossQuoteResult): Promise<EvmCall>;
|
|
35
29
|
getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
|
|
36
30
|
getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer, defaultGasLimit?: bigint): Promise<BridgeHook>;
|
|
37
31
|
decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
|
|
38
|
-
|
|
32
|
+
getBridgingParams(chainId: ChainId, provider: JsonRpcProvider, orderUid: string, txHash: string): Promise<BridgingDepositParams | null>;
|
|
39
33
|
getExplorerUrl(bridgingId: string): string;
|
|
40
|
-
getStatus(
|
|
34
|
+
getStatus(bridgingId: string, originChainId: SupportedChainId): Promise<BridgeStatusResult>;
|
|
41
35
|
getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
42
36
|
getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
37
|
+
private getSupportedTokensState;
|
|
43
38
|
}
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare const
|
|
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 {
|
|
2
|
-
import {
|
|
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,19 +1,20 @@
|
|
|
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[]>;
|
|
9
10
|
getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
|
|
10
|
-
getIntermediateTokens({ sellTokenChainId }: QuoteBridgeRequest): Promise<
|
|
11
|
+
getIntermediateTokens({ sellTokenChainId }: QuoteBridgeRequest): Promise<TokenInfo[]>;
|
|
11
12
|
getQuote(_request: QuoteBridgeRequest): Promise<BridgeQuoteResult>;
|
|
12
13
|
getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
|
|
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
|
-
|
|
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>;
|
package/dist/bridging/types.d.ts
CHANGED
|
@@ -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
|
-
|
|
85
|
-
|
|
85
|
+
EXPIRED = "expired",
|
|
86
|
+
REFUND = "refund"
|
|
86
87
|
}
|
|
87
88
|
export interface BridgeStatusResult {
|
|
88
89
|
status: BridgeStatus;
|
|
@@ -117,7 +118,7 @@ export interface BridgeProvider<Q extends BridgeQuoteResult> {
|
|
|
117
118
|
*
|
|
118
119
|
* @param request - The quote request
|
|
119
120
|
*/
|
|
120
|
-
getIntermediateTokens(request: QuoteBridgeRequest): Promise<
|
|
121
|
+
getIntermediateTokens(request: QuoteBridgeRequest): Promise<TokenInfo[]>;
|
|
121
122
|
/**
|
|
122
123
|
* Get a quote for a bridge request.
|
|
123
124
|
*
|
|
@@ -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
|
|
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
|
-
|
|
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,12 +275,25 @@ export interface BridgeQuoteResults extends BridgeQuoteResult {
|
|
|
272
275
|
*/
|
|
273
276
|
bridgeCallDetails: BridgeCallDetails;
|
|
274
277
|
}
|
|
275
|
-
export
|
|
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
|
+
}
|
|
276
291
|
export interface CrossChainOrder {
|
|
277
292
|
chainId: SupportedChainId;
|
|
278
293
|
order: EnrichedOrder;
|
|
279
294
|
status: BridgeStatus;
|
|
280
|
-
|
|
295
|
+
bridgingParams: BridgingDepositParams;
|
|
296
|
+
tradeTxHash: string;
|
|
281
297
|
explorerUrl?: string;
|
|
282
298
|
fillTimeInSeconds?: number;
|
|
283
299
|
}
|