@cowprotocol/cow-sdk 5.10.2 → 5.11.0-RC.0

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 (121) hide show
  1. package/README.md +2 -0
  2. package/dist/README.md +2 -0
  3. package/dist/bridging/BridgingSdk/BridgingSdk.d.ts +90 -0
  4. package/dist/bridging/BridgingSdk/getCrossChainOrder.d.ts +14 -0
  5. package/dist/bridging/BridgingSdk/getErc20Decimals.d.ts +4 -0
  6. package/dist/bridging/BridgingSdk/getQuoteWithBridging.d.ts +32 -0
  7. package/dist/bridging/BridgingSdk/getQuoteWithoutBridge.d.ts +7 -0
  8. package/dist/bridging/const.d.ts +2 -0
  9. package/dist/bridging/errors.d.ts +4 -0
  10. package/dist/bridging/index.d.ts +6 -0
  11. package/dist/bridging/providers/across/AcrossApi.d.ts +27 -0
  12. package/dist/bridging/providers/across/AcrossBridgeProvider.d.ts +43 -0
  13. package/dist/bridging/providers/across/abi.d.ts +154 -0
  14. package/dist/bridging/providers/across/const/contracts.d.ts +3 -0
  15. package/dist/bridging/providers/across/const/misc.d.ts +1 -0
  16. package/dist/bridging/providers/across/const/tokens.d.ts +11 -0
  17. package/dist/bridging/providers/across/createAcrossDepositCall.d.ts +9 -0
  18. package/dist/bridging/providers/across/types.d.ts +169 -0
  19. package/dist/bridging/providers/across/util.d.ts +39 -0
  20. package/dist/bridging/providers/mock/MockBridgeProvider.d.ts +21 -0
  21. package/dist/bridging/types.d.ts +287 -0
  22. package/dist/bridging/utils.d.ts +9 -0
  23. package/dist/chains/const/index.d.ts +25 -0
  24. package/dist/chains/const/path.d.ts +1 -0
  25. package/dist/chains/details/arbitrum.d.ts +7 -0
  26. package/dist/chains/details/avalanche.d.ts +2 -0
  27. package/dist/chains/details/base.d.ts +7 -0
  28. package/dist/chains/details/gnosis.d.ts +7 -0
  29. package/dist/chains/details/mainnet.d.ts +7 -0
  30. package/dist/chains/details/optimism.d.ts +2 -0
  31. package/dist/chains/details/polygon.d.ts +2 -0
  32. package/dist/chains/details/sepolia.d.ts +7 -0
  33. package/dist/chains/index.d.ts +3 -0
  34. package/dist/chains/types.d.ts +123 -0
  35. package/dist/chains/utils.d.ts +18 -0
  36. package/dist/common/consts/config.d.ts +9 -0
  37. package/dist/common/{consts.d.ts → consts/contracts.d.ts} +1 -12
  38. package/dist/common/consts/path.d.ts +1 -0
  39. package/dist/common/consts/tokens.d.ts +9 -0
  40. package/dist/common/index.d.ts +12 -5
  41. package/dist/common/{configs.d.ts → types/config.d.ts} +1 -9
  42. package/dist/common/{cow-error.d.ts → types/cow-error.d.ts} +0 -1
  43. package/dist/common/types/ethereum.d.ts +5 -0
  44. package/dist/common/types/tokens.d.ts +12 -0
  45. package/dist/common/types/wallets.d.ts +5 -0
  46. package/dist/common/utils/config.d.ts +4 -0
  47. package/dist/common/utils/log.d.ts +2 -0
  48. package/dist/common/utils/serialize.d.ts +1 -0
  49. package/dist/common/utils/wallet.d.ts +3 -0
  50. package/dist/composable/Multiplexer.d.ts +1 -1
  51. package/dist/composable/contracts.d.ts +1 -1
  52. package/dist/composable/types.d.ts +1 -1
  53. package/dist/composable/utils.d.ts +1 -1
  54. package/dist/cow-shed/CowShedSdk.d.ts +69 -0
  55. package/dist/cow-shed/{proxyInitCode.d.ts → contracts/CoWShedHooks.d.ts} +44 -0
  56. package/dist/cow-shed/contracts/utils.d.ts +4 -0
  57. package/dist/cow-shed/index.d.ts +2 -3
  58. package/dist/cow-shed/types.d.ts +0 -16
  59. package/dist/hooks/utils.d.ts +3 -0
  60. package/dist/index-ef9ef589.js +29 -0
  61. package/dist/index-ef9ef589.js.map +1 -0
  62. package/dist/index.d.ts +4 -0
  63. package/dist/index.js +4 -4
  64. package/dist/index.js.map +1 -1
  65. package/dist/index.modern.mjs +1 -1
  66. package/dist/index.module.js +4 -4
  67. package/dist/index.module.js.map +1 -1
  68. package/dist/order-book/api.d.ts +1 -1
  69. package/dist/order-book/quoteAmountsAndCostsUtils.d.ts +13 -2
  70. package/dist/order-book/types.d.ts +54 -18
  71. package/dist/order-signing/orderSigningUtils.d.ts +1 -1
  72. package/dist/order-signing/types.d.ts +1 -1
  73. package/dist/order-signing/utils.d.ts +1 -1
  74. package/dist/package.json +13 -11
  75. package/dist/schemas/trading/LimitOrderAdvancedSettings.ts +26 -0
  76. package/dist/schemas/trading/LimitTradeParameters.ts +3 -0
  77. package/dist/schemas/trading/QuoteResultsSerialized.ts +21 -12
  78. package/dist/schemas/trading/QuoterParameters.ts +11 -1
  79. package/dist/schemas/trading/SwapAdvancedSettings.ts +206 -0
  80. package/dist/schemas/trading/TradeParameters.ts +3 -0
  81. package/dist/src/bridging/README.md +54 -0
  82. package/dist/src/cow-shed/README.md +60 -0
  83. package/dist/src/trading/README.md +55 -7
  84. package/dist/src/weiroll/README.md +58 -0
  85. package/dist/subgraph/api.d.ts +2 -2
  86. package/dist/test/utils.d.ts +1 -0
  87. package/dist/trading/appDataUtils.d.ts +2 -1
  88. package/dist/trading/calculateUniqueOrderId.d.ts +3 -4
  89. package/dist/trading/consts.d.ts +2 -4
  90. package/dist/trading/getEthFlowTransaction.d.ts +6 -5
  91. package/dist/trading/getOrderTypedData.d.ts +1 -1
  92. package/dist/trading/getPreSignTransaction.d.ts +2 -2
  93. package/dist/trading/getQuote.d.ts +1 -1
  94. package/dist/trading/postCoWProtocolTrade.d.ts +4 -4
  95. package/dist/trading/postLimitOrder.d.ts +2 -2
  96. package/dist/trading/postSellNativeCurrencyOrder.d.ts +2 -6
  97. package/dist/trading/postSwapOrder.d.ts +3 -3
  98. package/dist/trading/tradingSdk.d.ts +14 -11
  99. package/dist/trading/types.d.ts +73 -11
  100. package/dist/trading/utils.d.ts +8 -4
  101. package/dist/utils-757fe114.js +2 -0
  102. package/dist/utils-757fe114.js.map +1 -0
  103. package/dist/utils-9a7618d8.js +2 -0
  104. package/dist/utils-9a7618d8.js.map +1 -0
  105. package/dist/utils-f4151c05.js +2 -0
  106. package/dist/utils-f4151c05.js.map +1 -0
  107. package/dist/utils.d.ts +1 -1
  108. package/dist/weiroll/index.d.ts +23 -0
  109. package/package.json +13 -11
  110. package/dist/common/chains.d.ts +0 -11
  111. package/dist/cow-shed/CoWShedHooks.d.ts +0 -35
  112. package/dist/cow-shed/contracts.d.ts +0 -4
  113. package/dist/index-2ed223c8.js +0 -29
  114. package/dist/index-2ed223c8.js.map +0 -1
  115. package/dist/utils-4bdd94dd.js +0 -2
  116. package/dist/utils-4bdd94dd.js.map +0 -1
  117. package/dist/utils-63156cab.js +0 -2
  118. package/dist/utils-63156cab.js.map +0 -1
  119. package/dist/utils-faedc0ab.js +0 -2
  120. package/dist/utils-faedc0ab.js.map +0 -1
  121. /package/dist/common/{ipfs.d.ts → consts/ipfs.d.ts} +0 -0
