timelock-sdk 0.0.175 → 0.0.177
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-tKAF1RaW.d.ts → client-BFfw9ee6.d.cts} +601 -601
- package/dist/{client-BiJu3aZe.d.cts → client-BiwrAgwX.d.ts} +853 -853
- package/dist/client.cjs +21 -10
- 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 +21 -10
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-C1TXirKy.cjs → optionUtils-BHU2evq2.cjs} +20 -8
- package/dist/{optionUtils-C1TXirKy.cjs.map → optionUtils-BHU2evq2.cjs.map} +1 -1
- package/dist/{optionUtils-D2-zFl18.js → optionUtils-DV3VdMvm.js} +20 -8
- package/dist/{optionUtils-D2-zFl18.js.map → optionUtils-DV3VdMvm.js.map} +1 -1
- package/dist/package.cjs +1 -1
- package/dist/package.d.cts +1 -1
- package/dist/package.d.ts +1 -1
- package/dist/package.js +1 -1
- package/package.json +1 -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-BHU2evq2.cjs');
|
|
5
5
|
const require_statelessStateView = require('./statelessStateView-CtzW08Yu.cjs');
|
|
6
6
|
const require_factory = require('./factory-DitVXzjQ.cjs');
|
|
7
7
|
let viem = require("viem");
|
|
@@ -10,8 +10,8 @@ react = require_optionUtils.__toESM(react);
|
|
|
10
10
|
let graphql_request = require("graphql-request");
|
|
11
11
|
let graphql_tag = require("graphql-tag");
|
|
12
12
|
graphql_tag = require_optionUtils.__toESM(graphql_tag);
|
|
13
|
-
let wagmi = require("wagmi");
|
|
14
13
|
let __tanstack_react_query = require("@tanstack/react-query");
|
|
14
|
+
let wagmi = require("wagmi");
|
|
15
15
|
let viem_actions = require("viem/actions");
|
|
16
16
|
let zod = require("zod");
|
|
17
17
|
|
|
@@ -441,11 +441,21 @@ const useTimelockConfig = () => {
|
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/hooks/useLens.ts
|
|
443
443
|
const useLens = () => {
|
|
444
|
-
const client = (0, wagmi.
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
444
|
+
const client = (0, wagmi.usePublicClient)();
|
|
445
|
+
const { data: timelockLens } = (0, __tanstack_react_query.useQuery)({
|
|
446
|
+
queryKey: ["timelockLens", client === null || client === void 0 ? void 0 : client.uid],
|
|
447
|
+
queryFn: () => client ? require_optionUtils.getTimelockLens(client) : void 0,
|
|
448
|
+
enabled: !!client
|
|
449
|
+
});
|
|
450
|
+
const { data: stateView } = (0, __tanstack_react_query.useQuery)({
|
|
451
|
+
queryKey: ["stateView", client === null || client === void 0 ? void 0 : client.uid],
|
|
452
|
+
queryFn: () => client ? require_optionUtils.getStateView(client) : void 0,
|
|
453
|
+
enabled: !!client
|
|
454
|
+
});
|
|
455
|
+
return {
|
|
456
|
+
timelockLens,
|
|
457
|
+
stateView
|
|
458
|
+
};
|
|
449
459
|
};
|
|
450
460
|
|
|
451
461
|
//#endregion
|
|
@@ -606,7 +616,7 @@ const useMintOption = (marketAddr) => {
|
|
|
606
616
|
if (!timelockLens) throw new Error("Timelock lens not available");
|
|
607
617
|
if (!tickSpacing) throw new Error("Pool data not available");
|
|
608
618
|
if (!vault || !payoutAsset || optionAssetIsToken0 === void 0) throw new Error("Market data not available");
|
|
609
|
-
const { data: {
|
|
619
|
+
const { data: { currentTick } = {} } = await refetchCurrentTick();
|
|
610
620
|
if (currentTick === void 0) throw new Error("Could not fetch current tick");
|
|
611
621
|
strikeTick = require_optionUtils.getNearestValidStrikeTick(optionType, optionAssetIsToken0, tickSpacing, currentTick, strikeTick);
|
|
612
622
|
const [premium, protocolFee] = await require_optionUtils.getTimelockMarket(marketAddr, client).read.calculatePremium([
|
|
@@ -616,7 +626,8 @@ const useMintOption = (marketAddr) => {
|
|
|
616
626
|
duration,
|
|
617
627
|
0
|
|
618
628
|
]);
|
|
619
|
-
|
|
629
|
+
const maxPremium = (premium + protocolFee) * 11n / 10n;
|
|
630
|
+
await askForApproval(payoutAsset, marketAddr, maxPremium);
|
|
620
631
|
const hash = await writeContractAsync({
|
|
621
632
|
address: marketAddr,
|
|
622
633
|
abi: require_statelessStateView.optionsMarketAbi,
|
|
@@ -627,7 +638,7 @@ const useMintOption = (marketAddr) => {
|
|
|
627
638
|
amount,
|
|
628
639
|
strikeTick,
|
|
629
640
|
duration,
|
|
630
|
-
|
|
641
|
+
maxPremium,
|
|
631
642
|
maxSteps,
|
|
632
643
|
await timelockLens.read.getRefTick([vault, strikeTick])
|
|
633
644
|
]
|