@cowprotocol/cow-sdk 6.0.0-RC.31 → 6.0.0-RC.33
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 +26 -3
- package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +14 -0
- package/dist/bridging/errors.d.ts +4 -0
- package/dist/bridging/index.d.ts +1 -0
- package/dist/bridging/providers/across/AcrossApi.d.ts +1 -169
- package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +5 -3
- package/dist/bridging/providers/across/const/misc.d.ts +1 -0
- package/dist/bridging/providers/across/types.d.ts +169 -0
- package/dist/bridging/providers/across/util.d.ts +1 -1
- package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +3 -2
- package/dist/bridging/types.d.ts +36 -3
- package/dist/bridging/utils.d.ts +3 -0
- package/dist/index-e14528d2.js +29 -0
- package/dist/index-e14528d2.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/{utils-006b4f6f.js → utils-7c0fb70b.js} +1 -1
- package/dist/{utils-006b4f6f.js.map → utils-7c0fb70b.js.map} +1 -1
- package/dist/{utils-2fcbdd1a.js → utils-89cc145e.js} +2 -2
- package/dist/{utils-2fcbdd1a.js.map → utils-89cc145e.js.map} +1 -1
- package/dist/{utils-f21515d0.js → utils-aa9fa7e1.js} +1 -1
- package/dist/{utils-f21515d0.js.map → utils-aa9fa7e1.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-39086c67.js +0 -29
- package/dist/index-39086c67.js.map +0 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SwapAdvancedSettings, TradingSdk } from '../../trading';
|
|
2
|
-
import { BridgeProvider, BridgeQuoteResult, CrossChainQuoteAndPost, GetErc20Decimals, QuoteBridgeRequest } from '../types';
|
|
3
|
-
import { TokenInfo } from '../../common';
|
|
4
|
-
import { ChainInfo, TargetChainId } from '../../chains';
|
|
2
|
+
import { BridgeProvider, BridgeQuoteResult, CrossChainOrder, CrossChainQuoteAndPost, GetErc20Decimals, QuoteBridgeRequest } from '../types';
|
|
3
|
+
import { CowEnv, TokenInfo } from '../../common';
|
|
4
|
+
import { ChainInfo, SupportedChainId, TargetChainId } from '../../chains';
|
|
5
|
+
import { OrderBookApi } from 'src/order-book';
|
|
5
6
|
export interface BridgingSdkOptions {
|
|
6
7
|
/**
|
|
7
8
|
* Providers for the bridging.
|
|
@@ -15,11 +16,32 @@ export interface BridgingSdkOptions {
|
|
|
15
16
|
* Trading SDK.
|
|
16
17
|
*/
|
|
17
18
|
tradingSdk?: TradingSdk;
|
|
19
|
+
/**
|
|
20
|
+
* Order book API.
|
|
21
|
+
*/
|
|
22
|
+
orderBookApi: OrderBookApi;
|
|
18
23
|
/**
|
|
19
24
|
* Enable logging for the bridging SDK.
|
|
20
25
|
*/
|
|
21
26
|
enableLogging?: boolean;
|
|
22
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Parameters for the `getOrder` method.
|
|
30
|
+
*/
|
|
31
|
+
export interface GetOrderParams {
|
|
32
|
+
/**
|
|
33
|
+
* The unique identifier of the order.
|
|
34
|
+
*/
|
|
35
|
+
orderId: string;
|
|
36
|
+
/**
|
|
37
|
+
* The chain ID of the order.
|
|
38
|
+
*/
|
|
39
|
+
chainId: SupportedChainId;
|
|
40
|
+
/**
|
|
41
|
+
* The environment of the order
|
|
42
|
+
*/
|
|
43
|
+
env?: CowEnv;
|
|
44
|
+
}
|
|
23
45
|
export type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging' | 'getErc20Decimals'>> & Pick<BridgingSdkOptions, 'getErc20Decimals'>;
|
|
24
46
|
/**
|
|
25
47
|
* SDK for bridging for swapping tokens between different chains.
|
|
@@ -64,4 +86,5 @@ export declare class BridgingSdk {
|
|
|
64
86
|
* @throws Error if no path is found
|
|
65
87
|
*/
|
|
66
88
|
getQuote(quoteBridgeRequest: QuoteBridgeRequest, advancedSettings?: SwapAdvancedSettings): Promise<CrossChainQuoteAndPost>;
|
|
89
|
+
getOrder(params: GetOrderParams): Promise<CrossChainOrder>;
|
|
67
90
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { BridgeProvider, BridgeQuoteResult, CrossChainOrder } from '../types';
|
|
2
|
+
import { SupportedChainId } from '../../chains';
|
|
3
|
+
import { OrderBookApi } from 'src/order-book';
|
|
4
|
+
import { CowEnv } from '../../common';
|
|
5
|
+
/**
|
|
6
|
+
* Fetch a cross-chain order and its status.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getCrossChainOrder(params: {
|
|
9
|
+
orderId: string;
|
|
10
|
+
chainId: SupportedChainId;
|
|
11
|
+
orderBookApi: OrderBookApi;
|
|
12
|
+
providers: BridgeProvider<BridgeQuoteResult>[];
|
|
13
|
+
env: CowEnv;
|
|
14
|
+
}): Promise<CrossChainOrder>;
|
package/dist/bridging/index.d.ts
CHANGED
|
@@ -1,172 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export interface AvailableRoutesRequest {
|
|
3
|
-
originChainId: string;
|
|
4
|
-
originToken: string;
|
|
5
|
-
destinationChainId: string;
|
|
6
|
-
destinationToken: string;
|
|
7
|
-
}
|
|
8
|
-
export interface Route {
|
|
9
|
-
originChainId: string;
|
|
10
|
-
originToken: string;
|
|
11
|
-
destinationChainId: string;
|
|
12
|
-
destinationToken: string;
|
|
13
|
-
originTokenSymbol: string;
|
|
14
|
-
destinationTokenSymbol: string;
|
|
15
|
-
}
|
|
16
|
-
export interface SuggestedFeesRequest {
|
|
17
|
-
token: string;
|
|
18
|
-
originChainId: TargetChainId;
|
|
19
|
-
destinationChainId: TargetChainId;
|
|
20
|
-
/**
|
|
21
|
-
* Amount of the token to transfer.
|
|
22
|
-
*
|
|
23
|
-
* Note that this amount is in the native decimals of the token. So, for WETH, this would be the amount of
|
|
24
|
-
* human-readable WETH multiplied by 1e18.
|
|
25
|
-
*
|
|
26
|
-
* For USDC, you would multiply the number of human-readable USDC by 1e6.
|
|
27
|
-
*
|
|
28
|
-
* Example: 1000000000000000000
|
|
29
|
-
*/
|
|
30
|
-
amount: bigint;
|
|
31
|
-
/**
|
|
32
|
-
* Recipient of the deposit. Can be an EOA or a contract. If this is an EOA and message is defined, then the API will throw a 4xx error.
|
|
33
|
-
*
|
|
34
|
-
* Example: 0xc186fA914353c44b2E33eBE05f21846F1048bEda
|
|
35
|
-
*/
|
|
36
|
-
recipient?: string;
|
|
37
|
-
/**
|
|
38
|
-
* The quote timestamp used to compute the LP fees. When bridging with across, the user only specifies the quote
|
|
39
|
-
* timestamp in their transaction. The relayer then determines the utilization at that timestamp to determine the
|
|
40
|
-
* user's fee. This timestamp must be close (within 10 minutes or so) to the current time on the chain where the
|
|
41
|
-
* user is depositing funds and it should be <= the current block timestamp on mainnet. This allows the user to know
|
|
42
|
-
* exactly what LP fee they will pay before sending the transaction.
|
|
43
|
-
*
|
|
44
|
-
* If this value isn't provided in the request, the API will assume the latest block timestamp on mainnet.
|
|
45
|
-
*
|
|
46
|
-
* Example: 1653547649
|
|
47
|
-
*/
|
|
48
|
-
timestamp?: number;
|
|
49
|
-
/**
|
|
50
|
-
* Optionally override the relayer address used to simulate the fillRelay() call that estimates the gas costs
|
|
51
|
-
* needed to fill a deposit. This simulation result impacts the returned suggested-fees. The reason to customize the
|
|
52
|
-
* EOA would be primarily if the recipientAddress is a contract and requires a certain relayer to submit the fill,
|
|
53
|
-
* or if one specific relayer has the necessary token balance to make the fill.
|
|
54
|
-
*
|
|
55
|
-
* Example: 0x428AB2BA90Eba0a4Be7aF34C9Ac451ab061AC010
|
|
56
|
-
*/
|
|
57
|
-
relayer?: string;
|
|
58
|
-
}
|
|
59
|
-
export interface SuggestedFeesLimits {
|
|
60
|
-
/**
|
|
61
|
-
* The minimum deposit size in the tokens' units.
|
|
62
|
-
*
|
|
63
|
-
* Note: USDC has 6 decimals, so this value would be the number of USDC multiplied by 1e6. For WETH, that would be 1e18.
|
|
64
|
-
*/
|
|
65
|
-
minDeposit: string;
|
|
66
|
-
/**
|
|
67
|
-
* The maximum deposit size in the tokens' units. Note: The formatting of this number is the same as minDeposit.
|
|
68
|
-
*/
|
|
69
|
-
maxDeposit: string;
|
|
70
|
-
/**
|
|
71
|
-
* The max deposit size that can be relayed "instantly" on the destination chain.
|
|
72
|
-
*
|
|
73
|
-
* Instantly means that there is relayer capital readily available and that a relayer is expected to relay within
|
|
74
|
-
* seconds to 5 minutes of the deposit.
|
|
75
|
-
*/
|
|
76
|
-
maxDepositInstant: string;
|
|
77
|
-
/**
|
|
78
|
-
* The max deposit size that can be relayed with a "short delay" on the destination chain.
|
|
79
|
-
*
|
|
80
|
-
* This means that there is relayer capital available on mainnet and that a relayer will immediately begin moving
|
|
81
|
-
* that capital over the canonical bridge to relay the deposit. Depending on the chain, the time for this can vary.
|
|
82
|
-
*
|
|
83
|
-
* Polygon is the worst case where it can take between 20 and 35 minutes for the relayer to receive the funds
|
|
84
|
-
* and relay.
|
|
85
|
-
*
|
|
86
|
-
* Arbitrum is much faster, with a range between 5 and 15 minutes. Note: if the transfer size is greater than this,
|
|
87
|
-
* the estimate should be between 2-4 hours for a slow relay to be processed from the mainnet pool.
|
|
88
|
-
*/
|
|
89
|
-
maxDepositShortDelay: string;
|
|
90
|
-
/**
|
|
91
|
-
* The recommended deposit size that can be relayed "instantly" on the destination chain.
|
|
92
|
-
*
|
|
93
|
-
* Instantly means that there is relayer capital readily available and that a relayer is expected to relay
|
|
94
|
-
* within seconds to 5 minutes of the deposit. Value is in the smallest unit of the respective token.
|
|
95
|
-
*/
|
|
96
|
-
recommendedDepositInstant: string;
|
|
97
|
-
}
|
|
98
|
-
export interface SuggestedFeesResponse {
|
|
99
|
-
/**
|
|
100
|
-
* Percentage of the transfer amount that should go to the relayer as a fee in total. The value is inclusive of lpFee.pct.
|
|
101
|
-
*
|
|
102
|
-
* This is the strongly recommended minimum value to ensure a relayer will perform the transfer under the current
|
|
103
|
-
* network conditions.
|
|
104
|
-
*
|
|
105
|
-
* The value returned in this field is guaranteed to be at least 0.03% in order to meet minimum relayer fee requirements
|
|
106
|
-
*/
|
|
107
|
-
totalRelayFee: PctFee;
|
|
108
|
-
/**
|
|
109
|
-
* The percentage of the transfer amount that should go the relayer as a fee to cover relayer capital costs.
|
|
110
|
-
*/
|
|
111
|
-
relayerCapitalFee: PctFee;
|
|
112
|
-
/**
|
|
113
|
-
* The percentage of the transfer amount that should go the relayer as a fee to cover relayer gas costs.
|
|
114
|
-
*/
|
|
115
|
-
relayerGasFee: PctFee;
|
|
116
|
-
/**
|
|
117
|
-
* The percent of the amount that will go to the LPs as a fee for borrowing their funds.
|
|
118
|
-
*/
|
|
119
|
-
lpFee: PctFee;
|
|
120
|
-
/**
|
|
121
|
-
* The quote timestamp that was used to compute the lpFeePct. To pay the quoted LP fee, the user would need to pass
|
|
122
|
-
* this quote timestamp to the protocol when sending their bridge transaction.
|
|
123
|
-
*/
|
|
124
|
-
timestamp: string;
|
|
125
|
-
/**
|
|
126
|
-
* Is the input amount below the minimum transfer amount.
|
|
127
|
-
*/
|
|
128
|
-
isAmountTooLow: boolean;
|
|
129
|
-
/**
|
|
130
|
-
* The block used associated with this quote, used to compute lpFeePct.
|
|
131
|
-
*/
|
|
132
|
-
quoteBlock: string;
|
|
133
|
-
/**
|
|
134
|
-
* The contract address of the origin SpokePool.
|
|
135
|
-
*/
|
|
136
|
-
spokePoolAddress: string;
|
|
137
|
-
/**
|
|
138
|
-
* The relayer that is suggested to be set as the exclusive relayer for in the depositV3 call for the fastest fill.
|
|
139
|
-
*
|
|
140
|
-
* Note: when set to "0x0000000000000000000000000000000000000000", relayer exclusivity will be disabled.
|
|
141
|
-
* This value is returned in cases where using an exclusive relayer is not recommended.
|
|
142
|
-
*/
|
|
143
|
-
exclusiveRelayer: string;
|
|
144
|
-
/**
|
|
145
|
-
* The suggested exclusivity period (in seconds) the exclusive relayer should be given to fill before other relayers
|
|
146
|
-
* are allowed to take the fill. Note: when set to "0", relayer exclusivity will be disabled.
|
|
147
|
-
*
|
|
148
|
-
* This value is returned in cases where using an exclusive relayer is not recommended.
|
|
149
|
-
*/
|
|
150
|
-
exclusivityDeadline: string;
|
|
151
|
-
/**
|
|
152
|
-
* The expected time (in seconds) for a fill to be made. Represents 75th percentile of the 7-day rolling average of times (updated daily). Times are dynamic by origin/destination token/chain for a given amount.
|
|
153
|
-
*/
|
|
154
|
-
estimatedFillTimeSec: string;
|
|
155
|
-
/**
|
|
156
|
-
* The recommended deadline (UNIX timestamp in seconds) for the relayer to fill the deposit. After this destination chain timestamp, the fill will revert on the destination chain.
|
|
157
|
-
*/
|
|
158
|
-
fillDeadline: string;
|
|
159
|
-
limits: SuggestedFeesLimits;
|
|
160
|
-
}
|
|
161
|
-
export interface PctFee {
|
|
162
|
-
/**
|
|
163
|
-
* Note: 1% is represented as 1e16, 100% is 1e18, 50% is 5e17, etc. These values are in the same format that the contract understands.
|
|
164
|
-
*
|
|
165
|
-
* Example: 100200000000000
|
|
166
|
-
*/
|
|
167
|
-
pct: string;
|
|
168
|
-
total: string;
|
|
169
|
-
}
|
|
1
|
+
import { AvailableRoutesRequest, Route, SuggestedFeesRequest, SuggestedFeesResponse } from './types';
|
|
170
2
|
export interface AcrossApiOptions {
|
|
171
3
|
apiBaseUrl?: string;
|
|
172
4
|
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
+
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
2
3
|
import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, QuoteBridgeRequest } from '../../types';
|
|
3
4
|
import { ChainId, ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
|
|
4
5
|
import { EvmCall, TokenInfo } from '../../../common';
|
|
5
|
-
import { AcrossApi, AcrossApiOptions
|
|
6
|
+
import { AcrossApi, AcrossApiOptions } from './AcrossApi';
|
|
6
7
|
import { CowShedSdk, CowShedSdkOptions } from '../../../cow-shed';
|
|
8
|
+
import { SuggestedFeesResponse } from './types';
|
|
7
9
|
export declare const ACROSS_SUPPORTED_NETWORKS: ChainInfo[];
|
|
8
10
|
export interface AcrossBridgeProviderOptions {
|
|
9
11
|
/**
|
|
@@ -32,8 +34,8 @@ export declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteR
|
|
|
32
34
|
getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: AcrossQuoteResult): Promise<EvmCall>;
|
|
33
35
|
getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
|
|
34
36
|
getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer): Promise<BridgeHook>;
|
|
35
|
-
decodeBridgeHook(_hook:
|
|
36
|
-
getBridgingId(_orderUid: string, _settlementTx: string): Promise<string>;
|
|
37
|
+
decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
|
|
38
|
+
getBridgingId(_orderUid: string, _settlementTx: string, _logIndex: number): Promise<string>;
|
|
37
39
|
getExplorerUrl(bridgingId: string): string;
|
|
38
40
|
getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
|
|
39
41
|
getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { TargetChainId } from '../../../chains';
|
|
2
|
+
export interface AvailableRoutesRequest {
|
|
3
|
+
originChainId: string;
|
|
4
|
+
originToken: string;
|
|
5
|
+
destinationChainId: string;
|
|
6
|
+
destinationToken: string;
|
|
7
|
+
}
|
|
8
|
+
export interface Route {
|
|
9
|
+
originChainId: string;
|
|
10
|
+
originToken: string;
|
|
11
|
+
destinationChainId: string;
|
|
12
|
+
destinationToken: string;
|
|
13
|
+
originTokenSymbol: string;
|
|
14
|
+
destinationTokenSymbol: string;
|
|
15
|
+
}
|
|
16
|
+
export interface SuggestedFeesRequest {
|
|
17
|
+
token: string;
|
|
18
|
+
originChainId: TargetChainId;
|
|
19
|
+
destinationChainId: TargetChainId;
|
|
20
|
+
/**
|
|
21
|
+
* Amount of the token to transfer.
|
|
22
|
+
*
|
|
23
|
+
* Note that this amount is in the native decimals of the token. So, for WETH, this would be the amount of
|
|
24
|
+
* human-readable WETH multiplied by 1e18.
|
|
25
|
+
*
|
|
26
|
+
* For USDC, you would multiply the number of human-readable USDC by 1e6.
|
|
27
|
+
*
|
|
28
|
+
* Example: 1000000000000000000
|
|
29
|
+
*/
|
|
30
|
+
amount: bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Recipient of the deposit. Can be an EOA or a contract. If this is an EOA and message is defined, then the API will throw a 4xx error.
|
|
33
|
+
*
|
|
34
|
+
* Example: 0xc186fA914353c44b2E33eBE05f21846F1048bEda
|
|
35
|
+
*/
|
|
36
|
+
recipient?: string;
|
|
37
|
+
/**
|
|
38
|
+
* The quote timestamp used to compute the LP fees. When bridging with across, the user only specifies the quote
|
|
39
|
+
* timestamp in their transaction. The relayer then determines the utilization at that timestamp to determine the
|
|
40
|
+
* user's fee. This timestamp must be close (within 10 minutes or so) to the current time on the chain where the
|
|
41
|
+
* user is depositing funds and it should be <= the current block timestamp on mainnet. This allows the user to know
|
|
42
|
+
* exactly what LP fee they will pay before sending the transaction.
|
|
43
|
+
*
|
|
44
|
+
* If this value isn't provided in the request, the API will assume the latest block timestamp on mainnet.
|
|
45
|
+
*
|
|
46
|
+
* Example: 1653547649
|
|
47
|
+
*/
|
|
48
|
+
timestamp?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Optionally override the relayer address used to simulate the fillRelay() call that estimates the gas costs
|
|
51
|
+
* needed to fill a deposit. This simulation result impacts the returned suggested-fees. The reason to customize the
|
|
52
|
+
* EOA would be primarily if the recipientAddress is a contract and requires a certain relayer to submit the fill,
|
|
53
|
+
* or if one specific relayer has the necessary token balance to make the fill.
|
|
54
|
+
*
|
|
55
|
+
* Example: 0x428AB2BA90Eba0a4Be7aF34C9Ac451ab061AC010
|
|
56
|
+
*/
|
|
57
|
+
relayer?: string;
|
|
58
|
+
}
|
|
59
|
+
export interface SuggestedFeesLimits {
|
|
60
|
+
/**
|
|
61
|
+
* The minimum deposit size in the tokens' units.
|
|
62
|
+
*
|
|
63
|
+
* Note: USDC has 6 decimals, so this value would be the number of USDC multiplied by 1e6. For WETH, that would be 1e18.
|
|
64
|
+
*/
|
|
65
|
+
minDeposit: string;
|
|
66
|
+
/**
|
|
67
|
+
* The maximum deposit size in the tokens' units. Note: The formatting of this number is the same as minDeposit.
|
|
68
|
+
*/
|
|
69
|
+
maxDeposit: string;
|
|
70
|
+
/**
|
|
71
|
+
* The max deposit size that can be relayed "instantly" on the destination chain.
|
|
72
|
+
*
|
|
73
|
+
* Instantly means that there is relayer capital readily available and that a relayer is expected to relay within
|
|
74
|
+
* seconds to 5 minutes of the deposit.
|
|
75
|
+
*/
|
|
76
|
+
maxDepositInstant: string;
|
|
77
|
+
/**
|
|
78
|
+
* The max deposit size that can be relayed with a "short delay" on the destination chain.
|
|
79
|
+
*
|
|
80
|
+
* This means that there is relayer capital available on mainnet and that a relayer will immediately begin moving
|
|
81
|
+
* that capital over the canonical bridge to relay the deposit. Depending on the chain, the time for this can vary.
|
|
82
|
+
*
|
|
83
|
+
* Polygon is the worst case where it can take between 20 and 35 minutes for the relayer to receive the funds
|
|
84
|
+
* and relay.
|
|
85
|
+
*
|
|
86
|
+
* Arbitrum is much faster, with a range between 5 and 15 minutes. Note: if the transfer size is greater than this,
|
|
87
|
+
* the estimate should be between 2-4 hours for a slow relay to be processed from the mainnet pool.
|
|
88
|
+
*/
|
|
89
|
+
maxDepositShortDelay: string;
|
|
90
|
+
/**
|
|
91
|
+
* The recommended deposit size that can be relayed "instantly" on the destination chain.
|
|
92
|
+
*
|
|
93
|
+
* Instantly means that there is relayer capital readily available and that a relayer is expected to relay
|
|
94
|
+
* within seconds to 5 minutes of the deposit. Value is in the smallest unit of the respective token.
|
|
95
|
+
*/
|
|
96
|
+
recommendedDepositInstant: string;
|
|
97
|
+
}
|
|
98
|
+
export interface SuggestedFeesResponse {
|
|
99
|
+
/**
|
|
100
|
+
* Percentage of the transfer amount that should go to the relayer as a fee in total. The value is inclusive of lpFee.pct.
|
|
101
|
+
*
|
|
102
|
+
* This is the strongly recommended minimum value to ensure a relayer will perform the transfer under the current
|
|
103
|
+
* network conditions.
|
|
104
|
+
*
|
|
105
|
+
* The value returned in this field is guaranteed to be at least 0.03% in order to meet minimum relayer fee requirements
|
|
106
|
+
*/
|
|
107
|
+
totalRelayFee: PctFee;
|
|
108
|
+
/**
|
|
109
|
+
* The percentage of the transfer amount that should go the relayer as a fee to cover relayer capital costs.
|
|
110
|
+
*/
|
|
111
|
+
relayerCapitalFee: PctFee;
|
|
112
|
+
/**
|
|
113
|
+
* The percentage of the transfer amount that should go the relayer as a fee to cover relayer gas costs.
|
|
114
|
+
*/
|
|
115
|
+
relayerGasFee: PctFee;
|
|
116
|
+
/**
|
|
117
|
+
* The percent of the amount that will go to the LPs as a fee for borrowing their funds.
|
|
118
|
+
*/
|
|
119
|
+
lpFee: PctFee;
|
|
120
|
+
/**
|
|
121
|
+
* The quote timestamp that was used to compute the lpFeePct. To pay the quoted LP fee, the user would need to pass
|
|
122
|
+
* this quote timestamp to the protocol when sending their bridge transaction.
|
|
123
|
+
*/
|
|
124
|
+
timestamp: string;
|
|
125
|
+
/**
|
|
126
|
+
* Is the input amount below the minimum transfer amount.
|
|
127
|
+
*/
|
|
128
|
+
isAmountTooLow: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* The block used associated with this quote, used to compute lpFeePct.
|
|
131
|
+
*/
|
|
132
|
+
quoteBlock: string;
|
|
133
|
+
/**
|
|
134
|
+
* The contract address of the origin SpokePool.
|
|
135
|
+
*/
|
|
136
|
+
spokePoolAddress: string;
|
|
137
|
+
/**
|
|
138
|
+
* The relayer that is suggested to be set as the exclusive relayer for in the depositV3 call for the fastest fill.
|
|
139
|
+
*
|
|
140
|
+
* Note: when set to "0x0000000000000000000000000000000000000000", relayer exclusivity will be disabled.
|
|
141
|
+
* This value is returned in cases where using an exclusive relayer is not recommended.
|
|
142
|
+
*/
|
|
143
|
+
exclusiveRelayer: string;
|
|
144
|
+
/**
|
|
145
|
+
* The suggested exclusivity period (in seconds) the exclusive relayer should be given to fill before other relayers
|
|
146
|
+
* are allowed to take the fill. Note: when set to "0", relayer exclusivity will be disabled.
|
|
147
|
+
*
|
|
148
|
+
* This value is returned in cases where using an exclusive relayer is not recommended.
|
|
149
|
+
*/
|
|
150
|
+
exclusivityDeadline: string;
|
|
151
|
+
/**
|
|
152
|
+
* The expected time (in seconds) for a fill to be made. Represents 75th percentile of the 7-day rolling average of times (updated daily). Times are dynamic by origin/destination token/chain for a given amount.
|
|
153
|
+
*/
|
|
154
|
+
estimatedFillTimeSec: string;
|
|
155
|
+
/**
|
|
156
|
+
* The recommended deadline (UNIX timestamp in seconds) for the relayer to fill the deposit. After this destination chain timestamp, the fill will revert on the destination chain.
|
|
157
|
+
*/
|
|
158
|
+
fillDeadline: string;
|
|
159
|
+
limits: SuggestedFeesLimits;
|
|
160
|
+
}
|
|
161
|
+
export interface PctFee {
|
|
162
|
+
/**
|
|
163
|
+
* Note: 1% is represented as 1e16, 100% is 1e18, 50% is 5e17, etc. These values are in the same format that the contract understands.
|
|
164
|
+
*
|
|
165
|
+
* Example: 100200000000000
|
|
166
|
+
*/
|
|
167
|
+
pct: string;
|
|
168
|
+
total: string;
|
|
169
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { QuoteBridgeRequest } from '../../../bridging/types';
|
|
2
2
|
import { TargetChainId } from '../../../chains';
|
|
3
|
-
import { SuggestedFeesResponse } from './AcrossApi';
|
|
4
3
|
import { AcrossQuoteResult } from './AcrossBridgeProvider';
|
|
5
4
|
import { AcrossChainConfig } from './const/tokens';
|
|
5
|
+
import { SuggestedFeesResponse } from './types';
|
|
6
6
|
/**
|
|
7
7
|
* Return the chain configs
|
|
8
8
|
*
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
1
2
|
import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, QuoteBridgeRequest } from '../../types';
|
|
2
3
|
import { EvmCall, TokenInfo } from '../../../common';
|
|
3
4
|
import { ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
|
|
@@ -11,8 +12,8 @@ export declare class MockBridgeProvider implements BridgeProvider<BridgeQuoteRes
|
|
|
11
12
|
getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
|
|
12
13
|
getUnsignedBridgeCall(_request: QuoteBridgeRequest, _quote: BridgeQuoteResult): Promise<EvmCall>;
|
|
13
14
|
getSignedHook(_chainId: SupportedChainId, _unsignedCall: EvmCall, _signer: Signer): Promise<BridgeHook>;
|
|
14
|
-
decodeBridgeHook(_hook:
|
|
15
|
-
getBridgingId(_orderUid: string, _settlementTx: string): Promise<string>;
|
|
15
|
+
decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
|
|
16
|
+
getBridgingId(_orderUid: string, _settlementTx: string, _logIndex: number): Promise<string>;
|
|
16
17
|
getExplorerUrl(bridgingId: string): string;
|
|
17
18
|
getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
|
|
18
19
|
getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
|
package/dist/bridging/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
2
2
|
import { ChainInfo, SupportedChainId, TargetChainId } from '../chains';
|
|
3
3
|
import { TokenInfo } from '../common/types/tokens';
|
|
4
|
-
import { Address, Amounts, OrderKind } from '../order-book';
|
|
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, TradeOptionalParameters, TraderParameters } from '../trading';
|
|
@@ -48,6 +48,30 @@ export interface BridgeQuoteResult {
|
|
|
48
48
|
* The timestamp of the quote.
|
|
49
49
|
*/
|
|
50
50
|
quoteTimestamp: number;
|
|
51
|
+
fees: {
|
|
52
|
+
/**
|
|
53
|
+
* The amount that should go to the relayer as a fee to cover relayer capital costs.
|
|
54
|
+
* In token atoms.
|
|
55
|
+
*/
|
|
56
|
+
bridgeFee: bigint;
|
|
57
|
+
/**
|
|
58
|
+
* The amount that should go to the relayer as a fee to cover relayer gas costs.
|
|
59
|
+
* In token atoms.
|
|
60
|
+
*/
|
|
61
|
+
destinationGasFee: bigint;
|
|
62
|
+
};
|
|
63
|
+
limits: {
|
|
64
|
+
/**
|
|
65
|
+
* The minimum amount that should be deposited in the source chain.
|
|
66
|
+
* In token atoms.
|
|
67
|
+
*/
|
|
68
|
+
minDeposit: bigint;
|
|
69
|
+
/**
|
|
70
|
+
* The maximum amount that can be deposited in the source chain.
|
|
71
|
+
* In token atoms.
|
|
72
|
+
*/
|
|
73
|
+
maxDeposit: bigint;
|
|
74
|
+
};
|
|
51
75
|
}
|
|
52
76
|
export interface BridgeHook {
|
|
53
77
|
postHook: latestAppData.CoWHook;
|
|
@@ -145,13 +169,14 @@ export interface BridgeProvider<Q extends BridgeQuoteResult> {
|
|
|
145
169
|
*
|
|
146
170
|
* @param hook - The bridge hook
|
|
147
171
|
*/
|
|
148
|
-
decodeBridgeHook(hook:
|
|
172
|
+
decodeBridgeHook(hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
|
|
149
173
|
/**
|
|
150
174
|
* Get the identifier of the bridging transaction from the settlement transaction.
|
|
151
175
|
* @param orderUid - The unique identifier of the order
|
|
152
176
|
* @param settlementTx - The settlement transaction in which the bridging post-hook was executed
|
|
177
|
+
* @param logIndex - The log index of the trade within the settlement transaction
|
|
153
178
|
*/
|
|
154
|
-
getBridgingId(orderUid: string, settlementTx: string): Promise<string>;
|
|
179
|
+
getBridgingId(orderUid: string, settlementTx: string, logIndex: number): Promise<string>;
|
|
155
180
|
/**
|
|
156
181
|
* Get the explorer url for a bridging id.
|
|
157
182
|
*
|
|
@@ -251,4 +276,12 @@ export interface BridgeQuoteResults extends BridgeQuoteResult {
|
|
|
251
276
|
bridgeCallDetails: BridgeCallDetails;
|
|
252
277
|
}
|
|
253
278
|
export type GetErc20Decimals = (chainId: TargetChainId, tokenAddress: string) => Promise<number>;
|
|
279
|
+
export interface CrossChainOrder {
|
|
280
|
+
chainId: SupportedChainId;
|
|
281
|
+
order: EnrichedOrder;
|
|
282
|
+
status: BridgeStatus;
|
|
283
|
+
bridgingId?: string;
|
|
284
|
+
explorerUrl?: string;
|
|
285
|
+
fillTimeInSeconds?: number;
|
|
286
|
+
}
|
|
254
287
|
export {};
|
package/dist/bridging/utils.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { QuoteAndPost } from '../trading';
|
|
2
|
+
import { latest as latestAppData } from '@cowprotocol/app-data';
|
|
2
3
|
import { BridgeQuoteAndPost, CrossChainQuoteAndPost } from './types';
|
|
3
4
|
export declare function isBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): quote is BridgeQuoteAndPost;
|
|
4
5
|
export declare function isQuoteAndPost(quote: CrossChainQuoteAndPost): quote is QuoteAndPost;
|
|
5
6
|
export declare function assertIsBridgeQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is BridgeQuoteAndPost;
|
|
6
7
|
export declare function assertIsQuoteAndPost(quote: CrossChainQuoteAndPost): asserts quote is QuoteAndPost;
|
|
8
|
+
export declare function getPostHooks(fullAppData?: string): latestAppData.CoWHook[];
|
|
9
|
+
export declare function isAppDoc(appData: unknown): appData is latestAppData.AppDataRootSchema;
|