timelock-sdk 0.0.119 → 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/abis.cjs +1 -1
- package/dist/abis.d.cts +1 -1
- package/dist/abis.d.ts +1 -1
- package/dist/abis.js +1 -1
- package/dist/{client-Cgi8okgz.d.cts → client-D7objc4l.d.ts} +2566 -2953
- package/dist/{client-CxAAahmW.d.ts → client-bCuyjf6z.d.cts} +2566 -2953
- package/dist/client.cjs +60 -60
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +2 -2
- package/dist/client.d.ts +2 -2
- package/dist/client.js +60 -60
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-ZSFOJxaV.cjs → optionUtils-DENHUR2w.cjs} +59 -15
- package/dist/optionUtils-DENHUR2w.cjs.map +1 -0
- package/dist/{optionUtils-D8zF6lcX.js → optionUtils-MZU-Gklx.js} +28 -14
- package/dist/optionUtils-MZU-Gklx.js.map +1 -0
- package/dist/{optionsMarket-D6zrIXc3.cjs → optionsMarket-C8-v8IvX.cjs} +65 -155
- package/dist/optionsMarket-C8-v8IvX.cjs.map +1 -0
- package/dist/{optionsMarket-DBuVI-kl.js → optionsMarket-Dkwpa2uO.js} +65 -155
- package/dist/optionsMarket-Dkwpa2uO.js.map +1 -0
- package/dist/package.cjs +8 -3
- package/dist/package.d.cts +3 -3
- package/dist/package.d.ts +3 -3
- package/dist/package.js +3 -3
- package/dist/{uniswapMathLens-ChJFZ6hc.d.ts → uniswapMathLens-DtacRMPz.d.cts} +55 -124
- package/dist/{uniswapMathLens-B_cHjOOB.d.cts → uniswapMathLens-JKcBN1v_.d.ts} +55 -124
- package/package.json +1 -1
- package/dist/optionUtils-D8zF6lcX.js.map +0 -1
- package/dist/optionUtils-ZSFOJxaV.cjs.map +0 -1
- package/dist/optionsMarket-D6zrIXc3.cjs.map +0 -1
- package/dist/optionsMarket-DBuVI-kl.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_optionUtils = require('./optionUtils-
|
|
5
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
4
|
+
const require_optionUtils = require('./optionUtils-DENHUR2w.cjs');
|
|
5
|
+
const require_optionsMarket = require('./optionsMarket-C8-v8IvX.cjs');
|
|
6
6
|
const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
8
8
|
let react = require("react");
|
|
@@ -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
|
|
@@ -487,7 +486,6 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
487
486
|
|
|
488
487
|
//#endregion
|
|
489
488
|
//#region src/hooks/options/useExerciseOption.ts
|
|
490
|
-
const swapper = "0x877309663591ad974bE2c0C7fB453844c8D613D8";
|
|
491
489
|
const useExerciseOption = (marketAddr) => {
|
|
492
490
|
const { vault, pool } = useMarketData(marketAddr);
|
|
493
491
|
const { fee } = usePoolData(pool);
|
|
@@ -502,6 +500,8 @@ const useExerciseOption = (marketAddr) => {
|
|
|
502
500
|
if (!timelockLens) throw new Error("Timelock lens not available");
|
|
503
501
|
if (!vault) throw new Error("Vault not available");
|
|
504
502
|
if (!fee) throw new Error("Pool data not available");
|
|
503
|
+
const swapper = require_optionUtils.swappers[client.chain.id];
|
|
504
|
+
if (!swapper) throw new Error("Swapper not available");
|
|
505
505
|
const refTick = await timelockLens.read.getRefTick([vault, option.startTick]);
|
|
506
506
|
const hash = await writeContractAsync({
|
|
507
507
|
address: marketAddr,
|
|
@@ -663,31 +663,71 @@ const useMintOption = (marketAddr) => {
|
|
|
663
663
|
return (0, __tanstack_react_query.useMutation)({ mutationFn: mintOption });
|
|
664
664
|
};
|
|
665
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
|
+
|
|
666
706
|
//#endregion
|
|
667
707
|
//#region src/hooks/options/useOptionPnl.ts
|
|
668
708
|
const useOptionPnl = (option) => {
|
|
669
709
|
const { marketAddr, optionType, strikeTick, positionSizeCurrent } = option;
|
|
670
710
|
const { pool, optionAssetIsToken0, payoutAssetDecimals, tickSpacing } = useMarketData(marketAddr);
|
|
671
|
-
const {
|
|
711
|
+
const { currentPrice } = useCurrentPrice(pool);
|
|
672
712
|
const displayPnl = (0, react.useMemo)(() => {
|
|
673
|
-
if (optionAssetIsToken0 === void 0 ||
|
|
674
|
-
const strikeSize = optionAssetIsToken0 ? require_optionUtils.
|
|
675
|
-
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;
|
|
676
716
|
return require_optionUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
677
717
|
}, [
|
|
678
718
|
strikeTick,
|
|
679
719
|
optionType,
|
|
680
720
|
optionAssetIsToken0,
|
|
681
|
-
|
|
721
|
+
currentPrice,
|
|
682
722
|
positionSizeCurrent,
|
|
683
723
|
payoutAssetDecimals
|
|
684
724
|
]);
|
|
685
725
|
return {
|
|
686
726
|
unrealizedPayout: (0, react.useMemo)(() => {
|
|
687
|
-
if (!payoutAssetDecimals || !
|
|
688
|
-
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);
|
|
689
729
|
}, [
|
|
690
|
-
|
|
730
|
+
currentPrice,
|
|
691
731
|
tickSpacing,
|
|
692
732
|
optionType,
|
|
693
733
|
payoutAssetDecimals,
|
|
@@ -858,20 +898,20 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
858
898
|
id: event.id,
|
|
859
899
|
optionType: event.optionType,
|
|
860
900
|
strikeTick: event.strikeTick,
|
|
861
|
-
|
|
862
|
-
expiresAt: /* @__PURE__ */ new Date(Number(event.expiresAt) * 1e3),
|
|
901
|
+
price: BigInt(event.price),
|
|
863
902
|
premium: BigInt(event.premium),
|
|
864
903
|
protocolFee: BigInt(event.protocolFee),
|
|
865
904
|
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
866
905
|
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
906
|
+
expiresAt: /* @__PURE__ */ new Date(Number(event.expiresAt) * 1e3),
|
|
867
907
|
blockNumber: BigInt(event.blockNumber),
|
|
868
908
|
transactionHash: event.transactionHash
|
|
869
909
|
}));
|
|
870
910
|
const exerciseEvents = result.ExerciseOptionEvent.map((event) => ({
|
|
871
911
|
id: event.id,
|
|
872
|
-
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
873
|
-
currentTick: event.currentTick,
|
|
874
912
|
payout: BigInt(event.payout),
|
|
913
|
+
price: BigInt(event.price),
|
|
914
|
+
liquidities: event.liquidities.map((l) => BigInt(l)),
|
|
875
915
|
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
876
916
|
blockNumber: BigInt(event.blockNumber),
|
|
877
917
|
transactionHash: event.transactionHash
|
|
@@ -880,7 +920,7 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
880
920
|
id: event.id,
|
|
881
921
|
premium: BigInt(event.premium),
|
|
882
922
|
protocolFee: BigInt(event.protocolFee),
|
|
883
|
-
|
|
923
|
+
price: BigInt(event.price),
|
|
884
924
|
addedDuration: BigInt(event.addedDuration),
|
|
885
925
|
timestamp: /* @__PURE__ */ new Date(Number(event.timestamp) * 1e3),
|
|
886
926
|
blockNumber: BigInt(event.blockNumber),
|
|
@@ -1188,46 +1228,6 @@ const useOperatorPerms = (marketAddr, userAddr, operatorAddr) => {
|
|
|
1188
1228
|
};
|
|
1189
1229
|
};
|
|
1190
1230
|
|
|
1191
|
-
//#endregion
|
|
1192
|
-
//#region src/hooks/pool/usePriceAtTick.ts
|
|
1193
|
-
const usePriceAtTick = (tick, poolAddr) => {
|
|
1194
|
-
const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
|
|
1195
|
-
const priceBigInt = (0, react.useMemo)(() => tick !== void 0 ? require_optionUtils.getPriceAtTick(tick) : void 0, [tick]);
|
|
1196
|
-
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
1197
|
-
priceBigInt,
|
|
1198
|
-
token0Decimals,
|
|
1199
|
-
token1Decimals
|
|
1200
|
-
]);
|
|
1201
|
-
};
|
|
1202
|
-
const usePriceSqrtPriceX96 = (sqrtPriceX96, poolAddr) => {
|
|
1203
|
-
const { token0Decimals, token1Decimals } = usePoolData(poolAddr);
|
|
1204
|
-
const priceBigInt = (0, react.useMemo)(() => sqrtPriceX96 !== void 0 ? require_optionUtils.getPriceSqrtPriceX96(sqrtPriceX96) : void 0, [sqrtPriceX96]);
|
|
1205
|
-
return (0, react.useMemo)(() => priceBigInt && token0Decimals && token1Decimals ? require_optionUtils.wrapPrice(priceBigInt, token0Decimals, token1Decimals) : void 0, [
|
|
1206
|
-
priceBigInt,
|
|
1207
|
-
token0Decimals,
|
|
1208
|
-
token1Decimals
|
|
1209
|
-
]);
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
//#endregion
|
|
1213
|
-
//#region src/hooks/pool/useCurrentPrice.ts
|
|
1214
|
-
const useCurrentPrice = (poolAddr) => {
|
|
1215
|
-
const { sqrtPriceX96, exact, rounded } = useCurrentTick(poolAddr);
|
|
1216
|
-
const currentPrice = usePriceSqrtPriceX96(sqrtPriceX96, poolAddr);
|
|
1217
|
-
return (0, react.useMemo)(() => ({
|
|
1218
|
-
currentPrice,
|
|
1219
|
-
sqrtPriceX96,
|
|
1220
|
-
currentTick: {
|
|
1221
|
-
exact,
|
|
1222
|
-
rounded
|
|
1223
|
-
}
|
|
1224
|
-
}), [
|
|
1225
|
-
currentPrice,
|
|
1226
|
-
exact,
|
|
1227
|
-
rounded
|
|
1228
|
-
]);
|
|
1229
|
-
};
|
|
1230
|
-
|
|
1231
1231
|
//#endregion
|
|
1232
1232
|
//#region src/hooks/pool/usePriceHistory.ts
|
|
1233
1233
|
const usePriceHistory = (pool, resolution, startTimestamp, endTimestamp) => {
|