@panoptic-eng/sdk 1.0.12 → 1.0.14
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 +23 -1
- package/dist/cow/index.js +1 -1
- package/dist/deployments.d.ts +127 -0
- package/dist/deployments.d.ts.map +1 -0
- package/dist/deployments.js +303 -0
- package/dist/deployments.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +302 -1
- package/dist/index.js.map +1 -1
- package/dist/panoptic/v2/index.d.ts +2 -2
- package/dist/panoptic/v2/index.d.ts.map +1 -1
- package/dist/panoptic/v2/index.js +1 -1
- package/dist/uniswap/index.js +1 -1
- package/dist/{writes-BeAgqpRs.js → writes-BjhsHNh-.js} +43 -11
- package/dist/writes-BjhsHNh-.js.map +1 -0
- package/package.json +25 -8
- package/dist/writes-BeAgqpRs.js.map +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BORROW_INDEX_BITS, BPS_SCALE, MARKET_EPOCH_BITS, MARKET_EPOCH_SHIFT, RATE_AT_TARGET_BITS, SECONDS_PER_YEAR, UNREALIZED_INTEREST_BITS, annualizePerSecondRateWad, deriveSupplyRatePerSecWad, formatPerSecondRateWadAsAprPct, formatPerSecondRateWadAsApyPct, formatRateWad, formatTokenAmount, formatTokenAmountSigned, formatTokenDelta, formatTokenFlow, formatWad, formatWadPercent, formatWadSigned, getAccountCollateral, getAccountSummaryBasic, getAccountSummaryRisk, getCollateralAddresses, getCollateralData, getCurrentRates, getInterestState, getIrmCurrent, getIrmCurve, getLiquidationPrices, getNetLiquidationValue, getNetLiquidationValues, isLiquidatable, packMarketState, panopticQueryAbi$1 as panopticQueryAbi, parseTokenAmount, parseWad, ratePerSecWadToAprPct, readBlockAndAggregate, requireReturnData, utilizationBpsToWad, utilizationPctToWad } from "../../irm-CzzPOxhR.js";
|
|
2
2
|
import { AccountInsolventError, AlreadyInitializedError, BPS_DENOMINATOR, BatchValidationError, BelowMinimumRedemptionError, CastingError, ChunkHasZeroLiquidityError, ChunkLimitError, CrossPoolError, DEFAULT_MAX_SPREAD, DEFAULT_VEGOID, DepositTooLargeError, DuplicateTokenIdError, EffectiveLiquidityAboveThresholdError, ExceedsMaximumRedemptionError, InputListFailError, InsufficientCreditLiquidityError, InvalidBuilderCodeError, InvalidHistoryRangeError, InvalidTickBoundError, InvalidTickError, InvalidTokenIdParameterError, InvalidUniswapCallbackError, LEG_BITS, LEG_LIMITS, LEG_MASKS, LengthMismatchError, LiquidityTooHighError, LoanSlotExhaustedError, MAX_TICK, MAX_TRACKED_CHUNKS, MIN_TICK, MaxRetriesExceededError, MissingPositionIdsError, NetLiquidityZeroError, NetworkMismatchError, NoLegsExercisableError, NotALongLegError, NotBuilderError, NotEnoughLiquidityInChunkError, NotEnoughTokensError, NotGuardianError, NotMarginCalledError, NotPanopticPoolError, ORACLE_EPOCH_SECONDS, OracleRateLimitedError, PanopticError$1 as PanopticError, PanopticHelperNotDeployedError, PanopticValidationError, PoolNotInitializedError, PositionCountNotZeroError, PositionNotOwnedError, PositionSnapshotNotFoundError, PositionTooLargeError, PriceBoundFailError, PriceImpactTooLargeError, ProviderLagError, REORG_DEPTH, ReentrancyError, RpcError, RpcResponseError, SCHEMA_VERSION, STANDARD_TICK_WIDTHS, STORAGE_PREFIX, SafeModeError, StaleDataError, StaleOracleError, StorageDataNotFoundError, SwapTokenMismatchError, SyncTimeoutError, TOKEN_ID_BITS, TokenIdHasZeroLegsError, TooManyLegsOpenError, TransferFailedError, UTILIZATION_DENOMINATOR, UnauthorizedUniswapCallbackError, UnderOverFlowError, UnhealthyPoolError, WAD, WrongPoolIdError, WrongUniswapPoolError, ZERO_COLLATERAL, ZERO_VALUATION, ZeroAddressError, ZeroCollateralRequirementError, calculatePositionDelta, calculatePositionDeltaWithSwap, calculatePositionGamma, calculatePositionGreeks, calculatePositionValue, collateralTrackerV2Abi, decodeLeftRightSigned, decodeLeftRightUnsigned, decodePosition, decodePositionBalance, decodeTickSpacing, fetchPoolId$1 as fetchPoolId, formatPriceRange$1 as formatPriceRange, formatTick$1 as formatTick, formatTickRange$1 as formatTickRange, getBlockMeta, getLegDelta, getLegGamma, getLegValue, getOracleState$1 as getOracleState, getPool$1 as getPool, getPoolMetadata$1 as getPoolMetadata, getPosition, getPositionGreeks, getPositions, getPricesAtTick$1 as getPricesAtTick, getRiskParameters$1 as getRiskParameters, getTickSpacing$1 as getTickSpacing, getUtilization$1 as getUtilization, isCall, isDefinedRisk, isPanopticErrorType, panopticFactoryV3Abi, panopticFactoryV4Abi, panopticGuardianAbi, panopticPoolV2Abi, panopticQueryAbi as panopticQueryAbi$1, parsePanopticError, priceToTick$1 as priceToTick, riskEngineAbi, roundToTickSpacing$1 as roundToTickSpacing, semiFungiblePositionManagerV3Abi, semiFungiblePositionManagerV4Abi, sqrtPriceX96ToPriceDecimalScaled$1 as sqrtPriceX96ToPriceDecimalScaled, sqrtPriceX96ToTick$1 as sqrtPriceX96ToTick, stateViewAbi, tickLimits$1 as tickLimits, tickToPrice$1 as tickToPrice, tickToPriceDecimalScaled$1 as tickToPriceDecimalScaled, tickToSqrtPriceX96$1 as tickToSqrtPriceX96, uniswapV3PoolAbi, validateBuilderCode$1 as validateBuilderCode } from "../../position-DiqNO8a0.js";
|
|
3
3
|
import { approveErc20ForCow, cancelCowOrder, checkCowApproval, getCowOrderStatus, isCowSupportedChain, quoteCowSwap, signAndSubmitCowOrder } from "../../cow-CS9QNWLv.js";
|
|
4
|
-
import { addLegToTokenId, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildOpenPositionCalldata, buildUniqueLoan, calculateResyncBlock, cancelTransaction, checkApproval, clearCheckpoint, clearTrackedPositions, closePosition, closePositionAndWait, countLegs, createFileStorage, createMemoryStorage, createNonceManager, createTokenIdBuilder, decodeAllLegs, decodeDispatchCalldata, decodeLeg, decodePoolId, decodeTickSpacing$1, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, detectReorg, dispatch, dispatchAndWait, encodeLeg, encodePoolId, encodeV4PoolId, executeBatchDispatch, executeBatchDispatchAndWait, forceExercise, forceExerciseAndWait, getAssetIndex, getClosedPositionsKey, getOpenPositionIds, getPendingPositionsKey, getPoolMetaKey, getPoolPrefix, getPositionMetaKey, getPositionsKey, getSchemaVersionKey, getSyncCheckpointKey, getTrackedChunksKey, getTrackedPositionIds, hasLoanOrCredit, hasLongLeg, isCredit, isCreditLeg, isGasError, isInputListFailError, isLoan, isLoanLeg, isNonceError, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, jsonSerializer, liquidate, liquidateAndWait, loadCheckpoint, mint, mintAndWait, openPosition, openPositionAndWait, pokeOracle, pokeOracleAndWait, previewBorrow, previewUnwrap, previewWrap, publicBroadcaster, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, repay, repayAndWait, resolveTokenIndex, rollPosition, rollPositionAndWait, saveCheckpoint, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, simulateOpenPosition, simulateWithTokenFlow, smartRepay, smartRepayAndWait, speedUpTransaction, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, validateBatch, validatePoolId, verifyBlockContinuity, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi } from "../../writes-
|
|
4
|
+
import { addLegToTokenId, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildOpenPositionCalldata, buildUniqueLoan, calculateResyncBlock, cancelTransaction, checkApproval, clearCheckpoint, clearTrackedPositions, closePosition, closePositionAndWait, countLegs, createFileStorage, createMemoryStorage, createNonceManager, createTokenIdBuilder, decodeAllLegs, decodeDispatchCalldata, decodeLeg, decodePoolId, decodeTickSpacing$1, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, detectReorg, dispatch, dispatchAndWait, encodeLeg, encodePoolId, encodeV4PoolId, executeBatchDispatch, executeBatchDispatchAndWait, forceExercise, forceExerciseAndWait, getAssetIndex, getClosedPositionsKey, getOpenPositionIds, getPendingPositionsKey, getPoolMetaKey, getPoolPrefix, getPositionMetaKey, getPositionsKey, getSchemaVersionKey, getSyncCheckpointKey, getTrackedChunksKey, getTrackedPositionIds, hasLoanOrCredit, hasLongLeg, isCredit, isCreditLeg, isGasError, isInputListFailError, isLoan, isLoanLeg, isNonceError, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, jsonSerializer, liquidate, liquidateAndWait, loadCheckpoint, mint, mintAndWait, openPosition, openPositionAndWait, pokeOracle, pokeOracleAndWait, previewBorrow, previewUnwrap, previewWrap, publicBroadcaster, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, repay, repayAndWait, resolveTokenIndex, rollPosition, rollPositionAndWait, saveCheckpoint, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, simulateOpenPosition, simulateWithTokenFlow, smartRepay, smartRepayAndWait, speedUpTransaction, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, validateBatch, validatePoolId, verifyBlockContinuity, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi } from "../../writes-BjhsHNh-.js";
|
|
5
5
|
import { approveErc20ForPermit2, approveRouterViaPermit2, checkRouterApproval, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, swapExactInViaRouter, swapExactOutViaRouter } from "../../router-CS84DV2k.js";
|
|
6
6
|
import { ContractFunctionExecutionError, decodeFunctionResult, encodeAbiParameters, encodeFunctionData, getAddress, keccak256, zeroAddress } from "viem";
|
|
7
7
|
import { multicall } from "viem/actions";
|
package/dist/uniswap/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import "../position-DiqNO8a0.js";
|
|
2
|
-
import "../writes-
|
|
2
|
+
import "../writes-BjhsHNh-.js";
|
|
3
3
|
import { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoterUnavailableError, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, TAKE_ALL, UNISWAP_V4_ADDRESSES, UnsupportedChainError, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait } from "../router-CS84DV2k.js";
|
|
4
4
|
|
|
5
5
|
export { AmountExceedsUint128Error, InvalidSwapTokenError, MissingSweepRecipientError, PERMIT2_ADDRESS, QuoterUnavailableError, SETTLE_ALL, SWAP_EXACT_IN_SINGLE, SWAP_EXACT_OUT_SINGLE, SWEEP, TAKE_ALL, UNISWAP_V4_ADDRESSES, UnsupportedChainError, V4_SWAP, approveErc20ForPermit2, approveErc20ForPermit2AndWait, approveRouterViaPermit2, approveRouterViaPermit2AndWait, buildV4ExactOutSwapExecuteArgs, buildV4ExactOutSwapExecuteCalldata, buildV4SwapExecuteArgs, buildV4SwapExecuteCalldata, checkRouterApproval, getUniswapV4Addresses, quoteSwapExactInViaRouter, quoteSwapExactOutViaRouter, resolveSwapRoute, swapExactInViaRouter, swapExactInViaRouterAndWait, swapExactOutViaRouter, swapExactOutViaRouterAndWait };
|
|
@@ -609,6 +609,7 @@ const jsonSerializer = {
|
|
|
609
609
|
|
|
610
610
|
//#endregion
|
|
611
611
|
//#region src/panoptic/v2/sync/snapshotRecovery.ts
|
|
612
|
+
const LOG_SCAN_WINDOW = 10000n;
|
|
612
613
|
/**
|
|
613
614
|
* Recover position snapshot from the last dispatch transaction.
|
|
614
615
|
* This is the primary recovery method - it finds the most recent dispatch()
|
|
@@ -621,6 +622,30 @@ async function recoverSnapshot(params) {
|
|
|
621
622
|
const { client, poolAddress, account, toBlock } = params;
|
|
622
623
|
const latestBlock = toBlock ?? await client.getBlockNumber();
|
|
623
624
|
const searchFromBlock = params.fromBlock ?? 0n;
|
|
625
|
+
if (latestBlock < searchFromBlock) return null;
|
|
626
|
+
let windowToBlock = latestBlock;
|
|
627
|
+
while (true) {
|
|
628
|
+
const windowFromBlock = windowToBlock - searchFromBlock + 1n > LOG_SCAN_WINDOW ? windowToBlock - LOG_SCAN_WINDOW + 1n : searchFromBlock;
|
|
629
|
+
const events = await getSnapshotEventsForWindow({
|
|
630
|
+
client,
|
|
631
|
+
poolAddress,
|
|
632
|
+
account,
|
|
633
|
+
fromBlock: windowFromBlock,
|
|
634
|
+
toBlock: windowToBlock
|
|
635
|
+
});
|
|
636
|
+
const snapshot = await recoverSnapshotFromEvents({
|
|
637
|
+
client,
|
|
638
|
+
account,
|
|
639
|
+
events
|
|
640
|
+
});
|
|
641
|
+
if (snapshot) return snapshot;
|
|
642
|
+
if (windowFromBlock === searchFromBlock) break;
|
|
643
|
+
windowToBlock = windowFromBlock - 1n;
|
|
644
|
+
}
|
|
645
|
+
return null;
|
|
646
|
+
}
|
|
647
|
+
async function getSnapshotEventsForWindow(params) {
|
|
648
|
+
const { client, poolAddress, account, fromBlock, toBlock } = params;
|
|
624
649
|
const [mintEvents, burnEvents, forceExerciseEvents, liquidationEvents] = await Promise.all([
|
|
625
650
|
client.getLogs({
|
|
626
651
|
address: poolAddress,
|
|
@@ -646,8 +671,8 @@ async function recoverSnapshot(params) {
|
|
|
646
671
|
]
|
|
647
672
|
},
|
|
648
673
|
args: { recipient: account },
|
|
649
|
-
fromBlock
|
|
650
|
-
toBlock
|
|
674
|
+
fromBlock,
|
|
675
|
+
toBlock
|
|
651
676
|
}),
|
|
652
677
|
client.getLogs({
|
|
653
678
|
address: poolAddress,
|
|
@@ -678,8 +703,8 @@ async function recoverSnapshot(params) {
|
|
|
678
703
|
]
|
|
679
704
|
},
|
|
680
705
|
args: { recipient: account },
|
|
681
|
-
fromBlock
|
|
682
|
-
toBlock
|
|
706
|
+
fromBlock,
|
|
707
|
+
toBlock
|
|
683
708
|
}),
|
|
684
709
|
client.getLogs({
|
|
685
710
|
address: poolAddress,
|
|
@@ -710,8 +735,8 @@ async function recoverSnapshot(params) {
|
|
|
710
735
|
]
|
|
711
736
|
},
|
|
712
737
|
args: { user: account },
|
|
713
|
-
fromBlock
|
|
714
|
-
toBlock
|
|
738
|
+
fromBlock,
|
|
739
|
+
toBlock
|
|
715
740
|
}),
|
|
716
741
|
client.getLogs({
|
|
717
742
|
address: poolAddress,
|
|
@@ -737,16 +762,20 @@ async function recoverSnapshot(params) {
|
|
|
737
762
|
]
|
|
738
763
|
},
|
|
739
764
|
args: { liquidatee: account },
|
|
740
|
-
fromBlock
|
|
741
|
-
toBlock
|
|
765
|
+
fromBlock,
|
|
766
|
+
toBlock
|
|
742
767
|
})
|
|
743
768
|
]);
|
|
744
|
-
|
|
769
|
+
return [
|
|
745
770
|
...mintEvents,
|
|
746
771
|
...burnEvents,
|
|
747
772
|
...forceExerciseEvents,
|
|
748
773
|
...liquidationEvents
|
|
749
|
-
]
|
|
774
|
+
];
|
|
775
|
+
}
|
|
776
|
+
async function recoverSnapshotFromEvents(params) {
|
|
777
|
+
const { client, account, events } = params;
|
|
778
|
+
const allEvents = events.filter(isSnapshotCandidateEvent).sort((a, b) => {
|
|
750
779
|
const blockDiff = Number(b.blockNumber - a.blockNumber);
|
|
751
780
|
if (blockDiff !== 0) return blockDiff;
|
|
752
781
|
return Number(b.logIndex - a.logIndex);
|
|
@@ -772,6 +801,9 @@ async function recoverSnapshot(params) {
|
|
|
772
801
|
} catch {}
|
|
773
802
|
return null;
|
|
774
803
|
}
|
|
804
|
+
function isSnapshotCandidateEvent(event) {
|
|
805
|
+
return event.transactionHash !== null && event.blockNumber !== null && event.logIndex !== null;
|
|
806
|
+
}
|
|
775
807
|
/**
|
|
776
808
|
* Recover position snapshot from a specific dispatch transaction hash.
|
|
777
809
|
*
|
|
@@ -4368,4 +4400,4 @@ async function smartRepayAndWait(params) {
|
|
|
4368
4400
|
|
|
4369
4401
|
//#endregion
|
|
4370
4402
|
export { addLegToTokenId, approve, approveAndWait, approvePool, assertCanBurn, assertCanForceExercise, assertCanLiquidate, assertCanMint, assertFresh, assertHealthy, assertTradeable, borrow, borrowAndWait, buildBatchDispatchArgs, buildOpenPositionCalldata, buildUniqueLoan, calculateResyncBlock, cancelTransaction, checkApproval, clearCheckpoint, clearTrackedPositions, closePosition, closePositionAndWait, countLegs, createFileStorage, createMemoryStorage, createNonceManager, createTokenIdBuilder, decodeAllLegs, decodeDispatchCalldata, decodeLeg, decodePoolId, decodeTickSpacing as decodeTickSpacing$1, decodeTokenId, decodeVegoid, deployNewPool, deployNewPoolAndWait, deposit, depositAndWait, detectReorg, dispatch, dispatchAndWait, encodeLeg, encodePoolId, encodeV4PoolId, executeBatchDispatch, executeBatchDispatchAndWait, forceExercise, forceExerciseAndWait, getAssetIndex, getClosedPositionsKey, getOpenPositionIds, getPendingPositionsKey, getPoolMetaKey, getPoolPrefix, getPositionMetaKey, getPositionsKey, getSchemaVersionKey, getSyncCheckpointKey, getTrackedChunksKey, getTrackedPositionIds, hasLoanOrCredit, hasLongLeg, isCredit, isCreditLeg, isGasError, isInputListFailError, isLoan, isLoanLeg, isNonceError, isPositionTracked, isRetryableRpcError, isShortOnly, isSpread, jsonSerializer, liquidate, liquidateAndWait, loadCheckpoint, mint, mintAndWait, openPosition, openPositionAndWait, pokeOracle, pokeOracleAndWait, previewBorrow, previewUnwrap, previewWrap, publicBroadcaster, recoverSnapshot, recoverSnapshotFromTx, redeem, redeemAndWait, repay, repayAndWait, resolveTokenIndex, rollPosition, rollPositionAndWait, saveCheckpoint, settleAccumulatedPremia, settleAccumulatedPremiaAndWait, simulateOpenPosition, simulateWithTokenFlow, smartRepay, smartRepayAndWait, speedUpTransaction, supply, supplyAndWait, swapExactIn, swapExactInAndWait, swapExactOut, swapExactOutAndWait, syncPositions, unsupply, unsupplyAndWait, unwrapWeth, unwrapWethAndWait, unwrapXstock, unwrapXstockAndWait, validateBatch, validatePoolId, verifyBlockContinuity, wethWrapAbi, withdraw, withdrawAndWait, withdrawWithPositions, withdrawWithPositionsAndWait, wrapEth, wrapEthAndWait, wrapXstock, wrapXstockAndWait, xstockWrapperAbi };
|
|
4371
|
-
//# sourceMappingURL=writes-
|
|
4403
|
+
//# sourceMappingURL=writes-BjhsHNh-.js.map
|