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.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { lensAbi, optionsMarketAbi } from "./optionsMarket-DyBxHplR.js";
|
|
5
|
-
import { getErc20, getPriceAtTick, getTimelockLens, getTimelockMarket, getUniswapMathLens, roundTickDown, timelockLenses, token0ToToken1, token1ToToken0, uniswapMathLenses, wrapAmount, wrapPrice } from "./numberUtils-CAMznXR5.js";
|
|
5
|
+
import { PRICE_PRECISION, getErc20, getPriceAtTick, getTimelockLens, getTimelockMarket, getUniswapMathLens, roundTickDown, timelockLenses, token0ToToken1, token1ToToken0, uniswapMathLenses, wrapAmount, wrapPrice } from "./numberUtils-CAMznXR5.js";
|
|
6
6
|
import { singleOwnerVaultAbi, uniswapV3PoolAbi } from "./uniswapV3Pool-Copswrde.js";
|
|
7
7
|
import { encodeFunctionData, erc20Abi, maxUint256 } from "viem";
|
|
8
8
|
import React, { createContext, useContext, useMemo } from "react";
|
|
@@ -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
|
|
@@ -377,37 +378,26 @@ const useMintOption = (marketAddr) => {
|
|
|
377
378
|
//#endregion
|
|
378
379
|
//#region src/hooks/market/useOptionPnl.ts
|
|
379
380
|
const useOptionPnl = (optionData) => {
|
|
380
|
-
const { marketAddr, optionType,
|
|
381
|
+
const { marketAddr, optionType, entryPrice, positionSizeCurrent } = optionData;
|
|
381
382
|
const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
|
|
382
383
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
383
|
-
|
|
384
|
-
if (optionAssetIsToken0 === void 0) return;
|
|
385
|
-
|
|
386
|
-
}, [
|
|
387
|
-
optionAssetIsToken0,
|
|
388
|
-
positionSizeCurrent,
|
|
389
|
-
entryTick
|
|
390
|
-
]);
|
|
391
|
-
const { displayPnl, unrealizedPayout } = useMemo(() => {
|
|
392
|
-
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals || !entrySize) return {};
|
|
384
|
+
return useMemo(() => {
|
|
385
|
+
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
|
|
386
|
+
const entrySize = positionSizeCurrent * entryPrice / PRICE_PRECISION;
|
|
393
387
|
const delta = (optionAssetIsToken0 ? token0ToToken1(positionSizeCurrent, currentTick) : token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
|
|
394
|
-
const displayPnl
|
|
388
|
+
const displayPnl = wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
395
389
|
return {
|
|
396
|
-
unrealizedPayout: wrapAmount(displayPnl
|
|
397
|
-
displayPnl
|
|
390
|
+
unrealizedPayout: wrapAmount(displayPnl.scaled < 0 ? 0n : displayPnl.scaled, payoutAssetDecimals),
|
|
391
|
+
displayPnl
|
|
398
392
|
};
|
|
399
393
|
}, [
|
|
400
|
-
|
|
394
|
+
entryPrice,
|
|
401
395
|
optionType,
|
|
402
396
|
optionAssetIsToken0,
|
|
403
397
|
currentTick,
|
|
404
398
|
positionSizeCurrent,
|
|
405
399
|
payoutAssetDecimals
|
|
406
400
|
]);
|
|
407
|
-
return {
|
|
408
|
-
displayPnl,
|
|
409
|
-
unrealizedPayout
|
|
410
|
-
};
|
|
411
401
|
};
|
|
412
402
|
|
|
413
403
|
//#endregion
|
|
@@ -502,10 +492,11 @@ const usePriceAtTick = (tick, poolAddr) => {
|
|
|
502
492
|
//#region src/hooks/pool/useCurrentPrice.ts
|
|
503
493
|
const useCurrentPrice = (poolAddr) => {
|
|
504
494
|
const currentTick = useCurrentTick(poolAddr);
|
|
505
|
-
|
|
506
|
-
|
|
495
|
+
const currentPrice = usePriceAtTick(currentTick.exact, poolAddr);
|
|
496
|
+
return useMemo(() => ({
|
|
497
|
+
currentPrice,
|
|
507
498
|
currentTick
|
|
508
|
-
};
|
|
499
|
+
}), [currentPrice, currentTick]);
|
|
509
500
|
};
|
|
510
501
|
|
|
511
502
|
//#endregion
|
|
@@ -736,20 +727,28 @@ const useVaultTVL = (vaultAddr) => {
|
|
|
736
727
|
args: [vaultAddr],
|
|
737
728
|
query: { enabled: !!vaultAddr && !!timelockLens }
|
|
738
729
|
});
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
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,
|
|
751
750
|
refetch
|
|
752
|
-
|
|
751
|
+
]);
|
|
753
752
|
};
|
|
754
753
|
|
|
755
754
|
//#endregion
|