timelock-sdk 0.0.120 → 0.0.121
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-CTL-mr5n.d.ts → client-D7objc4l.d.ts} +396 -446
- package/dist/{client-r3O6AK_5.d.cts → client-bCuyjf6z.d.cts} +246 -296
- package/dist/client.cjs +57 -58
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +57 -58
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-BHL27KMw.cjs → optionUtils-DENHUR2w.cjs} +50 -13
- package/dist/optionUtils-DENHUR2w.cjs.map +1 -0
- package/dist/{optionUtils-CtGcjfvf.js → optionUtils-MZU-Gklx.js} +25 -12
- package/dist/optionUtils-MZU-Gklx.js.map +1 -0
- package/dist/package.cjs +6 -2
- 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/optionUtils-BHL27KMw.cjs.map +0 -1
- package/dist/optionUtils-CtGcjfvf.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_optionUtils = require('./optionUtils-
|
|
4
|
+
const require_optionUtils = require('./optionUtils-DENHUR2w.cjs');
|
|
5
5
|
const require_optionsMarket = require('./optionsMarket-C8-v8IvX.cjs');
|
|
6
6
|
const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
@@ -28,7 +28,6 @@ const UserOptionFieldsFragmentDoc = graphql_tag.default`
|
|
|
28
28
|
}
|
|
29
29
|
optionType
|
|
30
30
|
strikeTick
|
|
31
|
-
entryTick
|
|
32
31
|
startTick
|
|
33
32
|
strikePrice
|
|
34
33
|
entryPrice
|
|
@@ -153,7 +152,7 @@ const GetOptionEventsDocument = graphql_tag.default`
|
|
|
153
152
|
id
|
|
154
153
|
optionType
|
|
155
154
|
strikeTick
|
|
156
|
-
|
|
155
|
+
price
|
|
157
156
|
expiresAt
|
|
158
157
|
premium
|
|
159
158
|
protocolFee
|
|
@@ -173,7 +172,7 @@ const GetOptionEventsDocument = graphql_tag.default`
|
|
|
173
172
|
) {
|
|
174
173
|
id
|
|
175
174
|
liquidities
|
|
176
|
-
|
|
175
|
+
price
|
|
177
176
|
payout
|
|
178
177
|
timestamp
|
|
179
178
|
blockNumber
|
|
@@ -191,7 +190,7 @@ const GetOptionEventsDocument = graphql_tag.default`
|
|
|
191
190
|
id
|
|
192
191
|
premium
|
|
193
192
|
protocolFee
|
|
194
|
-
|
|
193
|
+
price
|
|
195
194
|
addedDuration
|
|
196
195
|
timestamp
|
|
197
196
|
blockNumber
|
|
@@ -664,31 +663,71 @@ const useMintOption = (marketAddr) => {
|
|
|
664
663
|
return (0, __tanstack_react_query.useMutation)({ mutationFn: mintOption });
|
|
665
664
|
};
|
|
666
665
|
|
|
666
|
+
//#endregion
|
|
667
|
+
//#region src/hooks/pool/usePriceAtTick.ts
|
|
668
|
+
const usePriceAtTick = (tick, poolAddr) => {
|
|
669
|
+
const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
|
|
670
|
+
const priceBigInt = (0, react.useMemo)(() => tick !== void 0 ? require_optionUtils.getPriceAtTick(tick) : void 0, [tick]);
|
|
671
|
+
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
672
|
+
priceBigInt,
|
|
673
|
+
token0Decimals,
|
|
674
|
+
token1Decimals
|
|
675
|
+
]);
|
|
676
|
+
};
|
|
677
|
+
const usePriceSqrtPriceX96 = (sqrtPriceX96, poolAddr) => {
|
|
678
|
+
const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
|
|
679
|
+
const priceBigInt = (0, react.useMemo)(() => sqrtPriceX96 !== void 0 ? require_optionUtils.getPriceAtSqrtPriceX96(sqrtPriceX96) : void 0, [sqrtPriceX96]);
|
|
680
|
+
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
681
|
+
priceBigInt,
|
|
682
|
+
token0Decimals,
|
|
683
|
+
token1Decimals
|
|
684
|
+
]);
|
|
685
|
+
};
|
|
686
|
+
|
|
687
|
+
//#endregion
|
|
688
|
+
//#region src/hooks/pool/useCurrentPrice.ts
|
|
689
|
+
const useCurrentPrice = (poolAddr) => {
|
|
690
|
+
const { sqrtPriceX96, exact, rounded } = useCurrentTick(poolAddr);
|
|
691
|
+
const currentPrice = usePriceSqrtPriceX96(sqrtPriceX96, poolAddr);
|
|
692
|
+
return (0, react.useMemo)(() => ({
|
|
693
|
+
currentPrice,
|
|
694
|
+
sqrtPriceX96,
|
|
695
|
+
currentTick: {
|
|
696
|
+
exact,
|
|
697
|
+
rounded
|
|
698
|
+
}
|
|
699
|
+
}), [
|
|
700
|
+
currentPrice,
|
|
701
|
+
exact,
|
|
702
|
+
rounded
|
|
703
|
+
]);
|
|
704
|
+
};
|
|
705
|
+
|
|
667
706
|
//#endregion
|
|
668
707
|
//#region src/hooks/options/useOptionPnl.ts
|
|
669
708
|
const useOptionPnl = (option) => {
|
|
670
709
|
const { marketAddr, optionType, strikeTick, positionSizeCurrent } = option;
|
|
671
710
|
const { pool, optionAssetIsToken0, payoutAssetDecimals, tickSpacing } = useMarketData(marketAddr);
|
|
672
|
-
const {
|
|
711
|
+
const { currentPrice } = useCurrentPrice(pool);
|
|
673
712
|
const displayPnl = (0, react.useMemo)(() => {
|
|
674
|
-
if (optionAssetIsToken0 === void 0 ||
|
|
675
|
-
const strikeSize = optionAssetIsToken0 ? require_optionUtils.
|
|
676
|
-
const delta = (optionAssetIsToken0 ? require_optionUtils.token0ToToken1(positionSizeCurrent,
|
|
713
|
+
if (optionAssetIsToken0 === void 0 || currentPrice === void 0 || !payoutAssetDecimals) return void 0;
|
|
714
|
+
const strikeSize = optionAssetIsToken0 ? require_optionUtils.token0ToToken1AtTick(positionSizeCurrent, strikeTick) : require_optionUtils.token1ToToken0AtTick(positionSizeCurrent, strikeTick);
|
|
715
|
+
const delta = (optionAssetIsToken0 ? require_optionUtils.token0ToToken1(positionSizeCurrent, currentPrice.scaled) : require_optionUtils.token1ToToken0(positionSizeCurrent, currentPrice.scaled)) - strikeSize;
|
|
677
716
|
return require_optionUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
678
717
|
}, [
|
|
679
718
|
strikeTick,
|
|
680
719
|
optionType,
|
|
681
720
|
optionAssetIsToken0,
|
|
682
|
-
|
|
721
|
+
currentPrice,
|
|
683
722
|
positionSizeCurrent,
|
|
684
723
|
payoutAssetDecimals
|
|
685
724
|
]);
|
|
686
725
|
return {
|
|
687
726
|
unrealizedPayout: (0, react.useMemo)(() => {
|
|
688
|
-
if (!payoutAssetDecimals || !
|
|
689
|
-
return require_optionUtils.wrapAmount(require_optionUtils.
|
|
727
|
+
if (!payoutAssetDecimals || !currentPrice || !tickSpacing || optionAssetIsToken0 === void 0) return void 0;
|
|
728
|
+
return require_optionUtils.wrapAmount(require_optionUtils.getPayoutAtPrice(option, option.liquiditiesCurrent, currentPrice.scaled, tickSpacing, optionAssetIsToken0), payoutAssetDecimals);
|
|
690
729
|
}, [
|
|
691
|
-
|
|
730
|
+
currentPrice,
|
|
692
731
|
tickSpacing,
|
|
693
732
|
optionType,
|
|
694
733
|
payoutAssetDecimals,
|
|
@@ -859,20 +898,20 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
859
898
|
id: event.id,
|
|
860
899
|
optionType: event.optionType,
|
|
861
900
|
strikeTick: event.strikeTick,
|
|
862
|
-
|
|
863
|
-
expiresAt: /* @__PURE__ */ new Date(Number(event.expiresAt) * 1e3),
|
|
901
|
+
price: BigInt(event.price),
|
|
864
902
|
premium: BigInt(event.premium),
|
|
865
903
|
protocolFee: BigInt(event.protocolFee),
|
|
866
904
|
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
867
905
|
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
906
|
+
expiresAt: /* @__PURE__ */ new Date(Number(event.expiresAt) * 1e3),
|
|
868
907
|
blockNumber: BigInt(event.blockNumber),
|
|
869
908
|
transactionHash: event.transactionHash
|
|
870
909
|
}));
|
|
871
910
|
const exerciseEvents = result.ExerciseOptionEvent.map((event) => ({
|
|
872
911
|
id: event.id,
|
|
873
|
-
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
874
|
-
currentTick: event.currentTick,
|
|
875
912
|
payout: BigInt(event.payout),
|
|
913
|
+
price: BigInt(event.price),
|
|
914
|
+
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
876
915
|
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
877
916
|
blockNumber: BigInt(event.blockNumber),
|
|
878
917
|
transactionHash: event.transactionHash
|
|
@@ -881,7 +920,7 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
881
920
|
id: event.id,
|
|
882
921
|
premium: BigInt(event.premium),
|
|
883
922
|
protocolFee: BigInt(event.protocolFee),
|
|
884
|
-
|
|
923
|
+
price: BigInt(event.price),
|
|
885
924
|
addedDuration: BigInt(event.addedDuration),
|
|
886
925
|
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
887
926
|
blockNumber: BigInt(event.blockNumber),
|
|
@@ -1189,46 +1228,6 @@ const useOperatorPerms = (marketAddr, userAddr, operatorAddr) => {
|
|
|
1189
1228
|
};
|
|
1190
1229
|
};
|
|
1191
1230
|
|
|
1192
|
-
//#endregion
|
|
1193
|
-
//#region src/hooks/pool/usePriceAtTick.ts
|
|
1194
|
-
const usePriceAtTick = (tick, poolAddr) => {
|
|
1195
|
-
const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
|
|
1196
|
-
const priceBigInt = (0, react.useMemo)(() => tick !== void 0 ? require_optionUtils.getPriceAtTick(tick) : void 0, [tick]);
|
|
1197
|
-
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
1198
|
-
priceBigInt,
|
|
1199
|
-
token0Decimals,
|
|
1200
|
-
token1Decimals
|
|
1201
|
-
]);
|
|
1202
|
-
};
|
|
1203
|
-
const usePriceSqrtPriceX96 = (sqrtPriceX96, poolAddr) => {
|
|
1204
|
-
const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
|
|
1205
|
-
const priceBigInt = (0, react.useMemo)(() => sqrtPriceX96 !== void 0 ? require_optionUtils.getPriceSqrtPriceX96(sqrtPriceX96) : void 0, [sqrtPriceX96]);
|
|
1206
|
-
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
1207
|
-
priceBigInt,
|
|
1208
|
-
token0Decimals,
|
|
1209
|
-
token1Decimals
|
|
1210
|
-
]);
|
|
1211
|
-
};
|
|
1212
|
-
|
|
1213
|
-
//#endregion
|
|
1214
|
-
//#region src/hooks/pool/useCurrentPrice.ts
|
|
1215
|
-
const useCurrentPrice = (poolAddr) => {
|
|
1216
|
-
const { sqrtPriceX96, exact, rounded } = useCurrentTick(poolAddr);
|
|
1217
|
-
const currentPrice = usePriceSqrtPriceX96(sqrtPriceX96, poolAddr);
|
|
1218
|
-
return (0, react.useMemo)(() => ({
|
|
1219
|
-
currentPrice,
|
|
1220
|
-
sqrtPriceX96,
|
|
1221
|
-
currentTick: {
|
|
1222
|
-
exact,
|
|
1223
|
-
rounded
|
|
1224
|
-
}
|
|
1225
|
-
}), [
|
|
1226
|
-
currentPrice,
|
|
1227
|
-
exact,
|
|
1228
|
-
rounded
|
|
1229
|
-
]);
|
|
1230
|
-
};
|
|
1231
|
-
|
|
1232
1231
|
//#endregion
|
|
1233
1232
|
//#region src/hooks/pool/usePriceHistory.ts
|
|
1234
1233
|
const usePriceHistory = (pool, resolution, startTimestamp, endTimestamp) => {
|