package/README.md CHANGED
@@ -178,6 +178,8 @@ const orderBookApi = new OrderBookApi({
178
178
  [SupportedChainId.ARBITRUM]: 'https://YOUR_ENDPOINT/arbitrum_one',
179
179
  [SupportedChainId.BASE]: 'https://YOUR_ENDPOINT/base',
180
180
  [SupportedChainId.SEPOLIA]: 'https://YOUR_ENDPOINT/sepolia',
181
+ [SupportedChainId.POLYGON]: 'https://YOUR_ENDPOINT/polygon',
182
+ [SupportedChainId.AVALANCHE]: 'https://YOUR_ENDPOINT/avalanche',
181
183
  },
182
184
  })
183
185
  ```
package/dist/README.md CHANGED
@@ -178,6 +178,8 @@ const orderBookApi = new OrderBookApi({
178
178
  [SupportedChainId.ARBITRUM]: 'https://YOUR_ENDPOINT/arbitrum_one',
179
179
  [SupportedChainId.BASE]: 'https://YOUR_ENDPOINT/base',
180
180
  [SupportedChainId.SEPOLIA]: 'https://YOUR_ENDPOINT/sepolia',
181
+ [SupportedChainId.POLYGON]: 'https://YOUR_ENDPOINT/polygon',
182
+ [SupportedChainId.AVALANCHE]: 'https://YOUR_ENDPOINT/avalanche',
181
183
  },
182
184
  })
183
185
  ```
