timelock-sdk 0.0.53 → 0.0.55
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.cjs +20 -9
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +61 -61
- package/dist/client.d.ts +116 -116
- package/dist/client.js +21 -10
- package/dist/client.js.map +1 -1
- package/dist/{index-Dt4gerGl.d.ts → index-C2ZV26z-.d.cts} +2 -2
- package/dist/{index-HQTA4ETi.d.cts → index-D5xWncVD.d.ts} +93 -93
- package/dist/{numberUtils-Cznv1Tfa.js → numberUtils-BHnUMxbB.js} +2 -2
- package/dist/{numberUtils-Cznv1Tfa.js.map → numberUtils-BHnUMxbB.js.map} +1 -1
- package/dist/{numberUtils-CkwkoxOr.cjs → numberUtils-DUFFdMYG.cjs} +2 -2
- package/dist/{numberUtils-CkwkoxOr.cjs.map → numberUtils-DUFFdMYG.cjs.map} +1 -1
- package/dist/{optionsMarket-BDBU1gUS.js → optionsMarket-gAjmVL6j.js} +8 -3
- package/dist/{optionsMarket-BDBU1gUS.js.map → optionsMarket-gAjmVL6j.js.map} +1 -1
- package/dist/{optionsMarket-DEFMUI2G.cjs → optionsMarket-k4C_Yx7a.cjs} +8 -3
- package/dist/{optionsMarket-DEFMUI2G.cjs.map → optionsMarket-k4C_Yx7a.cjs.map} +1 -1
- package/dist/package.cjs +2 -2
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/dist/{uniswapMathLens-DCuaXAGZ.d.ts → uniswapMathLens-BCl11EO1.d.ts} +7 -3
- package/dist/{uniswapMathLens-BQ_ArpKd.d.cts → uniswapMathLens-CGKa7m43.d.cts} +7 -3
- package/package.json +1 -1
package/dist/abis.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
1
|
+
const require_optionsMarket = require('./optionsMarket-k4C_Yx7a.cjs');
|
|
2
2
|
const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
|
|
3
3
|
|
|
4
4
|
exports.erc20Abi = require_optionsMarket.erc20Abi;
|
package/dist/abis.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-
|
|
1
|
+
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-CGKa7m43.cjs";
|
|
2
2
|
|
|
3
3
|
//#region src/abis/erc20.d.ts
|
|
4
4
|
declare const erc20Abi: readonly [{
|
package/dist/abis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-
|
|
1
|
+
import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-BCl11EO1.js";
|
|
2
2
|
|
|
3
3
|
//#region src/abis/erc20.d.ts
|
|
4
4
|
declare const erc20Abi: readonly [{
|
package/dist/abis.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as erc20Abi, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-
|
|
1
|
+
import { i as erc20Abi, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-gAjmVL6j.js";
|
|
2
2
|
import { n as uniswapV3PoolAbi, t as singleOwnerVaultAbi } from "./singleOwnerVault-BeJChjfJ.js";
|
|
3
3
|
|
|
4
4
|
export { erc20Abi, lensAbi, optionsMarketAbi, singleOwnerVaultAbi, uniswapMathLensAbi, uniswapV3PoolAbi };
|
package/dist/client.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
const require_numberUtils = require('./numberUtils-
|
|
5
|
-
const require_optionsMarket = require('./optionsMarket-
|
|
4
|
+
const require_numberUtils = require('./numberUtils-DUFFdMYG.cjs');
|
|
5
|
+
const require_optionsMarket = require('./optionsMarket-k4C_Yx7a.cjs');
|
|
6
6
|
const require_singleOwnerVault = require('./singleOwnerVault-gf2zNZVk.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
8
8
|
viem = require_numberUtils.__toESM(viem);
|
|
@@ -253,11 +253,17 @@ const useExerciseOption = (marketAddr) => {
|
|
|
253
253
|
const { vault, pool } = useMarketData(marketAddr);
|
|
254
254
|
const { fee } = usePoolData(pool);
|
|
255
255
|
const { timelockLens } = useLens();
|
|
256
|
+
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
256
257
|
const client = (0, wagmi.useClient)();
|
|
258
|
+
const { address } = (0, wagmi.useAccount)();
|
|
257
259
|
const { writeContractAsync, data: hash, isPending, error } = (0, wagmi.useWriteContract)();
|
|
258
260
|
const { isLoading: isConfirming, isSuccess } = (0, wagmi.useWaitForTransactionReceipt)({ hash });
|
|
259
261
|
const exerciseOption = async (option, liquidities) => {
|
|
260
|
-
if (!client || !
|
|
262
|
+
if (!client || !address) throw new Error("Wallet not connected");
|
|
263
|
+
if (!marketAddr) throw new Error("Market address not available");
|
|
264
|
+
if (!timelockLens) throw new Error("Timelock lens not available");
|
|
265
|
+
if (!vault) throw new Error("Vault not available");
|
|
266
|
+
if (!fee) throw new Error("Pool data not available");
|
|
261
267
|
const refTick = await timelockLens.read.getRefTick([vault, option.startTick]);
|
|
262
268
|
const hash$1 = await writeContractAsync({
|
|
263
269
|
address: marketAddr,
|
|
@@ -273,6 +279,7 @@ const useExerciseOption = (marketAddr) => {
|
|
|
273
279
|
]
|
|
274
280
|
});
|
|
275
281
|
await (0, viem_actions.waitForTransactionReceipt)(client, { hash: hash$1 });
|
|
282
|
+
await queryClient.invalidateQueries({ queryKey: ["userOptions", address.toLowerCase()] });
|
|
276
283
|
return hash$1;
|
|
277
284
|
};
|
|
278
285
|
return {
|
|
@@ -355,6 +362,7 @@ const useMintOption = (marketAddr) => {
|
|
|
355
362
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
356
363
|
const client = (0, wagmi.useClient)();
|
|
357
364
|
const { address } = (0, wagmi.useAccount)();
|
|
365
|
+
const queryClient = (0, __tanstack_react_query.useQueryClient)();
|
|
358
366
|
const { writeContractAsync, data: hash, isPending, error } = (0, wagmi.useWriteContract)();
|
|
359
367
|
const { isLoading: isConfirming, isSuccess } = (0, wagmi.useWaitForTransactionReceipt)({ hash });
|
|
360
368
|
const askForApproval = async (premiumAmount) => {
|
|
@@ -368,7 +376,7 @@ const useMintOption = (marketAddr) => {
|
|
|
368
376
|
}) });
|
|
369
377
|
};
|
|
370
378
|
const mintOption = async (optionType, amount, duration, strikeTick) => {
|
|
371
|
-
if (!client) throw new Error("Wallet not connected");
|
|
379
|
+
if (!client || !address) throw new Error("Wallet not connected");
|
|
372
380
|
if (!marketAddr) throw new Error("Market address not available");
|
|
373
381
|
if (!timelockLens) throw new Error("Timelock lens not available");
|
|
374
382
|
if (!vault) throw new Error("Vault not available");
|
|
@@ -397,6 +405,7 @@ const useMintOption = (marketAddr) => {
|
|
|
397
405
|
]
|
|
398
406
|
});
|
|
399
407
|
await (0, viem_actions.waitForTransactionReceipt)(client, { hash: hash$1 });
|
|
408
|
+
await queryClient.invalidateQueries({ queryKey: ["userOptions", address.toLowerCase()] });
|
|
400
409
|
return hash$1;
|
|
401
410
|
};
|
|
402
411
|
return {
|
|
@@ -447,7 +456,7 @@ const useOptionPnl = (option) => {
|
|
|
447
456
|
|
|
448
457
|
//#endregion
|
|
449
458
|
//#region src/hooks/market/useOptionPremium.ts
|
|
450
|
-
const useOptionPremium = (marketAddr, optionType, optionAmount,
|
|
459
|
+
const useOptionPremium = (marketAddr, optionType, optionAmount, addedDuration, remainingDuration = 0, strikeTick) => {
|
|
451
460
|
const { pool, payoutAssetDecimals, optionAssetIsToken0 } = useMarketData(marketAddr);
|
|
452
461
|
const { tickSpacing } = usePoolData(pool);
|
|
453
462
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
@@ -471,7 +480,8 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, duration, strike
|
|
|
471
480
|
optionType === "CALL" ? 0 : 1,
|
|
472
481
|
optionAmount,
|
|
473
482
|
strikeTickRounded,
|
|
474
|
-
|
|
483
|
+
addedDuration,
|
|
484
|
+
remainingDuration
|
|
475
485
|
] : void 0,
|
|
476
486
|
query: { enabled: strikeTickRounded !== void 0 }
|
|
477
487
|
});
|
|
@@ -493,15 +503,16 @@ const useOptionPremium = (marketAddr, optionType, optionAmount, duration, strike
|
|
|
493
503
|
//#region src/hooks/market/useUserOptions.ts
|
|
494
504
|
const useUserOptions = (user, active = false) => {
|
|
495
505
|
const { graphqlClient } = useTimelockConfig();
|
|
506
|
+
user = user === null || user === void 0 ? void 0 : user.toLowerCase();
|
|
496
507
|
const { data,...rest } = (0, __tanstack_react_query.useQuery)({
|
|
497
508
|
queryKey: [
|
|
498
|
-
"
|
|
509
|
+
"userOptions",
|
|
499
510
|
user || "--",
|
|
500
511
|
active
|
|
501
512
|
],
|
|
502
513
|
queryFn: async () => {
|
|
503
|
-
if (!graphqlClient) return [];
|
|
504
|
-
return (active ? await graphqlClient.GetActiveUserOptions({ user
|
|
514
|
+
if (!graphqlClient || !user) return [];
|
|
515
|
+
return (active ? await graphqlClient.GetActiveUserOptions({ user }) : await graphqlClient.GetClosedUserOptions({ user })).UserOption.map((option) => ({
|
|
505
516
|
...option,
|
|
506
517
|
optionId: BigInt(option.optionId),
|
|
507
518
|
marketAddr: option.marketAddr,
|