timelock-sdk 0.0.78 → 0.0.79
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/{index-CdkTrz02.d.ts → client-D9QtRxOF.d.ts} +30559 -93
- package/dist/{index-CFBcBY1K.d.cts → client-h7lO3ik2.d.cts} +30468 -2
- package/dist/client.cjs +49 -50
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -30468
- package/dist/client.d.ts +2 -30468
- package/dist/client.js +18 -19
- package/dist/client.js.map +1 -1
- package/dist/{numberUtils-fHghA8Tv.cjs → optionUtils-CDD_7qmy.cjs} +23 -1
- package/dist/optionUtils-CDD_7qmy.cjs.map +1 -0
- package/dist/{numberUtils--YU8VSJO.js → optionUtils-CI-AZi8X.js} +12 -2
- package/dist/optionUtils-CI-AZi8X.js.map +1 -0
- package/dist/package.cjs +34 -32
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/package.json +1 -1
- package/dist/numberUtils--YU8VSJO.js.map +0 -1
- package/dist/numberUtils-fHghA8Tv.cjs.map +0 -1
package/dist/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-6PlyceXp.js";
|
|
5
|
-
import { A as
|
|
5
|
+
import { A as getTimelockMarket, D as token1ToToken0, E as token0ToToken1, M as timelockLenses, N as uniswapMathLenses, O as getErc20, d as wrapAmount, j as getUniswapMathLens, k as getTimelockLens, n as EMPTY_ARRAY, p as wrapPrice, t as getPayoutAtTick, v as getNearestValidStrikeTick, w as roundTickDown, y as getPriceAtTick } from "./optionUtils-CI-AZi8X.js";
|
|
6
6
|
import { n as uniswapV3PoolAbi, t as singleOwnerVaultAbi } from "./singleOwnerVault-BeJChjfJ.js";
|
|
7
7
|
import { encodeAbiParameters, encodeFunctionData, erc20Abi, maxUint256, zeroAddress } from "viem";
|
|
8
8
|
import React, { createContext, useContext, useMemo } from "react";
|
|
@@ -548,15 +548,16 @@ const useMintOption = (marketAddr) => {
|
|
|
548
548
|
//#endregion
|
|
549
549
|
//#region src/hooks/market/useOptionPnl.ts
|
|
550
550
|
const useOptionPnl = (option) => {
|
|
551
|
-
const { marketAddr, optionType,
|
|
551
|
+
const { marketAddr, optionType, entryTick, positionSizeCurrent } = option;
|
|
552
552
|
const { pool, optionAssetIsToken0, payoutAssetDecimals, tickSpacing } = useMarketData(marketAddr);
|
|
553
553
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
554
|
-
const strikeSize = positionSizeCurrent * strikePrice / PRICE_PRECISION;
|
|
555
554
|
const displayPnl = useMemo(() => {
|
|
556
|
-
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !
|
|
557
|
-
const
|
|
555
|
+
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !payoutAssetDecimals) return void 0;
|
|
556
|
+
const entrySize = optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, entryTick) : token1ToToken0(positionSizeCurrent, entryTick);
|
|
557
|
+
const delta = (optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, currentTick) : token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
|
|
558
558
|
return wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
559
559
|
}, [
|
|
560
|
+
entryTick,
|
|
560
561
|
optionType,
|
|
561
562
|
optionAssetIsToken0,
|
|
562
563
|
currentTick,
|
|
@@ -565,16 +566,14 @@ const useOptionPnl = (option) => {
|
|
|
565
566
|
]);
|
|
566
567
|
return {
|
|
567
568
|
unrealizedPayout: useMemo(() => {
|
|
568
|
-
if (!payoutAssetDecimals || !currentTick || !tickSpacing) return void 0;
|
|
569
|
-
|
|
570
|
-
const delta = (optionAssetIsToken0 ? amount1 + token0ToToken1(amount0, currentTick) : amount0 + token1ToToken0(amount1, currentTick)) - strikeSize;
|
|
571
|
-
const pnl = optionType === "CALL" ? delta : -delta;
|
|
572
|
-
return wrapAmount(pnl < 0 ? 0n : pnl, payoutAssetDecimals);
|
|
569
|
+
if (!payoutAssetDecimals || !currentTick || !tickSpacing || optionAssetIsToken0 === void 0) return void 0;
|
|
570
|
+
return wrapAmount(getPayoutAtTick(option, option.liquiditiesCurrent, currentTick, tickSpacing, optionAssetIsToken0), payoutAssetDecimals);
|
|
573
571
|
}, [
|
|
574
572
|
currentTick,
|
|
575
573
|
tickSpacing,
|
|
576
574
|
optionType,
|
|
577
|
-
payoutAssetDecimals
|
|
575
|
+
payoutAssetDecimals,
|
|
576
|
+
optionAssetIsToken0
|
|
578
577
|
]),
|
|
579
578
|
displayPnl
|
|
580
579
|
};
|
|
@@ -667,7 +666,7 @@ const useUserOptions = (userAddr, marketAddr, active = false) => {
|
|
|
667
666
|
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
668
667
|
});
|
|
669
668
|
return {
|
|
670
|
-
data: data ||
|
|
669
|
+
data: data || EMPTY_ARRAY,
|
|
671
670
|
...rest
|
|
672
671
|
};
|
|
673
672
|
};
|
|
@@ -742,7 +741,7 @@ const useUserOperators = (userAddr, marketAddr) => {
|
|
|
742
741
|
});
|
|
743
742
|
return {
|
|
744
743
|
...rest,
|
|
745
|
-
data: data ||
|
|
744
|
+
data: data || EMPTY_ARRAY
|
|
746
745
|
};
|
|
747
746
|
};
|
|
748
747
|
|
|
@@ -784,17 +783,17 @@ const useSetOperatorPerms = (marketAddr) => {
|
|
|
784
783
|
//#region src/hooks/market/useOptionTimeline.ts
|
|
785
784
|
const useOptionTimeline = (marketAddr, optionId) => {
|
|
786
785
|
const { graphqlClient } = useTimelockConfig();
|
|
787
|
-
|
|
786
|
+
marketAddr = marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase();
|
|
788
787
|
const { data,...rest } = useQuery({
|
|
789
788
|
queryKey: [
|
|
790
789
|
"optionTimeline",
|
|
791
|
-
|
|
790
|
+
marketAddr || "--",
|
|
792
791
|
(optionId === null || optionId === void 0 ? void 0 : optionId.toString()) || "--"
|
|
793
792
|
],
|
|
794
793
|
queryFn: async () => {
|
|
795
|
-
if (!graphqlClient || !
|
|
794
|
+
if (!graphqlClient || !marketAddr || optionId === void 0) return [];
|
|
796
795
|
const result = await graphqlClient.GetOptionEvents({
|
|
797
|
-
marketAddr
|
|
796
|
+
marketAddr,
|
|
798
797
|
optionId: optionId.toString()
|
|
799
798
|
});
|
|
800
799
|
const mintEvents = result.MintOptionEvent.map((event) => ({
|
|
@@ -844,10 +843,10 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
844
843
|
}))
|
|
845
844
|
].sort((a, b) => a.data.timestamp.getTime() - b.data.timestamp.getTime());
|
|
846
845
|
},
|
|
847
|
-
enabled: !!
|
|
846
|
+
enabled: !!marketAddr && optionId !== void 0 && !!graphqlClient
|
|
848
847
|
});
|
|
849
848
|
return {
|
|
850
|
-
data: data ||
|
|
849
|
+
data: data || EMPTY_ARRAY,
|
|
851
850
|
...rest
|
|
852
851
|
};
|
|
853
852
|
};
|