timelock-sdk 0.0.24 → 0.0.25
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 +40 -34
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +14782 -14770
- package/dist/client.d.ts +14783 -14771
- package/dist/client.js +40 -34
- package/dist/client.js.map +1 -1
- package/dist/{index-B20z73_3.d.ts → index-CRhFaRiq.d.ts} +92 -92
- package/dist/package.d.ts +1 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -235,11 +235,10 @@ const useExerciseOption = (marketAddr) => {
|
|
|
235
235
|
//#region src/hooks/useLens.ts
|
|
236
236
|
const useLens = () => {
|
|
237
237
|
const client = useClient();
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
uniswapLens:
|
|
241
|
-
|
|
242
|
-
};
|
|
238
|
+
return useMemo(() => ({
|
|
239
|
+
timelockLens: client ? getTimelockLens(client) : void 0,
|
|
240
|
+
uniswapLens: client ? getUniswapMathLens(client) : void 0
|
|
241
|
+
}), [client]);
|
|
243
242
|
};
|
|
244
243
|
|
|
245
244
|
//#endregion
|
|
@@ -308,11 +307,13 @@ const useCurrentTick = (poolAddr) => {
|
|
|
308
307
|
functionName: "slot0",
|
|
309
308
|
args: []
|
|
310
309
|
});
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
310
|
+
return useMemo(() => {
|
|
311
|
+
const exact = data === null || data === void 0 ? void 0 : data[1];
|
|
312
|
+
return {
|
|
313
|
+
exact,
|
|
314
|
+
rounded: exact && tickSpacing ? Math.floor(exact / tickSpacing) * tickSpacing : void 0
|
|
315
|
+
};
|
|
316
|
+
}, [data, tickSpacing]);
|
|
316
317
|
};
|
|
317
318
|
|
|
318
319
|
//#endregion
|
|
@@ -380,14 +381,14 @@ const useOptionPnl = (optionData) => {
|
|
|
380
381
|
const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
|
|
381
382
|
const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
|
|
382
383
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
383
|
-
|
|
384
|
+
return useMemo(() => {
|
|
384
385
|
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
|
|
385
386
|
const entrySize = positionSizeCurrent * entryPrice / PRICE_PRECISION;
|
|
386
387
|
const delta = (optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, currentTick) : token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
|
|
387
|
-
const displayPnl
|
|
388
|
+
const displayPnl = wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
388
389
|
return {
|
|
389
|
-
unrealizedPayout: wrapAmount(displayPnl
|
|
390
|
-
displayPnl
|
|
390
|
+
unrealizedPayout: wrapAmount(displayPnl.scaled < 0 ? 0n : displayPnl.scaled, payoutAssetDecimals),
|
|
391
|
+
displayPnl
|
|
391
392
|
};
|
|
392
393
|
}, [
|
|
393
394
|
entryPrice,
|
|
@@ -397,10 +398,6 @@ const useOptionPnl = (optionData) => {
|
|
|
397
398
|
positionSizeCurrent,
|
|
398
399
|
payoutAssetDecimals
|
|
399
400
|
]);
|
|
400
|
-
return {
|
|
401
|
-
displayPnl,
|
|
402
|
-
unrealizedPayout
|
|
403
|
-
};
|
|
404
401
|
};
|
|
405
402
|
|
|
406
403
|
//#endregion
|
|
@@ -495,10 +492,11 @@ const usePriceAtTick = (tick, poolAddr) => {
|
|
|
495
492
|
//#region src/hooks/pool/useCurrentPrice.ts
|
|
496
493
|
const useCurrentPrice = (poolAddr) => {
|
|
497
494
|
const currentTick = useCurrentTick(poolAddr);
|
|
498
|
-
|
|
499
|
-
|
|
495
|
+
const currentPrice = usePriceAtTick(currentTick.exact, poolAddr);
|
|
496
|
+
return useMemo(() => ({
|
|
497
|
+
currentPrice,
|
|
500
498
|
currentTick
|
|
501
|
-
};
|
|
499
|
+
}), [currentPrice, currentTick]);
|
|
502
500
|
};
|
|
503
501
|
|
|
504
502
|
//#endregion
|
|
@@ -729,20 +727,28 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
729
727
|
args: [vaultAddr],
|
|
730
728
|
query: { enabled: !!vaultAddr && !!timelockLens }
|
|
731
729
|
});
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
730
|
+
return useMemo(() => {
|
|
731
|
+
if (!token0Decimals || !token1Decimals || !data) return {};
|
|
732
|
+
const totalAmount0 = wrapAmount(data[0], token0Decimals);
|
|
733
|
+
const totalAmount1 = wrapAmount(data[1], token1Decimals);
|
|
734
|
+
const borrowedAmount0 = wrapAmount(data[2], token0Decimals);
|
|
735
|
+
const borrowedAmount1 = wrapAmount(data[3], token1Decimals);
|
|
736
|
+
return {
|
|
737
|
+
tvl0: wrapAmount(data[4], token0Decimals),
|
|
738
|
+
tvl1: wrapAmount(data[5], token1Decimals),
|
|
739
|
+
totalAmount0,
|
|
740
|
+
totalAmount1,
|
|
741
|
+
borrowedAmount0,
|
|
742
|
+
borrowedAmount1,
|
|
743
|
+
blocksCount: data[6],
|
|
744
|
+
refetch
|
|
745
|
+
};
|
|
746
|
+
}, [
|
|
747
|
+
data,
|
|
748
|
+
token0Decimals,
|
|
749
|
+
token1Decimals,
|
|
744
750
|
refetch
|
|
745
|
-
|
|
751
|
+
]);
|
|
746
752
|
};
|
|
747
753
|
|
|
748
754
|
//#endregion
|