@@ -0,0 +1,90 @@
1
+ import { SwapAdvancedSettings, TradingSdk } from '../../trading';
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';
6
+ export interface BridgingSdkOptions {
7
+ /**
8
+ * Providers for the bridging.
9
+ */
10
+ providers: BridgeProvider<BridgeQuoteResult>[];
11
+ /**
12
+ * Function to get the decimals of the ERC20 tokens
13
+ */
14
+ getErc20Decimals?: GetErc20Decimals;
15
+ /**
16
+ * Trading SDK.
17
+ */
18
+ tradingSdk?: TradingSdk;
19
+ /**
20
+ * Order book API.
21
+ */
22
+ orderBookApi: OrderBookApi;
23
+ /**
24
+ * Enable logging for the bridging SDK.
25
+ */
26
+ enableLogging?: boolean;
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
+ }
45
+ export type BridgingSdkConfig = Required<Omit<BridgingSdkOptions, 'enableLogging' | 'getErc20Decimals'>> & Pick<BridgingSdkOptions, 'getErc20Decimals'>;
46
+ /**
47
+ * SDK for bridging for swapping tokens between different chains.
48
+ */
49
+ export declare class BridgingSdk {
50
+ readonly options: BridgingSdkOptions;
51
+ protected config: BridgingSdkConfig;
52
+ constructor(options: BridgingSdkOptions);
53
+ private get provider();
54
+ /**
55
+ * Get the providers for the bridging.
56
+ */
57
+ getProviders(): BridgeProvider<BridgeQuoteResult>[];
58
+ /**
59
+ * Get the available sources networks for the bridging.
60
+ */
61
+ getSourceNetworks(): Promise<ChainInfo[]>;
62
+ /**
63
+ * Get the available target networks for the bridging.
64
+ */
65
+ getTargetNetworks(): Promise<ChainInfo[]>;
66
+ /**
67
+ * Get the available buy tokens for buying in a specific target chain
68
+ *
69
+ * @param param
70
+ * @returns
71
+ */
72
+ getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
73
+ /**
74
+ * Get quote details, including a callback function to post the order on-chain.
75
+ *
76
+ * This method support both, cross-chain swaps and single-chain swap.
77
+ *
78
+ * The return type will be either `QuoteAndPost` or `BridgeQuoteAndPost`.
79
+ *
80
+ * To safely assert the type in Typescript, you can use:
81
+ * - `isBridgeQuoteAndPost(result)` utility.
82
+ * - `isQuoteAndPost(result)` utility.
83
+ * - `assertIsBridgeQuoteAndPost(result)` assertion.
84
+ * - `assertIsQuoteAndPost(result)` assertion.
85
+ *
86
+ * @throws Error if no path is found
87
+ */
88
+ getQuote(quoteBridgeRequest: QuoteBridgeRequest, advancedSettings?: SwapAdvancedSettings): Promise<CrossChainQuoteAndPost>;
89
+ getOrder(params: GetOrderParams): Promise<CrossChainOrder>;
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>;
@@ -0,0 +1,4 @@
1
+ import { Provider } from '@ethersproject/providers';
2
+ import { Signer } from '@ethersproject/abstract-signer';
3
+ import { GetErc20Decimals } from '../types';
4
+ export declare function factoryGetErc20Decimals(provider: Signer | Provider): GetErc20Decimals;
@@ -0,0 +1,32 @@
1
+ import { SwapAdvancedSettings, TradingSdk } from '../../trading';
2
+ import { BridgeProvider, BridgeQuoteAndPost, BridgeQuoteResult, GetErc20Decimals, QuoteBridgeRequest } from '../types';
3
+ import { SignerLike } from '../../common';
4
+ type GetQuoteWithBridgeParams<T extends BridgeQuoteResult> = {
5
+ /**
6
+ * Overall request for the swap and the bridge.
7
+ */
8
+ swapAndBridgeRequest: QuoteBridgeRequest;
9
+ /**
10
+ * Advanced settings for the swap.
11
+ */
12
+ advancedSettings?: SwapAdvancedSettings;
13
+ /**
14
+ * Provider for the bridge.
15
+ */
16
+ provider: BridgeProvider<T>;
17
+ /**
18
+ * Trading SDK.
19
+ */
20
+ tradingSdk: TradingSdk;
21
+ /**
22
+ * Function to get the decimals of the ERC20 tokens.
23
+ */
24
+ getErc20Decimals: GetErc20Decimals;
25
+ /**
26
+ * For quote fetching we have to sign bridging hooks.
27
+ * But we won't do that using users wallet and will use some static PK.
28
+ */
29
+ bridgeHookSigner?: SignerLike;
30
+ };
31
+ export declare function getQuoteWithBridge<T extends BridgeQuoteResult>(params: GetQuoteWithBridgeParams<T>): Promise<BridgeQuoteAndPost>;
32
+ export {};
@@ -0,0 +1,7 @@
1
+ import { QuoteAndPost, SwapAdvancedSettings, TradingSdk } from '../../trading';
2
+ import { QuoteBridgeRequest } from '../types';
3
+ export declare function getQuoteWithoutBridge(params: {
4
+ quoteBridgeRequest: QuoteBridgeRequest;
5
+ advancedSettings?: SwapAdvancedSettings;
6
+ tradingSdk: TradingSdk;
7
+ }): Promise<QuoteAndPost>;
@@ -0,0 +1,2 @@
1
+ export declare const RAW_PROVIDERS_FILES_PATH: string;
2
+ export declare const DEFAULT_GAS_COST_FOR_HOOK_ESTIMATION = 110000;
@@ -0,0 +1,4 @@
1
+ export declare class BridgeProviderQuoteError extends Error {
2
+ readonly context: any;
3
+ constructor(message: string, context: any);
4
+ }
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ export * from './errors';
3
+ export * from './utils';
4
+ export * from './BridgingSdk/BridgingSdk';
5
+ export { MockBridgeProvider } from './providers/mock/MockBridgeProvider';
6
+ export { AcrossBridgeProvider, AcrossQuoteResult, AcrossBridgeProviderOptions, } from './providers/across/AcrossBridgeProvider';
@@ -0,0 +1,27 @@
1
+ import { AvailableRoutesRequest, Route, SuggestedFeesRequest, SuggestedFeesResponse } from './types';
2
+ export interface AcrossApiOptions {
3
+ apiBaseUrl?: string;
4
+ }
5
+ export declare class AcrossApi {
6
+ private readonly options;
7
+ constructor(options?: AcrossApiOptions);
8
+ /**
9
+ * Retrieve available routes for transfers
10
+ *
11
+ * Returns available routes based on specified parameters. If no parameters are provided, available routes on all
12
+ * chains are returned.
13
+ *
14
+ * See https://docs.across.to/reference/api-reference#available-routes
15
+ */
16
+ getAvailableRoutes({ originChainId, originToken, destinationChainId, destinationToken, }: AvailableRoutesRequest): Promise<Route[]>;
17
+ /**
18
+ * Retrieve suggested fee quote for a deposit.
19
+ *
20
+ * Returns suggested fees based inputToken+outputToken, originChainId, destinationChainId, and amount.
21
+ * Also includes data used to compute the fees.
22
+ *
23
+ * * See https://docs.across.to/reference/api-reference#suggested-fees
24
+ */
25
+ getSuggestedFees(request: SuggestedFeesRequest): Promise<SuggestedFeesResponse>;
26
+ protected fetchApi<T>(path: string, params: Record<string, string>, isValidResponse?: (response: unknown) => response is T): Promise<T>;
27
+ }
@@ -0,0 +1,43 @@
1
+ import { Signer } from 'ethers';
2
+ import { latest as latestAppData } from '@cowprotocol/app-data';
3
+ import { BridgeDeposit, BridgeHook, BridgeProvider, BridgeProviderInfo, BridgeQuoteResult, BridgeStatusResult, QuoteBridgeRequest } from '../../types';
4
+ import { ChainId, ChainInfo, SupportedChainId, TargetChainId } from '../../../chains';
5
+ import { EvmCall, TokenInfo } from '../../../common';
6
+ import { AcrossApi, AcrossApiOptions } from './AcrossApi';
7
+ import { CowShedSdk, CowShedSdkOptions } from '../../../cow-shed';
8
+ import { SuggestedFeesResponse } from './types';
9
+ export declare const ACROSS_SUPPORTED_NETWORKS: ChainInfo[];
10
+ 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
+ apiOptions?: AcrossApiOptions;
19
+ cowShedOptions?: CowShedSdkOptions;
20
+ }
21
+ export interface AcrossQuoteResult extends BridgeQuoteResult {
22
+ suggestedFees: SuggestedFeesResponse;
23
+ }
24
+ export declare class AcrossBridgeProvider implements BridgeProvider<AcrossQuoteResult> {
25
+ private options;
26
+ protected api: AcrossApi;
27
+ protected cowShedSdk: CowShedSdk;
28
+ constructor(options?: AcrossBridgeProviderOptions);
29
+ info: BridgeProviderInfo;
30
+ getNetworks(): Promise<ChainInfo[]>;
31
+ getBuyTokens(targetChainId: TargetChainId): Promise<TokenInfo[]>;
32
+ getIntermediateTokens(request: QuoteBridgeRequest): Promise<string[]>;
33
+ getQuote(request: QuoteBridgeRequest): Promise<AcrossQuoteResult>;
34
+ getUnsignedBridgeCall(request: QuoteBridgeRequest, quote: AcrossQuoteResult): Promise<EvmCall>;
35
+ getGasLimitEstimationForHook(_request: QuoteBridgeRequest): number;
36
+ getSignedHook(chainId: SupportedChainId, unsignedCall: EvmCall, signer: Signer): Promise<BridgeHook>;
37
+ decodeBridgeHook(_hook: latestAppData.CoWHook): Promise<BridgeDeposit>;
38
+ getBridgingId(_orderUid: string, _settlementTx: string, _logIndex: number): Promise<string>;
39
+ getExplorerUrl(bridgingId: string): string;
40
+ getStatus(_bridgingId: string): Promise<BridgeStatusResult>;
41
+ getCancelBridgingTx(_bridgingId: string): Promise<EvmCall>;
42
+ getRefundBridgingTx(_bridgingId: string): Promise<EvmCall>;
43
+ }
@@ -0,0 +1,154 @@
1
+ export declare const ACROSS_MATH_ABI: {
2
+ inputs: {
3
+ internalType: string;
4
+ name: string;
5
+ type: string;
6
+ }[];
7
+ name: string;
8
+ outputs: {
9
+ internalType: string;
10
+ name: string;
11
+ type: string;
12
+ }[];
13
+ stateMutability: string;
14
+ type: string;
15
+ }[];
16
+ export declare const ACROSS_SPOKE_POOL_ABI: ({
17
+ inputs: {
18
+ internalType: string;
19
+ name: string;
20
+ type: string;
21
+ }[];
22
+ stateMutability: string;
23
+ type: string;
24
+ name?: undefined;
25
+ anonymous?: undefined;
26
+ outputs?: undefined;
27
+ } | {
28
+ inputs: {
29
+ internalType: string;
30
+ name: string;
31
+ type: string;
32
+ }[];
33
+ name: string;
34
+ type: string;
35
+ stateMutability?: undefined;
36
+ anonymous?: undefined;
37
+ outputs?: undefined;
38
+ } | {
39
+ anonymous: boolean;
40
+ inputs: ({
41
+ indexed: boolean;
42
+ internalType: string;
43
+ name: string;
44
+ type: string;
45
+ components?: undefined;
46
+ } | {
47
+ components: {
48
+ internalType: string;
49
+ name: string;
50
+ type: string;
51
+ }[];
52
+ indexed: boolean;
53
+ internalType: string;
54
+ name: string;
55
+ type: string;
56
+ })[];
57
+ name: string;
58
+ type: string;
59
+ stateMutability?: undefined;
60
+ outputs?: undefined;
61
+ } | {
62
+ inputs: {
63
+ internalType: string;
64
+ name: string;
65
+ type: string;
66
+ }[];
67
+ name: string;
68
+ outputs: {
69
+ internalType: string;
70
+ name: string;
71
+ type: string;
72
+ }[];
73
+ stateMutability: string;
74
+ type: string;
75
+ anonymous?: undefined;
76
+ } | {
77
+ inputs: ({
78
+ components: ({
79
+ components: {
80
+ internalType: string;
81
+ name: string;
82
+ type: string;
83
+ }[];
84
+ internalType: string;
85
+ name: string;
86
+ type: string;
87
+ } | {
88
+ internalType: string;
89
+ name: string;
90
+ type: string;
91
+ components?: undefined;
92
+ })[];
93
+ internalType: string;
94
+ name: string;
95
+ type: string;
96
+ } | {
97
+ internalType: string;
98
+ name: string;
99
+ type: string;
100
+ components?: undefined;
101
+ })[];
102
+ name: string;
103
+ outputs: never[];
104
+ stateMutability: string;
105
+ type: string;
106
+ anonymous?: undefined;
107
+ } | {
108
+ inputs: {
109
+ components: {
110
+ internalType: string;
111
+ name: string;
112
+ type: string;
113
+ }[];
114
+ internalType: string;
115
+ name: string;
116
+ type: string;
117
+ }[];
118
+ name: string;
119
+ outputs: {
120
+ internalType: string;
121
+ name: string;
122
+ type: string;
123
+ }[];
124
+ stateMutability: string;
125
+ type: string;
126
+ anonymous?: undefined;
127
+ } | {
128
+ inputs: {
129
+ internalType: string;
130
+ name: string;
131
+ type: string;
132
+ }[];
133
+ name: string;
134
+ outputs: {
135
+ components: {
136
+ internalType: string;
137
+ name: string;
138
+ type: string;
139
+ }[];
140
+ internalType: string;
141
+ name: string;
142
+ type: string;
143
+ }[];
144
+ stateMutability: string;
145
+ type: string;
146
+ anonymous?: undefined;
147
+ } | {
148
+ stateMutability: string;
149
+ type: string;
150
+ inputs?: undefined;
151
+ name?: undefined;
152
+ anonymous?: undefined;
153
+ outputs?: undefined;
154
+ })[];
@@ -0,0 +1,3 @@
1
+ import { TargetChainId } from '../../../../chains';
2
+ export declare const ACROSS_SPOOK_CONTRACT_ADDRESSES: Record<TargetChainId, string | undefined>;
3
+ export declare const ACROSS_MATH_CONTRACT_ADDRESSES: Record<TargetChainId, string | undefined>;
@@ -0,0 +1 @@
1
+ export declare const HOOK_DAPP_BRIDGE_PROVIDER_PREFIX = "cow-sdk://bridging/providers";
@@ -0,0 +1,11 @@
1
+ import { TargetChainId } from '../../../../chains/types';
2
+ /**
3
+ * Chain config for Across. Includes all the supported tokens for the chain.
4
+ */
5
+ export interface AcrossChainConfig {
6
+ chainId: TargetChainId;
7
+ tokens: {
8
+ [name: string]: string | undefined;
9
+ };
10
+ }
11
+ export declare const ACROSS_TOKEN_MAPPING: Partial<Record<TargetChainId, AcrossChainConfig>>;
@@ -0,0 +1,9 @@
1
+ import { EvmCall } from '../../../common';
2
+ import { CowShedSdk } from '../../../cow-shed';
3
+ import { AcrossQuoteResult } from './AcrossBridgeProvider';
4
+ import { QuoteBridgeRequest } from '../../types';
5
+ export declare function createAcrossDepositCall(params: {
6
+ request: QuoteBridgeRequest;
7
+ quote: AcrossQuoteResult;
8
+ cowShedSdk: CowShedSdk;
9
+ }): EvmCall;
@@ -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
+ }
@@ -0,0 +1,39 @@
1
+ import { QuoteBridgeRequest } from '../../../bridging/types';
2
+ import { TargetChainId } from '../../../chains';
3
+ import { AcrossQuoteResult } from './AcrossBridgeProvider';
4
+ import { AcrossChainConfig } from './const/tokens';
5
+ import { SuggestedFeesResponse } from './types';
6
+ /**
7
+ * Return the chain configs
8
+ *
9
+ * This is a temporary implementation. We should use the Across API to get the intermediate tokens (see this.getAvailableRoutes())
10
+ */
11
+ export declare function getChainConfigs(sourceChainId: TargetChainId, targetChainId: TargetChainId): {
12
+ sourceChainConfig: AcrossChainConfig;
13
+ targetChainConfig: AcrossChainConfig;
14
+ } | undefined;
15
+ export declare function getTokenSymbol(tokenAddress: string, chainConfig: AcrossChainConfig): string | undefined;
16
+ export declare function getTokenAddress(tokenSymbol: string, chainConfig: AcrossChainConfig): string | undefined;
17
+ export declare function toBridgeQuoteResult(request: QuoteBridgeRequest, slippageBps: number, suggestedFees: SuggestedFeesResponse): AcrossQuoteResult;
18
+ /**
19
+ * pct represents a percentage.
20
+ *
21
+ * Note: 1% is represented as 1e16, 100% is 1e18, 50% is 5e17, etc. These values are in the same format that the contract understands.
22
+ *
23
+ * Bps is a percentage in basis points (1/100th of a percent). For example, 1% is 100 bps.
24
+ *
25
+ * @param pct - The percentage to convert to bps
26
+ * @returns The percentage in bps
27
+ * @throws If the percentage is greater than 100% or less than 0%
28
+ */
29
+ export declare function pctToBps(pct: bigint): number;
30
+ /**
31
+ * Apply a percentage fee to an amount.
32
+ *
33
+ * @param amount - The amount to apply the fee to
34
+ * @param pct - The percentage fee to apply
35
+ * @throws If the percentage fee is greater than 100% or less than 0%
36
+ * @returns The amount after the fee has been applied
37
+ */
38
+ export declare function applyPctFee(amount: bigint, pct: bigint): bigint;
39
+ export declare function applyBps(amount: bigint, bps: number): bigint;