timelock-sdk 0.0.134 → 0.0.136
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 +602 -3
- package/dist/abis.cjs.map +1 -0
- package/dist/abis.d.cts +354 -90
- package/dist/abis.d.ts +354 -90
- package/dist/abis.js +602 -3
- package/dist/abis.js.map +1 -0
- package/dist/{client-CJcTIGGv.d.cts → client-B7kKAk49.d.cts} +44622 -34761
- package/dist/{client-CZdmjIOb.d.ts → client-D4EJlSs_.d.ts} +44623 -34762
- package/dist/client.cjs +88 -74
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +3 -3
- package/dist/client.d.ts +3 -3
- package/dist/client.js +87 -75
- package/dist/client.js.map +1 -1
- package/dist/optionUtils-B0rlRtfb.js +1401 -0
- package/dist/optionUtils-B0rlRtfb.js.map +1 -0
- package/dist/{optionUtils-OfLzCR6R.cjs → optionUtils-pH0o9gTm.cjs} +1069 -37
- package/dist/optionUtils-pH0o9gTm.cjs.map +1 -0
- package/dist/{optionsMarket-B2IsvbeA.js → optionsMarket-CjlRzn2K.js} +213 -21
- package/dist/optionsMarket-CjlRzn2K.js.map +1 -0
- package/dist/{optionsMarket-C6K82im8.cjs → optionsMarket-iZiYJCuW.cjs} +213 -21
- package/dist/optionsMarket-iZiYJCuW.cjs.map +1 -0
- package/dist/package.cjs +5 -6
- package/dist/package.d.cts +3 -3
- package/dist/package.d.ts +3 -3
- package/dist/package.js +3 -3
- package/dist/singleOwnerVault-BJyEs_D_.js +847 -0
- package/dist/singleOwnerVault-BJyEs_D_.js.map +1 -0
- package/dist/singleOwnerVault-GCpQV7pN.cjs +853 -0
- package/dist/singleOwnerVault-GCpQV7pN.cjs.map +1 -0
- package/dist/{uniswapMathLens-DHfzEjej.d.ts → uniswapMathLens-B0xWynAN.d.cts} +182 -21
- package/dist/{uniswapMathLens-Be6lFJcD.d.cts → uniswapMathLens-DAI2a8aU.d.ts} +182 -21
- package/package.json +38 -38
- package/dist/optionUtils-CQzUsKpO.js +0 -369
- package/dist/optionUtils-CQzUsKpO.js.map +0 -1
- package/dist/optionUtils-OfLzCR6R.cjs.map +0 -1
- package/dist/optionsMarket-B2IsvbeA.js.map +0 -1
- package/dist/optionsMarket-C6K82im8.cjs.map +0 -1
- package/dist/singleOwnerVault-gf2zNZVk.cjs +0 -1131
- package/dist/singleOwnerVault-gf2zNZVk.cjs.map +0 -1
- package/dist/singleOwnerVault-p81IjmWe.js +0 -1119
- package/dist/singleOwnerVault-p81IjmWe.js.map +0 -1
package/dist/client.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_optionUtils = require('./optionUtils-
|
|
5
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
6
|
-
const require_singleOwnerVault = require('./singleOwnerVault-
|
|
4
|
+
const require_optionUtils = require('./optionUtils-pH0o9gTm.cjs');
|
|
5
|
+
const require_optionsMarket = require('./optionsMarket-iZiYJCuW.cjs');
|
|
6
|
+
const require_singleOwnerVault = require('./singleOwnerVault-GCpQV7pN.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
8
8
|
let react = require("react");
|
|
9
9
|
react = require_optionUtils.__toESM(react);
|
|
10
|
-
let wagmi = require("wagmi");
|
|
11
10
|
let graphql_request = require("graphql-request");
|
|
12
11
|
let graphql_tag = require("graphql-tag");
|
|
13
12
|
graphql_tag = require_optionUtils.__toESM(graphql_tag);
|
|
14
13
|
let viem_actions = require("viem/actions");
|
|
14
|
+
let wagmi = require("wagmi");
|
|
15
15
|
let __tanstack_react_query = require("@tanstack/react-query");
|
|
16
16
|
let zod = require("zod");
|
|
17
17
|
|
|
@@ -401,9 +401,6 @@ var PerpsOperator = class {
|
|
|
401
401
|
//#region src/providers/TimelockProvider.tsx
|
|
402
402
|
const TimelockContext = (0, react.createContext)(void 0);
|
|
403
403
|
const TimelockProvider = ({ children, marketData, envioGraphqlUrl, perpsOperatorUrl }) => {
|
|
404
|
-
const chainId = (0, wagmi.useChainId)();
|
|
405
|
-
const lensAddr = require_optionUtils.timelockLenses[chainId];
|
|
406
|
-
const uniswapMathLensAddr = require_optionUtils.uniswapMathLenses[chainId];
|
|
407
404
|
const graphqlClient = (0, react.useMemo)(() => {
|
|
408
405
|
if (envioGraphqlUrl) return getSdk(new graphql_request.GraphQLClient(envioGraphqlUrl));
|
|
409
406
|
}, [envioGraphqlUrl]);
|
|
@@ -412,16 +409,12 @@ const TimelockProvider = ({ children, marketData, envioGraphqlUrl, perpsOperator
|
|
|
412
409
|
}, [perpsOperatorUrl]);
|
|
413
410
|
const contextValue = (0, react.useMemo)(() => ({
|
|
414
411
|
marketData: marketData || {},
|
|
415
|
-
lensAddr,
|
|
416
|
-
uniswapMathLensAddr,
|
|
417
412
|
envioGraphqlUrl,
|
|
418
413
|
perpsOperator,
|
|
419
414
|
graphqlClient,
|
|
420
415
|
perpsOperatorUrl
|
|
421
416
|
}), [
|
|
422
417
|
marketData,
|
|
423
|
-
lensAddr,
|
|
424
|
-
uniswapMathLensAddr,
|
|
425
418
|
envioGraphqlUrl,
|
|
426
419
|
perpsOperator,
|
|
427
420
|
graphqlClient,
|
|
@@ -446,7 +439,7 @@ const useLens = () => {
|
|
|
446
439
|
const client = (0, wagmi.useClient)();
|
|
447
440
|
return (0, react.useMemo)(() => ({
|
|
448
441
|
timelockLens: client ? require_optionUtils.getTimelockLens(client) : void 0,
|
|
449
|
-
|
|
442
|
+
stateView: client ? require_optionUtils.getStateView(client) : void 0
|
|
450
443
|
}), [client]);
|
|
451
444
|
};
|
|
452
445
|
|
|
@@ -486,15 +479,14 @@ const useMarketData = (marketAddr) => {
|
|
|
486
479
|
|
|
487
480
|
//#endregion
|
|
488
481
|
//#region src/hooks/pool/usePoolData.ts
|
|
489
|
-
const usePoolData = (
|
|
482
|
+
const usePoolData = (poolManager, poolKey) => {
|
|
490
483
|
const { timelockLens } = useLens();
|
|
491
|
-
const client = (0, wagmi.useClient)();
|
|
492
484
|
const { data } = (0, wagmi.useReadContract)({
|
|
493
485
|
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
494
486
|
abi: require_optionsMarket.lensAbi,
|
|
495
487
|
functionName: "getPoolData",
|
|
496
|
-
args:
|
|
497
|
-
query: { enabled: !!
|
|
488
|
+
args: poolManager && poolKey ? [poolManager, poolKey] : void 0,
|
|
489
|
+
query: { enabled: !!poolManager && !!poolKey }
|
|
498
490
|
});
|
|
499
491
|
return data || {};
|
|
500
492
|
};
|
|
@@ -511,7 +503,7 @@ const useExerciseOption = (marketAddr) => {
|
|
|
511
503
|
const { timelockLens } = useLens();
|
|
512
504
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
513
505
|
const client = (0, wagmi.useClient)();
|
|
514
|
-
const { address } = (0, wagmi.
|
|
506
|
+
const { address } = (0, wagmi.useConnection)();
|
|
515
507
|
const { writeContractAsync } = (0, wagmi.useWriteContract)();
|
|
516
508
|
const exerciseOption = async ({ option, liquidities }) => {
|
|
517
509
|
if (!client || !address) throw new Error("Wallet not connected");
|
|
@@ -549,9 +541,8 @@ const useExerciseOption = (marketAddr) => {
|
|
|
549
541
|
//#region src/hooks/options/useMarketVolume.ts
|
|
550
542
|
const useMarketVolume = (marketAddr) => {
|
|
551
543
|
const { graphqlClient } = useTimelockConfig();
|
|
552
|
-
const { timelockLens } = useLens();
|
|
553
544
|
const { data } = (0, __tanstack_react_query.useQuery)({
|
|
554
|
-
queryKey: ["
|
|
545
|
+
queryKey: ["marketVolume", (marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"],
|
|
555
546
|
queryFn: async () => {
|
|
556
547
|
const result = await graphqlClient.GetMarketVolume({ marketAddr: marketAddr.toLowerCase() });
|
|
557
548
|
return {
|
|
@@ -564,18 +555,7 @@ const useMarketVolume = (marketAddr) => {
|
|
|
564
555
|
},
|
|
565
556
|
enabled: !!marketAddr && !!graphqlClient
|
|
566
557
|
});
|
|
567
|
-
|
|
568
|
-
queryKey: ["marketData", marketAddr || "--"],
|
|
569
|
-
queryFn: async () => {
|
|
570
|
-
if (!marketAddr || !timelockLens) return void 0;
|
|
571
|
-
return {
|
|
572
|
-
...await timelockLens.read.getMarketData([marketAddr]),
|
|
573
|
-
tradersCount: void 0
|
|
574
|
-
};
|
|
575
|
-
},
|
|
576
|
-
enabled: !!marketAddr && !!timelockLens
|
|
577
|
-
});
|
|
578
|
-
return data || fallback || {};
|
|
558
|
+
return data || {};
|
|
579
559
|
};
|
|
580
560
|
|
|
581
561
|
//#endregion
|
|
@@ -604,21 +584,22 @@ const useMaxPositionSize = (marketAddr, maxBorrowableRange = 100) => {
|
|
|
604
584
|
|
|
605
585
|
//#endregion
|
|
606
586
|
//#region src/hooks/pool/useCurrentTick.ts
|
|
607
|
-
const useCurrentTick = (
|
|
608
|
-
const { tickSpacing } = usePoolData(
|
|
587
|
+
const useCurrentTick = (poolManager, poolKey) => {
|
|
588
|
+
const { tickSpacing } = usePoolData(poolManager, poolKey);
|
|
609
589
|
const { data, ...rest } = (0, wagmi.useReadContract)({
|
|
610
|
-
address:
|
|
611
|
-
abi:
|
|
612
|
-
functionName: "
|
|
613
|
-
args: [],
|
|
590
|
+
address: poolManager,
|
|
591
|
+
abi: require_optionUtils.statelessStateViewAbi,
|
|
592
|
+
functionName: "getSlot0",
|
|
593
|
+
args: poolManager && poolKey ? [poolManager, poolKey] : void 0,
|
|
614
594
|
query: {
|
|
595
|
+
enabled: !!poolManager && !!poolKey,
|
|
615
596
|
refetchInterval: 3e3,
|
|
616
597
|
select: (raw) => {
|
|
617
|
-
const sqrtPriceX96 = raw
|
|
618
|
-
const exact = raw
|
|
598
|
+
const sqrtPriceX96 = raw[0];
|
|
599
|
+
const exact = raw[1];
|
|
619
600
|
return {
|
|
620
601
|
exact,
|
|
621
|
-
rounded:
|
|
602
|
+
rounded: tickSpacing ? require_optionUtils.roundTick(exact, tickSpacing) : void 0,
|
|
622
603
|
sqrtPriceX96
|
|
623
604
|
};
|
|
624
605
|
}
|
|
@@ -633,10 +614,10 @@ const useCurrentTick = (poolAddr) => {
|
|
|
633
614
|
};
|
|
634
615
|
|
|
635
616
|
//#endregion
|
|
636
|
-
//#region src/hooks/useApproval.ts
|
|
617
|
+
//#region src/hooks/tokens/useApproval.ts
|
|
637
618
|
const useApproval = () => {
|
|
638
619
|
const client = (0, wagmi.useClient)();
|
|
639
|
-
const { address } = (0, wagmi.
|
|
620
|
+
const { address } = (0, wagmi.useConnection)();
|
|
640
621
|
const { writeContractAsync, data: hash, isPending, error, reset } = (0, wagmi.useWriteContract)();
|
|
641
622
|
const askForApproval = async (tokenAddress, spenderAddress, amount) => {
|
|
642
623
|
if (!client || !address) throw new Error("Wallet not connected");
|
|
@@ -664,7 +645,7 @@ const useMintOption = (marketAddr) => {
|
|
|
664
645
|
const { refetch: refetchCurrentTick } = useCurrentTick(pool);
|
|
665
646
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
666
647
|
const client = (0, wagmi.useClient)();
|
|
667
|
-
const { address } = (0, wagmi.
|
|
648
|
+
const { address } = (0, wagmi.useConnection)();
|
|
668
649
|
const { timelockLens } = useLens();
|
|
669
650
|
const { askForApproval } = useApproval();
|
|
670
651
|
const { writeContractAsync } = (0, wagmi.useWriteContract)();
|
|
@@ -791,7 +772,7 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, r
|
|
|
791
772
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
792
773
|
const strikeTickRounded = (0, react.useMemo)(() => {
|
|
793
774
|
if (!tickSpacing || currentTick === void 0) return;
|
|
794
|
-
let strikeTickRounded$1 = require_optionUtils.
|
|
775
|
+
let strikeTickRounded$1 = require_optionUtils.roundTick(strikeTick ?? currentTick, tickSpacing);
|
|
795
776
|
if (optionType === "CALL" && optionAssetIsToken0 || optionType === "PUT" && !optionAssetIsToken0) strikeTickRounded$1 += tickSpacing;
|
|
796
777
|
return strikeTickRounded$1;
|
|
797
778
|
}, [
|
|
@@ -887,7 +868,7 @@ const useExtendOption = (marketAddr) => {
|
|
|
887
868
|
const { payoutAsset } = useMarketData(marketAddr);
|
|
888
869
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
889
870
|
const client = (0, wagmi.useClient)();
|
|
890
|
-
const { address } = (0, wagmi.
|
|
871
|
+
const { address } = (0, wagmi.useConnection)();
|
|
891
872
|
const { askForApproval } = useApproval();
|
|
892
873
|
const { writeContractAsync } = (0, wagmi.useWriteContract)();
|
|
893
874
|
const extendOption = async ({ option, duration }) => {
|
|
@@ -1026,7 +1007,7 @@ const clearSignature = (userAddr) => {
|
|
|
1026
1007
|
localStorage.removeItem(key);
|
|
1027
1008
|
};
|
|
1028
1009
|
const usePerpsOperator = () => {
|
|
1029
|
-
const { address: userAddr } = (0, wagmi.
|
|
1010
|
+
const { address: userAddr } = (0, wagmi.useConnection)();
|
|
1030
1011
|
const { perpsOperatorUrl, perpsOperator: operator } = useTimelockConfig();
|
|
1031
1012
|
const { signMessageAsync } = (0, wagmi.useSignMessage)();
|
|
1032
1013
|
const { data: address } = (0, __tanstack_react_query.useQuery)({
|
|
@@ -1073,7 +1054,7 @@ const usePerpsOperator = () => {
|
|
|
1073
1054
|
const useMintPerp = (marketAddr) => {
|
|
1074
1055
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
1075
1056
|
const client = (0, wagmi.useClient)();
|
|
1076
|
-
const { address } = (0, wagmi.
|
|
1057
|
+
const { address } = (0, wagmi.useConnection)();
|
|
1077
1058
|
const { operator, address: operatorAddr, signMessage: { mutateAsync: signMessage } } = usePerpsOperator();
|
|
1078
1059
|
const { askForApproval } = useApproval();
|
|
1079
1060
|
const { pool, optionAssetIsToken0, payoutAsset } = useMarketData(marketAddr);
|
|
@@ -1161,14 +1142,43 @@ const useClosedUserPerps = (marketAddr, userAddr) => {
|
|
|
1161
1142
|
return useUserPerps(marketAddr, userAddr, "closed");
|
|
1162
1143
|
};
|
|
1163
1144
|
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region src/hooks/tokens/useTokenData.ts
|
|
1147
|
+
const useTokenData = (tokenAddr) => {
|
|
1148
|
+
const { timelockLens } = useLens();
|
|
1149
|
+
const client = (0, wagmi.useClient)();
|
|
1150
|
+
const { data } = (0, wagmi.useReadContract)({
|
|
1151
|
+
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
1152
|
+
abi: require_optionsMarket.lensAbi,
|
|
1153
|
+
functionName: "getTokenData",
|
|
1154
|
+
args: tokenAddr ? [tokenAddr] : void 0,
|
|
1155
|
+
query: { enabled: !!tokenAddr && !!client }
|
|
1156
|
+
});
|
|
1157
|
+
return data || {};
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
//#endregion
|
|
1161
|
+
//#region src/hooks/tokens/useTokenBalance.ts
|
|
1162
|
+
const useTokenBalance = (token, user) => {
|
|
1163
|
+
const { decimals } = useTokenData(token);
|
|
1164
|
+
const { data: raw, ...rest } = (0, wagmi.useReadContract)({
|
|
1165
|
+
address: token,
|
|
1166
|
+
abi: require_optionsMarket.erc20Abi,
|
|
1167
|
+
functionName: "balanceOf",
|
|
1168
|
+
args: user ? [user] : void 0,
|
|
1169
|
+
query: { enabled: !!token && !!user }
|
|
1170
|
+
});
|
|
1171
|
+
return {
|
|
1172
|
+
data: (0, react.useMemo)(() => raw !== void 0 && decimals !== void 0 ? require_optionUtils.wrapAmount(raw, decimals) : void 0, [raw, decimals]),
|
|
1173
|
+
...rest
|
|
1174
|
+
};
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1164
1177
|
//#endregion
|
|
1165
1178
|
//#region src/hooks/operators/useOperatorPerms.ts
|
|
1166
1179
|
const useOperatorPerms = (marketAddr, userAddr, operatorAddr) => {
|
|
1167
1180
|
const { payoutAsset } = useMarketData(marketAddr);
|
|
1168
|
-
const { data: payoutAssetBalance } = (
|
|
1169
|
-
address: userAddr,
|
|
1170
|
-
token: payoutAsset
|
|
1171
|
-
});
|
|
1181
|
+
const { data: payoutAssetBalance } = useTokenBalance(payoutAsset, userAddr);
|
|
1172
1182
|
const { data, ...rest } = (0, wagmi.useReadContract)({
|
|
1173
1183
|
abi: require_optionsMarket.optionsMarketAbi,
|
|
1174
1184
|
address: marketAddr,
|
|
@@ -1181,7 +1191,7 @@ const useOperatorPerms = (marketAddr, userAddr, operatorAddr) => {
|
|
|
1181
1191
|
});
|
|
1182
1192
|
const [canExtend, canExercise, canTransfer, canMint, spendingApproval] = data || [];
|
|
1183
1193
|
const min = (a, b) => a < b ? a : b;
|
|
1184
|
-
const effectiveApproval = spendingApproval && payoutAssetBalance ? min(spendingApproval, payoutAssetBalance.
|
|
1194
|
+
const effectiveApproval = spendingApproval && payoutAssetBalance ? min(spendingApproval, payoutAssetBalance.scaled) : 0n;
|
|
1185
1195
|
return {
|
|
1186
1196
|
data: (0, react.useMemo)(() => ({
|
|
1187
1197
|
canExtend,
|
|
@@ -1236,7 +1246,7 @@ const useUserOperators = (userAddr, marketAddr) => {
|
|
|
1236
1246
|
const useSetOperatorPerms = (marketAddr) => {
|
|
1237
1247
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
1238
1248
|
const client = (0, wagmi.useClient)();
|
|
1239
|
-
const { address } = (0, wagmi.
|
|
1249
|
+
const { address } = (0, wagmi.useConnection)();
|
|
1240
1250
|
const { writeContractAsync } = (0, wagmi.useWriteContract)();
|
|
1241
1251
|
const setOperatorPerms = async ({ operator, canExtend, canExercise, canTransfer, canMint, spendingApproval }) => {
|
|
1242
1252
|
if (!client || !address) throw new Error("Wallet not connected");
|
|
@@ -1290,12 +1300,14 @@ const useMarketPriceHistory = (marketAddr, resolution, startTimestamp, endTimest
|
|
|
1290
1300
|
//#endregion
|
|
1291
1301
|
//#region src/hooks/vault/useVaultData.ts
|
|
1292
1302
|
const useVaultData = (vaultAddr) => {
|
|
1303
|
+
const { timelockLens } = useLens();
|
|
1293
1304
|
const { data } = (0, wagmi.useReadContract)({
|
|
1294
|
-
address:
|
|
1295
|
-
abi:
|
|
1296
|
-
functionName: "
|
|
1305
|
+
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
1306
|
+
abi: require_optionsMarket.lensAbi,
|
|
1307
|
+
functionName: "getVaultData",
|
|
1308
|
+
args: vaultAddr ? [vaultAddr] : void 0
|
|
1297
1309
|
});
|
|
1298
|
-
return
|
|
1310
|
+
return data || {};
|
|
1299
1311
|
};
|
|
1300
1312
|
|
|
1301
1313
|
//#endregion
|
|
@@ -1303,8 +1315,8 @@ const useVaultData = (vaultAddr) => {
|
|
|
1303
1315
|
const useBurnLiquidity = (vaultAddr) => {
|
|
1304
1316
|
const client = (0, wagmi.useClient)();
|
|
1305
1317
|
const { timelockLens } = useLens();
|
|
1306
|
-
const {
|
|
1307
|
-
const currentTick = useCurrentTick(
|
|
1318
|
+
const { poolManager, poolKey } = useVaultData(vaultAddr);
|
|
1319
|
+
const currentTick = useCurrentTick(poolManager, poolKey);
|
|
1308
1320
|
const { writeContractAsync, data: hash, isPending, error } = (0, wagmi.useWriteContract)();
|
|
1309
1321
|
const { isLoading: isConfirming, isSuccess } = (0, wagmi.useWaitForTransactionReceipt)({ hash });
|
|
1310
1322
|
const burn = async (tickLower, tickUpper, liquidity) => {
|
|
@@ -1402,10 +1414,10 @@ const batchGetAmountsFromLiquidity = (tickLowers, tickUppers, liquidities, curre
|
|
|
1402
1414
|
const useMintLiquidity = (vaultAddr) => {
|
|
1403
1415
|
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
1404
1416
|
const client = (0, wagmi.useClient)();
|
|
1405
|
-
const {
|
|
1417
|
+
const { poolManager, poolKey } = useVaultData(vaultAddr);
|
|
1406
1418
|
const { timelockLens } = useLens();
|
|
1407
|
-
const { exact: currentTick } = useCurrentTick(
|
|
1408
|
-
const { token0, token1 } = usePoolData(
|
|
1419
|
+
const { exact: currentTick } = useCurrentTick(poolManager, poolKey);
|
|
1420
|
+
const { token0, token1 } = usePoolData(poolManager, poolKey);
|
|
1409
1421
|
const { askForApproval } = useApproval();
|
|
1410
1422
|
const { writeContractAsync } = (0, wagmi.useWriteContract)();
|
|
1411
1423
|
const processApproval = async (params) => {
|
|
@@ -1445,8 +1457,8 @@ const useMintLiquidity = (vaultAddr) => {
|
|
|
1445
1457
|
//#region src/hooks/vault/useVaultTVL.ts
|
|
1446
1458
|
const useVaultTVL = (vaultAddr) => {
|
|
1447
1459
|
const { timelockLens } = useLens();
|
|
1448
|
-
const {
|
|
1449
|
-
const { token0Decimals, token1Decimals } = usePoolData(
|
|
1460
|
+
const { poolManager, poolKey } = useVaultData(vaultAddr);
|
|
1461
|
+
const { token0Decimals, token1Decimals } = usePoolData(poolManager, poolKey);
|
|
1450
1462
|
const { data, refetch } = (0, wagmi.useReadContract)({
|
|
1451
1463
|
address: timelockLens === null || timelockLens === void 0 ? void 0 : timelockLens.address,
|
|
1452
1464
|
abi: require_optionsMarket.lensAbi,
|
|
@@ -1456,17 +1468,17 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
1456
1468
|
});
|
|
1457
1469
|
return (0, react.useMemo)(() => {
|
|
1458
1470
|
if (!token0Decimals || !token1Decimals || !data) return {};
|
|
1459
|
-
const
|
|
1460
|
-
const
|
|
1461
|
-
const
|
|
1462
|
-
const
|
|
1471
|
+
const total0 = require_optionUtils.wrapAmount(data[0], token0Decimals);
|
|
1472
|
+
const total1 = require_optionUtils.wrapAmount(data[1], token1Decimals);
|
|
1473
|
+
const borrowed0 = require_optionUtils.wrapAmount(data[2], token0Decimals);
|
|
1474
|
+
const borrowed1 = require_optionUtils.wrapAmount(data[3], token1Decimals);
|
|
1463
1475
|
return {
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1476
|
+
tvlAs0: require_optionUtils.wrapAmount(data[4], token0Decimals),
|
|
1477
|
+
tvlAs1: require_optionUtils.wrapAmount(data[5], token1Decimals),
|
|
1478
|
+
total0,
|
|
1479
|
+
total1,
|
|
1480
|
+
borrowed0,
|
|
1481
|
+
borrowed1,
|
|
1470
1482
|
blocksCount: data[6],
|
|
1471
1483
|
refetch
|
|
1472
1484
|
};
|
|
@@ -1513,6 +1525,8 @@ exports.usePriceHistory = usePriceHistory;
|
|
|
1513
1525
|
exports.usePriceSqrtPriceX96 = usePriceSqrtPriceX96;
|
|
1514
1526
|
exports.useSetOperatorPerms = useSetOperatorPerms;
|
|
1515
1527
|
exports.useTimelockConfig = useTimelockConfig;
|
|
1528
|
+
exports.useTokenBalance = useTokenBalance;
|
|
1529
|
+
exports.useTokenData = useTokenData;
|
|
1516
1530
|
exports.useUserOperators = useUserOperators;
|
|
1517
1531
|
exports.useUserPerps = useUserPerps;
|
|
1518
1532
|
exports.useVaultData = useVaultData;
|