timelock-sdk 0.0.23 → 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 +44 -45
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +14784 -14772
- package/dist/client.d.ts +14784 -14772
- package/dist/client.js +45 -46
- package/dist/client.js.map +1 -1
- package/dist/{index-B20z73_3.d.ts → index-B7b3c8cu.d.cts} +2 -2
- package/dist/{index-CA5kB-yT.d.cts → index-CRhFaRiq.d.ts} +2 -2
- 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
|
|
@@ -384,37 +385,26 @@ const useMintOption = (marketAddr) => {
|
|
|
384
385
|
//#endregion
|
|
385
386
|
//#region src/hooks/market/useOptionPnl.ts
|
|
386
387
|
const useOptionPnl = (optionData) => {
|
|
387
|
-
const { marketAddr, optionType,
|
|
388
|
+
const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
|
|
388
389
|
const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
|
|
389
390
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
390
|
-
|
|
391
|
-
if (optionAssetIsToken0 === void 0) return;
|
|
392
|
-
|
|
393
|
-
}, [
|
|
394
|
-
optionAssetIsToken0,
|
|
395
|
-
positionSizeCurrent,
|
|
396
|
-
entryTick
|
|
397
|
-
]);
|
|
398
|
-
const { displayPnl, unrealizedPayout } = (0, react.useMemo)(() => {
|
|
399
|
-
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals || !entrySize) return {};
|
|
391
|
+
return (0, react.useMemo)(() => {
|
|
392
|
+
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
|
|
393
|
+
const entrySize = positionSizeCurrent * entryPrice / require_numberUtils.PRICE_PRECISION;
|
|
400
394
|
const delta = (optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, currentTick) : require_numberUtils.token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
|
|
401
|
-
const displayPnl
|
|
395
|
+
const displayPnl = require_numberUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
402
396
|
return {
|
|
403
|
-
unrealizedPayout: require_numberUtils.wrapAmount(displayPnl
|
|
404
|
-
displayPnl
|
|
397
|
+
unrealizedPayout: require_numberUtils.wrapAmount(displayPnl.scaled < 0 ? 0n : displayPnl.scaled, payoutAssetDecimals),
|
|
398
|
+
displayPnl
|
|
405
399
|
};
|
|
406
400
|
}, [
|
|
407
|
-
|
|
401
|
+
entryPrice,
|
|
408
402
|
optionType,
|
|
409
403
|
optionAssetIsToken0,
|
|
410
404
|
currentTick,
|
|
411
405
|
positionSizeCurrent,
|
|
412
406
|
payoutAssetDecimals
|
|
413
407
|
]);
|
|
414
|
-
return {
|
|
415
|
-
displayPnl,
|
|
416
|
-
unrealizedPayout
|
|
417
|
-
};
|
|
418
408
|
};
|
|
419
409
|
|
|
420
410
|
//#endregion
|
|
@@ -509,10 +499,11 @@ const usePriceAtTick = (tick, poolAddr) => {
|
|
|
509
499
|
//#region src/hooks/pool/useCurrentPrice.ts
|
|
510
500
|
const useCurrentPrice = (poolAddr) => {
|
|
511
501
|
const currentTick = useCurrentTick(poolAddr);
|
|
512
|
-
|
|
513
|
-
|
|
502
|
+
const currentPrice = usePriceAtTick(currentTick.exact, poolAddr);
|
|
503
|
+
return (0, react.useMemo)(() => ({
|
|
504
|
+
currentPrice,
|
|
514
505
|
currentTick
|
|
515
|
-
};
|
|
506
|
+
}), [currentPrice, currentTick]);
|
|
516
507
|
};
|
|
517
508
|
|
|
518
509
|
//#endregion
|
|
@@ -743,20 +734,28 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
743
734
|
args: [vaultAddr],
|
|
744
735
|
query: { enabled: !!vaultAddr && !!timelockLens }
|
|
745
736
|
});
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
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,
|
|
758
757
|
refetch
|
|
759
|
-
|
|
758
|
+
]);
|
|
760
759
|
};
|
|
761
760
|
|
|
762
761
|
//#endregion
|