@panoptic-eng/sdk 1.0.21 → 1.0.23
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/cow/index.d.ts +4 -4
- package/dist/cow/index.js +3 -3
- package/dist/cow/types.d.ts +2 -3
- package/dist/{cow-C_SGXoWr.js → cow-BilQfbNT.js} +2 -2
- package/dist/{cow-C_SGXoWr.js.map → cow-BilQfbNT.js.map} +1 -1
- package/dist/{index-BuJcj5aO.d.ts → index-CIlr4SNh.d.ts} +4 -3
- package/dist/index-CIlr4SNh.d.ts.map +1 -0
- package/dist/index.d.ts +696 -5908
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1393 -579
- package/dist/index.js.map +1 -1
- package/dist/{irm-CfM383Ku.js → irm-C7EQwrga.js} +332 -3
- package/dist/irm-C7EQwrga.js.map +1 -0
- package/dist/irm-CSJX9BsU.d.ts +5694 -0
- package/dist/irm-CSJX9BsU.d.ts.map +1 -0
- package/dist/panoptic/v2/index.d.ts +438 -10
- package/dist/panoptic/v2/index.d.ts.map +1 -1
- package/dist/panoptic/v2/index.js +200 -8
- package/dist/panoptic/v2/index.js.map +1 -1
- package/dist/{position-BK4a-Yyu.js → position-CsIEneku.js} +33 -2
- package/dist/position-CsIEneku.js.map +1 -0
- package/dist/{router-CMrp245w.js → router-BM10ZWY5.js} +90 -40
- package/dist/router-BM10ZWY5.js.map +1 -0
- package/dist/simulation-4SzTI-xf.d.ts +435 -0
- package/dist/simulation-4SzTI-xf.d.ts.map +1 -0
- package/dist/test/index.d.ts +2 -2
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -1
- package/dist/tx-Banz1S18.d.ts +367 -0
- package/dist/tx-Banz1S18.d.ts.map +1 -0
- package/dist/{types-CRvvn2ce.d.ts → types-Bzw_7NJv.d.ts} +2 -2
- package/dist/{types-CRvvn2ce.d.ts.map → types-Bzw_7NJv.d.ts.map} +1 -1
- package/dist/types-CspUPolV.d.ts +892 -0
- package/dist/types-CspUPolV.d.ts.map +1 -0
- package/dist/uniswap/index.d.ts +121 -4
- package/dist/uniswap/index.d.ts.map +1 -1
- package/dist/uniswap/index.js +228 -4
- package/dist/uniswap/index.js.map +1 -0
- package/dist/{writes-DymnVbiE.js → writes-BnO9zj-Z.js} +42 -11
- package/dist/writes-BnO9zj-Z.js.map +1 -0
- package/dist/zodiac/index.d.ts +439 -0
- package/dist/zodiac/index.d.ts.map +1 -0
- package/dist/zodiac/index.js +944 -0
- package/dist/zodiac/index.js.map +1 -0
- package/package.json +6 -1
- package/dist/index-BuJcj5aO.d.ts.map +0 -1
- package/dist/index-DVMjZi1E.d.ts +0 -1801
- package/dist/index-DVMjZi1E.d.ts.map +0 -1
- package/dist/irm-CGykVo3q.d.ts +0 -32
- package/dist/irm-CGykVo3q.d.ts.map +0 -1
- package/dist/irm-CfM383Ku.js.map +0 -1
- package/dist/irm-zWjtffWA.d.ts +0 -85
- package/dist/irm-zWjtffWA.d.ts.map +0 -1
- package/dist/panoptic/v2/types/index.d.ts +0 -3
- package/dist/panoptic/v2/types/index.js +0 -0
- package/dist/position-BK4a-Yyu.js.map +0 -1
- package/dist/router-CMrp245w.js.map +0 -1
- package/dist/types-BQejAFnu.d.ts +0 -245
- package/dist/types-BQejAFnu.d.ts.map +0 -1
- package/dist/writes-DymnVbiE.js.map +0 -1
|
@@ -0,0 +1,892 @@
|
|
|
1
|
+
import { BlockMeta } from "./simulation-4SzTI-xf.js";
|
|
2
|
+
import { TxOverrides } from "./tx-Banz1S18.js";
|
|
3
|
+
import { Address, PublicClient, WalletClient } from "viem";
|
|
4
|
+
|
|
5
|
+
//#region src/panoptic/v2/formatters/tick.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Tick and price formatters for Uniswap V3/V4 pools.
|
|
8
|
+
*
|
|
9
|
+
* Ticks represent logarithmic prices where: price = 1.0001^tick
|
|
10
|
+
*
|
|
11
|
+
* @module v2/formatters/tick
|
|
12
|
+
*/
|
|
13
|
+
/**
|
|
14
|
+
* Tick and price formatters for Uniswap V3/V4 pools.
|
|
15
|
+
*
|
|
16
|
+
* Ticks represent logarithmic prices where: price = 1.0001^tick
|
|
17
|
+
*
|
|
18
|
+
* @module v2/formatters/tick
|
|
19
|
+
*/
|
|
20
|
+
declare function tickToSqrtPriceX96(tick: bigint): bigint;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a tick to a raw price string (no decimal adjustment).
|
|
23
|
+
* Uses the formula: price = 1.0001^tick
|
|
24
|
+
*
|
|
25
|
+
* This returns the raw price ratio, not adjusted for token decimals.
|
|
26
|
+
* A fixed internal precision is used and trailing zeros are trimmed.
|
|
27
|
+
*
|
|
28
|
+
* @param tick - The tick value
|
|
29
|
+
* @returns Price string
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* tickToPrice(0n) // "1"
|
|
34
|
+
* tickToPrice(1000n) // "1.105..." (approximately)
|
|
35
|
+
* tickToPrice(-1000n) // "0.904..." (approximately)
|
|
36
|
+
* tickToPrice(200000n) // Very large number
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
declare function tickToPrice(tick: bigint): string;
|
|
40
|
+
/**
|
|
41
|
+
* Convert a tick to a human-readable price with decimal scaling.
|
|
42
|
+
* Uses the formula: price = 1.0001^tick * 10^(decimals0-decimals1)
|
|
43
|
+
*
|
|
44
|
+
* This adjusts for the different decimals of the two tokens in the pair.
|
|
45
|
+
*
|
|
46
|
+
* @param tick - The tick value
|
|
47
|
+
* @param decimals0 - Decimals of token0
|
|
48
|
+
* @param decimals1 - Decimals of token1
|
|
49
|
+
* @param precision - Number of decimal places to display
|
|
50
|
+
* @returns Formatted price string
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* // WETH/USDC pool (18 decimals / 6 decimals)
|
|
55
|
+
* // At tick ~200000, price is roughly $2000 per ETH
|
|
56
|
+
* tickToPriceDecimalScaled(200000n, 18n, 6n, 2n) // "2000.00" (approximately)
|
|
57
|
+
*
|
|
58
|
+
* // For token1/token0 price, swap the decimals
|
|
59
|
+
* tickToPriceDecimalScaled(200000n, 6n, 18n, 6n) // "0.000500" (approximately)
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
declare function tickToPriceDecimalScaled(tick: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): string;
|
|
63
|
+
/**
|
|
64
|
+
* Convert a sqrtPriceX96 to a human-readable price with decimal scaling.
|
|
65
|
+
*
|
|
66
|
+
* Uses the formula: price = (sqrtPriceX96^2 / 2^192) * 10^(decimals0-decimals1)
|
|
67
|
+
*
|
|
68
|
+
* @param sqrtPriceX96 - The sqrt price in Q64.96 format
|
|
69
|
+
* @param decimals0 - Decimals of token0
|
|
70
|
+
* @param decimals1 - Decimals of token1
|
|
71
|
+
* @param precision - Number of decimal places to display
|
|
72
|
+
* @returns Formatted price string
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* sqrtPriceX96ToPriceDecimalScaled(2n ** 96n, 18n, 18n, 2n) // "1.00"
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare function sqrtPriceX96ToPriceDecimalScaled(sqrtPriceX96: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): string;
|
|
80
|
+
/**
|
|
81
|
+
* Convert a price to a tick value.
|
|
82
|
+
*
|
|
83
|
+
* @param price - The price string
|
|
84
|
+
* @param decimals0 - Decimals of token0
|
|
85
|
+
* @param decimals1 - Decimals of token1
|
|
86
|
+
* @returns The tick value (rounded to nearest integer)
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // WETH/USDC: What tick for $2000 per ETH?
|
|
91
|
+
* priceToTick("2000", 18n, 6n) // ~200000n
|
|
92
|
+
*
|
|
93
|
+
* // Inverse: What tick for 0.0005 ETH per USDC?
|
|
94
|
+
* priceToTick("0.0005", 6n, 18n) // ~200000n
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
declare function priceToTick(price: string, decimals0: bigint, decimals1: bigint): bigint;
|
|
98
|
+
/**
|
|
99
|
+
* Convert a sqrtPriceX96 value to the nearest tick.
|
|
100
|
+
*
|
|
101
|
+
* @param sqrtPriceX96 - The sqrt price in Q64.96 format
|
|
102
|
+
* @returns The tick value (rounded to nearest integer)
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const tick = sqrtPriceX96ToTick(2n ** 96n) // 0n
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
declare function sqrtPriceX96ToTick(sqrtPriceX96: bigint): bigint;
|
|
110
|
+
/**
|
|
111
|
+
* Format a tick value for display.
|
|
112
|
+
*
|
|
113
|
+
* @param tick - The tick value
|
|
114
|
+
* @returns Formatted tick string
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* formatTick(200000n) // "200000"
|
|
119
|
+
* formatTick(-50000n) // "-50000"
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
declare function formatTick(tick: bigint): string;
|
|
123
|
+
/**
|
|
124
|
+
* Get the price at a specific tick, returning both token0/token1 and token1/token0 prices.
|
|
125
|
+
*
|
|
126
|
+
* @param tick - The tick value
|
|
127
|
+
* @param decimals0 - Decimals of token0
|
|
128
|
+
* @param decimals1 - Decimals of token1
|
|
129
|
+
* @param precision - Number of decimal places to display
|
|
130
|
+
* @returns Object with both price directions
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const prices = getPricesAtTick(200000n, 18n, 6n, 2n)
|
|
135
|
+
* // prices.token0PerToken1 = "0.00" (very small)
|
|
136
|
+
* // prices.token1PerToken0 = "2000.00" (USDC per ETH)
|
|
137
|
+
* ```
|
|
138
|
+
*/
|
|
139
|
+
declare function getPricesAtTick(tick: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): {
|
|
140
|
+
token0PerToken1: string;
|
|
141
|
+
token1PerToken0: string;
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Format a tick range for display.
|
|
145
|
+
*
|
|
146
|
+
* @param tickLower - Lower tick
|
|
147
|
+
* @param tickUpper - Upper tick
|
|
148
|
+
* @returns Formatted tick range string
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* ```typescript
|
|
152
|
+
* formatTickRange(-50000n, 200000n) // "-50000 - 200000"
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
declare function formatTickRange(tickLower: bigint, tickUpper: bigint): string;
|
|
156
|
+
/**
|
|
157
|
+
* Format a price range for display.
|
|
158
|
+
*
|
|
159
|
+
* @param tickLower - Lower tick
|
|
160
|
+
* @param tickUpper - Upper tick
|
|
161
|
+
* @param decimals0 - Decimals of token0
|
|
162
|
+
* @param decimals1 - Decimals of token1
|
|
163
|
+
* @param precision - Number of decimal places to display
|
|
164
|
+
* @returns Formatted price range string
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* formatPriceRange(0n, 0n, 18n, 18n, 2n) // "1.00 - 1.00"
|
|
169
|
+
* ```
|
|
170
|
+
*/
|
|
171
|
+
declare function formatPriceRange(tickLower: bigint, tickUpper: bigint, decimals0: bigint, decimals1: bigint, precision: bigint): string;
|
|
172
|
+
/**
|
|
173
|
+
* Calculate the tick spacing for a given fee tier.
|
|
174
|
+
*
|
|
175
|
+
* @param feeBps - Fee in basis points (e.g., 500n for 0.05%)
|
|
176
|
+
* @returns Tick spacing
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```typescript
|
|
180
|
+
* getTickSpacing(100n) // 1n (0.01% fee tier)
|
|
181
|
+
* getTickSpacing(500n) // 10n (0.05% fee tier)
|
|
182
|
+
* getTickSpacing(3000n) // 60n (0.30% fee tier)
|
|
183
|
+
* getTickSpacing(10000n) // 200n (1.00% fee tier)
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
declare function getTickSpacing(feeBps: bigint): bigint;
|
|
187
|
+
/**
|
|
188
|
+
* Round a tick to the nearest valid tick for a given tick spacing.
|
|
189
|
+
*
|
|
190
|
+
* @param tick - The tick to round
|
|
191
|
+
* @param tickSpacing - The tick spacing
|
|
192
|
+
* @returns Rounded tick
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* roundToTickSpacing(12345n, 10n) // 12340n
|
|
197
|
+
* roundToTickSpacing(12345n, 60n) // 12360n
|
|
198
|
+
* roundToTickSpacing(-12345n, 10n) // -12350n
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
declare function roundToTickSpacing(tick: bigint, tickSpacing: bigint): bigint;
|
|
202
|
+
/**
|
|
203
|
+
* Result of {@link tickLimits}.
|
|
204
|
+
*/
|
|
205
|
+
interface TickLimitsResult {
|
|
206
|
+
/** Lower tick limit (clamped to MIN_TICK). */
|
|
207
|
+
low: bigint;
|
|
208
|
+
/** Upper tick limit (clamped to MAX_TICK). */
|
|
209
|
+
high: bigint;
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Compute slippage-bounded tick limits around the current tick.
|
|
213
|
+
*
|
|
214
|
+
* 1 tick ≈ 1 basis point (0.01 %) of price change, so a `toleranceBps`
|
|
215
|
+
* of 500 allows roughly 5 % price movement. The result is clamped to
|
|
216
|
+
* the protocol's `[MIN_TICK, MAX_TICK]` range.
|
|
217
|
+
*
|
|
218
|
+
* Useful for setting `tickLimitLow` / `tickLimitHigh` on `openPosition`
|
|
219
|
+
* and `closePosition` to protect against MEV sandwiches and volatile
|
|
220
|
+
* tick moves.
|
|
221
|
+
*
|
|
222
|
+
* @param currentTick - The current pool tick (must be within [MIN_TICK, MAX_TICK]).
|
|
223
|
+
* @param toleranceBps - Slippage tolerance in basis points (≈ ticks). Must be non-negative.
|
|
224
|
+
* @returns Clamped `{ low, high }` tick limits.
|
|
225
|
+
* @throws {RangeError} If `toleranceBps` is negative or `currentTick` is out of bounds.
|
|
226
|
+
*
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const { low, high } = tickLimits(200_000n, 500n)
|
|
230
|
+
* // low = 199_500n
|
|
231
|
+
* // high = 200_500n
|
|
232
|
+
*
|
|
233
|
+
* await openPosition({ ..., tickLimitLow: low, tickLimitHigh: high })
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
declare function tickLimits(currentTick: bigint, toleranceBps: bigint): TickLimitsResult; //#endregion
|
|
237
|
+
//#region src/panoptic/v2/reads/pool.d.ts
|
|
238
|
+
/**
|
|
239
|
+
* Immutable pool metadata that can be cached.
|
|
240
|
+
* These values never change for a given pool, so they're exempt from
|
|
241
|
+
* same-block consistency requirements (per PLAN.md "Static Prefetches" exception).
|
|
242
|
+
*/
|
|
243
|
+
interface PoolMetadata {
|
|
244
|
+
/** Pool key bytes */
|
|
245
|
+
poolKeyBytes: `0x${string}`;
|
|
246
|
+
/** Pool ID */
|
|
247
|
+
poolId: bigint;
|
|
248
|
+
/** Collateral tracker 0 address */
|
|
249
|
+
collateralToken0Address: Address;
|
|
250
|
+
/** Collateral tracker 1 address */
|
|
251
|
+
collateralToken1Address: Address;
|
|
252
|
+
/** Risk engine address */
|
|
253
|
+
riskEngineAddress: Address;
|
|
254
|
+
/** Token 0 underlying asset address */
|
|
255
|
+
token0Asset: Address;
|
|
256
|
+
/** Token 1 underlying asset address */
|
|
257
|
+
token1Asset: Address;
|
|
258
|
+
/** Token 0 symbol */
|
|
259
|
+
token0Symbol: string;
|
|
260
|
+
/** Token 1 symbol */
|
|
261
|
+
token1Symbol: string;
|
|
262
|
+
/** Token 0 decimals */
|
|
263
|
+
token0Decimals: bigint;
|
|
264
|
+
/** Token 1 decimals */
|
|
265
|
+
token1Decimals: bigint;
|
|
266
|
+
/** Token 0 name */
|
|
267
|
+
token0Name: string;
|
|
268
|
+
/** Token 1 name */
|
|
269
|
+
token1Name: string;
|
|
270
|
+
/** Underlying pool ID (V3: pool address, V4: keccak256(poolKeyBytes)) */
|
|
271
|
+
underlyingPoolId: string;
|
|
272
|
+
/** Whether this is a V4 pool (poolManager is non-zero) */
|
|
273
|
+
isV4: boolean;
|
|
274
|
+
/** Tick spacing */
|
|
275
|
+
tickSpacing: bigint;
|
|
276
|
+
/** Fee tier (V4: from poolKey, V3: from Uniswap pool fee()) */
|
|
277
|
+
fee: bigint;
|
|
278
|
+
/** SemiFungiblePositionManager address */
|
|
279
|
+
sfpmAddress: Address;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Parameters for getPoolMetadata.
|
|
283
|
+
*/
|
|
284
|
+
interface GetPoolMetadataParams {
|
|
285
|
+
/** viem PublicClient */
|
|
286
|
+
client: PublicClient;
|
|
287
|
+
/** PanopticPool address */
|
|
288
|
+
poolAddress: Address;
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Fetch immutable pool metadata (addresses, symbols, decimals).
|
|
292
|
+
* This data never changes for a given pool and can be cached indefinitely.
|
|
293
|
+
*
|
|
294
|
+
* This is the "static prefetch" per PLAN.md §6 - exempt from same-block consistency.
|
|
295
|
+
*
|
|
296
|
+
* @param params - The parameters
|
|
297
|
+
* @returns Immutable pool metadata
|
|
298
|
+
*/
|
|
299
|
+
declare function getPoolMetadata(params: GetPoolMetadataParams): Promise<PoolMetadata>;
|
|
300
|
+
/**
|
|
301
|
+
* Parameters for getPool.
|
|
302
|
+
*/
|
|
303
|
+
interface GetPoolParams {
|
|
304
|
+
/** viem PublicClient */
|
|
305
|
+
client: PublicClient;
|
|
306
|
+
/** PanopticPool address */
|
|
307
|
+
poolAddress: Address;
|
|
308
|
+
/** Chain ID */
|
|
309
|
+
chainId: bigint;
|
|
310
|
+
/** Optional block number for historical queries */
|
|
311
|
+
blockNumber?: bigint;
|
|
312
|
+
/** Optional pre-fetched pool metadata (for caching/optimization) */
|
|
313
|
+
poolMetadata?: PoolMetadata;
|
|
314
|
+
/** Optional StateView address for V4 pools (needed to read Uniswap pool liquidity) */
|
|
315
|
+
stateViewAddress?: Address;
|
|
316
|
+
/** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
|
|
317
|
+
_meta?: BlockMeta;
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Get full pool data including both collateral trackers and oracle state.
|
|
321
|
+
*
|
|
322
|
+
* ## Same-Block Guarantee
|
|
323
|
+
* All dynamic data is fetched in ONE multicall at the target block.
|
|
324
|
+
* Static metadata (addresses, symbols, decimals) is either provided via
|
|
325
|
+
* poolMetadata or fetched separately (static prefetch exception).
|
|
326
|
+
*
|
|
327
|
+
* @param params - The parameters
|
|
328
|
+
* @returns Pool data with block metadata
|
|
329
|
+
*/
|
|
330
|
+
declare function getPool(params: GetPoolParams): Promise<Pool>;
|
|
331
|
+
/**
|
|
332
|
+
* Parameters for getUtilization.
|
|
333
|
+
*/
|
|
334
|
+
interface GetUtilizationParams {
|
|
335
|
+
/** viem PublicClient */
|
|
336
|
+
client: PublicClient;
|
|
337
|
+
/** PanopticPool address */
|
|
338
|
+
poolAddress: Address;
|
|
339
|
+
/** Optional block number for historical queries */
|
|
340
|
+
blockNumber?: bigint;
|
|
341
|
+
/** Optional pre-fetched collateral tracker addresses (for caching/optimization) */
|
|
342
|
+
collateralAddresses?: {
|
|
343
|
+
collateralToken0: Address;
|
|
344
|
+
collateralToken1: Address;
|
|
345
|
+
};
|
|
346
|
+
/** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
|
|
347
|
+
_meta?: BlockMeta;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Get current pool utilization for both tokens.
|
|
351
|
+
*
|
|
352
|
+
* ## Same-Block Guarantee
|
|
353
|
+
* All dynamic data is fetched in ONE multicall at the target block.
|
|
354
|
+
* Collateral tracker addresses are either provided or fetched separately (static prefetch).
|
|
355
|
+
*
|
|
356
|
+
* @param params - The parameters
|
|
357
|
+
* @returns Utilization data with block metadata
|
|
358
|
+
*/
|
|
359
|
+
declare function getUtilization(params: GetUtilizationParams): Promise<Utilization>;
|
|
360
|
+
/**
|
|
361
|
+
* Parameters for getOracleState.
|
|
362
|
+
*/
|
|
363
|
+
interface GetOracleStateParams {
|
|
364
|
+
/** viem PublicClient */
|
|
365
|
+
client: PublicClient;
|
|
366
|
+
/** PanopticPool address */
|
|
367
|
+
poolAddress: Address;
|
|
368
|
+
/** Optional block number for historical queries */
|
|
369
|
+
blockNumber?: bigint;
|
|
370
|
+
/** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
|
|
371
|
+
_meta?: BlockMeta;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* Get current oracle state from the pool.
|
|
375
|
+
*
|
|
376
|
+
* ## Same-Block Guarantee
|
|
377
|
+
* Single contract call + block meta fetch at the same block.
|
|
378
|
+
*
|
|
379
|
+
* @param params - The parameters
|
|
380
|
+
* @returns Oracle state with block metadata
|
|
381
|
+
*/
|
|
382
|
+
declare function getOracleState(params: GetOracleStateParams): Promise<OracleState>;
|
|
383
|
+
/**
|
|
384
|
+
* Parameters for getRiskParameters.
|
|
385
|
+
*/
|
|
386
|
+
interface GetRiskParametersParams {
|
|
387
|
+
/** viem PublicClient */
|
|
388
|
+
client: PublicClient;
|
|
389
|
+
/** PanopticPool address */
|
|
390
|
+
poolAddress: Address;
|
|
391
|
+
/** Builder code (default: 0) */
|
|
392
|
+
builderCode?: bigint;
|
|
393
|
+
/** Optional block number for historical queries */
|
|
394
|
+
blockNumber?: bigint;
|
|
395
|
+
/** Optional pre-fetched risk engine address (for caching/optimization) */
|
|
396
|
+
riskEngineAddress?: Address;
|
|
397
|
+
/** Optional pre-fetched block metadata (skips getBlockMeta RPC call) */
|
|
398
|
+
_meta?: BlockMeta;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Get risk parameters from the pool.
|
|
402
|
+
*
|
|
403
|
+
* ## Same-Block Guarantee
|
|
404
|
+
* All dynamic data is fetched in ONE multicall at the target block.
|
|
405
|
+
* Risk engine address is either provided or fetched separately (static prefetch).
|
|
406
|
+
*
|
|
407
|
+
* @param params - The parameters
|
|
408
|
+
* @returns Risk parameters with block metadata
|
|
409
|
+
*/
|
|
410
|
+
declare function getRiskParameters(params: GetRiskParametersParams): Promise<RiskParameters>;
|
|
411
|
+
/**
|
|
412
|
+
* Validate whether a builder code maps to a deployed builder wallet.
|
|
413
|
+
*
|
|
414
|
+
* Calls `PanopticPool.getRiskParameters(builderCode)` — the contract reverts
|
|
415
|
+
* with `InvalidBuilderCode` when the computed CREATE2 address has no bytecode.
|
|
416
|
+
*
|
|
417
|
+
* @returns `true` when valid, `false` when the contract reverts.
|
|
418
|
+
*/
|
|
419
|
+
declare function validateBuilderCode(params: {
|
|
420
|
+
client: PublicClient;
|
|
421
|
+
poolAddress: Address;
|
|
422
|
+
builderCode: bigint;
|
|
423
|
+
}): Promise<boolean>;
|
|
424
|
+
/**
|
|
425
|
+
* Parameters for fetchPoolId.
|
|
426
|
+
*/
|
|
427
|
+
interface FetchPoolIdParams {
|
|
428
|
+
/** viem PublicClient */
|
|
429
|
+
client: PublicClient;
|
|
430
|
+
/** PanopticPool address */
|
|
431
|
+
poolAddress: Address;
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Result of fetchPoolId, including block metadata for same-block consistency.
|
|
435
|
+
*/
|
|
436
|
+
interface FetchPoolIdResult {
|
|
437
|
+
/** The encoded 64-bit pool ID */
|
|
438
|
+
poolId: bigint;
|
|
439
|
+
/** Block metadata from the pinned read */
|
|
440
|
+
_meta: BlockMeta;
|
|
441
|
+
}
|
|
442
|
+
/**
|
|
443
|
+
* Fetch the encoded 64-bit pool ID from a PanopticPool contract.
|
|
444
|
+
*
|
|
445
|
+
* Use this when you need the poolId without fetching the full pool state.
|
|
446
|
+
* The returned poolId can be passed directly to `createTokenIdBuilder()`.
|
|
447
|
+
* The read is pinned to the latest block at call time.
|
|
448
|
+
*
|
|
449
|
+
* @param params - The parameters
|
|
450
|
+
* @returns The pool ID and block metadata
|
|
451
|
+
*/
|
|
452
|
+
declare function fetchPoolId(params: FetchPoolIdParams): Promise<FetchPoolIdResult>;
|
|
453
|
+
|
|
454
|
+
//#endregion
|
|
455
|
+
//#region src/panoptic/v2/types/pool.d.ts
|
|
456
|
+
/**
|
|
457
|
+
* Pool health status.
|
|
458
|
+
*/
|
|
459
|
+
type PoolHealthStatus = 'active' | 'low_liquidity' | 'paused';
|
|
460
|
+
/**
|
|
461
|
+
* Collateral tracker information.
|
|
462
|
+
*/
|
|
463
|
+
interface CollateralTracker {
|
|
464
|
+
/** Address of the collateral tracker contract */
|
|
465
|
+
address: Address;
|
|
466
|
+
/** Address of the underlying token */
|
|
467
|
+
token: Address;
|
|
468
|
+
/** Token symbol */
|
|
469
|
+
symbol: string;
|
|
470
|
+
/** Token decimals */
|
|
471
|
+
decimals: bigint;
|
|
472
|
+
/** Total assets accounted to the pool (deposited assets plus assets in the AMM) */
|
|
473
|
+
totalAssets: bigint;
|
|
474
|
+
/** Assets currently inside the AMM (deployed as liquidity) */
|
|
475
|
+
insideAMM: bigint;
|
|
476
|
+
/** Credited shares (shares owed to liquidity providers) */
|
|
477
|
+
creditedShares: bigint;
|
|
478
|
+
/** Total shares outstanding */
|
|
479
|
+
totalShares: bigint;
|
|
480
|
+
/** Current utilization (0-10000 bps) */
|
|
481
|
+
utilization: bigint;
|
|
482
|
+
/** Current borrow rate (annualized, WAD-scaled: 1e18 = 100%/year) */
|
|
483
|
+
borrowRate: bigint;
|
|
484
|
+
/** Current supply rate (annualized, WAD-scaled: 1e18 = 100%/year) */
|
|
485
|
+
supplyRate: bigint;
|
|
486
|
+
}
|
|
487
|
+
/**
|
|
488
|
+
* Risk engine information.
|
|
489
|
+
*/
|
|
490
|
+
interface RiskEngine {
|
|
491
|
+
/** Address of the risk engine contract */
|
|
492
|
+
address: Address;
|
|
493
|
+
/** Collateral requirement factor (in bps) */
|
|
494
|
+
collateralRequirement: bigint;
|
|
495
|
+
/** Maintenance margin factor (in bps) */
|
|
496
|
+
maintenanceMargin: bigint;
|
|
497
|
+
/** Commission rate (in bps) */
|
|
498
|
+
commissionRate: bigint;
|
|
499
|
+
/** VEGOID constant used in spread calculation */
|
|
500
|
+
vegoid: bigint;
|
|
501
|
+
/** Maximum spread parameter (in bps) */
|
|
502
|
+
maxSpread: bigint;
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Uniswap V4 pool key.
|
|
506
|
+
*/
|
|
507
|
+
interface PoolKey {
|
|
508
|
+
/** Token 0 address */
|
|
509
|
+
currency0: Address;
|
|
510
|
+
/** Token 1 address */
|
|
511
|
+
currency1: Address;
|
|
512
|
+
/** Fee tier */
|
|
513
|
+
fee: bigint;
|
|
514
|
+
/** Tick spacing */
|
|
515
|
+
tickSpacing: bigint;
|
|
516
|
+
/** Hook address (if any) */
|
|
517
|
+
hooks: Address;
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Pool data returned by getPool().
|
|
521
|
+
*/
|
|
522
|
+
interface Pool {
|
|
523
|
+
/** Address of the PanopticPool contract */
|
|
524
|
+
address: Address;
|
|
525
|
+
/** Chain ID */
|
|
526
|
+
chainId: bigint;
|
|
527
|
+
/** Encoded pool ID (64-bit) */
|
|
528
|
+
poolId: bigint;
|
|
529
|
+
/** Uniswap pool key (V4: full struct, V3: zeroed fields) */
|
|
530
|
+
poolKey: PoolKey;
|
|
531
|
+
/** Tick spacing (extracted from encoded poolId) */
|
|
532
|
+
tickSpacing: bigint;
|
|
533
|
+
/** Token 0 collateral tracker */
|
|
534
|
+
collateralTracker0: CollateralTracker;
|
|
535
|
+
/** Token 1 collateral tracker */
|
|
536
|
+
collateralTracker1: CollateralTracker;
|
|
537
|
+
/** Risk engine */
|
|
538
|
+
riskEngine: RiskEngine;
|
|
539
|
+
/** Current tick */
|
|
540
|
+
currentTick: bigint;
|
|
541
|
+
/** Current sqrt price (Q64.96) */
|
|
542
|
+
sqrtPriceX96: bigint;
|
|
543
|
+
/** Uniswap pool in-range liquidity (from V3 pool.liquidity() or V4 StateView.getLiquidity()) */
|
|
544
|
+
uniswapPoolLiquidity: bigint;
|
|
545
|
+
/** Pool health status */
|
|
546
|
+
healthStatus: PoolHealthStatus;
|
|
547
|
+
/** Immutable pool metadata (addresses, symbols, decimals, names, underlyingPoolId) */
|
|
548
|
+
metadata: PoolMetadata;
|
|
549
|
+
/** Block metadata */
|
|
550
|
+
_meta: BlockMeta;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Utilization data for both tokens.
|
|
554
|
+
*/
|
|
555
|
+
interface Utilization {
|
|
556
|
+
/** Token 0 utilization (0-10000 bps) */
|
|
557
|
+
utilization0: bigint;
|
|
558
|
+
/** Token 1 utilization (0-10000 bps) */
|
|
559
|
+
utilization1: bigint;
|
|
560
|
+
/** Block metadata */
|
|
561
|
+
_meta: BlockMeta;
|
|
562
|
+
}
|
|
563
|
+
|
|
564
|
+
//#endregion
|
|
565
|
+
//#region src/panoptic/v2/types/oracle.d.ts
|
|
566
|
+
/**
|
|
567
|
+
* Safe mode level from the RiskEngine.
|
|
568
|
+
*/
|
|
569
|
+
type SafeMode = 'normal' | 'restricted' | 'emergency';
|
|
570
|
+
/**
|
|
571
|
+
* Oracle state from the PanopticPool.
|
|
572
|
+
*/
|
|
573
|
+
interface OracleState {
|
|
574
|
+
/** Last update epoch (64-second intervals) */
|
|
575
|
+
epoch: bigint;
|
|
576
|
+
/** Last update timestamp */
|
|
577
|
+
lastUpdateTimestamp: bigint;
|
|
578
|
+
/** Reference tick */
|
|
579
|
+
referenceTick: bigint;
|
|
580
|
+
/** Spot EMA tick */
|
|
581
|
+
spotEMA: bigint;
|
|
582
|
+
/** Fast EMA tick */
|
|
583
|
+
fastEMA: bigint;
|
|
584
|
+
/** Slow EMA tick */
|
|
585
|
+
slowEMA: bigint;
|
|
586
|
+
/** Eons EMA tick */
|
|
587
|
+
eonsEMA: bigint;
|
|
588
|
+
/** Lock mode (0 = unlocked, 1 = spot locked, 2 = full locked) */
|
|
589
|
+
lockMode: bigint;
|
|
590
|
+
/** Median tick from sorted observations */
|
|
591
|
+
medianTick: bigint;
|
|
592
|
+
/** Block metadata */
|
|
593
|
+
_meta: BlockMeta;
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Safe mode state from the RiskEngine.
|
|
597
|
+
*/
|
|
598
|
+
interface SafeModeState {
|
|
599
|
+
/** Current safe mode level */
|
|
600
|
+
mode: SafeMode;
|
|
601
|
+
/** Whether minting new positions is allowed */
|
|
602
|
+
canMint: boolean;
|
|
603
|
+
/** Whether burning positions is allowed */
|
|
604
|
+
canBurn: boolean;
|
|
605
|
+
/** Whether force exercise is allowed */
|
|
606
|
+
canForceExercise: boolean;
|
|
607
|
+
/** Whether liquidations are allowed */
|
|
608
|
+
canLiquidate: boolean;
|
|
609
|
+
/** Whether swapAtMint is allowed (false for NO_SWAP level 2+) */
|
|
610
|
+
canSwapAtMint: boolean;
|
|
611
|
+
/** Reason for current safe mode (if not normal) */
|
|
612
|
+
reason?: string;
|
|
613
|
+
/** Block metadata */
|
|
614
|
+
_meta: BlockMeta;
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Risk parameters from the RiskEngine.
|
|
618
|
+
*/
|
|
619
|
+
interface RiskParameters {
|
|
620
|
+
/** Collateral requirement multiplier (in bps, e.g., 10000 = 100%) */
|
|
621
|
+
collateralRequirement: bigint;
|
|
622
|
+
/** Maintenance margin requirement (in bps) */
|
|
623
|
+
maintenanceMargin: bigint;
|
|
624
|
+
/** Commission rate (in bps) */
|
|
625
|
+
commissionRate: bigint;
|
|
626
|
+
/** Target pool utilization (in bps) */
|
|
627
|
+
targetUtilization: bigint;
|
|
628
|
+
/** Saturated pool utilization threshold (in bps) */
|
|
629
|
+
saturatedUtilization: bigint;
|
|
630
|
+
/** ITM spread multiplier */
|
|
631
|
+
itmSpreadMultiplier: bigint;
|
|
632
|
+
/** Block metadata */
|
|
633
|
+
_meta: BlockMeta;
|
|
634
|
+
}
|
|
635
|
+
/**
|
|
636
|
+
* Current interest rates from the CollateralTrackers.
|
|
637
|
+
*/
|
|
638
|
+
interface CurrentRates {
|
|
639
|
+
/** Token 0 borrow rate (per-second, WAD-scaled) */
|
|
640
|
+
borrowRate0: bigint;
|
|
641
|
+
/** Token 0 supply rate (per-second, WAD-scaled) */
|
|
642
|
+
supplyRate0: bigint;
|
|
643
|
+
/** Token 1 borrow rate (per-second, WAD-scaled) */
|
|
644
|
+
borrowRate1: bigint;
|
|
645
|
+
/** Token 1 supply rate (per-second, WAD-scaled) */
|
|
646
|
+
supplyRate1: bigint;
|
|
647
|
+
/** Block metadata */
|
|
648
|
+
_meta: BlockMeta;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region src/uniswap/v4/addresses.d.ts
|
|
653
|
+
/**
|
|
654
|
+
* Uniswap v4 contract addresses required for a Universal Router spot swap.
|
|
655
|
+
*/
|
|
656
|
+
interface UniswapV4Addresses {
|
|
657
|
+
/** Universal Router (v4-capable build) — entrypoint for `execute(...)`. */
|
|
658
|
+
universalRouter: Address;
|
|
659
|
+
/** V4Quoter — `quoteExactInputSingle` (revert/staticcall-based). */
|
|
660
|
+
v4Quoter: Address;
|
|
661
|
+
/** Uniswap v4 PoolManager (singleton). */
|
|
662
|
+
poolManager: Address;
|
|
663
|
+
/** Canonical Permit2 (same address on every chain). */
|
|
664
|
+
permit2: Address;
|
|
665
|
+
}
|
|
666
|
+
/**
|
|
667
|
+
* Canonical Permit2, identical across all chains.
|
|
668
|
+
*/
|
|
669
|
+
declare const PERMIT2_ADDRESS: Address;
|
|
670
|
+
/**
|
|
671
|
+
* Verified Uniswap v4 deployment addresses keyed by chainId.
|
|
672
|
+
*
|
|
673
|
+
* Sourced from the official Uniswap v4 deployments. Add a chain here only after
|
|
674
|
+
* verifying each address against the canonical Uniswap deployment listing —
|
|
675
|
+
* Universal Router in particular is NOT the same address across chains.
|
|
676
|
+
*/
|
|
677
|
+
declare const UNISWAP_V4_ADDRESSES: Record<number, UniswapV4Addresses>;
|
|
678
|
+
/**
|
|
679
|
+
* Resolve the Uniswap v4 addresses for a chain, applying optional overrides.
|
|
680
|
+
*
|
|
681
|
+
* @param chainId - Target chain ID.
|
|
682
|
+
* @param overrides - Partial override of any address (e.g. for fork tests).
|
|
683
|
+
* @returns Fully-resolved {@link UniswapV4Addresses}.
|
|
684
|
+
* @throws {UnsupportedChainError} when the chain is not listed and the
|
|
685
|
+
* overrides do not supply every required address.
|
|
686
|
+
*/
|
|
687
|
+
declare function getUniswapV4Addresses(chainId: bigint, overrides?: Partial<UniswapV4Addresses>): UniswapV4Addresses;
|
|
688
|
+
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region src/uniswap/v4/router/types.d.ts
|
|
691
|
+
/**
|
|
692
|
+
* Parameters for {@link swapExactInViaRouter}.
|
|
693
|
+
*/
|
|
694
|
+
interface SwapExactInViaRouterParams {
|
|
695
|
+
/** Public client for reads + receipts. */
|
|
696
|
+
client: PublicClient;
|
|
697
|
+
/** Wallet client for signing. */
|
|
698
|
+
walletClient: WalletClient;
|
|
699
|
+
/** Account address. */
|
|
700
|
+
account: Address;
|
|
701
|
+
/** PanopticPool address — used to resolve the underlying v4 PoolKey. */
|
|
702
|
+
poolAddress: Address;
|
|
703
|
+
/** Chain ID (selects per-chain Uniswap v4 addresses). */
|
|
704
|
+
chainId: bigint;
|
|
705
|
+
/** Token to sell. `address(0)` (zero address) for native ETH. */
|
|
706
|
+
tokenIn: Address;
|
|
707
|
+
/** Exact amount of `tokenIn` to spend (must fit uint128). */
|
|
708
|
+
amountIn: bigint;
|
|
709
|
+
/** Slippage tolerance in bps (e.g. 500n = 5%). */
|
|
710
|
+
slippageBps: bigint;
|
|
711
|
+
/** Absolute deadline (unix seconds). If omitted, derived from block timestamp. */
|
|
712
|
+
deadline?: bigint;
|
|
713
|
+
/** Recipient of the output. Defaults to `account`. */
|
|
714
|
+
recipient?: Address;
|
|
715
|
+
/** Gas and transaction overrides. */
|
|
716
|
+
txOverrides?: TxOverrides;
|
|
717
|
+
/** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
|
|
718
|
+
addresses?: Partial<UniswapV4Addresses>;
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Parameters for {@link quoteSwapExactInViaRouter}.
|
|
722
|
+
*/
|
|
723
|
+
interface QuoteSwapExactInViaRouterParams {
|
|
724
|
+
/** Public client. */
|
|
725
|
+
client: PublicClient;
|
|
726
|
+
/** PanopticPool address — used to resolve the underlying v4 PoolKey. */
|
|
727
|
+
poolAddress: Address;
|
|
728
|
+
/** Chain ID. */
|
|
729
|
+
chainId: bigint;
|
|
730
|
+
/** Token to sell. `address(0)` for native ETH. */
|
|
731
|
+
tokenIn: Address;
|
|
732
|
+
/** Exact amount of `tokenIn` to spend (must fit uint128). */
|
|
733
|
+
amountIn: bigint;
|
|
734
|
+
/** Slippage tolerance in bps (used to compute `amountOutMinimum`). */
|
|
735
|
+
slippageBps: bigint;
|
|
736
|
+
/** Optional block number for the quote. */
|
|
737
|
+
blockNumber?: bigint;
|
|
738
|
+
/** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
|
|
739
|
+
addresses?: Partial<UniswapV4Addresses>;
|
|
740
|
+
}
|
|
741
|
+
/**
|
|
742
|
+
* Quote result data (carried inside a `SimulationResult`).
|
|
743
|
+
*/
|
|
744
|
+
interface SwapExactInQuote {
|
|
745
|
+
/** Quoted output amount of `tokenOut`. */
|
|
746
|
+
amountOut: bigint;
|
|
747
|
+
/** Minimum acceptable output after applying slippage. */
|
|
748
|
+
amountOutMinimum: bigint;
|
|
749
|
+
/** Whether the swap goes currency0 → currency1. */
|
|
750
|
+
zeroForOne: boolean;
|
|
751
|
+
/** Output token address (`address(0)` for native ETH). */
|
|
752
|
+
tokenOut: Address;
|
|
753
|
+
/** Resolved v4 PoolKey (reused by the swap calldata builder). */
|
|
754
|
+
poolKey: PoolKey;
|
|
755
|
+
/** Quoter's gas estimate. */
|
|
756
|
+
gasEstimate: bigint;
|
|
757
|
+
}
|
|
758
|
+
/**
|
|
759
|
+
* Parameters for {@link swapExactOutViaRouter}.
|
|
760
|
+
*/
|
|
761
|
+
interface SwapExactOutViaRouterParams {
|
|
762
|
+
/** Public client for reads + receipts. */
|
|
763
|
+
client: PublicClient;
|
|
764
|
+
/** Wallet client for signing. */
|
|
765
|
+
walletClient: WalletClient;
|
|
766
|
+
/** Account address. */
|
|
767
|
+
account: Address;
|
|
768
|
+
/** PanopticPool address — used to resolve the underlying v4 PoolKey. */
|
|
769
|
+
poolAddress: Address;
|
|
770
|
+
/** Chain ID (selects per-chain Uniswap v4 addresses). */
|
|
771
|
+
chainId: bigint;
|
|
772
|
+
/** Token to sell (the pay token). `address(0)` (zero address) for native ETH. */
|
|
773
|
+
tokenIn: Address;
|
|
774
|
+
/** Exact amount of the output token to receive (must fit uint128). */
|
|
775
|
+
amountOut: bigint;
|
|
776
|
+
/** Slippage tolerance in bps (e.g. 500n = 5%); caps the input. */
|
|
777
|
+
slippageBps: bigint;
|
|
778
|
+
/** Absolute deadline (unix seconds). If omitted, derived from block timestamp. */
|
|
779
|
+
deadline?: bigint;
|
|
780
|
+
/** Recipient of the output. Defaults to `account`. */
|
|
781
|
+
recipient?: Address;
|
|
782
|
+
/** Gas and transaction overrides. */
|
|
783
|
+
txOverrides?: TxOverrides;
|
|
784
|
+
/** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
|
|
785
|
+
addresses?: Partial<UniswapV4Addresses>;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Parameters for {@link quoteSwapExactOutViaRouter}.
|
|
789
|
+
*/
|
|
790
|
+
interface QuoteSwapExactOutViaRouterParams {
|
|
791
|
+
/** Public client. */
|
|
792
|
+
client: PublicClient;
|
|
793
|
+
/** PanopticPool address — used to resolve the underlying v4 PoolKey. */
|
|
794
|
+
poolAddress: Address;
|
|
795
|
+
/** Chain ID. */
|
|
796
|
+
chainId: bigint;
|
|
797
|
+
/** Token to sell (the pay token). `address(0)` for native ETH. */
|
|
798
|
+
tokenIn: Address;
|
|
799
|
+
/** Exact amount of the output token to receive (must fit uint128). */
|
|
800
|
+
amountOut: bigint;
|
|
801
|
+
/** Slippage tolerance in bps (used to compute `amountInMaximum`). */
|
|
802
|
+
slippageBps: bigint;
|
|
803
|
+
/** Optional block number for the quote. */
|
|
804
|
+
blockNumber?: bigint;
|
|
805
|
+
/** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
|
|
806
|
+
addresses?: Partial<UniswapV4Addresses>;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Quote result data for an exact-out swap (carried inside a `SimulationResult`).
|
|
810
|
+
*/
|
|
811
|
+
interface SwapExactOutQuote {
|
|
812
|
+
/** Quoted input amount of `tokenIn` required for the exact output. */
|
|
813
|
+
amountIn: bigint;
|
|
814
|
+
/** Maximum acceptable input after applying slippage. */
|
|
815
|
+
amountInMaximum: bigint;
|
|
816
|
+
/** Whether the swap goes currency0 → currency1. */
|
|
817
|
+
zeroForOne: boolean;
|
|
818
|
+
/** Output token address (`address(0)` for native ETH). */
|
|
819
|
+
tokenOut: Address;
|
|
820
|
+
/** Resolved v4 PoolKey (reused by the swap calldata builder). */
|
|
821
|
+
poolKey: PoolKey;
|
|
822
|
+
/** Quoter's gas estimate. */
|
|
823
|
+
gasEstimate: bigint;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Parameters for {@link checkRouterApproval}.
|
|
827
|
+
*/
|
|
828
|
+
interface CheckRouterApprovalParams {
|
|
829
|
+
/** Public client. */
|
|
830
|
+
client: PublicClient;
|
|
831
|
+
/** Chain ID. */
|
|
832
|
+
chainId: bigint;
|
|
833
|
+
/** ERC20 token being spent (must not be native ETH). */
|
|
834
|
+
tokenIn: Address;
|
|
835
|
+
/** Token owner. */
|
|
836
|
+
owner: Address;
|
|
837
|
+
/** Amount that must be spendable. */
|
|
838
|
+
amount: bigint;
|
|
839
|
+
/** Override per-chain Uniswap v4 addresses (e.g. fork tests). */
|
|
840
|
+
addresses?: Partial<UniswapV4Addresses>;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* Result of {@link checkRouterApproval}.
|
|
844
|
+
*/
|
|
845
|
+
interface RouterApprovalStatus {
|
|
846
|
+
/** ERC20 → Permit2 allowance is insufficient. */
|
|
847
|
+
needsErc20Approval: boolean;
|
|
848
|
+
/** Permit2 → Universal Router allowance is insufficient or expired. */
|
|
849
|
+
needsPermit2Approval: boolean;
|
|
850
|
+
/** Current ERC20 → Permit2 allowance. */
|
|
851
|
+
erc20Allowance: bigint;
|
|
852
|
+
/** Current Permit2 → router allowance amount. */
|
|
853
|
+
permit2Amount: bigint;
|
|
854
|
+
/** Current Permit2 → router allowance expiration (unix seconds). */
|
|
855
|
+
permit2Expiration: bigint;
|
|
856
|
+
}
|
|
857
|
+
/**
|
|
858
|
+
* Parameters for {@link approveErc20ForPermit2}.
|
|
859
|
+
*/
|
|
860
|
+
interface ApproveErc20ForPermit2Params {
|
|
861
|
+
client: PublicClient;
|
|
862
|
+
walletClient: WalletClient;
|
|
863
|
+
account: Address;
|
|
864
|
+
chainId: bigint;
|
|
865
|
+
/** ERC20 token to approve to Permit2. */
|
|
866
|
+
tokenIn: Address;
|
|
867
|
+
/** Amount to approve. Defaults to uint256 max. */
|
|
868
|
+
amount?: bigint;
|
|
869
|
+
txOverrides?: TxOverrides;
|
|
870
|
+
addresses?: Partial<UniswapV4Addresses>;
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Parameters for {@link approveRouterViaPermit2}.
|
|
874
|
+
*/
|
|
875
|
+
interface ApproveRouterViaPermit2Params {
|
|
876
|
+
client: PublicClient;
|
|
877
|
+
walletClient: WalletClient;
|
|
878
|
+
account: Address;
|
|
879
|
+
chainId: bigint;
|
|
880
|
+
/** ERC20 token the router is allowed to spend via Permit2. */
|
|
881
|
+
tokenIn: Address;
|
|
882
|
+
/** Amount to approve (must fit uint160). Defaults to uint160 max. */
|
|
883
|
+
amount?: bigint;
|
|
884
|
+
/** Allowance expiration (unix seconds, uint48). If omitted, block timestamp + 30 days. */
|
|
885
|
+
expiration?: bigint;
|
|
886
|
+
txOverrides?: TxOverrides;
|
|
887
|
+
addresses?: Partial<UniswapV4Addresses>;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
//#endregion
|
|
891
|
+
export { ApproveErc20ForPermit2Params, ApproveRouterViaPermit2Params, CheckRouterApprovalParams, CollateralTracker, CurrentRates, FetchPoolIdParams, FetchPoolIdResult, GetOracleStateParams, GetPoolMetadataParams, GetPoolParams, GetRiskParametersParams, GetUtilizationParams, OracleState, PERMIT2_ADDRESS as PERMIT2_ADDRESS$1, Pool, PoolHealthStatus, PoolKey, PoolMetadata, QuoteSwapExactInViaRouterParams, QuoteSwapExactOutViaRouterParams, RiskEngine, RiskParameters, RouterApprovalStatus, SafeMode, SafeModeState, SwapExactInQuote, SwapExactInViaRouterParams, SwapExactOutQuote, SwapExactOutViaRouterParams, TickLimitsResult, UNISWAP_V4_ADDRESSES as UNISWAP_V4_ADDRESSES$1, UniswapV4Addresses, Utilization, fetchPoolId as fetchPoolId$1, formatPriceRange as formatPriceRange$1, formatTick as formatTick$1, formatTickRange as formatTickRange$1, getOracleState as getOracleState$1, getPool as getPool$1, getPoolMetadata as getPoolMetadata$1, getPricesAtTick as getPricesAtTick$1, getRiskParameters as getRiskParameters$1, getTickSpacing as getTickSpacing$1, getUniswapV4Addresses as getUniswapV4Addresses$1, getUtilization as getUtilization$1, priceToTick as priceToTick$1, roundToTickSpacing as roundToTickSpacing$1, sqrtPriceX96ToPriceDecimalScaled as sqrtPriceX96ToPriceDecimalScaled$1, sqrtPriceX96ToTick as sqrtPriceX96ToTick$1, tickLimits as tickLimits$1, tickToPrice as tickToPrice$1, tickToPriceDecimalScaled as tickToPriceDecimalScaled$1, tickToSqrtPriceX96 as tickToSqrtPriceX96$1, validateBuilderCode as validateBuilderCode$1 };
|
|
892
|
+
//# sourceMappingURL=types-CspUPolV.d.ts.map
|