@steerprotocol/sdk 1.19.16 → 1.19.18
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/cjs/base/vault/single-asset/simulateSwap.js +43 -17
- package/dist/cjs/base/vault/single-asset/simulateSwap.js.map +1 -1
- package/dist/cjs/base/vault/single-asset/singleAssetDeposit.js +24 -21
- package/dist/cjs/base/vault/single-asset/singleAssetDeposit.js.map +1 -1
- package/dist/cjs/const/abis/quoter.js +1337 -1
- package/dist/cjs/const/abis/quoter.js.map +1 -1
- package/dist/cjs/const/amm/configs/protocols/machinex.js +3 -0
- package/dist/cjs/const/amm/configs/protocols/machinex.js.map +1 -1
- package/dist/cjs/const/amm/configs/protocols/quickswap.js +3 -0
- package/dist/cjs/const/amm/configs/protocols/quickswap.js.map +1 -1
- package/dist/cjs/const/amm/configs/protocols/retro.js +3 -0
- package/dist/cjs/const/amm/configs/protocols/retro.js.map +1 -1
- package/dist/cjs/const/amm/configs/protocols/sushi.js +3 -0
- package/dist/cjs/const/amm/configs/protocols/sushi.js.map +1 -1
- package/dist/cjs/const/amm/utils/contracts.js +6 -0
- package/dist/cjs/const/amm/utils/contracts.js.map +1 -1
- package/dist/cjs/const/deployments/peaq.js +8 -0
- package/dist/cjs/const/deployments/peaq.js.map +1 -1
- package/dist/cjs/const/deployments/polygon.js +2 -2
- package/dist/cjs/const/index.js.map +1 -1
- package/dist/cjs/const/network.js +9 -0
- package/dist/cjs/const/network.js.map +1 -1
- package/dist/cjs/const/protocol.js +18 -1
- package/dist/cjs/const/protocol.js.map +1 -1
- package/dist/cjs/const/quoter.js +412 -25
- package/dist/cjs/const/quoter.js.map +1 -1
- package/dist/esm/base/vault/single-asset/simulateSwap.js +43 -17
- package/dist/esm/base/vault/single-asset/simulateSwap.js.map +1 -1
- package/dist/esm/base/vault/single-asset/singleAssetDeposit.js +24 -21
- package/dist/esm/base/vault/single-asset/singleAssetDeposit.js.map +1 -1
- package/dist/esm/const/abis/quoter.js +1336 -0
- package/dist/esm/const/abis/quoter.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/machinex.js +3 -0
- package/dist/esm/const/amm/configs/protocols/machinex.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/quickswap.js +3 -0
- package/dist/esm/const/amm/configs/protocols/quickswap.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/retro.js +3 -0
- package/dist/esm/const/amm/configs/protocols/retro.js.map +1 -1
- package/dist/esm/const/amm/configs/protocols/sushi.js +3 -0
- package/dist/esm/const/amm/configs/protocols/sushi.js.map +1 -1
- package/dist/esm/const/amm/utils/contracts.js +5 -0
- package/dist/esm/const/amm/utils/contracts.js.map +1 -1
- package/dist/esm/const/deployments/peaq.js +8 -0
- package/dist/esm/const/deployments/peaq.js.map +1 -1
- package/dist/esm/const/deployments/polygon.js +2 -2
- package/dist/esm/const/index.js.map +1 -1
- package/dist/esm/const/network.js +7 -0
- package/dist/esm/const/network.js.map +1 -1
- package/dist/esm/const/protocol.js +16 -0
- package/dist/esm/const/protocol.js.map +1 -1
- package/dist/esm/const/quoter.js +412 -32
- package/dist/esm/const/quoter.js.map +1 -1
- package/dist/types/base/VaultClient.d.ts +1 -1
- package/dist/types/base/vault/single-asset/simulateSwap.d.ts.map +1 -1
- package/dist/types/base/vault/single-asset/singleAssetDeposit.d.ts +1 -1
- package/dist/types/base/vault/single-asset/singleAssetDeposit.d.ts.map +1 -1
- package/dist/types/base/vault/single-asset/types.d.ts +2 -0
- package/dist/types/base/vault/single-asset/types.d.ts.map +1 -1
- package/dist/types/const/abis/quoter.d.ts +226 -0
- package/dist/types/const/abis/quoter.d.ts.map +1 -1
- package/dist/types/const/amm/configs/protocols/machinex.d.ts.map +1 -1
- package/dist/types/const/amm/configs/protocols/quickswap.d.ts.map +1 -1
- package/dist/types/const/amm/configs/protocols/retro.d.ts.map +1 -1
- package/dist/types/const/amm/configs/protocols/sushi.d.ts.map +1 -1
- package/dist/types/const/amm/utils/contracts.d.ts +2 -0
- package/dist/types/const/amm/utils/contracts.d.ts.map +1 -1
- package/dist/types/const/deployments/peaq.d.ts.map +1 -1
- package/dist/types/const/index.d.ts.map +1 -1
- package/dist/types/const/network.d.ts +2 -0
- package/dist/types/const/network.d.ts.map +1 -1
- package/dist/types/const/protocol.d.ts +2 -0
- package/dist/types/const/protocol.d.ts.map +1 -1
- package/dist/types/const/quoter.d.ts +451 -12
- package/dist/types/const/quoter.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,17 +1,456 @@
|
|
|
1
|
-
import type { Address } from 'viem';
|
|
2
|
-
import {
|
|
1
|
+
import type { Address, PublicClient } from 'viem';
|
|
2
|
+
import { Protocol } from "./chain";
|
|
3
|
+
import { UniswapV3QuoterABI, QuickSwapQuoterV2, QuoterV2Thick, QuoterV2AlgebgraIntegral, QuoterV2AlgebgraIntegral21, QuoterV2Shadow } from "./abis/quoter";
|
|
4
|
+
import { NetworkConfig } from './network';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param chain - The chain to get the Quoter address for
|
|
6
|
-
* @returns The Quoter contract address
|
|
7
|
-
* @throws Error if no Quoter address is available for the chain
|
|
6
|
+
* Base interface for quote parameters
|
|
8
7
|
*/
|
|
9
|
-
export
|
|
8
|
+
export interface BaseQuoteParams {
|
|
9
|
+
tokenIn: Address;
|
|
10
|
+
tokenOut: Address;
|
|
11
|
+
amountIn: bigint;
|
|
12
|
+
}
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @param chainId - The chain ID to get the Quoter address for
|
|
13
|
-
* @returns The Quoter contract address
|
|
14
|
-
* @throws Error if no Quoter address is available for the chain ID
|
|
14
|
+
* Quote parameters for Uniswap V3 style quoters (fee-based)
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export interface UniswapQuoteParams extends BaseQuoteParams {
|
|
17
|
+
fee: number;
|
|
18
|
+
sqrtPriceLimitX96?: bigint;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Quote parameters for Algebra style quoters (limit price)
|
|
22
|
+
*/
|
|
23
|
+
export interface AlgebraQuoteParams extends BaseQuoteParams {
|
|
24
|
+
limitSqrtPrice?: bigint;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Quote parameters for Thick V2 quoters (tick spacing)
|
|
28
|
+
*/
|
|
29
|
+
export interface ThickQuoteParams extends BaseQuoteParams {
|
|
30
|
+
tickSpacing: number;
|
|
31
|
+
sqrtPriceLimitX96?: bigint;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Quote parameters for Algebra Integral v2.1 quoters (with deployer)
|
|
35
|
+
*/
|
|
36
|
+
export interface AlgebraIntegral21QuoteParams extends BaseQuoteParams {
|
|
37
|
+
deployer: Address;
|
|
38
|
+
limitSqrtPrice?: bigint;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Quote parameters for Shadow quoters (tick spacing)
|
|
42
|
+
*/
|
|
43
|
+
export interface ShadowQuoteParams extends BaseQuoteParams {
|
|
44
|
+
tickSpacing: number;
|
|
45
|
+
sqrtPriceLimitX96?: bigint;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Union type for all possible quote parameters
|
|
49
|
+
*/
|
|
50
|
+
export type QuoteParams = UniswapQuoteParams | AlgebraQuoteParams | ThickQuoteParams | AlgebraIntegral21QuoteParams | ShadowQuoteParams;
|
|
51
|
+
/**
|
|
52
|
+
* Union type for all possible QuoterV2 ABIs
|
|
53
|
+
*/
|
|
54
|
+
export type QuoterV2ABI = typeof UniswapV3QuoterABI | typeof QuickSwapQuoterV2 | typeof QuoterV2Thick | typeof QuoterV2AlgebgraIntegral | typeof QuoterV2AlgebgraIntegral21 | typeof QuoterV2Shadow;
|
|
55
|
+
/**
|
|
56
|
+
* Union type for all possible quoter function arguments
|
|
57
|
+
*/
|
|
58
|
+
export type QuoterFunctionArgs = {
|
|
59
|
+
tokenIn: Address;
|
|
60
|
+
tokenOut: Address;
|
|
61
|
+
amountIn: bigint;
|
|
62
|
+
fee: number;
|
|
63
|
+
sqrtPriceLimitX96: bigint;
|
|
64
|
+
} | {
|
|
65
|
+
tokenIn: Address;
|
|
66
|
+
tokenOut: Address;
|
|
67
|
+
amountIn: bigint;
|
|
68
|
+
limitSqrtPrice: bigint;
|
|
69
|
+
} | {
|
|
70
|
+
tokenIn: Address;
|
|
71
|
+
tokenOut: Address;
|
|
72
|
+
amountIn: bigint;
|
|
73
|
+
tickSpacing: number;
|
|
74
|
+
sqrtPriceLimitX96: bigint;
|
|
75
|
+
} | {
|
|
76
|
+
tokenIn: Address;
|
|
77
|
+
tokenOut: Address;
|
|
78
|
+
deployer: Address;
|
|
79
|
+
amountIn: bigint;
|
|
80
|
+
limitSqrtPrice: bigint;
|
|
81
|
+
};
|
|
82
|
+
/**
|
|
83
|
+
* Factory class for creating QuoterV2 contract instances with the appropriate ABI
|
|
84
|
+
* based on the protocol type detected from beacon names.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```typescript
|
|
88
|
+
* import { createPublicClient, http, parseEther } from 'viem';
|
|
89
|
+
* import { polygon } from 'viem/chains';
|
|
90
|
+
* import { QuoterV2Factory } from './quoter';
|
|
91
|
+
*
|
|
92
|
+
* // Create a viem client
|
|
93
|
+
* const client = createPublicClient({
|
|
94
|
+
* chain: polygon,
|
|
95
|
+
* transport: http()
|
|
96
|
+
* });
|
|
97
|
+
*
|
|
98
|
+
* // Configure network with quoter addresses
|
|
99
|
+
* const networkConfig = {
|
|
100
|
+
* quoterV2: {
|
|
101
|
+
* 'QuickSwap': '0x...',
|
|
102
|
+
* 'Uniswap': '0x...',
|
|
103
|
+
* 'ThickV2': '0x...',
|
|
104
|
+
* 'Shadow': '0x...',
|
|
105
|
+
* 'KatanaIntegral': '0x...'
|
|
106
|
+
* }
|
|
107
|
+
* };
|
|
108
|
+
*
|
|
109
|
+
* const factory = new QuoterV2Factory(networkConfig);
|
|
110
|
+
*
|
|
111
|
+
* // Example 1: Uniswap V3 style (fee-based)
|
|
112
|
+
* const { quoter: uniQuoter, params: uniParams } = factory.createQuoterWithParams('uniswap', client, {
|
|
113
|
+
* tokenIn: '0xA0b86a33E6f73c7C6789b65f71C1ab8EbAbD3A01',
|
|
114
|
+
* tokenOut: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
|
|
115
|
+
* amountIn: parseEther('1'),
|
|
116
|
+
* fee: 3000,
|
|
117
|
+
* sqrtPriceLimitX96: 0n
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* // Example 2: QuickSwap (Algebra style)
|
|
121
|
+
* const { quoter: quickQuoter, params: quickParams } = factory.createQuoterWithParams('quickswap', client, {
|
|
122
|
+
* tokenIn: '0xA0b86a33E6f73c7C6789b65f71C1ab8EbAbD3A01',
|
|
123
|
+
* tokenOut: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
|
|
124
|
+
* amountIn: parseEther('1'),
|
|
125
|
+
* limitSqrtPrice: 0n
|
|
126
|
+
* });
|
|
127
|
+
*
|
|
128
|
+
* // Example 3: Thick V2 (tick spacing)
|
|
129
|
+
* const { quoter: thickQuoter, params: thickParams } = factory.createQuoterWithParams('thickv2', client, {
|
|
130
|
+
* tokenIn: '0xA0b86a33E6f73c7C6789b65f71C1ab8EbAbD3A01',
|
|
131
|
+
* tokenOut: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
|
|
132
|
+
* amountIn: parseEther('1'),
|
|
133
|
+
* tickSpacing: 60,
|
|
134
|
+
* sqrtPriceLimitX96: 0n
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* // Example 4: Katana Integral (with deployer)
|
|
138
|
+
* const { quoter: katanaQuoter, params: katanaParams } = factory.createQuoterWithParams('katanaintegral', client, {
|
|
139
|
+
* tokenIn: '0xA0b86a33E6f73c7C6789b65f71C1ab8EbAbD3A01',
|
|
140
|
+
* tokenOut: '0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
|
|
141
|
+
* amountIn: parseEther('1'),
|
|
142
|
+
* deployer: '0x...',
|
|
143
|
+
* limitSqrtPrice: 0n
|
|
144
|
+
* });
|
|
145
|
+
*
|
|
146
|
+
* // Use the quoter contracts
|
|
147
|
+
* const uniResult = await uniQuoter.read.quoteExactInputSingle([uniParams]);
|
|
148
|
+
* const quickResult = await quickQuoter.read.quoteExactInputSingle([quickParams]);
|
|
149
|
+
* const thickResult = await thickQuoter.read.quoteExactInputSingle([thickParams]);
|
|
150
|
+
* const katanaResult = await katanaQuoter.read.quoteExactInputSingle([katanaParams]);
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare class QuoterV2Factory {
|
|
154
|
+
private networkConfig;
|
|
155
|
+
constructor(networkConfig: NetworkConfig);
|
|
156
|
+
/**
|
|
157
|
+
* Creates quote parameters for the quoteExactInputSingle function based on the protocol type.
|
|
158
|
+
*
|
|
159
|
+
* @param beaconName - The beacon identifier to determine the protocol type
|
|
160
|
+
* @param params - The input parameters for the quote
|
|
161
|
+
* @returns Formatted parameters object for the specific protocol's quoteExactInputSingle function
|
|
162
|
+
* @throws Error if protocol type is not supported
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```typescript
|
|
166
|
+
* const factory = new QuoterV2Factory(networkConfig);
|
|
167
|
+
*
|
|
168
|
+
* // For Uniswap V3
|
|
169
|
+
* const uniParams = factory.getQuoteParams('uniswap', {
|
|
170
|
+
* tokenIn: '0x...',
|
|
171
|
+
* tokenOut: '0x...',
|
|
172
|
+
* amountIn: parseEther('1'),
|
|
173
|
+
* fee: 3000,
|
|
174
|
+
* sqrtPriceLimitX96: 0n
|
|
175
|
+
* });
|
|
176
|
+
*
|
|
177
|
+
* // For QuickSwap (Algebra)
|
|
178
|
+
* const quickParams = factory.getQuoteParams('quickswap', {
|
|
179
|
+
* tokenIn: '0x...',
|
|
180
|
+
* tokenOut: '0x...',
|
|
181
|
+
* amountIn: parseEther('1'),
|
|
182
|
+
* limitSqrtPrice: 0n
|
|
183
|
+
* });
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
getQuoteParams(protocol: Protocol, params: QuoteParams): {
|
|
187
|
+
tokenIn: `0x${string}`;
|
|
188
|
+
tokenOut: `0x${string}`;
|
|
189
|
+
deployer: `0x${string}`;
|
|
190
|
+
amountIn: bigint;
|
|
191
|
+
limitSqrtPrice: bigint;
|
|
192
|
+
tickSpacing?: undefined;
|
|
193
|
+
sqrtPriceLimitX96?: undefined;
|
|
194
|
+
fee?: undefined;
|
|
195
|
+
} | {
|
|
196
|
+
tokenIn: `0x${string}`;
|
|
197
|
+
tokenOut: `0x${string}`;
|
|
198
|
+
amountIn: bigint;
|
|
199
|
+
tickSpacing: number;
|
|
200
|
+
sqrtPriceLimitX96: bigint;
|
|
201
|
+
deployer?: undefined;
|
|
202
|
+
limitSqrtPrice?: undefined;
|
|
203
|
+
fee?: undefined;
|
|
204
|
+
} | {
|
|
205
|
+
tokenIn: `0x${string}`;
|
|
206
|
+
tokenOut: `0x${string}`;
|
|
207
|
+
amountIn: bigint;
|
|
208
|
+
limitSqrtPrice: bigint;
|
|
209
|
+
deployer?: undefined;
|
|
210
|
+
tickSpacing?: undefined;
|
|
211
|
+
sqrtPriceLimitX96?: undefined;
|
|
212
|
+
fee?: undefined;
|
|
213
|
+
} | {
|
|
214
|
+
tokenIn: `0x${string}`;
|
|
215
|
+
tokenOut: `0x${string}`;
|
|
216
|
+
amountIn: bigint;
|
|
217
|
+
fee: number;
|
|
218
|
+
sqrtPriceLimitX96: bigint;
|
|
219
|
+
deployer?: undefined;
|
|
220
|
+
limitSqrtPrice?: undefined;
|
|
221
|
+
tickSpacing?: undefined;
|
|
222
|
+
};
|
|
223
|
+
/**
|
|
224
|
+
* Creates a QuoterV2 contract instance with the appropriate ABI for the given beacon.
|
|
225
|
+
*
|
|
226
|
+
* @param beaconName - The beacon identifier to determine the protocol type
|
|
227
|
+
* @param client - The viem client for contract interactions
|
|
228
|
+
* @returns A viem contract instance with the appropriate ABI
|
|
229
|
+
* @throws Error if quoter address is not found for the protocol
|
|
230
|
+
*/
|
|
231
|
+
createQuoterV2(protocol: Protocol, client: PublicClient): {
|
|
232
|
+
read: {
|
|
233
|
+
[x: string]: (args: readonly unknown[], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<QuoterV2ABI, never, readonly unknown[]>, "address" | "abi" | "functionName" | "args">> | undefined) => Promise<unknown>;
|
|
234
|
+
};
|
|
235
|
+
estimateGas: {
|
|
236
|
+
[x: string]: (args: readonly unknown[], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined>, "address" | "abi" | "functionName" | "args">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
237
|
+
} & {
|
|
238
|
+
[x: string]: (args: readonly unknown[], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined>, "address" | "abi" | "functionName" | "args">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
239
|
+
};
|
|
240
|
+
simulate: {
|
|
241
|
+
[x: string]: <chainOverride extends import("viem").Chain | undefined = undefined, accountOverride extends import("viem").Account | Address | undefined = undefined>(args: readonly unknown[], options?: Omit<import("viem").SimulateContractParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "abi" | "functionName" | "args"> | undefined) => Promise<import("viem").SimulateContractReturnType<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, undefined, chainOverride, accountOverride>>;
|
|
242
|
+
};
|
|
243
|
+
createEventFilter: {
|
|
244
|
+
[x: string]: <const args extends Record<string, unknown> | readonly unknown[] | undefined, strict extends boolean | undefined = undefined>(options?: ({
|
|
245
|
+
fromBlock?: bigint | import("viem").BlockTag | undefined;
|
|
246
|
+
toBlock?: bigint | import("viem").BlockTag | undefined;
|
|
247
|
+
} & {
|
|
248
|
+
strict?: strict | undefined;
|
|
249
|
+
}) | undefined) => Promise<import("viem").CreateContractEventFilterReturnType<QuoterV2ABI, string, args, strict>>;
|
|
250
|
+
};
|
|
251
|
+
getEvents: {
|
|
252
|
+
[x: string]: (options?: {
|
|
253
|
+
strict?: boolean | undefined;
|
|
254
|
+
fromBlock?: bigint | import("viem").BlockTag | undefined;
|
|
255
|
+
toBlock?: bigint | import("viem").BlockTag | undefined;
|
|
256
|
+
blockHash?: `0x${string}` | undefined;
|
|
257
|
+
} | undefined) => Promise<import("viem").GetContractEventsReturnType<QuoterV2ABI, string>>;
|
|
258
|
+
};
|
|
259
|
+
watchEvent: {
|
|
260
|
+
[x: string]: (options: {
|
|
261
|
+
batch?: boolean | undefined | undefined;
|
|
262
|
+
pollingInterval?: number | undefined | undefined;
|
|
263
|
+
strict?: boolean | undefined;
|
|
264
|
+
fromBlock?: bigint | undefined;
|
|
265
|
+
onError?: ((error: Error) => void) | undefined | undefined;
|
|
266
|
+
onLogs: import("viem").WatchContractEventOnLogsFn<QuoterV2ABI, string, undefined>;
|
|
267
|
+
poll?: true | undefined | undefined;
|
|
268
|
+
}) => import("viem").WatchContractEventReturnType;
|
|
269
|
+
};
|
|
270
|
+
write: {
|
|
271
|
+
[x: string]: <chainOverride extends import("viem").Chain | undefined, options extends import("viem").UnionOmit<import("viem").WriteContractParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, undefined, chainOverride>, "address" | "abi" | "functionName" | "args"> extends infer T ? { [K in keyof T]: import("viem").UnionOmit<import("viem").WriteContractParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, undefined, chainOverride>, "address" | "abi" | "functionName" | "args">[K]; } : never>(args: readonly unknown[], options: options) => Promise<import("viem").WriteContractReturnType>;
|
|
272
|
+
};
|
|
273
|
+
address: `0x${string}`;
|
|
274
|
+
abi: QuoterV2ABI;
|
|
275
|
+
};
|
|
276
|
+
/**
|
|
277
|
+
* Convenience function that creates both the quoter contract and properly formatted quote parameters.
|
|
278
|
+
*
|
|
279
|
+
* @param beaconName - The beacon identifier to determine the protocol type
|
|
280
|
+
* @param client - The viem client for contract interactions
|
|
281
|
+
* @param params - The input parameters for the quote
|
|
282
|
+
* @returns Object containing the quoter contract and formatted parameters
|
|
283
|
+
* @throws Error if quoter address is not found for the protocol
|
|
284
|
+
*
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* const factory = new QuoterV2Factory(networkConfig);
|
|
288
|
+
*
|
|
289
|
+
* const { quoter, params } = factory.createQuoterWithParams('quickswap', client, {
|
|
290
|
+
* tokenIn: '0x...',
|
|
291
|
+
* tokenOut: '0x...',
|
|
292
|
+
* amountIn: parseEther('1'),
|
|
293
|
+
* limitSqrtPrice: 0n
|
|
294
|
+
* });
|
|
295
|
+
*
|
|
296
|
+
* // Use directly
|
|
297
|
+
* const result = await quoter.read.quoteExactInputSingle([params]);
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
createQuoterWithParams(protocol: Protocol, client: PublicClient, params: QuoteParams): {
|
|
301
|
+
quoter: {
|
|
302
|
+
read: {
|
|
303
|
+
[x: string]: (args: readonly unknown[], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<QuoterV2ABI, never, readonly unknown[]>, "address" | "abi" | "functionName" | "args">> | undefined) => Promise<unknown>;
|
|
304
|
+
};
|
|
305
|
+
estimateGas: {
|
|
306
|
+
[x: string]: (args: readonly unknown[], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined>, "address" | "abi" | "functionName" | "args">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
307
|
+
} & {
|
|
308
|
+
[x: string]: (args: readonly unknown[], options: import("viem").Prettify<import("viem").UnionOmit<import("viem").EstimateContractGasParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined>, "address" | "abi" | "functionName" | "args">>) => Promise<import("viem").EstimateContractGasReturnType>;
|
|
309
|
+
};
|
|
310
|
+
simulate: {
|
|
311
|
+
[x: string]: <chainOverride extends import("viem").Chain | undefined = undefined, accountOverride extends import("viem").Account | Address | undefined = undefined>(args: readonly unknown[], options?: Omit<import("viem").SimulateContractParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, chainOverride, accountOverride>, "address" | "abi" | "functionName" | "args"> | undefined) => Promise<import("viem").SimulateContractReturnType<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, undefined, chainOverride, accountOverride>>;
|
|
312
|
+
};
|
|
313
|
+
createEventFilter: {
|
|
314
|
+
[x: string]: <const args extends Record<string, unknown> | readonly unknown[] | undefined, strict extends boolean | undefined = undefined>(options?: ({
|
|
315
|
+
fromBlock?: bigint | import("viem").BlockTag | undefined;
|
|
316
|
+
toBlock?: bigint | import("viem").BlockTag | undefined;
|
|
317
|
+
} & {
|
|
318
|
+
strict?: strict | undefined;
|
|
319
|
+
}) | undefined) => Promise<import("viem").CreateContractEventFilterReturnType<QuoterV2ABI, string, args, strict>>;
|
|
320
|
+
};
|
|
321
|
+
getEvents: {
|
|
322
|
+
[x: string]: (options?: {
|
|
323
|
+
strict?: boolean | undefined;
|
|
324
|
+
fromBlock?: bigint | import("viem").BlockTag | undefined;
|
|
325
|
+
toBlock?: bigint | import("viem").BlockTag | undefined;
|
|
326
|
+
blockHash?: `0x${string}` | undefined;
|
|
327
|
+
} | undefined) => Promise<import("viem").GetContractEventsReturnType<QuoterV2ABI, string>>;
|
|
328
|
+
};
|
|
329
|
+
watchEvent: {
|
|
330
|
+
[x: string]: (options: {
|
|
331
|
+
batch?: boolean | undefined | undefined;
|
|
332
|
+
pollingInterval?: number | undefined | undefined;
|
|
333
|
+
strict?: boolean | undefined;
|
|
334
|
+
fromBlock?: bigint | undefined;
|
|
335
|
+
onError?: ((error: Error) => void) | undefined | undefined;
|
|
336
|
+
onLogs: import("viem").WatchContractEventOnLogsFn<QuoterV2ABI, string, undefined>;
|
|
337
|
+
poll?: true | undefined | undefined;
|
|
338
|
+
}) => import("viem").WatchContractEventReturnType;
|
|
339
|
+
};
|
|
340
|
+
write: {
|
|
341
|
+
[x: string]: <chainOverride extends import("viem").Chain | undefined, options extends import("viem").UnionOmit<import("viem").WriteContractParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, undefined, chainOverride>, "address" | "abi" | "functionName" | "args"> extends infer T ? { [K in keyof T]: import("viem").UnionOmit<import("viem").WriteContractParameters<QuoterV2ABI, never, readonly unknown[], import("viem").Chain | undefined, undefined, chainOverride>, "address" | "abi" | "functionName" | "args">[K]; } : never>(args: readonly unknown[], options: options) => Promise<import("viem").WriteContractReturnType>;
|
|
342
|
+
};
|
|
343
|
+
address: `0x${string}`;
|
|
344
|
+
abi: QuoterV2ABI;
|
|
345
|
+
};
|
|
346
|
+
params: {
|
|
347
|
+
tokenIn: `0x${string}`;
|
|
348
|
+
tokenOut: `0x${string}`;
|
|
349
|
+
deployer: `0x${string}`;
|
|
350
|
+
amountIn: bigint;
|
|
351
|
+
limitSqrtPrice: bigint;
|
|
352
|
+
tickSpacing?: undefined;
|
|
353
|
+
sqrtPriceLimitX96?: undefined;
|
|
354
|
+
fee?: undefined;
|
|
355
|
+
} | {
|
|
356
|
+
tokenIn: `0x${string}`;
|
|
357
|
+
tokenOut: `0x${string}`;
|
|
358
|
+
amountIn: bigint;
|
|
359
|
+
tickSpacing: number;
|
|
360
|
+
sqrtPriceLimitX96: bigint;
|
|
361
|
+
deployer?: undefined;
|
|
362
|
+
limitSqrtPrice?: undefined;
|
|
363
|
+
fee?: undefined;
|
|
364
|
+
} | {
|
|
365
|
+
tokenIn: `0x${string}`;
|
|
366
|
+
tokenOut: `0x${string}`;
|
|
367
|
+
amountIn: bigint;
|
|
368
|
+
limitSqrtPrice: bigint;
|
|
369
|
+
deployer?: undefined;
|
|
370
|
+
tickSpacing?: undefined;
|
|
371
|
+
sqrtPriceLimitX96?: undefined;
|
|
372
|
+
fee?: undefined;
|
|
373
|
+
} | {
|
|
374
|
+
tokenIn: `0x${string}`;
|
|
375
|
+
tokenOut: `0x${string}`;
|
|
376
|
+
amountIn: bigint;
|
|
377
|
+
fee: number;
|
|
378
|
+
sqrtPriceLimitX96: bigint;
|
|
379
|
+
deployer?: undefined;
|
|
380
|
+
limitSqrtPrice?: undefined;
|
|
381
|
+
tickSpacing?: undefined;
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Gets the appropriate QuoterV2 ABI based on the beacon name and protocol.
|
|
386
|
+
*
|
|
387
|
+
* @param protocol - The detected protocol type
|
|
388
|
+
* @returns The appropriate ABI array
|
|
389
|
+
*/
|
|
390
|
+
getQuoterAbi(protocol: Protocol | null): QuoterV2ABI;
|
|
391
|
+
/**
|
|
392
|
+
* Gets the QuoterV2 address for the given protocol from the network configuration.
|
|
393
|
+
*
|
|
394
|
+
* @param protocol - The protocol type
|
|
395
|
+
* @returns The quoter address or undefined if not found
|
|
396
|
+
*/
|
|
397
|
+
getQuoterV2Address(protocol: Protocol | null): string | undefined;
|
|
398
|
+
/**
|
|
399
|
+
* Checks if the beacon represents an Algebra Integral v2.1 vault.
|
|
400
|
+
*
|
|
401
|
+
* @param beaconName - The beacon identifier
|
|
402
|
+
* @returns True if it's an Algebra Integral v2.1 vault
|
|
403
|
+
*/
|
|
404
|
+
private isAlgebraIntegral21Vault;
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Helper function to get QuoterV2 address for a protocol from network config.
|
|
408
|
+
*
|
|
409
|
+
* @param protocol - The protocol to get the quoter address for
|
|
410
|
+
* @param networkConfig - The network configuration object
|
|
411
|
+
* @returns The quoter address or undefined if not found
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* ```typescript
|
|
415
|
+
* const quoterAddress = getQuoterV2Address(Protocol.QuickSwap, networkConfig);
|
|
416
|
+
* if (quoterAddress) {
|
|
417
|
+
* // Use the quoter address
|
|
418
|
+
* }
|
|
419
|
+
* ```
|
|
420
|
+
*/
|
|
421
|
+
/**
|
|
422
|
+
* Type guard to check if parameters are for Uniswap V3 style quoter
|
|
423
|
+
*/
|
|
424
|
+
export declare function isUniswapQuoteParams(params: QuoteParams): params is UniswapQuoteParams;
|
|
425
|
+
/**
|
|
426
|
+
* Type guard to check if parameters are for Algebra style quoter
|
|
427
|
+
*/
|
|
428
|
+
export declare function isAlgebraQuoteParams(params: QuoteParams): params is AlgebraQuoteParams;
|
|
429
|
+
/**
|
|
430
|
+
* Type guard to check if parameters are for Thick V2 style quoter
|
|
431
|
+
*/
|
|
432
|
+
export declare function isThickQuoteParams(params: QuoteParams): params is ThickQuoteParams;
|
|
433
|
+
/**
|
|
434
|
+
* Type guard to check if parameters are for Algebra Integral v2.1 style quoter
|
|
435
|
+
*/
|
|
436
|
+
export declare function isAlgebraIntegral21QuoteParams(params: QuoteParams): params is AlgebraIntegral21QuoteParams;
|
|
437
|
+
/**
|
|
438
|
+
* Type guard to check if parameters are for Shadow style quoter
|
|
439
|
+
*/
|
|
440
|
+
export declare function isShadowQuoteParams(params: QuoteParams): params is ShadowQuoteParams;
|
|
441
|
+
/**
|
|
442
|
+
* Validates quote parameters based on the protocol type detected from beacon name
|
|
443
|
+
*
|
|
444
|
+
* @param beaconName - The beacon identifier to determine the protocol type
|
|
445
|
+
* @param params - The parameters to validate
|
|
446
|
+
* @throws Error if parameters don't match the expected protocol type
|
|
447
|
+
*/
|
|
448
|
+
export declare function validateQuoteParams(protocol: Protocol, params: QuoteParams): void;
|
|
449
|
+
/**
|
|
450
|
+
* Gets the expected parameter type for a given beacon name
|
|
451
|
+
*
|
|
452
|
+
* @param beaconName - The beacon identifier
|
|
453
|
+
* @returns String describing the expected parameter type
|
|
454
|
+
*/
|
|
455
|
+
export declare function getExpectedParamType(beaconName: string): string;
|
|
17
456
|
//# sourceMappingURL=quoter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quoter.d.ts","sourceRoot":"","sources":["../../../src/const/quoter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"quoter.d.ts","sourceRoot":"","sources":["../../../src/const/quoter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGnC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,aAAa,EACb,wBAAwB,EACxB,0BAA0B,EAC1B,cAAc,EACf,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,GAAG,EAAE,MAAM,CAAC;IACZ,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,kBAAmB,SAAQ,eAAe;IACzD,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,eAAe;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAkB,SAAQ,eAAe;IACxD,WAAW,EAAE,MAAM,CAAC;IACpB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;GAEG;AACH,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