@panoptic-eng/sdk 1.0.47 → 1.0.48
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.js +48 -4
- package/dist/cow/index.js.map +1 -1
- package/dist/{cow-DIYBU1j9.js → cow-BPcuMjYR.js} +1 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +203 -162
- package/dist/index.js.map +1 -1
- package/dist/{irm-CvLqxTAo.js → irm-C7QhFiwL.js} +7 -246
- package/dist/panoptic/v2/index.d.ts +167 -32
- package/dist/panoptic/v2/index.d.ts.map +1 -1
- package/dist/panoptic/v2/index.js +1562 -930
- package/dist/panoptic/v2/index.js.map +1 -1
- package/dist/panoptic/v2/react-public.d.ts +167 -32
- package/dist/panoptic/v2/react-public.d.ts.map +1 -1
- package/dist/panoptic/v2/react-public.js +1164 -528
- package/dist/panoptic/v2/react-public.js.map +1 -1
- package/dist/{getTrackedPositionIds-CwBHzOO2.js → rates-5oQD-SuM.js} +256 -4
- package/dist/{router-OcmdMkXx.js → router-C26q7i8w.js} +2 -2
- package/dist/{router-CUlQfzoc.js → router-ClhAkKjh.js} +1 -1
- package/dist/uniswap/index.js +59 -15
- package/dist/uniswap/index.js.map +1 -1
- package/dist/{v2-DeGgMN2a.js → v2-DVcophLf.js} +1379 -2671
- package/dist/{writes-BZW7UA4N.js → writes-DBHwfbDD.js} +2855 -944
- package/dist/zodiac/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -8150,6 +8150,19 @@ var SwapTokenMismatchError = class extends PanopticError {
|
|
|
8150
8150
|
this.token1 = token1;
|
|
8151
8151
|
}
|
|
8152
8152
|
};
|
|
8153
|
+
/**
|
|
8154
|
+
* A premium settlement would advance the seller checkpoint while some
|
|
8155
|
+
* displayed premium is still unavailable, or a required buyer cannot settle.
|
|
8156
|
+
*/
|
|
8157
|
+
var UnsafePremiumSettlementError = class extends PanopticError {
|
|
8158
|
+
name = "UnsafePremiumSettlementError";
|
|
8159
|
+
constructor(remainingForfeit, failedBuyerCount, cause) {
|
|
8160
|
+
const [token0, token1] = remainingForfeit;
|
|
8161
|
+
super(failedBuyerCount > 0 ? `Premium settlement blocked: ${failedBuyerCount} buyer settlement${failedBuyerCount === 1 ? "" : "s"} would fail` : `Premium settlement blocked: uncollectable premium remains (${token0}, ${token1})`, cause);
|
|
8162
|
+
this.remainingForfeit = remainingForfeit;
|
|
8163
|
+
this.failedBuyerCount = failedBuyerCount;
|
|
8164
|
+
}
|
|
8165
|
+
};
|
|
8153
8166
|
|
|
8154
8167
|
//#endregion
|
|
8155
8168
|
//#region src/panoptic/v2/errors/errorsAbi.ts
|
|
@@ -9471,9 +9484,9 @@ async function getPool(params) {
|
|
|
9471
9484
|
fee: metadata.fee,
|
|
9472
9485
|
tickSpacing
|
|
9473
9486
|
};
|
|
9474
|
-
const SECONDS_PER_YEAR = 31536000n;
|
|
9475
|
-
const borrowRate0 = BigInt(token0InterestRate) * SECONDS_PER_YEAR;
|
|
9476
|
-
const borrowRate1 = BigInt(token1InterestRate) * SECONDS_PER_YEAR;
|
|
9487
|
+
const SECONDS_PER_YEAR$1 = 31536000n;
|
|
9488
|
+
const borrowRate0 = BigInt(token0InterestRate) * SECONDS_PER_YEAR$1;
|
|
9489
|
+
const borrowRate1 = BigInt(token1InterestRate) * SECONDS_PER_YEAR$1;
|
|
9477
9490
|
const utilization0 = token0PoolData[3];
|
|
9478
9491
|
const utilization1 = token1PoolData[3];
|
|
9479
9492
|
const supplyRate0 = borrowRate0 * utilization0 / 10000n;
|
|
@@ -11157,4 +11170,243 @@ async function getOpenPositionIds(params) {
|
|
|
11157
11170
|
}
|
|
11158
11171
|
|
|
11159
11172
|
//#endregion
|
|
11160
|
-
|
|
11173
|
+
//#region src/panoptic/v2/formatters/amount.ts
|
|
11174
|
+
/**
|
|
11175
|
+
* Format a raw token amount to a human-readable string.
|
|
11176
|
+
*
|
|
11177
|
+
* @param amount - The amount in smallest units (e.g., wei)
|
|
11178
|
+
* @param decimals - Token decimals (e.g., 18n for WETH, 6n for USDC)
|
|
11179
|
+
* @param precision - Number of decimal places to display
|
|
11180
|
+
* @returns Formatted string
|
|
11181
|
+
*
|
|
11182
|
+
* @example
|
|
11183
|
+
* ```typescript
|
|
11184
|
+
* formatTokenAmount(1500000000000000000n, 18n, 4n) // "1.5000"
|
|
11185
|
+
* formatTokenAmount(1500000000000000000n, 18n, 2n) // "1.50"
|
|
11186
|
+
* formatTokenAmount(1500000n, 6n, 2n) // "1.50" (USDC)
|
|
11187
|
+
* formatTokenAmount(-500000000000000000n, 18n, 4n) // "-0.5000"
|
|
11188
|
+
* ```
|
|
11189
|
+
*/
|
|
11190
|
+
function formatTokenAmount(amount, decimals, precision) {
|
|
11191
|
+
const isNegative = amount < 0n;
|
|
11192
|
+
const absAmount = isNegative ? -amount : amount;
|
|
11193
|
+
const divisor = 10n ** decimals;
|
|
11194
|
+
const integerPart = absAmount / divisor;
|
|
11195
|
+
const fractionalPart = absAmount % divisor;
|
|
11196
|
+
const fullFractionalStr = fractionalPart.toString().padStart(Number(decimals), "0");
|
|
11197
|
+
const truncatedFractionalStr = fullFractionalStr.slice(0, Number(precision));
|
|
11198
|
+
const paddedFractionalStr = truncatedFractionalStr.padEnd(Number(precision), "0");
|
|
11199
|
+
const sign = isNegative ? "-" : "";
|
|
11200
|
+
return precision > 0n ? `${sign}${integerPart}.${paddedFractionalStr}` : `${sign}${integerPart}`;
|
|
11201
|
+
}
|
|
11202
|
+
/**
|
|
11203
|
+
* Format a token amount with a sign prefix (+/-) for non-zero values.
|
|
11204
|
+
* Useful for displaying PnL, deltas, or changes.
|
|
11205
|
+
*
|
|
11206
|
+
* @param amount - The amount in smallest units
|
|
11207
|
+
* @param decimals - Token decimals
|
|
11208
|
+
* @param precision - Number of decimal places to display
|
|
11209
|
+
* @returns Formatted string with sign prefix
|
|
11210
|
+
*
|
|
11211
|
+
* @example
|
|
11212
|
+
* ```typescript
|
|
11213
|
+
* formatTokenAmountSigned(1500000000000000000n, 18n, 4n) // "+1.5000"
|
|
11214
|
+
* formatTokenAmountSigned(-500000000000000000n, 18n, 4n) // "-0.5000"
|
|
11215
|
+
* formatTokenAmountSigned(0n, 18n, 4n) // "0.0000"
|
|
11216
|
+
* ```
|
|
11217
|
+
*/
|
|
11218
|
+
function formatTokenAmountSigned(amount, decimals, precision) {
|
|
11219
|
+
const formatted = formatTokenAmount(amount, decimals, precision);
|
|
11220
|
+
if (amount > 0n) return `+${formatted}`;
|
|
11221
|
+
return formatted;
|
|
11222
|
+
}
|
|
11223
|
+
/**
|
|
11224
|
+
* Parse a human-readable token amount string to raw units.
|
|
11225
|
+
*
|
|
11226
|
+
* @param amount - Human-readable amount string (e.g., "1.5")
|
|
11227
|
+
* @param decimals - Token decimals
|
|
11228
|
+
* @returns Amount in smallest units
|
|
11229
|
+
*
|
|
11230
|
+
* @example
|
|
11231
|
+
* ```typescript
|
|
11232
|
+
* parseTokenAmount("1.5", 18n) // 1500000000000000000n
|
|
11233
|
+
* parseTokenAmount("1.5", 6n) // 1500000n (USDC)
|
|
11234
|
+
* parseTokenAmount("100", 18n) // 100000000000000000000n
|
|
11235
|
+
* parseTokenAmount("-0.5", 18n) // -500000000000000000n
|
|
11236
|
+
* ```
|
|
11237
|
+
*/
|
|
11238
|
+
function parseTokenAmount(amount, decimals) {
|
|
11239
|
+
const trimmed = amount.trim();
|
|
11240
|
+
const isNegative = trimmed.startsWith("-");
|
|
11241
|
+
const cleanAmount = isNegative ? trimmed.slice(1) : trimmed;
|
|
11242
|
+
const [integerStr, fractionalStr = ""] = cleanAmount.split(".");
|
|
11243
|
+
const paddedFractional = fractionalStr.padEnd(Number(decimals), "0").slice(0, Number(decimals));
|
|
11244
|
+
const integerPart = BigInt(integerStr || "0") * 10n ** decimals;
|
|
11245
|
+
const fractionalPart = BigInt(paddedFractional || "0");
|
|
11246
|
+
const result = integerPart + fractionalPart;
|
|
11247
|
+
return isNegative ? -result : result;
|
|
11248
|
+
}
|
|
11249
|
+
/**
|
|
11250
|
+
* Format a token delta amount with a sign prefix (+/-) for non-zero values.
|
|
11251
|
+
* Alias for formatTokenAmountSigned, useful for clarity at call sites.
|
|
11252
|
+
*
|
|
11253
|
+
* @param amount - The delta amount in smallest units
|
|
11254
|
+
* @param decimals - Token decimals
|
|
11255
|
+
* @param precision - Number of decimal places to display
|
|
11256
|
+
* @returns Formatted string with sign prefix
|
|
11257
|
+
*/
|
|
11258
|
+
function formatTokenDelta(amount, decimals, precision) {
|
|
11259
|
+
return formatTokenAmountSigned(amount, decimals, precision);
|
|
11260
|
+
}
|
|
11261
|
+
/**
|
|
11262
|
+
* Format token flow deltas and balances from simulation results.
|
|
11263
|
+
*
|
|
11264
|
+
* @param flow - Token flow data
|
|
11265
|
+
* @param decimals0 - Token0 decimals
|
|
11266
|
+
* @param decimals1 - Token1 decimals
|
|
11267
|
+
* @param precision0 - Precision for token0 formatting
|
|
11268
|
+
* @param precision1 - Precision for token1 formatting
|
|
11269
|
+
* @returns Formatted token flow strings
|
|
11270
|
+
*/
|
|
11271
|
+
function formatTokenFlow(flow, decimals0, decimals1, precision0, precision1) {
|
|
11272
|
+
return {
|
|
11273
|
+
delta0: formatTokenAmountSigned(flow.delta0, decimals0, precision0),
|
|
11274
|
+
delta1: formatTokenAmountSigned(flow.delta1, decimals1, precision1),
|
|
11275
|
+
balanceBefore0: formatTokenAmount(flow.balanceBefore0, decimals0, precision0),
|
|
11276
|
+
balanceBefore1: formatTokenAmount(flow.balanceBefore1, decimals1, precision1),
|
|
11277
|
+
balanceAfter0: formatTokenAmount(flow.balanceAfter0, decimals0, precision0),
|
|
11278
|
+
balanceAfter1: formatTokenAmount(flow.balanceAfter1, decimals1, precision1)
|
|
11279
|
+
};
|
|
11280
|
+
}
|
|
11281
|
+
|
|
11282
|
+
//#endregion
|
|
11283
|
+
//#region src/panoptic/v2/formatters/wad.ts
|
|
11284
|
+
/**
|
|
11285
|
+
* Format a WAD-scaled value (1e18 = 1.0).
|
|
11286
|
+
*
|
|
11287
|
+
* @param wad - WAD-scaled value
|
|
11288
|
+
* @param precision - Number of decimal places to display
|
|
11289
|
+
* @returns Formatted string
|
|
11290
|
+
*
|
|
11291
|
+
* @example
|
|
11292
|
+
* ```typescript
|
|
11293
|
+
* formatWad(1220000000000000000n, 2n) // "1.22"
|
|
11294
|
+
* formatWad(1220000000000000000n, 4n) // "1.2200"
|
|
11295
|
+
* formatWad(1000000000000000000n, 2n) // "1.00"
|
|
11296
|
+
* formatWad(500000000000000000n, 2n) // "0.50"
|
|
11297
|
+
* ```
|
|
11298
|
+
*/
|
|
11299
|
+
function formatWad(wad, precision) {
|
|
11300
|
+
return formatTokenAmount(wad, 18n, precision);
|
|
11301
|
+
}
|
|
11302
|
+
/**
|
|
11303
|
+
* Format a WAD-scaled value with sign prefix (+/-) for non-zero values.
|
|
11304
|
+
*
|
|
11305
|
+
* @param wad - WAD-scaled value
|
|
11306
|
+
* @param precision - Number of decimal places to display
|
|
11307
|
+
* @returns Formatted string with sign prefix
|
|
11308
|
+
*
|
|
11309
|
+
* @example
|
|
11310
|
+
* ```typescript
|
|
11311
|
+
* formatWadSigned(1220000000000000000n, 2n) // "+1.22"
|
|
11312
|
+
* formatWadSigned(-500000000000000000n, 2n) // "-0.50"
|
|
11313
|
+
* formatWadSigned(0n, 2n) // "0.00"
|
|
11314
|
+
* ```
|
|
11315
|
+
*/
|
|
11316
|
+
function formatWadSigned(wad, precision) {
|
|
11317
|
+
const formatted = formatWad(wad, precision);
|
|
11318
|
+
if (wad > 0n) return `+${formatted}`;
|
|
11319
|
+
return formatted;
|
|
11320
|
+
}
|
|
11321
|
+
/**
|
|
11322
|
+
* Format a WAD-scaled value as a percentage string.
|
|
11323
|
+
*
|
|
11324
|
+
* @param wad - WAD-scaled value
|
|
11325
|
+
* @param precision - Number of decimal places to display
|
|
11326
|
+
* @returns Formatted percentage string
|
|
11327
|
+
*
|
|
11328
|
+
* @example
|
|
11329
|
+
* ```typescript
|
|
11330
|
+
* formatWadPercent(50000000000000000n, 2n) // "5.00%"
|
|
11331
|
+
* formatWadPercent(1000000000000000000n, 1n) // "100.0%"
|
|
11332
|
+
* ```
|
|
11333
|
+
*/
|
|
11334
|
+
function formatWadPercent(wad, precision) {
|
|
11335
|
+
return `${formatTokenAmount(wad * 100n, 18n, precision)}%`;
|
|
11336
|
+
}
|
|
11337
|
+
/**
|
|
11338
|
+
* Format an annualized rate stored as a WAD-scaled value.
|
|
11339
|
+
* Alias for formatWadPercent.
|
|
11340
|
+
*
|
|
11341
|
+
* @param rateWad - Rate in WAD (1e18 = 1.0)
|
|
11342
|
+
* @param precision - Number of decimal places to display
|
|
11343
|
+
* @returns Formatted percentage string
|
|
11344
|
+
*/
|
|
11345
|
+
function formatRateWad(rateWad, precision) {
|
|
11346
|
+
return formatWadPercent(rateWad, precision);
|
|
11347
|
+
}
|
|
11348
|
+
/**
|
|
11349
|
+
* Parse a decimal string to a WAD-scaled value.
|
|
11350
|
+
*
|
|
11351
|
+
* @param value - Decimal string (e.g., "1.5")
|
|
11352
|
+
* @returns WAD-scaled bigint
|
|
11353
|
+
*
|
|
11354
|
+
* @example
|
|
11355
|
+
* ```typescript
|
|
11356
|
+
* parseWad("1.5") // 1500000000000000000n
|
|
11357
|
+
* parseWad("0.5") // 500000000000000000n
|
|
11358
|
+
* parseWad("100") // 100000000000000000000n
|
|
11359
|
+
* parseWad("-1.22") // -1220000000000000000n
|
|
11360
|
+
* ```
|
|
11361
|
+
*/
|
|
11362
|
+
function parseWad(value) {
|
|
11363
|
+
const trimmed = value.trim();
|
|
11364
|
+
const isNegative = trimmed.startsWith("-");
|
|
11365
|
+
const cleanValue = isNegative ? trimmed.slice(1) : trimmed;
|
|
11366
|
+
const [integerStr, fractionalStr = ""] = cleanValue.split(".");
|
|
11367
|
+
const paddedFractional = fractionalStr.padEnd(18, "0").slice(0, 18);
|
|
11368
|
+
const integerPart = BigInt(integerStr || "0") * 10n ** 18n;
|
|
11369
|
+
const fractionalPart = BigInt(paddedFractional || "0");
|
|
11370
|
+
const result = integerPart + fractionalPart;
|
|
11371
|
+
return isNegative ? -result : result;
|
|
11372
|
+
}
|
|
11373
|
+
|
|
11374
|
+
//#endregion
|
|
11375
|
+
//#region src/panoptic/v2/formatters/rates.ts
|
|
11376
|
+
const SECONDS_PER_DAY = 86400n;
|
|
11377
|
+
const DAYS_PER_YEAR = 365n;
|
|
11378
|
+
const SECONDS_PER_YEAR = SECONDS_PER_DAY * DAYS_PER_YEAR;
|
|
11379
|
+
/**
|
|
11380
|
+
* Annualize a per-second WAD-scaled rate to annual WAD.
|
|
11381
|
+
*
|
|
11382
|
+
* @param ratePerSecondWad - Rate in WAD per second
|
|
11383
|
+
* @returns Annualized rate in WAD
|
|
11384
|
+
*/
|
|
11385
|
+
function annualizePerSecondRateWad(ratePerSecondWad) {
|
|
11386
|
+
return ratePerSecondWad * SECONDS_PER_YEAR;
|
|
11387
|
+
}
|
|
11388
|
+
/**
|
|
11389
|
+
* Format a per-second WAD rate as APY percentage text.
|
|
11390
|
+
* Uses linear annualization, then formats as WAD percent.
|
|
11391
|
+
*
|
|
11392
|
+
* @param ratePerSecondWad - Rate in WAD per second
|
|
11393
|
+
* @param precision - Decimal places
|
|
11394
|
+
* @returns Percentage string, e.g. "2.41%"
|
|
11395
|
+
*/
|
|
11396
|
+
function formatPerSecondRateWadAsApyPct(ratePerSecondWad, precision) {
|
|
11397
|
+
return formatWadPercent(annualizePerSecondRateWad(ratePerSecondWad), precision);
|
|
11398
|
+
}
|
|
11399
|
+
/**
|
|
11400
|
+
* Format a per-second WAD rate as APR percentage text.
|
|
11401
|
+
* For this rate model, APR presentation uses the same annualized output.
|
|
11402
|
+
*
|
|
11403
|
+
* @param ratePerSecondWad - Rate in WAD per second
|
|
11404
|
+
* @param precision - Decimal places
|
|
11405
|
+
* @returns Percentage string, e.g. "2.41%"
|
|
11406
|
+
*/
|
|
11407
|
+
function formatPerSecondRateWadAsAprPct(ratePerSecondWad, precision) {
|
|
11408
|
+
return formatWadPercent(annualizePerSecondRateWad(ratePerSecondWad), precision);
|
|
11409
|
+
}
|
|
11410
|
+
|
|
11411
|
+
//#endregion
|
|
11412
|
+
export { AccountInsolventError, AlreadyInitializedError, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_MINT_BUFFER, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTickLimitsError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MINT_BUFFER, MINT_BUFFER_DENOMINATOR, MaxRetriesExceededError, MissingPositionIdsError, MulticallNoDataError, MulticallResultFailedError, MulticallResultMissingError, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NoLoanPositionsError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, OracleRateLimitedError, PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, ReentrancyError, RpcError, RpcResponseError, STANDARD_TICK_WIDTHS, STRIKE_CONVERSION_FACTOR, SafeModeError, StaleDataError, StaleOracleError, StorageDataNotFoundError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, UnsafePremiumSettlementError, WrongPoolIdError, WrongUniswapPoolError, ZeroAddressError, ZeroCollateralRequirementError, annualizePerSecondRateWad, applyMintBuffer, applyMintBufferPerToken, clearTrackedPositions, collateralTrackerV2Abi, createFileStorage, createMemoryStorage, createTxResult, decodeAllDispatchCalldata, decodeDispatchCalldata, decodeLeftRightSigned, decodeLeftRightUnsigned, decodeOraclePack, decodeOracleRiskParameters, decodeOracleTiming, decodePosition, decodePositionBalance$1 as decodePositionBalance, decodeTickSpacing, diagnoseOracleSafeMode, fetchPoolId, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatRateWad, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatWad, formatWadPercent, formatWadSigned, getBlockMeta, getClosedPositionsKey, getOpenPositionIds, getOracleRiskParameters, getOracleState, getPendingPositionsKey, getPool, getPoolMetaKey, getPoolMetadata, getPoolPrefix, getPosition, getPositionGreeks, getPositionMetaKey, getPositions, getPositionsKey, getRiskParameters, getSchemaVersionKey, getSyncCheckpointKey, getTrackedChunksKey, getTrackedPositionIds, getUtilization, isPanopticErrorType, isPositionTracked, jsonSerializer, mintableAfterBuffer, oracleEpochAt, panopticErrorsAbi, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticPoolV2Abi, panopticQueryAbi as panopticQueryAbi$1, parsePanopticError, parseTokenAmount, parseWad, recoverSnapshot, recoverSnapshotFromTx, riskEngineAbi, selectDispatchForAccount, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, stateViewAbi, submitWrite, uniswapV3PoolAbi, validateBuilderCode };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { PanopticError, getBlockMeta, getPool, submitWrite } from "./
|
|
2
|
-
import { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, QuoterUnavailableError, UnsupportedChainError, universalRouterAbi } from "./router-
|
|
1
|
+
import { PanopticError, getBlockMeta, getPool, submitWrite } from "./rates-5oQD-SuM.js";
|
|
2
|
+
import { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, QuoterUnavailableError, UnsupportedChainError, universalRouterAbi } from "./router-ClhAkKjh.js";
|
|
3
3
|
import { BaseError, ContractFunctionRevertedError, encodeAbiParameters, encodeFunctionData, encodePacked, erc20Abi, isAddressEqual, maxUint256, zeroAddress } from "viem";
|
|
4
4
|
|
|
5
5
|
//#region src/uniswap/v4/addresses.ts
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PanopticError } from "./
|
|
1
|
+
import { PanopticError } from "./rates-5oQD-SuM.js";
|
|
2
2
|
import { BaseError, ContractFunctionRevertedError, encodeAbiParameters, encodeFunctionData, encodePacked, zeroAddress } from "viem";
|
|
3
3
|
|
|
4
4
|
//#region src/uniswap/v4/router/errors.ts
|
package/dist/uniswap/index.js
CHANGED
|
@@ -31,7 +31,7 @@ const NO_UPPER_LIQUIDATION_TICK = (1n << 23n) - 1n;
|
|
|
31
31
|
|
|
32
32
|
//#endregion
|
|
33
33
|
//#region src/panoptic/v2/formatters/tick.ts
|
|
34
|
-
const Q192$
|
|
34
|
+
const Q192$4 = 1n << 192n;
|
|
35
35
|
function tickToSqrtPriceX96(tick) {
|
|
36
36
|
if (tick < MIN_TICK || tick > MAX_TICK) throw new RangeError("Tick out of bounds");
|
|
37
37
|
const absTick = tick < 0n ? -tick : tick;
|
|
@@ -65,8 +65,8 @@ const MAX_SQRT_PRICE_X96 = tickToSqrtPriceX96(MAX_TICK);
|
|
|
65
65
|
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/uniswap/lpGreeks.ts
|
|
68
|
-
const Q96$
|
|
69
|
-
const Q192$
|
|
68
|
+
const Q96$2 = 1n << 96n;
|
|
69
|
+
const Q192$3 = 1n << 192n;
|
|
70
70
|
/**
|
|
71
71
|
* Compute the token0/token1 amounts backing `liquidity` over `[sqrtA, sqrtB]`
|
|
72
72
|
* at the current price `sqrtP`, mirroring Uniswap's `LiquidityAmounts`
|
|
@@ -76,8 +76,8 @@ const Q192$1 = 1n << 192n;
|
|
|
76
76
|
function getAmountsForLiquidity(sqrtPriceX96, sqrtRatioAX96, sqrtRatioBX96, liquidity) {
|
|
77
77
|
const [sqrtA, sqrtB] = sqrtRatioAX96 <= sqrtRatioBX96 ? [sqrtRatioAX96, sqrtRatioBX96] : [sqrtRatioBX96, sqrtRatioAX96];
|
|
78
78
|
const sqrtC = sqrtPriceX96 < sqrtA ? sqrtA : sqrtPriceX96 > sqrtB ? sqrtB : sqrtPriceX96;
|
|
79
|
-
const amount0 = sqrtC < sqrtB ? liquidity * (sqrtB - sqrtC) * Q96$
|
|
80
|
-
const amount1 = sqrtC > sqrtA ? liquidity * (sqrtC - sqrtA) / Q96$
|
|
79
|
+
const amount0 = sqrtC < sqrtB ? liquidity * (sqrtB - sqrtC) * Q96$2 / (sqrtC * sqrtB) : 0n;
|
|
80
|
+
const amount1 = sqrtC > sqrtA ? liquidity * (sqrtC - sqrtA) / Q96$2 : 0n;
|
|
81
81
|
return {
|
|
82
82
|
amount0,
|
|
83
83
|
amount1
|
|
@@ -103,18 +103,18 @@ function getLpGreeks(input) {
|
|
|
103
103
|
const sqrtP2 = sqrtP * sqrtP;
|
|
104
104
|
const inRange = sqrtP > sqrtA && sqrtP < sqrtB;
|
|
105
105
|
if (assetIndex === 0) {
|
|
106
|
-
const value$1 = amount1 + amount0 * sqrtP2 / Q192$
|
|
106
|
+
const value$1 = amount1 + amount0 * sqrtP2 / Q192$3;
|
|
107
107
|
const delta$1 = amount0;
|
|
108
|
-
const gamma$1 = inRange ? -(liquidity * sqrtP) / (2n * Q96$
|
|
108
|
+
const gamma$1 = inRange ? -(liquidity * sqrtP) / (2n * Q96$2) : 0n;
|
|
109
109
|
return {
|
|
110
110
|
value: value$1,
|
|
111
111
|
delta: delta$1,
|
|
112
112
|
gamma: gamma$1
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
const value = amount0 + amount1 * Q192$
|
|
115
|
+
const value = amount0 + amount1 * Q192$3 / sqrtP2;
|
|
116
116
|
const delta = amount1;
|
|
117
|
-
const gamma = inRange ? -(liquidity * Q96$
|
|
117
|
+
const gamma = inRange ? -(liquidity * Q96$2) / (2n * sqrtP) : 0n;
|
|
118
118
|
return {
|
|
119
119
|
value,
|
|
120
120
|
delta,
|
|
@@ -5127,9 +5127,9 @@ async function getPool(params) {
|
|
|
5127
5127
|
fee: metadata.fee,
|
|
5128
5128
|
tickSpacing
|
|
5129
5129
|
};
|
|
5130
|
-
const SECONDS_PER_YEAR = 31536000n;
|
|
5131
|
-
const borrowRate0 = BigInt(token0InterestRate) * SECONDS_PER_YEAR;
|
|
5132
|
-
const borrowRate1 = BigInt(token1InterestRate) * SECONDS_PER_YEAR;
|
|
5130
|
+
const SECONDS_PER_YEAR$1 = 31536000n;
|
|
5131
|
+
const borrowRate0 = BigInt(token0InterestRate) * SECONDS_PER_YEAR$1;
|
|
5132
|
+
const borrowRate1 = BigInt(token1InterestRate) * SECONDS_PER_YEAR$1;
|
|
5133
5133
|
const utilization0 = token0PoolData[3];
|
|
5134
5134
|
const utilization1 = token1PoolData[3];
|
|
5135
5135
|
const supplyRate0 = borrowRate0 * utilization0 / 10000n;
|
|
@@ -5236,8 +5236,8 @@ function parsePoolKey(poolKeyBytes) {
|
|
|
5236
5236
|
//#endregion
|
|
5237
5237
|
//#region src/panoptic/v2/greeks/index.ts
|
|
5238
5238
|
/** Fixed-point scale constants for sqrtPriceX96 arithmetic */
|
|
5239
|
-
const Q96 = 1n << 96n;
|
|
5240
|
-
const Q192 = 1n << 192n;
|
|
5239
|
+
const Q96$1 = 1n << 96n;
|
|
5240
|
+
const Q192$2 = 1n << 192n;
|
|
5241
5241
|
|
|
5242
5242
|
//#endregion
|
|
5243
5243
|
//#region src/panoptic/v2/tokenId/constants.ts
|
|
@@ -5293,6 +5293,15 @@ const LEG_MASKS = {
|
|
|
5293
5293
|
WIDTH: (1n << LEG_BITS.WIDTH_SIZE) - 1n,
|
|
5294
5294
|
LEG: (1n << TOKEN_ID_BITS.LEG_SIZE) - 1n
|
|
5295
5295
|
};
|
|
5296
|
+
/**
|
|
5297
|
+
* Maximum and minimum values for leg fields.
|
|
5298
|
+
*/
|
|
5299
|
+
const LEG_LIMITS = {
|
|
5300
|
+
MAX_RATIO: 127n,
|
|
5301
|
+
MAX_WIDTH: 4095n,
|
|
5302
|
+
MAX_STRIKE: 8388607n,
|
|
5303
|
+
MIN_STRIKE: -8388608n
|
|
5304
|
+
};
|
|
5296
5305
|
|
|
5297
5306
|
//#endregion
|
|
5298
5307
|
//#region src/panoptic/v2/utils/option-encoding-v2.ts
|
|
@@ -5325,9 +5334,40 @@ const OPTION_BURNT_EVENT = getAbiItem({
|
|
|
5325
5334
|
name: "OptionBurnt"
|
|
5326
5335
|
});
|
|
5327
5336
|
|
|
5337
|
+
//#endregion
|
|
5338
|
+
//#region src/panoptic/v2/formatters/rates.ts
|
|
5339
|
+
const SECONDS_PER_DAY = 86400n;
|
|
5340
|
+
const DAYS_PER_YEAR = 365n;
|
|
5341
|
+
const SECONDS_PER_YEAR = SECONDS_PER_DAY * DAYS_PER_YEAR;
|
|
5342
|
+
|
|
5343
|
+
//#endregion
|
|
5344
|
+
//#region src/panoptic/v2/tokenId/deriveUniqueTokenId.ts
|
|
5345
|
+
const POOL_ID_MASK$2 = (1n << 64n) - 1n;
|
|
5346
|
+
const MAX_LEGS = TOKEN_ID_BITS.MAX_LEGS;
|
|
5347
|
+
const MAX_OPTION_RATIO = LEG_LIMITS.MAX_RATIO;
|
|
5348
|
+
const Q192$1 = 1n << 192n;
|
|
5349
|
+
|
|
5350
|
+
//#endregion
|
|
5351
|
+
//#region src/panoptic/v2/tokenId/generateOverlapping.ts
|
|
5352
|
+
const MAX_UINT64 = (1n << 64n) - 1n;
|
|
5353
|
+
const MAX_UINT128$2 = (1n << 128n) - 1n;
|
|
5354
|
+
const Q192 = 1n << 192n;
|
|
5355
|
+
|
|
5356
|
+
//#endregion
|
|
5357
|
+
//#region src/panoptic/v2/tokenId/split.ts
|
|
5358
|
+
const POOL_ID_MASK$1 = (1n << TOKEN_ID_BITS.POOL_ID_SIZE) - 1n;
|
|
5359
|
+
const MAX_UINT128$1 = (1n << 128n) - 1n;
|
|
5360
|
+
const MAX_UINT256 = (1n << 256n) - 1n;
|
|
5361
|
+
|
|
5362
|
+
//#endregion
|
|
5363
|
+
//#region src/panoptic/v2/writes/protectedSettle.ts
|
|
5364
|
+
const POOL_ID_MASK = (1n << 64n) - 1n;
|
|
5365
|
+
const Q96 = 1n << 96n;
|
|
5366
|
+
const MAX_UINT128 = (1n << 128n) - 1n;
|
|
5367
|
+
|
|
5328
5368
|
//#endregion
|
|
5329
5369
|
//#region src/panoptic/v2/reads/positionSizes.ts
|
|
5330
|
-
const BIT_MASK_128 = (1n << 128n) - 1n;
|
|
5370
|
+
const BIT_MASK_128$1 = (1n << 128n) - 1n;
|
|
5331
5371
|
|
|
5332
5372
|
//#endregion
|
|
5333
5373
|
//#region src/panoptic/v2/simulations/tokenFlow.ts
|
|
@@ -5349,6 +5389,10 @@ const multicallAbi = [{
|
|
|
5349
5389
|
stateMutability: "nonpayable"
|
|
5350
5390
|
}, ...panopticErrorsAbi];
|
|
5351
5391
|
|
|
5392
|
+
//#endregion
|
|
5393
|
+
//#region src/panoptic/v2/simulations/simulateSettle.ts
|
|
5394
|
+
const BIT_MASK_128 = (1n << 128n) - 1n;
|
|
5395
|
+
|
|
5352
5396
|
//#endregion
|
|
5353
5397
|
//#region src/uniswap/v4/abis/permit2.ts
|
|
5354
5398
|
/**
|