timelock-sdk 0.0.176 → 0.0.178
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-DbQo5Dsk.d.cts → client-BClT812n.d.cts} +511 -511
- package/dist/{client-Bs4nrL5u.d.ts → client-DNpVpttQ.d.ts} +91 -91
- package/dist/client.cjs +80 -66
- 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 +83 -69
- package/dist/client.js.map +1 -1
- package/dist/package.d.cts +1 -1
- package/dist/package.d.ts +1 -1
- package/package.json +1 -1
package/dist/client.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "./optionsMarket-c4hgszY_.cjs";
|
|
2
|
-
import { A as useCurrentPrice, Bt as useMarketVolume, C as useLiquidityBlocks, Ct as useMintOption, D as usePriceAtSqrtPriceX96, E as usePriceHistory, Gt as useTimelockConfig, Ht as useMarketData, M as UniswapPoolData, N as usePoolData, O as usePriceAtTick, S as LiquidityBlockData, St as useClosedUserOptions, T as useMarketPriceHistory, Ut as TimelockProvider, Vt as useMarketState, Wt as useCurrentMarket, _ as useTokenData, _t as useOptionPremium, a as OptionPricingParams, at as useActiveUserPerps, b as batchGetAmountsFromLiquidity, bt as OptionData, c as usePricingParams, ct as usePerpsOperator, d as usePauseMarketTrading, dt as ExerciseOptionEvent, f as usePauseGlobalTrading, ft as ExtendEvent, g as TokenData, gt as useExtendOption, h as useTokenBalance, ht as useOptionTimeline, i as useOptionPricingParams, it as useOperatorPerms, j as PoolKey, k as useCurrentTick, l as useUpdateMarketFees, lt as useClosePerp, m as useApproval, mt as OptionEvent, n as useUpdateMarketPricing, nt as useSetOperatorPerms, o as PricingParams, ot as useClosedUserPerps, p as useGuardianGlobalState, pt as MintOptionEvent, r as useStaticPricingParams, rt as useUserOperators, s as StaticPricingParams, st as useUserPerps, t as useLens, u as useFeeRates, ut as useMintPerp, v as useVaultTVL, vt as useOptionPnl, w as useBurnLiquidity, wt as useMaxPositionSize, x as useMintLiquidity, xt as useActiveUserOptions, y as useVaultData, yt as useExerciseOption } from "./client-
|
|
2
|
+
import { A as useCurrentPrice, Bt as useMarketVolume, C as useLiquidityBlocks, Ct as useMintOption, D as usePriceAtSqrtPriceX96, E as usePriceHistory, Gt as useTimelockConfig, Ht as useMarketData, M as UniswapPoolData, N as usePoolData, O as usePriceAtTick, S as LiquidityBlockData, St as useClosedUserOptions, T as useMarketPriceHistory, Ut as TimelockProvider, Vt as useMarketState, Wt as useCurrentMarket, _ as useTokenData, _t as useOptionPremium, a as OptionPricingParams, at as useActiveUserPerps, b as batchGetAmountsFromLiquidity, bt as OptionData, c as usePricingParams, ct as usePerpsOperator, d as usePauseMarketTrading, dt as ExerciseOptionEvent, f as usePauseGlobalTrading, ft as ExtendEvent, g as TokenData, gt as useExtendOption, h as useTokenBalance, ht as useOptionTimeline, i as useOptionPricingParams, it as useOperatorPerms, j as PoolKey, k as useCurrentTick, l as useUpdateMarketFees, lt as useClosePerp, m as useApproval, mt as OptionEvent, n as useUpdateMarketPricing, nt as useSetOperatorPerms, o as PricingParams, ot as useClosedUserPerps, p as useGuardianGlobalState, pt as MintOptionEvent, r as useStaticPricingParams, rt as useUserOperators, s as StaticPricingParams, st as useUserPerps, t as useLens, u as useFeeRates, ut as useMintPerp, v as useVaultTVL, vt as useOptionPnl, w as useBurnLiquidity, wt as useMaxPositionSize, x as useMintLiquidity, xt as useActiveUserOptions, y as useVaultData, yt as useExerciseOption } from "./client-BClT812n.cjs";
|
|
3
3
|
export { ExerciseOptionEvent, ExtendEvent, LiquidityBlockData, MintOptionEvent, OptionData, OptionEvent, OptionPricingParams, PoolKey, PricingParams, StaticPricingParams, TimelockProvider, TokenData, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useFeeRates, useGuardianGlobalState, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMarketState, useMarketVolume, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionPricingParams, useOptionTimeline, usePauseGlobalTrading, usePauseMarketTrading, usePerpsOperator, usePoolData, usePriceAtSqrtPriceX96, usePriceAtTick, usePriceHistory, usePricingParams, useSetOperatorPerms, useStaticPricingParams, useTimelockConfig, useTokenBalance, useTokenData, useUpdateMarketFees, useUpdateMarketPricing, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "./optionsMarket-2HZ-p_dl.js";
|
|
2
|
-
import { A as useCurrentPrice, Bt as useMarketVolume, C as useLiquidityBlocks, Ct as useMintOption, D as usePriceAtSqrtPriceX96, E as usePriceHistory, Gt as useTimelockConfig, Ht as useMarketData, M as UniswapPoolData, N as usePoolData, O as usePriceAtTick, S as LiquidityBlockData, St as useClosedUserOptions, T as useMarketPriceHistory, Ut as TimelockProvider, Vt as useMarketState, Wt as useCurrentMarket, _ as useTokenData, _t as useOptionPremium, a as OptionPricingParams, at as useActiveUserPerps, b as batchGetAmountsFromLiquidity, bt as OptionData, c as usePricingParams, ct as usePerpsOperator, d as usePauseMarketTrading, dt as ExerciseOptionEvent, f as usePauseGlobalTrading, ft as ExtendEvent, g as TokenData, gt as useExtendOption, h as useTokenBalance, ht as useOptionTimeline, i as useOptionPricingParams, it as useOperatorPerms, j as PoolKey, k as useCurrentTick, l as useUpdateMarketFees, lt as useClosePerp, m as useApproval, mt as OptionEvent, n as useUpdateMarketPricing, nt as useSetOperatorPerms, o as PricingParams, ot as useClosedUserPerps, p as useGuardianGlobalState, pt as MintOptionEvent, r as useStaticPricingParams, rt as useUserOperators, s as StaticPricingParams, st as useUserPerps, t as useLens, u as useFeeRates, ut as useMintPerp, v as useVaultTVL, vt as useOptionPnl, w as useBurnLiquidity, wt as useMaxPositionSize, x as useMintLiquidity, xt as useActiveUserOptions, y as useVaultData, yt as useExerciseOption } from "./client-
|
|
2
|
+
import { A as useCurrentPrice, Bt as useMarketVolume, C as useLiquidityBlocks, Ct as useMintOption, D as usePriceAtSqrtPriceX96, E as usePriceHistory, Gt as useTimelockConfig, Ht as useMarketData, M as UniswapPoolData, N as usePoolData, O as usePriceAtTick, S as LiquidityBlockData, St as useClosedUserOptions, T as useMarketPriceHistory, Ut as TimelockProvider, Vt as useMarketState, Wt as useCurrentMarket, _ as useTokenData, _t as useOptionPremium, a as OptionPricingParams, at as useActiveUserPerps, b as batchGetAmountsFromLiquidity, bt as OptionData, c as usePricingParams, ct as usePerpsOperator, d as usePauseMarketTrading, dt as ExerciseOptionEvent, f as usePauseGlobalTrading, ft as ExtendEvent, g as TokenData, gt as useExtendOption, h as useTokenBalance, ht as useOptionTimeline, i as useOptionPricingParams, it as useOperatorPerms, j as PoolKey, k as useCurrentTick, l as useUpdateMarketFees, lt as useClosePerp, m as useApproval, mt as OptionEvent, n as useUpdateMarketPricing, nt as useSetOperatorPerms, o as PricingParams, ot as useClosedUserPerps, p as useGuardianGlobalState, pt as MintOptionEvent, r as useStaticPricingParams, rt as useUserOperators, s as StaticPricingParams, st as useUserPerps, t as useLens, u as useFeeRates, ut as useMintPerp, v as useVaultTVL, vt as useOptionPnl, w as useBurnLiquidity, wt as useMaxPositionSize, x as useMintLiquidity, xt as useActiveUserOptions, y as useVaultData, yt as useExerciseOption } from "./client-DNpVpttQ.js";
|
|
3
3
|
export { ExerciseOptionEvent, ExtendEvent, LiquidityBlockData, MintOptionEvent, OptionData, OptionEvent, OptionPricingParams, PoolKey, PricingParams, StaticPricingParams, TimelockProvider, TokenData, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useActiveUserPerps, useApproval, useBurnLiquidity, useClosePerp, useClosedUserOptions, useClosedUserPerps, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useFeeRates, useGuardianGlobalState, useLens, useLiquidityBlocks, useMarketData, useMarketPriceHistory, useMarketState, useMarketVolume, useMaxPositionSize, useMintLiquidity, useMintOption, useMintPerp, useOperatorPerms, useOptionPnl, useOptionPremium, useOptionPricingParams, useOptionTimeline, usePauseGlobalTrading, usePauseMarketTrading, usePerpsOperator, usePoolData, usePriceAtSqrtPriceX96, usePriceAtTick, usePriceHistory, usePricingParams, useSetOperatorPerms, useStaticPricingParams, useTimelockConfig, useTokenBalance, useTokenData, useUpdateMarketFees, useUpdateMarketPricing, useUserOperators, useUserPerps, useVaultData, useVaultTVL };
|
package/dist/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { i as erc20Abi$1, n as optionsMarketAbi, r as lensAbi, t as statelessStateViewAbi } from "./statelessStateView-MGdfMvC4.js";
|
|
5
|
-
import { A as token1ToToken0, B as swappers, D as roundTick, F as getStateView, I as getTimelockLens, L as getTimelockMarket, N as getPriceHistory, O as token0ToToken1, P as getErc20, V as timelockFactories, b as getPriceAtSqrtPriceX96, f as wrapAmount, j as token1ToToken0AtTick, k as token0ToToken1AtTick, m as wrapPrice, r as EMPTY_ARRAY, t as getPayoutAtPrice, v as getAmountsFromLiquidity, x as getPriceAtTick, y as getNearestValidStrikeTick } from "./optionUtils-DV3VdMvm.js";
|
|
5
|
+
import { A as token1ToToken0, B as swappers, D as roundTick, F as getStateView, I as getTimelockLens, L as getTimelockMarket, N as getPriceHistory, O as token0ToToken1, P as getErc20, V as timelockFactories, b as getPriceAtSqrtPriceX96, f as wrapAmount, j as token1ToToken0AtTick, k as token0ToToken1AtTick, m as wrapPrice, r as EMPTY_ARRAY$1, t as getPayoutAtPrice, v as getAmountsFromLiquidity, x as getPriceAtTick, y as getNearestValidStrikeTick } from "./optionUtils-DV3VdMvm.js";
|
|
6
6
|
import { n as guardianAbi, r as singleOwnerVaultAbi, t as factoryAbi } from "./factory-y-iVl_er.js";
|
|
7
7
|
import { decodeAbiParameters, decodeEventLog, encodeAbiParameters, encodeFunctionData, erc20Abi, maxUint256, zeroAddress } from "viem";
|
|
8
8
|
import React, { createContext, useContext, useEffect, useMemo } from "react";
|
|
@@ -614,7 +614,7 @@ const useMintOption = (marketAddr) => {
|
|
|
614
614
|
if (!timelockLens) throw new Error("Timelock lens not available");
|
|
615
615
|
if (!tickSpacing) throw new Error("Pool data not available");
|
|
616
616
|
if (!vault || !payoutAsset || optionAssetIsToken0 === void 0) throw new Error("Market data not available");
|
|
617
|
-
const { data: {
|
|
617
|
+
const { data: { currentTick } = {} } = await refetchCurrentTick();
|
|
618
618
|
if (currentTick === void 0) throw new Error("Could not fetch current tick");
|
|
619
619
|
strikeTick = getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
|
|
620
620
|
const [premium, protocolFee] = await getTimelockMarket(marketAddr, client).read.calculatePremium([
|
|
@@ -624,7 +624,8 @@ const useMintOption = (marketAddr) => {
|
|
|
624
624
|
duration,
|
|
625
625
|
0
|
|
626
626
|
]);
|
|
627
|
-
|
|
627
|
+
const maxPremium = (premium + protocolFee) * 11n / 10n;
|
|
628
|
+
await askForApproval(payoutAsset, marketAddr, maxPremium);
|
|
628
629
|
const hash = await writeContractAsync({
|
|
629
630
|
address: marketAddr,
|
|
630
631
|
abi: optionsMarketAbi,
|
|
@@ -635,7 +636,7 @@ const useMintOption = (marketAddr) => {
|
|
|
635
636
|
amount,
|
|
636
637
|
strikeTick,
|
|
637
638
|
duration,
|
|
638
|
-
|
|
639
|
+
maxPremium,
|
|
639
640
|
maxSteps,
|
|
640
641
|
await timelockLens.read.getRefTick([vault, strikeTick])
|
|
641
642
|
]
|
|
@@ -881,7 +882,7 @@ const useUserOptions = (userAddr, marketAddr, active = false) => {
|
|
|
881
882
|
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
882
883
|
});
|
|
883
884
|
return {
|
|
884
|
-
data: data || EMPTY_ARRAY,
|
|
885
|
+
data: data || EMPTY_ARRAY$1,
|
|
885
886
|
...rest
|
|
886
887
|
};
|
|
887
888
|
};
|
|
@@ -1001,7 +1002,7 @@ const useOptionTimeline = (marketAddr, optionId) => {
|
|
|
1001
1002
|
enabled: !!marketAddr && optionId !== void 0 && !!graphqlClient
|
|
1002
1003
|
});
|
|
1003
1004
|
return {
|
|
1004
|
-
data: data || EMPTY_ARRAY,
|
|
1005
|
+
data: data || EMPTY_ARRAY$1,
|
|
1005
1006
|
...rest
|
|
1006
1007
|
};
|
|
1007
1008
|
};
|
|
@@ -1079,6 +1080,66 @@ const usePerpsOperator = () => {
|
|
|
1079
1080
|
};
|
|
1080
1081
|
};
|
|
1081
1082
|
|
|
1083
|
+
//#endregion
|
|
1084
|
+
//#region src/hooks/operators/useUserOperators.ts
|
|
1085
|
+
const useUserOperators = (userAddr, marketAddr) => {
|
|
1086
|
+
const { graphqlClient } = useTimelockConfig();
|
|
1087
|
+
const { data, ...rest } = useQuery({
|
|
1088
|
+
queryKey: [
|
|
1089
|
+
"userOperators",
|
|
1090
|
+
(userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase()) || "--",
|
|
1091
|
+
(marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"
|
|
1092
|
+
],
|
|
1093
|
+
queryFn: async () => {
|
|
1094
|
+
if (!userAddr || !marketAddr) return void 0;
|
|
1095
|
+
return (await graphqlClient.GetUserMarketOperators({
|
|
1096
|
+
userAddr: userAddr.toLowerCase(),
|
|
1097
|
+
marketAddr: marketAddr.toLowerCase()
|
|
1098
|
+
})).UserMarketOperator.map((operator) => ({
|
|
1099
|
+
...operator,
|
|
1100
|
+
spendingApproval: BigInt(operator.spendingApproval),
|
|
1101
|
+
operatorAddr: operator.operator.address.toLowerCase()
|
|
1102
|
+
}));
|
|
1103
|
+
},
|
|
1104
|
+
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
1105
|
+
});
|
|
1106
|
+
return {
|
|
1107
|
+
...rest,
|
|
1108
|
+
data: data || EMPTY_ARRAY$1
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
//#endregion
|
|
1113
|
+
//#region src/hooks/operators/useSetOperatorPerms.ts
|
|
1114
|
+
const useSetOperatorPerms = (marketAddr) => {
|
|
1115
|
+
const queryClient = useQueryClient();
|
|
1116
|
+
const client = useClient();
|
|
1117
|
+
const { address } = useConnection();
|
|
1118
|
+
const { writeContractAsync } = useWriteContract();
|
|
1119
|
+
const setOperatorPerms = async ({ operator, canExtend, canExercise, canTransfer, canMint, spendingApproval }) => {
|
|
1120
|
+
if (!client || !address) throw new Error("Wallet not connected");
|
|
1121
|
+
if (!marketAddr) throw new Error("Market address not available");
|
|
1122
|
+
const hash = await writeContractAsync({
|
|
1123
|
+
address: marketAddr,
|
|
1124
|
+
abi: optionsMarketAbi,
|
|
1125
|
+
functionName: "setOperatorPerms",
|
|
1126
|
+
args: [
|
|
1127
|
+
operator,
|
|
1128
|
+
canExtend,
|
|
1129
|
+
canExercise,
|
|
1130
|
+
canTransfer,
|
|
1131
|
+
canMint,
|
|
1132
|
+
spendingApproval
|
|
1133
|
+
]
|
|
1134
|
+
});
|
|
1135
|
+
await waitForTransactionReceipt(client, { hash });
|
|
1136
|
+
queryClient.invalidateQueries({ queryKey: ["userOperators"] });
|
|
1137
|
+
queryClient.invalidateQueries({ queryKey: ["readContract"] });
|
|
1138
|
+
return hash;
|
|
1139
|
+
};
|
|
1140
|
+
return useMutation({ mutationFn: setOperatorPerms });
|
|
1141
|
+
};
|
|
1142
|
+
|
|
1082
1143
|
//#endregion
|
|
1083
1144
|
//#region src/hooks/perps/useMintPerp.ts
|
|
1084
1145
|
const useMintPerp = (marketAddr) => {
|
|
@@ -1087,9 +1148,13 @@ const useMintPerp = (marketAddr) => {
|
|
|
1087
1148
|
const { address } = useConnection();
|
|
1088
1149
|
const { operator, address: operatorAddr, signMessage: { mutateAsync: signMessage } } = usePerpsOperator();
|
|
1089
1150
|
const { askForApproval } = useApproval();
|
|
1151
|
+
const { data: operators } = useUserOperators(address, marketAddr);
|
|
1152
|
+
const { mutateAsync: setOperatorPerms } = useSetOperatorPerms(marketAddr);
|
|
1090
1153
|
const { poolManager, poolKey, optionAssetIsToken0, payoutAsset } = useMarketData(marketAddr);
|
|
1091
1154
|
const { tickSpacing } = usePoolData(poolManager, poolKey);
|
|
1092
1155
|
const { refetch: refetchCurrentTick } = useCurrentTick(poolManager, poolKey);
|
|
1156
|
+
const userPerms = operatorAddr ? operators.find((o) => o.operatorAddr.toLowerCase() === operatorAddr.toLowerCase()) : void 0;
|
|
1157
|
+
const hasEnoughPerms = userPerms && userPerms.canMint && userPerms.canExtend && userPerms.canExercise;
|
|
1093
1158
|
const mintPerp = async (data) => {
|
|
1094
1159
|
const { optionType, amount, duration, strikeTick } = data;
|
|
1095
1160
|
if (!client || !address) throw new Error("Wallet not connected");
|
|
@@ -1109,7 +1174,16 @@ const useMintPerp = (marketAddr) => {
|
|
|
1109
1174
|
duration,
|
|
1110
1175
|
0
|
|
1111
1176
|
]);
|
|
1112
|
-
|
|
1177
|
+
const maxPremium = (premium + protocolFee) * 11n / 10n;
|
|
1178
|
+
if (!hasEnoughPerms) await setOperatorPerms({
|
|
1179
|
+
operator: operatorAddr,
|
|
1180
|
+
canMint: true,
|
|
1181
|
+
canExtend: true,
|
|
1182
|
+
canExercise: true,
|
|
1183
|
+
canTransfer: (userPerms === null || userPerms === void 0 ? void 0 : userPerms.canTransfer) || false,
|
|
1184
|
+
spendingApproval: maxPremium
|
|
1185
|
+
});
|
|
1186
|
+
await askForApproval(payoutAsset, marketAddr, maxPremium);
|
|
1113
1187
|
await operator.mintPerp({
|
|
1114
1188
|
marketAddr,
|
|
1115
1189
|
amount,
|
|
@@ -1143,7 +1217,7 @@ const useClosePerp = () => {
|
|
|
1143
1217
|
|
|
1144
1218
|
//#endregion
|
|
1145
1219
|
//#region src/hooks/perps/useUserPerps.ts
|
|
1146
|
-
const EMPTY_ARRAY
|
|
1220
|
+
const EMPTY_ARRAY = [];
|
|
1147
1221
|
const useUserPerps = (marketAddr, userAddr, type) => {
|
|
1148
1222
|
const { operator } = usePerpsOperator();
|
|
1149
1223
|
userAddr = userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase();
|
|
@@ -1161,7 +1235,7 @@ const useUserPerps = (marketAddr, userAddr, type) => {
|
|
|
1161
1235
|
refetchInterval: 1e4
|
|
1162
1236
|
});
|
|
1163
1237
|
return {
|
|
1164
|
-
data: data || EMPTY_ARRAY
|
|
1238
|
+
data: data || EMPTY_ARRAY,
|
|
1165
1239
|
...rest
|
|
1166
1240
|
};
|
|
1167
1241
|
};
|
|
@@ -1242,66 +1316,6 @@ const useOperatorPerms = (marketAddr, userAddr, operatorAddr) => {
|
|
|
1242
1316
|
};
|
|
1243
1317
|
};
|
|
1244
1318
|
|
|
1245
|
-
//#endregion
|
|
1246
|
-
//#region src/hooks/operators/useUserOperators.ts
|
|
1247
|
-
const useUserOperators = (userAddr, marketAddr) => {
|
|
1248
|
-
const { graphqlClient } = useTimelockConfig();
|
|
1249
|
-
const { data, ...rest } = useQuery({
|
|
1250
|
-
queryKey: [
|
|
1251
|
-
"userOperators",
|
|
1252
|
-
(userAddr === null || userAddr === void 0 ? void 0 : userAddr.toLowerCase()) || "--",
|
|
1253
|
-
(marketAddr === null || marketAddr === void 0 ? void 0 : marketAddr.toLowerCase()) || "--"
|
|
1254
|
-
],
|
|
1255
|
-
queryFn: async () => {
|
|
1256
|
-
if (!userAddr || !marketAddr) return void 0;
|
|
1257
|
-
return (await graphqlClient.GetUserMarketOperators({
|
|
1258
|
-
userAddr: userAddr.toLowerCase(),
|
|
1259
|
-
marketAddr: marketAddr.toLowerCase()
|
|
1260
|
-
})).UserMarketOperator.map((operator) => ({
|
|
1261
|
-
...operator,
|
|
1262
|
-
spendingApproval: BigInt(operator.spendingApproval),
|
|
1263
|
-
operatorAddr: operator.operator.address.toLowerCase()
|
|
1264
|
-
}));
|
|
1265
|
-
},
|
|
1266
|
-
enabled: !!userAddr && !!marketAddr && !!graphqlClient
|
|
1267
|
-
});
|
|
1268
|
-
return {
|
|
1269
|
-
...rest,
|
|
1270
|
-
data: data || EMPTY_ARRAY
|
|
1271
|
-
};
|
|
1272
|
-
};
|
|
1273
|
-
|
|
1274
|
-
//#endregion
|
|
1275
|
-
//#region src/hooks/operators/useSetOperatorPerms.ts
|
|
1276
|
-
const useSetOperatorPerms = (marketAddr) => {
|
|
1277
|
-
const queryClient = useQueryClient();
|
|
1278
|
-
const client = useClient();
|
|
1279
|
-
const { address } = useConnection();
|
|
1280
|
-
const { writeContractAsync } = useWriteContract();
|
|
1281
|
-
const setOperatorPerms = async ({ operator, canExtend, canExercise, canTransfer, canMint, spendingApproval }) => {
|
|
1282
|
-
if (!client || !address) throw new Error("Wallet not connected");
|
|
1283
|
-
if (!marketAddr) throw new Error("Market address not available");
|
|
1284
|
-
const hash = await writeContractAsync({
|
|
1285
|
-
address: marketAddr,
|
|
1286
|
-
abi: optionsMarketAbi,
|
|
1287
|
-
functionName: "setOperatorPerms",
|
|
1288
|
-
args: [
|
|
1289
|
-
operator,
|
|
1290
|
-
canExtend,
|
|
1291
|
-
canExercise,
|
|
1292
|
-
canTransfer,
|
|
1293
|
-
canMint,
|
|
1294
|
-
spendingApproval
|
|
1295
|
-
]
|
|
1296
|
-
});
|
|
1297
|
-
await waitForTransactionReceipt(client, { hash });
|
|
1298
|
-
queryClient.invalidateQueries({ queryKey: ["userOperators"] });
|
|
1299
|
-
queryClient.invalidateQueries({ queryKey: ["readContract"] });
|
|
1300
|
-
return hash;
|
|
1301
|
-
};
|
|
1302
|
-
return useMutation({ mutationFn: setOperatorPerms });
|
|
1303
|
-
};
|
|
1304
|
-
|
|
1305
1319
|
//#endregion
|
|
1306
1320
|
//#region src/hooks/pool/usePriceHistory.ts
|
|
1307
1321
|
const usePriceHistory = (pool, token, resolution, startTimestamp, endTimestamp) => {
|