timelock-sdk 0.0.24 → 0.0.26
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.cjs +41 -35
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +14783 -14771
- package/dist/client.d.ts +14783 -14771
- package/dist/client.js +41 -35
- package/dist/client.js.map +1 -1
- package/dist/{index-B7b3c8cu.d.cts → index-CA5kB-yT.d.cts} +92 -92
- package/dist/{index-B20z73_3.d.ts → index-CRhFaRiq.d.ts} +92 -92
- package/dist/package.d.cts +1 -1
- package/dist/package.d.ts +1 -1
- package/package.json +1 -1
package/dist/client.cjs
CHANGED
|
@@ -242,11 +242,10 @@ const useExerciseOption = (marketAddr) => {
|
|
|
242
242
|
//#region src/hooks/useLens.ts
|
|
243
243
|
const useLens = () => {
|
|
244
244
|
const client = (0, wagmi.useClient)();
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
uniswapLens:
|
|
248
|
-
|
|
249
|
-
};
|
|
245
|
+
return (0, react.useMemo)(() => ({
|
|
246
|
+
timelockLens: client ? require_numberUtils.getTimelockLens(client) : void 0,
|
|
247
|
+
uniswapLens: client ? require_numberUtils.getUniswapMathLens(client) : void 0
|
|
248
|
+
}), [client]);
|
|
250
249
|
};
|
|
251
250
|
|
|
252
251
|
//#endregion
|
|
@@ -315,11 +314,13 @@ const useCurrentTick = (poolAddr) => {
|
|
|
315
314
|
functionName: "slot0",
|
|
316
315
|
args: []
|
|
317
316
|
});
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
317
|
+
return (0, react.useMemo)(() => {
|
|
318
|
+
const exact = data === null || data === void 0 ? void 0 : data[1];
|
|
319
|
+
return {
|
|
320
|
+
exact,
|
|
321
|
+
rounded: exact && tickSpacing ? Math.floor(exact / tickSpacing) * tickSpacing : void 0
|
|
322
|
+
};
|
|
323
|
+
}, [data, tickSpacing]);
|
|
323
324
|
};
|
|
324
325
|
|
|
325
326
|
//#endregion
|
|
@@ -387,14 +388,14 @@ const useOptionPnl = (optionData) => {
|
|
|
387
388
|
const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
|
|
388
389
|
const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
|
|
389
390
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
390
|
-
|
|
391
|
+
return (0, react.useMemo)(() => {
|
|
391
392
|
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
|
|
392
393
|
const entrySize = positionSizeCurrent * entryPrice / require_numberUtils.PRICE_PRECISION;
|
|
393
394
|
const delta = (optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, currentTick) : require_numberUtils.token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
|
|
394
|
-
const displayPnl
|
|
395
|
+
const displayPnl = require_numberUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
395
396
|
return {
|
|
396
|
-
unrealizedPayout: require_numberUtils.wrapAmount(displayPnl
|
|
397
|
-
displayPnl
|
|
397
|
+
unrealizedPayout: require_numberUtils.wrapAmount(displayPnl.scaled < 0 ? 0n : displayPnl.scaled, payoutAssetDecimals),
|
|
398
|
+
displayPnl
|
|
398
399
|
};
|
|
399
400
|
}, [
|
|
400
401
|
entryPrice,
|
|
@@ -404,10 +405,6 @@ const useOptionPnl = (optionData) => {
|
|
|
404
405
|
positionSizeCurrent,
|
|
405
406
|
payoutAssetDecimals
|
|
406
407
|
]);
|
|
407
|
-
return {
|
|
408
|
-
displayPnl,
|
|
409
|
-
unrealizedPayout
|
|
410
|
-
};
|
|
411
408
|
};
|
|
412
409
|
|
|
413
410
|
//#endregion
|
|
@@ -475,7 +472,7 @@ const useUserOptions = (user, active = false) => {
|
|
|
475
472
|
enabled: !!user && !!graphqlClient
|
|
476
473
|
});
|
|
477
474
|
return {
|
|
478
|
-
data: (0, react.useMemo)(() =>
|
|
475
|
+
data: (0, react.useMemo)(() => [...options || []].sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime()), [options]),
|
|
479
476
|
...rest
|
|
480
477
|
};
|
|
481
478
|
};
|
|
@@ -502,10 +499,11 @@ const usePriceAtTick = (tick, poolAddr) => {
|
|
|
502
499
|
//#region src/hooks/pool/useCurrentPrice.ts
|
|
503
500
|
const useCurrentPrice = (poolAddr) => {
|
|
504
501
|
const currentTick = useCurrentTick(poolAddr);
|
|
505
|
-
|
|
506
|
-
|
|
502
|
+
const currentPrice = usePriceAtTick(currentTick.exact, poolAddr);
|
|
503
|
+
return (0, react.useMemo)(() => ({
|
|
504
|
+
currentPrice,
|
|
507
505
|
currentTick
|
|
508
|
-
};
|
|
506
|
+
}), [currentPrice, currentTick]);
|
|
509
507
|
};
|
|
510
508
|
|
|
511
509
|
//#endregion
|
|
@@ -736,20 +734,28 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
736
734
|
args: [vaultAddr],
|
|
737
735
|
query: { enabled: !!vaultAddr && !!timelockLens }
|
|
738
736
|
});
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
737
|
+
return (0, react.useMemo)(() => {
|
|
738
|
+
if (!token0Decimals || !token1Decimals || !data) return {};
|
|
739
|
+
const totalAmount0 = require_numberUtils.wrapAmount(data[0], token0Decimals);
|
|
740
|
+
const totalAmount1 = require_numberUtils.wrapAmount(data[1], token1Decimals);
|
|
741
|
+
const borrowedAmount0 = require_numberUtils.wrapAmount(data[2], token0Decimals);
|
|
742
|
+
const borrowedAmount1 = require_numberUtils.wrapAmount(data[3], token1Decimals);
|
|
743
|
+
return {
|
|
744
|
+
tvl0: require_numberUtils.wrapAmount(data[4], token0Decimals),
|
|
745
|
+
tvl1: require_numberUtils.wrapAmount(data[5], token1Decimals),
|
|
746
|
+
totalAmount0,
|
|
747
|
+
totalAmount1,
|
|
748
|
+
borrowedAmount0,
|
|
749
|
+
borrowedAmount1,
|
|
750
|
+
blocksCount: data[6],
|
|
751
|
+
refetch
|
|
752
|
+
};
|
|
753
|
+
}, [
|
|
754
|
+
data,
|
|
755
|
+
token0Decimals,
|
|
756
|
+
token1Decimals,
|
|
751
757
|
refetch
|
|
752
|
-
|
|
758
|
+
]);
|
|
753
759
|
};
|
|
754
760
|
|
|
755
761
|
//#endregion
|