timelock-sdk 0.0.77 → 0.0.78

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/client.js CHANGED
@@ -780,6 +780,78 @@ const useSetOperatorPerms = (marketAddr) => {
780
780
  return useMutation({ mutationFn: setOperatorPerms });
781
781
  };
782
782
 
783
+ //#endregion
784
+ //#region src/hooks/market/useOptionTimeline.ts
785
+ const useOptionTimeline = (marketAddr, optionId) => {
786
+ const { graphqlClient } = useTimelockConfig();
787
+ const normalizedMarketAddr = marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase();
788
+ const { data,...rest } = useQuery({
789
+ queryKey: [
790
+ "optionTimeline",
791
+ normalizedMarketAddr || "--",
792
+ (optionId === null || optionId === void 0 ? void 0 : optionId.toString()) || "--"
793
+ ],
794
+ queryFn: async () => {
795
+ if (!graphqlClient || !normalizedMarketAddr || optionId === void 0) return [];
796
+ const result = await graphqlClient.GetOptionEvents({
797
+ marketAddr: normalizedMarketAddr,
798
+ optionId: optionId.toString()
799
+ });
800
+ const mintEvents = result.MintOptionEvent.map((event) => ({
801
+ id: event.id,
802
+ optionType: event.optionType,
803
+ strikeTick: event.strikeTick,
804
+ currentTick: event.currentTick,
805
+ expiresAt: /* @__PURE__ */ new Date(Number(event.expiresAt) * 1e3),
806
+ premium: BigInt(event.premium),
807
+ protocolFee: BigInt(event.protocolFee),
808
+ liquidities: event.liquidities.map((l) => BigInt(l)),
809
+ timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
810
+ blockNumber: BigInt(event.blockNumber),
811
+ transactionHash: event.transactionHash
812
+ }));
813
+ const exerciseEvents = result.ExerciseOptionEvent.map((event) => ({
814
+ id: event.id,
815
+ liquidities: event.liquidities.map((l) => BigInt(l)),
816
+ currentTick: event.currentTick,
817
+ payout: BigInt(event.payout),
818
+ timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
819
+ blockNumber: BigInt(event.blockNumber),
820
+ transactionHash: event.transactionHash
821
+ }));
822
+ const extendEvents = result.ExtendOptionEvent.map((event) => ({
823
+ id: event.id,
824
+ premium: BigInt(event.premium),
825
+ protocolFee: BigInt(event.protocolFee),
826
+ currentTick: event.currentTick,
827
+ addedDuration: BigInt(event.addedDuration),
828
+ timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
829
+ blockNumber: BigInt(event.blockNumber),
830
+ transactionHash: event.transactionHash
831
+ }));
832
+ return [
833
+ ...mintEvents.map((data$1) => ({
834
+ type: "mint",
835
+ data: data$1
836
+ })),
837
+ ...exerciseEvents.map((data$1) => ({
838
+ type: "exercise",
839
+ data: data$1
840
+ })),
841
+ ...extendEvents.map((data$1) => ({
842
+ type: "extend",
843
+ data: data$1
844
+ }))
845
+ ].sort((a, b) => a.data.timestamp.getTime() - b.data.timestamp.getTime());
846
+ },
847
+ enabled: !!normalizedMarketAddr && optionId !== void 0 && !!graphqlClient
848
+ });
849
+ return {
850
+ data: data || [],
851
+ ...rest
852
+ };
853
+ };
854
+
783
855
  //#endregion
784
856
  //#region src/hooks/pool/usePriceAtTick.ts
785
857
  const usePriceAtTick = (tick, poolAddr) => {
@@ -1151,5 +1223,5 @@ const useVaultTVL = (vaultAddr) => {
1151
1223
  };
1152
1224
 
1153
1225
  //#endregion
1154
- export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useApproval, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
1226
+ export { TimelockMarketProvider, batchGetAmountsFromLiquidity, useActiveUserOptions, useApproval, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, useOptionTimeline, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
1155
1227
  //# sourceMappingURL=client.js.map