@panoptic-eng/sdk 1.0.62 → 1.0.64
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/README.md +1 -1
- package/dist/cow/index.d.ts +1 -1
- package/dist/cow/index.d.ts.map +1 -1
- package/dist/cow/index.js +1 -1
- package/dist/cow/index.js.map +1 -1
- package/dist/{cow-DTi3GjQz.js → cow-BIzmQHon.js} +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{irm-BDlcUNgJ.js → irm-BGog_tSR.js} +3 -3
- package/dist/panoptic/v2/index.d.ts +137 -135
- package/dist/panoptic/v2/index.d.ts.map +1 -1
- package/dist/panoptic/v2/index.js +52 -51
- package/dist/panoptic/v2/index.js.map +1 -1
- package/dist/panoptic/v2/react-public.d.ts +144 -142
- package/dist/panoptic/v2/react-public.d.ts.map +1 -1
- package/dist/panoptic/v2/react-public.js +55 -54
- package/dist/panoptic/v2/react-public.js.map +1 -1
- package/dist/providers-1WdiaRbY.js +54 -0
- package/dist/{rates-BwZnK0tG.js → rates-O6Sn-xqL.js} +3 -3
- package/dist/{router-Y1OxL9Nt.js → router-BuAvFpbu.js} +137 -10
- package/dist/{router-jMP7fVno.js → router-DHn0rNd7.js} +2 -2
- package/dist/rpc/index.d.ts +112 -0
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js +242 -0
- package/dist/rpc/index.js.map +1 -0
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.d.ts.map +1 -1
- package/dist/test/index.js +1 -14
- package/dist/test/index.js.map +1 -1
- package/dist/uniswap/index.d.ts +311 -216
- package/dist/uniswap/index.d.ts.map +1 -1
- package/dist/uniswap/index.js +254 -21
- package/dist/uniswap/index.js.map +1 -1
- package/dist/{v2-B27ILZl4.js → v2-D2Bg1SeN.js} +19 -144
- package/dist/{writes-B8NGXzUG.js → writes-jz-N6C_4.js} +37 -37
- package/dist/zodiac/index.d.ts +3 -3
- package/dist/zodiac/index.d.ts.map +1 -1
- package/dist/zodiac/index.js +3 -3
- package/dist/zodiac/index.js.map +1 -1
- package/package.json +5 -1
package/dist/uniswap/index.d.ts
CHANGED
|
@@ -203,6 +203,8 @@ interface LpGreeksInput {
|
|
|
203
203
|
tickUpper: bigint;
|
|
204
204
|
/** Pool's current tick. */
|
|
205
205
|
currentTick: bigint;
|
|
206
|
+
/** Exact pool price, when available; takes precedence over currentTick. */
|
|
207
|
+
sqrtPriceX96?: bigint;
|
|
206
208
|
/** Which token is the asset: `0` (token0) or `1` (token1). */
|
|
207
209
|
assetIndex: 0 | 1;
|
|
208
210
|
}
|
|
@@ -227,222 +229,12 @@ declare function getAmountsForLiquidity(sqrtPriceX96: bigint, sqrtRatioAX96: big
|
|
|
227
229
|
declare function getLpGreeks(input: LpGreeksInput): LpGreeks;
|
|
228
230
|
|
|
229
231
|
//#endregion
|
|
230
|
-
//#region src/
|
|
231
|
-
|
|
232
|
-
* Forward-looking "will this LP range stay in range?" statistics.
|
|
233
|
-
*
|
|
234
|
-
* Model: driftless geometric Brownian motion of the pool price. In log space the
|
|
235
|
-
* position is inside its range while `ln(lower) < ln(S_t) < ln(upper)`; with
|
|
236
|
-
* `x_t = ln(S_t) ∼ N(x0, σ²·t)` the probability of being in range at horizon `t`
|
|
237
|
-
* is a difference of two standard-normal CDFs. Expected fraction of time in range
|
|
238
|
-
* over `[0, T]` is the time-average of that same probability (exact by Fubini):
|
|
239
|
-
* `(1/T)·∫₀ᵀ P(in range at t) dt`, computed by numeric integration.
|
|
240
|
-
*
|
|
241
|
-
* Both column values in the portfolio LP rows (P(in range) and E[time in range])
|
|
242
|
-
* fall out of the single {@link pInRangeAt} kernel, so they can never disagree in
|
|
243
|
-
* sign: a position that starts in range always has E ≥ P at every horizon, and one
|
|
244
|
-
* that starts out of range always has E ≤ P.
|
|
245
|
-
*
|
|
246
|
-
* Drift is assumed zero — this is a pure volatility read, not a directional
|
|
247
|
-
* forecast. Vol estimation lives with the caller (the UI already has realized-vol
|
|
248
|
-
* estimators); pass the annualized σ in.
|
|
249
|
-
*
|
|
250
|
-
* @module uniswap/rangeProbability
|
|
251
|
-
*/
|
|
252
|
-
/**
|
|
253
|
-
* Standard-normal CDF Φ(x). Uses a rational erf approximation
|
|
254
|
-
* (Abramowitz & Stegun 7.1.26), max abs error ≈ 1.5e-7 — ample for a
|
|
255
|
-
* percentage read.
|
|
256
|
-
*/
|
|
257
|
-
declare function normalCdf(x: number): number;
|
|
258
|
-
interface RangeProbabilityInput {
|
|
259
|
-
/** Current pool price in the display frame (quote per asset). */
|
|
260
|
-
spot: number;
|
|
261
|
-
/** Lower range bound in the same frame. `0` or non-finite means unbounded below. */
|
|
262
|
-
lower: number;
|
|
263
|
-
/** Upper range bound in the same frame. `Infinity` or non-finite means unbounded above. */
|
|
264
|
-
upper: number;
|
|
265
|
-
/** Annualized volatility as a fraction (e.g. 0.8 = 80%). */
|
|
266
|
-
sigmaAnnual: number;
|
|
267
|
-
/** Horizon in years. */
|
|
268
|
-
tYears: number;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Probability the price is inside `[lower, upper]` at horizon `tYears`.
|
|
272
|
-
* Returns 1 for a full-range position (both bounds unbounded) and is well-defined
|
|
273
|
-
* for an out-of-range spot (then it reads as "chance of being back in range by t").
|
|
274
|
-
*/
|
|
275
|
-
declare function pInRangeAt(input: RangeProbabilityInput): number;
|
|
276
|
-
interface ExpectedTimeInRangeInput extends RangeProbabilityInput {
|
|
277
|
-
/** Integration steps over [0, T]. Default 64 — smooth to <0.1% for these curves. */
|
|
278
|
-
steps?: number;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Expected fraction of `[0, tYears]` spent in range — the time-average of
|
|
282
|
-
* {@link pInRangeAt}. Trapezoidal integration; the integrand starts at exactly
|
|
283
|
-
* 1 (in-range now) or 0 (out-of-range now) at t=0, which the trapezoid endpoint
|
|
284
|
-
* captures.
|
|
285
|
-
*/
|
|
286
|
-
declare function expectedTimeInRange(input: ExpectedTimeInRangeInput): number;
|
|
287
|
-
interface RangeStatsInput {
|
|
288
|
-
spot: number;
|
|
289
|
-
lower: number;
|
|
290
|
-
upper: number;
|
|
291
|
-
sigmaAnnual: number;
|
|
292
|
-
}
|
|
293
|
-
interface RangeStats {
|
|
294
|
-
/** P(in range at each horizon), index-aligned to `horizonsYears`. */
|
|
295
|
-
p: number[];
|
|
296
|
-
/** E[fraction of time in range up to each horizon], index-aligned. */
|
|
297
|
-
e: number[];
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Compute both statistics for a set of horizons in one call — the shape the LP
|
|
301
|
-
* row (7d / 30d / 365d) and the portfolio KPI aggregation consume.
|
|
302
|
-
*/
|
|
303
|
-
declare function rangeStats(input: RangeStatsInput, horizonsYears: readonly number[]): RangeStats;
|
|
304
|
-
/** Horizons used by the LP portfolio display, in years. */
|
|
305
|
-
declare const LP_RANGE_HORIZONS_DAYS: readonly [7, 30, 365];
|
|
306
|
-
declare const LP_RANGE_HORIZONS_YEARS: number[];
|
|
307
|
-
|
|
308
|
-
//#endregion
|
|
309
|
-
//#region src/uniswap/v3/addresses.d.ts
|
|
310
|
-
interface UniswapV3Addresses {
|
|
311
|
-
/** Uniswap v3 QuoterV2 — `quoteExactInputSingle` (revert/staticcall-based). */
|
|
312
|
-
quoterV2: Address;
|
|
313
|
-
/** Uniswap v3 NonfungiblePositionManager — ERC721 LP position NFTs. */
|
|
314
|
-
nonfungiblePositionManager: Address;
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Verified Uniswap v3 QuoterV2 addresses keyed by chainId. Add a chain only
|
|
318
|
-
* after verifying against the canonical Uniswap v3 deployment listing.
|
|
319
|
-
*/
|
|
320
|
-
declare const UNISWAP_V3_ADDRESSES: Record<number, UniswapV3Addresses>;
|
|
321
|
-
/**
|
|
322
|
-
* Resolve Uniswap v3 addresses for a chain, applying optional overrides.
|
|
323
|
-
*
|
|
324
|
-
* @throws {UnsupportedChainError} when the chain is not listed and overrides do
|
|
325
|
-
* not supply every required address.
|
|
326
|
-
*/
|
|
327
|
-
declare function getUniswapV3Addresses(chainId: number | bigint, overrides?: Partial<UniswapV3Addresses>): UniswapV3Addresses;
|
|
328
|
-
|
|
329
|
-
//#endregion
|
|
330
|
-
//#region src/uniswap/v3/router/encodeSwap.d.ts
|
|
331
|
-
/** Universal Router command byte for a v3 exact-in swap. */
|
|
332
|
-
declare const V3_SWAP_EXACT_IN = 0;
|
|
333
|
-
/** Universal Router command byte for a v3 exact-out swap. */
|
|
334
|
-
declare const V3_SWAP_EXACT_OUT = 1;
|
|
335
|
-
/**
|
|
336
|
-
* Universal Router recipient sentinel: the router maps `address(1)` to
|
|
337
|
-
* `msg.sender` (the `execute` caller). Uniswap `Constants.MSG_SENDER`.
|
|
338
|
-
*/
|
|
339
|
-
declare const MSG_SENDER: Address;
|
|
340
|
-
/** Arguments for {@link buildV3SwapExecuteCalldata}. */
|
|
341
|
-
interface BuildV3SwapCalldataArgs {
|
|
342
|
-
/** Input token (funds pulled from the caller via Permit2). */
|
|
343
|
-
tokenIn: Address;
|
|
344
|
-
/** Output token. */
|
|
345
|
-
tokenOut: Address;
|
|
346
|
-
/** v3 pool fee tier (e.g. 500, 3000). */
|
|
347
|
-
fee: bigint;
|
|
348
|
-
/** Exact input amount (uint128). */
|
|
349
|
-
amountIn: bigint;
|
|
350
|
-
/** Minimum acceptable output (uint128). */
|
|
351
|
-
amountOutMinimum: bigint;
|
|
352
|
-
/**
|
|
353
|
-
* Absolute deadline (unix seconds) — the `execute(commands, inputs, deadline)`
|
|
354
|
-
* argument, enforced by the Universal Router.
|
|
355
|
-
*/
|
|
356
|
-
deadline: bigint;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Encode the packed v3 single-hop path `tokenIn ++ fee(uint24) ++ tokenOut`.
|
|
360
|
-
*/
|
|
361
|
-
declare function encodeV3Path(tokenIn: Address, fee: bigint, tokenOut: Address): Hex;
|
|
362
|
-
/**
|
|
363
|
-
* Build the typed `execute(...)` args for an exact-in single-hop v3 swap whose
|
|
364
|
-
* output is delivered to the `execute` caller (recipient = MSG_SENDER).
|
|
365
|
-
*/
|
|
366
|
-
declare function buildV3SwapExecuteArgs(args: BuildV3SwapCalldataArgs): {
|
|
367
|
-
args: readonly [Hex, readonly Hex[], bigint];
|
|
368
|
-
value: bigint;
|
|
369
|
-
};
|
|
370
|
-
/**
|
|
371
|
-
* Build the `execute(commands, inputs, deadline)` calldata for an exact-in
|
|
372
|
-
* single-hop v3 swap.
|
|
373
|
-
*/
|
|
374
|
-
declare function buildV3SwapExecuteCalldata(args: BuildV3SwapCalldataArgs): {
|
|
375
|
-
data: Hex;
|
|
376
|
-
value: bigint;
|
|
377
|
-
};
|
|
378
|
-
interface BuildV3ExactOutSwapCalldataArgs {
|
|
379
|
-
tokenIn: Address;
|
|
380
|
-
tokenOut: Address;
|
|
381
|
-
fee: bigint;
|
|
382
|
-
amountOut: bigint;
|
|
383
|
-
amountInMaximum: bigint;
|
|
384
|
-
deadline: bigint;
|
|
385
|
-
}
|
|
386
|
-
/**
|
|
387
|
-
* Build the typed `execute(...)` args for an exact-out single-hop v3 swap.
|
|
388
|
-
* The v3 exact-out path is reversed: `tokenOut ++ fee ++ tokenIn`.
|
|
389
|
-
*/
|
|
390
|
-
declare function buildV3ExactOutSwapExecuteArgs(args: BuildV3ExactOutSwapCalldataArgs): {
|
|
391
|
-
args: readonly [Hex, readonly Hex[], bigint];
|
|
392
|
-
value: bigint;
|
|
393
|
-
};
|
|
394
|
-
declare function buildV3ExactOutSwapExecuteCalldata(args: BuildV3ExactOutSwapCalldataArgs): {
|
|
395
|
-
data: Hex;
|
|
396
|
-
value: bigint;
|
|
397
|
-
};
|
|
398
|
-
|
|
399
|
-
//#endregion
|
|
400
|
-
//#region src/uniswap/v3/router/quote.d.ts
|
|
401
|
-
interface QuoteV3ExactInParams {
|
|
402
|
-
client: PublicClient;
|
|
403
|
-
chainId: bigint;
|
|
404
|
-
tokenIn: Address;
|
|
405
|
-
tokenOut: Address;
|
|
406
|
-
fee: bigint;
|
|
407
|
-
amountIn: bigint;
|
|
408
|
-
slippageBps: bigint;
|
|
409
|
-
blockNumber?: bigint;
|
|
410
|
-
addresses?: Partial<UniswapV3Addresses>;
|
|
411
|
-
}
|
|
412
|
-
interface V3ExactInQuote {
|
|
413
|
-
amountOut: bigint;
|
|
414
|
-
amountOutMinimum: bigint;
|
|
415
|
-
gasEstimate: bigint;
|
|
416
|
-
}
|
|
417
|
-
/**
|
|
418
|
-
* Quote an exact-in v3 swap. Returns `null` when the quote reverts (e.g. the
|
|
419
|
-
* pool does not exist / has no liquidity) so callers can skip that pool when
|
|
420
|
-
* ranking venues, rather than aborting the whole cycle.
|
|
421
|
-
*/
|
|
422
|
-
declare function quoteV3ExactIn(params: QuoteV3ExactInParams): Promise<V3ExactInQuote | null>;
|
|
423
|
-
interface QuoteV3ExactOutParams {
|
|
424
|
-
client: PublicClient;
|
|
425
|
-
chainId: bigint;
|
|
426
|
-
tokenIn: Address;
|
|
427
|
-
tokenOut: Address;
|
|
428
|
-
fee: bigint;
|
|
429
|
-
amountOut: bigint;
|
|
430
|
-
slippageBps: bigint;
|
|
431
|
-
blockNumber?: bigint;
|
|
432
|
-
addresses?: Partial<UniswapV3Addresses>;
|
|
433
|
-
}
|
|
434
|
-
interface V3ExactOutQuote {
|
|
435
|
-
amountIn: bigint;
|
|
436
|
-
amountInMaximum: bigint;
|
|
437
|
-
gasEstimate: bigint;
|
|
438
|
-
}
|
|
439
|
-
/**
|
|
440
|
-
* Quote an exact-out v3 swap. Returns `null` on revert (no pool / no liquidity).
|
|
441
|
-
*/
|
|
442
|
-
declare function quoteV3ExactOut(params: QuoteV3ExactOutParams): Promise<V3ExactOutQuote | null>;
|
|
232
|
+
//#region src/panoptic/v2/greeks/positionVolatility.d.ts
|
|
233
|
+
type VolatilityComparisonReason = 'insufficient-exposure' | 'changing-sign' | 'premium-unavailable' | 'inconsistent-premium-direction';
|
|
443
234
|
|
|
444
235
|
//#endregion
|
|
445
236
|
//#region src/panoptic/v2/types/meta.d.ts
|
|
237
|
+
/** Historical whole-position diagnostics, with signs retained independently of eligibility. */
|
|
446
238
|
/**
|
|
447
239
|
* Block metadata types for the Panoptic v2 SDK.
|
|
448
240
|
* @module v2/types/meta
|
|
@@ -539,7 +331,7 @@ interface OptionBurntEvent extends BaseEvent {
|
|
|
539
331
|
tokenId: bigint;
|
|
540
332
|
/** Position size that was burnt */
|
|
541
333
|
positionSize: bigint;
|
|
542
|
-
/**
|
|
334
|
+
/** Streamia settled for each leg (token0 right, token1 left per leg) */
|
|
543
335
|
premiaByLeg: readonly [bigint, bigint, bigint, bigint];
|
|
544
336
|
}
|
|
545
337
|
/**
|
|
@@ -871,10 +663,313 @@ type SimulationResult<T> = {
|
|
|
871
663
|
};
|
|
872
664
|
|
|
873
665
|
//#endregion
|
|
874
|
-
//#region src/
|
|
666
|
+
//#region src/panoptic/v2/reads/uniswapFeeHistory.d.ts
|
|
875
667
|
/**
|
|
876
668
|
* Open position simulation result data.
|
|
877
669
|
*/
|
|
670
|
+
/** A single snapshot of Uniswap fee data at a particular block. */
|
|
671
|
+
interface UniswapFeeSnapshot {
|
|
672
|
+
/** Resolved block number for this snapshot. */
|
|
673
|
+
blockNumber: bigint;
|
|
674
|
+
/** Timestamp of the resolved block in Unix seconds. */
|
|
675
|
+
blockTimestamp: bigint;
|
|
676
|
+
/** Pool tick used for principal valuation at this block. */
|
|
677
|
+
currentTick: number;
|
|
678
|
+
/** Exact pool sqrt price (Q96) used for principal valuation at this block. */
|
|
679
|
+
sqrtPriceX96: bigint;
|
|
680
|
+
/** Uniswap fee delta from the first block in the series */
|
|
681
|
+
fees: {
|
|
682
|
+
token0: bigint;
|
|
683
|
+
token1: bigint;
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
//#endregion
|
|
688
|
+
//#region src/uniswap/lpVolatility.d.ts
|
|
689
|
+
/** Result from getUniswapFeeHistory. */
|
|
690
|
+
/** Historical convexity and fee coverage at constant LP liquidity, in human quote units. */
|
|
691
|
+
declare function calculateLpPositionVolatility({
|
|
692
|
+
liquidity,
|
|
693
|
+
tickLower,
|
|
694
|
+
tickUpper,
|
|
695
|
+
quoteIsToken0,
|
|
696
|
+
quoteDecimals,
|
|
697
|
+
snapshots
|
|
698
|
+
}: {
|
|
699
|
+
liquidity: bigint;
|
|
700
|
+
tickLower: bigint;
|
|
701
|
+
tickUpper: bigint;
|
|
702
|
+
quoteIsToken0: boolean;
|
|
703
|
+
quoteDecimals: number;
|
|
704
|
+
snapshots: readonly UniswapFeeSnapshot[];
|
|
705
|
+
}): {
|
|
706
|
+
gammaSign: string;
|
|
707
|
+
exposure: string;
|
|
708
|
+
signedConvexity: string;
|
|
709
|
+
absoluteConvexity: string;
|
|
710
|
+
netPremium: string | null;
|
|
711
|
+
estimatedHedgedResult: string | null;
|
|
712
|
+
weightedRealizedVolatility: string | null;
|
|
713
|
+
premiumEquivalentVolatility: string | null;
|
|
714
|
+
premiumToConvexity: string | null;
|
|
715
|
+
baseFees: string | null;
|
|
716
|
+
feeEquivalentVolatility: string | null;
|
|
717
|
+
feeToConvexity: string | null;
|
|
718
|
+
comparisonReason: VolatilityComparisonReason | null;
|
|
719
|
+
};
|
|
720
|
+
|
|
721
|
+
//#endregion
|
|
722
|
+
//#region src/uniswap/quoteTokenPrices.d.ts
|
|
723
|
+
/** Prices tokens in a common quote asset, selecting the deepest quote-side virtual reserve. */
|
|
724
|
+
declare function quoteTokenPrices(pools: readonly {
|
|
725
|
+
id: string;
|
|
726
|
+
token0: {
|
|
727
|
+
address: string;
|
|
728
|
+
decimals: bigint;
|
|
729
|
+
};
|
|
730
|
+
token1: {
|
|
731
|
+
address: string;
|
|
732
|
+
decimals: bigint;
|
|
733
|
+
};
|
|
734
|
+
tick: bigint;
|
|
735
|
+
liquidity: bigint;
|
|
736
|
+
}[], quoteAddresses: readonly string[]): Map<string, Decimal>;
|
|
737
|
+
|
|
738
|
+
//#endregion
|
|
739
|
+
//#region src/uniswap/rangeProbability.d.ts
|
|
740
|
+
/**
|
|
741
|
+
* Forward-looking "will this LP range stay in range?" statistics.
|
|
742
|
+
*
|
|
743
|
+
* Model: driftless geometric Brownian motion of the pool price. In log space the
|
|
744
|
+
* position is inside its range while `ln(lower) < ln(S_t) < ln(upper)`; with
|
|
745
|
+
* `x_t = ln(S_t) ∼ N(x0, σ²·t)` the probability of being in range at horizon `t`
|
|
746
|
+
* is a difference of two standard-normal CDFs. Expected fraction of time in range
|
|
747
|
+
* over `[0, T]` is the time-average of that same probability (exact by Fubini):
|
|
748
|
+
* `(1/T)·∫₀ᵀ P(in range at t) dt`, computed by numeric integration.
|
|
749
|
+
*
|
|
750
|
+
* Both column values in the portfolio LP rows (P(in range) and E[time in range])
|
|
751
|
+
* fall out of the single {@link pInRangeAt} kernel, so they can never disagree in
|
|
752
|
+
* sign: a position that starts in range always has E ≥ P at every horizon, and one
|
|
753
|
+
* that starts out of range always has E ≤ P.
|
|
754
|
+
*
|
|
755
|
+
* Drift is assumed zero — this is a pure volatility read, not a directional
|
|
756
|
+
* forecast. Vol estimation lives with the caller (the UI already has realized-vol
|
|
757
|
+
* estimators); pass the annualized σ in.
|
|
758
|
+
*
|
|
759
|
+
* @module uniswap/rangeProbability
|
|
760
|
+
*/
|
|
761
|
+
/**
|
|
762
|
+
* Standard-normal CDF Φ(x). Uses a rational erf approximation
|
|
763
|
+
* (Abramowitz & Stegun 7.1.26), max abs error ≈ 1.5e-7 — ample for a
|
|
764
|
+
* percentage read.
|
|
765
|
+
*/
|
|
766
|
+
declare function normalCdf(x: number): number;
|
|
767
|
+
interface RangeProbabilityInput {
|
|
768
|
+
/** Current pool price in the display frame (quote per asset). */
|
|
769
|
+
spot: number;
|
|
770
|
+
/** Lower range bound in the same frame. `0` or non-finite means unbounded below. */
|
|
771
|
+
lower: number;
|
|
772
|
+
/** Upper range bound in the same frame. `Infinity` or non-finite means unbounded above. */
|
|
773
|
+
upper: number;
|
|
774
|
+
/** Annualized volatility as a fraction (e.g. 0.8 = 80%). */
|
|
775
|
+
sigmaAnnual: number;
|
|
776
|
+
/** Horizon in years. */
|
|
777
|
+
tYears: number;
|
|
778
|
+
}
|
|
779
|
+
/**
|
|
780
|
+
* Probability the price is inside `[lower, upper]` at horizon `tYears`.
|
|
781
|
+
* Returns 1 for a full-range position (both bounds unbounded) and is well-defined
|
|
782
|
+
* for an out-of-range spot (then it reads as "chance of being back in range by t").
|
|
783
|
+
*/
|
|
784
|
+
declare function pInRangeAt(input: RangeProbabilityInput): number;
|
|
785
|
+
interface ExpectedTimeInRangeInput extends RangeProbabilityInput {
|
|
786
|
+
/** Integration steps over [0, T]. Default 64 — smooth to <0.1% for these curves. */
|
|
787
|
+
steps?: number;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Expected fraction of `[0, tYears]` spent in range — the time-average of
|
|
791
|
+
* {@link pInRangeAt}. Trapezoidal integration; the integrand starts at exactly
|
|
792
|
+
* 1 (in-range now) or 0 (out-of-range now) at t=0, which the trapezoid endpoint
|
|
793
|
+
* captures.
|
|
794
|
+
*/
|
|
795
|
+
declare function expectedTimeInRange(input: ExpectedTimeInRangeInput): number;
|
|
796
|
+
interface RangeStatsInput {
|
|
797
|
+
spot: number;
|
|
798
|
+
lower: number;
|
|
799
|
+
upper: number;
|
|
800
|
+
sigmaAnnual: number;
|
|
801
|
+
}
|
|
802
|
+
interface RangeStats {
|
|
803
|
+
/** P(in range at each horizon), index-aligned to `horizonsYears`. */
|
|
804
|
+
p: number[];
|
|
805
|
+
/** E[fraction of time in range up to each horizon], index-aligned. */
|
|
806
|
+
e: number[];
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Compute both statistics for a set of horizons in one call — the shape the LP
|
|
810
|
+
* row (7d / 30d / 365d) and the portfolio KPI aggregation consume.
|
|
811
|
+
*/
|
|
812
|
+
declare function rangeStats(input: RangeStatsInput, horizonsYears: readonly number[]): RangeStats;
|
|
813
|
+
/** Horizons used by the LP portfolio display, in years. */
|
|
814
|
+
declare const LP_RANGE_HORIZONS_DAYS: readonly [7, 30, 365];
|
|
815
|
+
declare const LP_RANGE_HORIZONS_YEARS: number[];
|
|
816
|
+
|
|
817
|
+
//#endregion
|
|
818
|
+
//#region src/uniswap/v3/addresses.d.ts
|
|
819
|
+
interface UniswapV3Addresses {
|
|
820
|
+
/** Uniswap v3 QuoterV2 — `quoteExactInputSingle` (revert/staticcall-based). */
|
|
821
|
+
quoterV2: Address;
|
|
822
|
+
/** Uniswap v3 NonfungiblePositionManager — ERC721 LP position NFTs. */
|
|
823
|
+
nonfungiblePositionManager: Address;
|
|
824
|
+
}
|
|
825
|
+
/**
|
|
826
|
+
* Verified Uniswap v3 QuoterV2 addresses keyed by chainId. Add a chain only
|
|
827
|
+
* after verifying against the canonical Uniswap v3 deployment listing.
|
|
828
|
+
*/
|
|
829
|
+
declare const UNISWAP_V3_ADDRESSES: Record<number, UniswapV3Addresses>;
|
|
830
|
+
/**
|
|
831
|
+
* Resolve Uniswap v3 addresses for a chain, applying optional overrides.
|
|
832
|
+
*
|
|
833
|
+
* @throws {UnsupportedChainError} when the chain is not listed and overrides do
|
|
834
|
+
* not supply every required address.
|
|
835
|
+
*/
|
|
836
|
+
declare function getUniswapV3Addresses(chainId: number | bigint, overrides?: Partial<UniswapV3Addresses>): UniswapV3Addresses;
|
|
837
|
+
|
|
838
|
+
//#endregion
|
|
839
|
+
//#region src/uniswap/v3/poolBalances.d.ts
|
|
840
|
+
/** V3 pools custody their own tokens; balances include principal and uncollected fees. */
|
|
841
|
+
declare function getUniswapV3PoolBalances({
|
|
842
|
+
client,
|
|
843
|
+
pools
|
|
844
|
+
}: {
|
|
845
|
+
client: PublicClient;
|
|
846
|
+
pools: readonly {
|
|
847
|
+
id: Address;
|
|
848
|
+
token0: Address;
|
|
849
|
+
token1: Address;
|
|
850
|
+
}[];
|
|
851
|
+
}): Promise<Map<string, {
|
|
852
|
+
amount0: bigint;
|
|
853
|
+
amount1: bigint;
|
|
854
|
+
}>>;
|
|
855
|
+
|
|
856
|
+
//#endregion
|
|
857
|
+
//#region src/uniswap/v3/router/encodeSwap.d.ts
|
|
858
|
+
/** Universal Router command byte for a v3 exact-in swap. */
|
|
859
|
+
declare const V3_SWAP_EXACT_IN = 0;
|
|
860
|
+
/** Universal Router command byte for a v3 exact-out swap. */
|
|
861
|
+
declare const V3_SWAP_EXACT_OUT = 1;
|
|
862
|
+
/**
|
|
863
|
+
* Universal Router recipient sentinel: the router maps `address(1)` to
|
|
864
|
+
* `msg.sender` (the `execute` caller). Uniswap `Constants.MSG_SENDER`.
|
|
865
|
+
*/
|
|
866
|
+
declare const MSG_SENDER: Address;
|
|
867
|
+
/** Arguments for {@link buildV3SwapExecuteCalldata}. */
|
|
868
|
+
interface BuildV3SwapCalldataArgs {
|
|
869
|
+
/** Input token (funds pulled from the caller via Permit2). */
|
|
870
|
+
tokenIn: Address;
|
|
871
|
+
/** Output token. */
|
|
872
|
+
tokenOut: Address;
|
|
873
|
+
/** v3 pool fee tier (e.g. 500, 3000). */
|
|
874
|
+
fee: bigint;
|
|
875
|
+
/** Exact input amount (uint128). */
|
|
876
|
+
amountIn: bigint;
|
|
877
|
+
/** Minimum acceptable output (uint128). */
|
|
878
|
+
amountOutMinimum: bigint;
|
|
879
|
+
/**
|
|
880
|
+
* Absolute deadline (unix seconds) — the `execute(commands, inputs, deadline)`
|
|
881
|
+
* argument, enforced by the Universal Router.
|
|
882
|
+
*/
|
|
883
|
+
deadline: bigint;
|
|
884
|
+
}
|
|
885
|
+
/**
|
|
886
|
+
* Encode the packed v3 single-hop path `tokenIn ++ fee(uint24) ++ tokenOut`.
|
|
887
|
+
*/
|
|
888
|
+
declare function encodeV3Path(tokenIn: Address, fee: bigint, tokenOut: Address): Hex;
|
|
889
|
+
/**
|
|
890
|
+
* Build the typed `execute(...)` args for an exact-in single-hop v3 swap whose
|
|
891
|
+
* output is delivered to the `execute` caller (recipient = MSG_SENDER).
|
|
892
|
+
*/
|
|
893
|
+
declare function buildV3SwapExecuteArgs(args: BuildV3SwapCalldataArgs): {
|
|
894
|
+
args: readonly [Hex, readonly Hex[], bigint];
|
|
895
|
+
value: bigint;
|
|
896
|
+
};
|
|
897
|
+
/**
|
|
898
|
+
* Build the `execute(commands, inputs, deadline)` calldata for an exact-in
|
|
899
|
+
* single-hop v3 swap.
|
|
900
|
+
*/
|
|
901
|
+
declare function buildV3SwapExecuteCalldata(args: BuildV3SwapCalldataArgs): {
|
|
902
|
+
data: Hex;
|
|
903
|
+
value: bigint;
|
|
904
|
+
};
|
|
905
|
+
interface BuildV3ExactOutSwapCalldataArgs {
|
|
906
|
+
tokenIn: Address;
|
|
907
|
+
tokenOut: Address;
|
|
908
|
+
fee: bigint;
|
|
909
|
+
amountOut: bigint;
|
|
910
|
+
amountInMaximum: bigint;
|
|
911
|
+
deadline: bigint;
|
|
912
|
+
}
|
|
913
|
+
/**
|
|
914
|
+
* Build the typed `execute(...)` args for an exact-out single-hop v3 swap.
|
|
915
|
+
* The v3 exact-out path is reversed: `tokenOut ++ fee ++ tokenIn`.
|
|
916
|
+
*/
|
|
917
|
+
declare function buildV3ExactOutSwapExecuteArgs(args: BuildV3ExactOutSwapCalldataArgs): {
|
|
918
|
+
args: readonly [Hex, readonly Hex[], bigint];
|
|
919
|
+
value: bigint;
|
|
920
|
+
};
|
|
921
|
+
declare function buildV3ExactOutSwapExecuteCalldata(args: BuildV3ExactOutSwapCalldataArgs): {
|
|
922
|
+
data: Hex;
|
|
923
|
+
value: bigint;
|
|
924
|
+
};
|
|
925
|
+
|
|
926
|
+
//#endregion
|
|
927
|
+
//#region src/uniswap/v3/router/quote.d.ts
|
|
928
|
+
interface QuoteV3ExactInParams {
|
|
929
|
+
client: PublicClient;
|
|
930
|
+
chainId: bigint;
|
|
931
|
+
tokenIn: Address;
|
|
932
|
+
tokenOut: Address;
|
|
933
|
+
fee: bigint;
|
|
934
|
+
amountIn: bigint;
|
|
935
|
+
slippageBps: bigint;
|
|
936
|
+
blockNumber?: bigint;
|
|
937
|
+
addresses?: Partial<UniswapV3Addresses>;
|
|
938
|
+
}
|
|
939
|
+
interface V3ExactInQuote {
|
|
940
|
+
amountOut: bigint;
|
|
941
|
+
amountOutMinimum: bigint;
|
|
942
|
+
gasEstimate: bigint;
|
|
943
|
+
}
|
|
944
|
+
/**
|
|
945
|
+
* Quote an exact-in v3 swap. Returns `null` when the quote reverts (e.g. the
|
|
946
|
+
* pool does not exist / has no liquidity) so callers can skip that pool when
|
|
947
|
+
* ranking venues, rather than aborting the whole cycle.
|
|
948
|
+
*/
|
|
949
|
+
declare function quoteV3ExactIn(params: QuoteV3ExactInParams): Promise<V3ExactInQuote | null>;
|
|
950
|
+
interface QuoteV3ExactOutParams {
|
|
951
|
+
client: PublicClient;
|
|
952
|
+
chainId: bigint;
|
|
953
|
+
tokenIn: Address;
|
|
954
|
+
tokenOut: Address;
|
|
955
|
+
fee: bigint;
|
|
956
|
+
amountOut: bigint;
|
|
957
|
+
slippageBps: bigint;
|
|
958
|
+
blockNumber?: bigint;
|
|
959
|
+
addresses?: Partial<UniswapV3Addresses>;
|
|
960
|
+
}
|
|
961
|
+
interface V3ExactOutQuote {
|
|
962
|
+
amountIn: bigint;
|
|
963
|
+
amountInMaximum: bigint;
|
|
964
|
+
gasEstimate: bigint;
|
|
965
|
+
}
|
|
966
|
+
/**
|
|
967
|
+
* Quote an exact-out v3 swap. Returns `null` on revert (no pool / no liquidity).
|
|
968
|
+
*/
|
|
969
|
+
declare function quoteV3ExactOut(params: QuoteV3ExactOutParams): Promise<V3ExactOutQuote | null>;
|
|
970
|
+
|
|
971
|
+
//#endregion
|
|
972
|
+
//#region src/uniswap/v4/addresses.d.ts
|
|
878
973
|
/**
|
|
879
974
|
* Uniswap v4 contract addresses required for a Universal Router spot swap.
|
|
880
975
|
*/
|
|
@@ -1496,5 +1591,5 @@ declare function swapExactOutViaRouter(params: SwapExactOutViaRouterParams): Pro
|
|
|
1496
1591
|
declare function swapExactOutViaRouterAndWait(params: SwapExactOutViaRouterParams): Promise<TxReceipt>;
|
|
1497
1592
|
|
|
1498
1593
|
//#endregion
|
|
1499
|
-
export { AmountExceedsUint128Error, ApproveErc20ForPermit2Params, ApproveRouterViaPermit2Params, BuildV3ExactOutSwapCalldataArgs, BuildV3SwapCalldataArgs, BuildV4ExactOutSwapCalldataArgs, BuildV4SwapCalldataArgs, CheckRouterApprovalParams, ExpectedTimeInRangeInput, InvalidSwapTokenError, LP_RANGE_HORIZONS_DAYS, LP_RANGE_HORIZONS_YEARS, LpAmounts, LpFeeCandle, LpFeeRange, LpGreeks, LpGreeksInput, LpPositionFundingParams, MSG_SENDER, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoteSwapExactInViaRouterParams, QuoteSwapExactInViaV3RouterParams, QuoteSwapExactOutViaRouterParams, QuoteSwapExactOutViaV3RouterParams, QuoteV3ExactInParams, QuoteV3ExactOutParams, QuoteV4ExactInByPoolKeyParams, QuoterUnavailableError, RangeProbabilityInput, RangeStats, RangeStatsInput, ResolveSwapRouteParams, ResolveV3SwapRouteParams, ResolvedSwapRoute, ResolvedV3SwapRoute, RouterApprovalStatus, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, SwapExactInQuote, SwapExactInViaRouterParams, SwapExactInViaV3RouterParams, SwapExactOutQuote, SwapExactOutViaRouterParams, SwapExactOutViaV3RouterParams, TAKE_ALL, UNISWAP_V3_ADDRESSES, UNISWAP_V4_ADDRESSES, UniswapV3Addresses, UniswapV4Addresses, UnsupportedChainError, V3ExactInQuote, V3ExactOutQuote, V3_SWAP_EXACT_IN, V3_SWAP_EXACT_OUT, V4ExactInQuote, V4_SWAP, annualizeLpFeeReturn, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV3ExactOutSwapExecuteArgs, buildV3ExactOutSwapExecuteCalldata, buildV3SwapExecuteArgs, buildV3SwapExecuteCalldata, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, encodeV3Path, estimateLpFees, expectedTimeInRange, getAmountsForLiquidity, getLpDepositAmounts, getLpDepositBreakdown, getLpFeeReturnSeries, getLpFundingDeposit, getLpGreeks, getLpPositionFunding, getMaxLpPositionSize, getUnhedgedLpRanges, getUniswapV3Addresses, getUniswapV4Addresses, normalCdf, pInRangeAt, quoteSwapExactInViaRouter, quoteSwapExactInViaV3Router, quoteSwapExactOutViaRouter, quoteSwapExactOutViaV3Router, quoteV3ExactIn, quoteV3ExactOut, quoteV4ExactInByPoolKey, rangeStats, resolveSwapRoute, resolveV3SwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactInViaV3Router, swapExactOutViaRouter, swapExactOutViaRouterAndWait, swapExactOutViaV3Router };
|
|
1594
|
+
export { AmountExceedsUint128Error, ApproveErc20ForPermit2Params, ApproveRouterViaPermit2Params, BuildV3ExactOutSwapCalldataArgs, BuildV3SwapCalldataArgs, BuildV4ExactOutSwapCalldataArgs, BuildV4SwapCalldataArgs, CheckRouterApprovalParams, ExpectedTimeInRangeInput, InvalidSwapTokenError, LP_RANGE_HORIZONS_DAYS, LP_RANGE_HORIZONS_YEARS, LpAmounts, LpFeeCandle, LpFeeRange, LpGreeks, LpGreeksInput, LpPositionFundingParams, MSG_SENDER, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoteSwapExactInViaRouterParams, QuoteSwapExactInViaV3RouterParams, QuoteSwapExactOutViaRouterParams, QuoteSwapExactOutViaV3RouterParams, QuoteV3ExactInParams, QuoteV3ExactOutParams, QuoteV4ExactInByPoolKeyParams, QuoterUnavailableError, RangeProbabilityInput, RangeStats, RangeStatsInput, ResolveSwapRouteParams, ResolveV3SwapRouteParams, ResolvedSwapRoute, ResolvedV3SwapRoute, RouterApprovalStatus, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, SwapExactInQuote, SwapExactInViaRouterParams, SwapExactInViaV3RouterParams, SwapExactOutQuote, SwapExactOutViaRouterParams, SwapExactOutViaV3RouterParams, TAKE_ALL, UNISWAP_V3_ADDRESSES, UNISWAP_V4_ADDRESSES, UniswapV3Addresses, UniswapV4Addresses, UnsupportedChainError, V3ExactInQuote, V3ExactOutQuote, V3_SWAP_EXACT_IN, V3_SWAP_EXACT_OUT, V4ExactInQuote, V4_SWAP, annualizeLpFeeReturn, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV3ExactOutSwapExecuteArgs, buildV3ExactOutSwapExecuteCalldata, buildV3SwapExecuteArgs, buildV3SwapExecuteCalldata, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, calculateLpPositionVolatility, checkRouterApproval, encodeV3Path, estimateLpFees, expectedTimeInRange, getAmountsForLiquidity, getLpDepositAmounts, getLpDepositBreakdown, getLpFeeReturnSeries, getLpFundingDeposit, getLpGreeks, getLpPositionFunding, getMaxLpPositionSize, getUnhedgedLpRanges, getUniswapV3Addresses, getUniswapV3PoolBalances, getUniswapV4Addresses, normalCdf, pInRangeAt, quoteSwapExactInViaRouter, quoteSwapExactInViaV3Router, quoteSwapExactOutViaRouter, quoteSwapExactOutViaV3Router, quoteTokenPrices, quoteV3ExactIn, quoteV3ExactOut, quoteV4ExactInByPoolKey, rangeStats, resolveSwapRoute, resolveV3SwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactInViaV3Router, swapExactOutViaRouter, swapExactOutViaRouterAndWait, swapExactOutViaV3Router };
|
|
1500
1595
|
//# sourceMappingURL=index.d.ts.map
|