timelock-sdk 0.0.79 → 0.0.80
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-D9QtRxOF.d.ts → client-D_t-2-g5.d.cts} +248 -240
- package/dist/{client-h7lO3ik2.d.cts → client-euowNGgz.d.ts} +104 -96
- package/dist/client.cjs +2 -77
- 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 +1 -76
- package/dist/client.js.map +1 -1
- package/dist/{optionUtils-CI-AZi8X.js → optionUtils-CoIk8zAr.js} +97 -2
- package/dist/optionUtils-CoIk8zAr.js.map +1 -0
- package/dist/{optionUtils-CDD_7qmy.cjs → optionUtils-DAjhbiQ5.cjs} +108 -1
- package/dist/optionUtils-DAjhbiQ5.cjs.map +1 -0
- package/dist/package.cjs +3 -1
- package/dist/package.d.cts +2 -2
- package/dist/package.d.ts +2 -2
- package/dist/package.js +2 -2
- package/package.json +1 -1
- package/dist/optionUtils-CDD_7qmy.cjs.map +0 -1
- package/dist/optionUtils-CI-AZi8X.js.map +0 -1
package/dist/client.d.cts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "./uniswapMathLens-CK8C7WOt.cjs";
|
|
2
|
-
import {
|
|
2
|
+
import { B as useOptionPnl, F as useOptionTimeline, H as useMaxPositionSize, I as useSetOperatorPerms, L as useUserOperators, P as OptionTimelineData, R as useExtendOption, V as useMintOption, a as batchGetAmountsFromLiquidity, at as useExerciseOption, c as useLiquidityBlocks, ct as useClosedUserOptions, d as usePriceAtTick, dt as useTimelockConfig, f as UniswapPoolData, h as useCurrentPrice, i as useVaultData, it as useMarketData, l as useBurnLiquidity, lt as TimelockMarketProvider, m as useCurrentTick, n as useLens, o as useMintLiquidity, ot as OptionData, p as usePoolData, r as useVaultTVL, s as LiquidityBlockData, st as useActiveUserOptions, t as useApproval, u as usePriceHistory, ut as useCurrentMarket, z as useOptionPremium } from "./client-D_t-2-g5.cjs";
|
|
3
3
|
export { LiquidityBlockData, OptionData, OptionTimelineData, TimelockMarketProvider, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useApproval, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, useOptionTimeline, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import "./uniswapMathLens-C54iWXpi.js";
|
|
2
|
-
import {
|
|
2
|
+
import { B as useOptionPnl, F as useOptionTimeline, H as useMaxPositionSize, I as useSetOperatorPerms, L as useUserOperators, P as OptionTimelineData, R as useExtendOption, V as useMintOption, a as batchGetAmountsFromLiquidity, at as useExerciseOption, c as useLiquidityBlocks, ct as useClosedUserOptions, d as usePriceAtTick, dt as useTimelockConfig, f as UniswapPoolData, h as useCurrentPrice, i as useVaultData, it as useMarketData, l as useBurnLiquidity, lt as TimelockMarketProvider, m as useCurrentTick, n as useLens, o as useMintLiquidity, ot as OptionData, p as usePoolData, r as useVaultTVL, s as LiquidityBlockData, st as useActiveUserOptions, t as useApproval, u as usePriceHistory, ut as useCurrentMarket, z as useOptionPremium } from "./client-euowNGgz.js";
|
|
3
3
|
export { LiquidityBlockData, OptionData, OptionTimelineData, TimelockMarketProvider, UniswapPoolData, batchGetAmountsFromLiquidity, useActiveUserOptions, useApproval, useBurnLiquidity, useClosedUserOptions, useCurrentMarket, useCurrentPrice, useCurrentTick, useExerciseOption, useExtendOption, useLens, useLiquidityBlocks, useMarketData, useMaxPositionSize, useMintLiquidity, useMintOption, useOptionPnl, useOptionPremium, useOptionTimeline, usePoolData, usePriceAtTick, usePriceHistory, useSetOperatorPerms, useTimelockConfig, useUserOperators, useVaultData, useVaultTVL };
|
package/dist/client.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
import { r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-6PlyceXp.js";
|
|
5
|
-
import { A as
|
|
5
|
+
import { A as getErc20, D as token1ToToken0, E as token0ToToken1, F as uniswapMathLenses, M as getTimelockMarket, N as getUniswapMathLens, P as timelockLenses, d as wrapAmount, j as getTimelockLens, k as getPriceHistory, n as EMPTY_ARRAY, p as wrapPrice, t as getPayoutAtTick, v as getNearestValidStrikeTick, w as roundTickDown, y as getPriceAtTick } from "./optionUtils-CoIk8zAr.js";
|
|
6
6
|
import { n as uniswapV3PoolAbi, t as singleOwnerVaultAbi } from "./singleOwnerVault-BeJChjfJ.js";
|
|
7
7
|
import { encodeAbiParameters, encodeFunctionData, erc20Abi, maxUint256, zeroAddress } from "viem";
|
|
8
8
|
import React, { createContext, useContext, useMemo } from "react";
|
|
@@ -874,81 +874,6 @@ const useCurrentPrice = (poolAddr) => {
|
|
|
874
874
|
}), [currentPrice, currentTick]);
|
|
875
875
|
};
|
|
876
876
|
|
|
877
|
-
//#endregion
|
|
878
|
-
//#region src/lib/price.ts
|
|
879
|
-
const getResolutionConfig = (resolution) => {
|
|
880
|
-
return {
|
|
881
|
-
"1m": {
|
|
882
|
-
timeframe: "minute",
|
|
883
|
-
aggregate: "1",
|
|
884
|
-
seconds: 60
|
|
885
|
-
},
|
|
886
|
-
"5m": {
|
|
887
|
-
timeframe: "minute",
|
|
888
|
-
aggregate: "5",
|
|
889
|
-
seconds: 300
|
|
890
|
-
},
|
|
891
|
-
"15m": {
|
|
892
|
-
timeframe: "minute",
|
|
893
|
-
aggregate: "15",
|
|
894
|
-
seconds: 900
|
|
895
|
-
},
|
|
896
|
-
"1h": {
|
|
897
|
-
timeframe: "hour",
|
|
898
|
-
aggregate: "1",
|
|
899
|
-
seconds: 3600
|
|
900
|
-
},
|
|
901
|
-
"4h": {
|
|
902
|
-
timeframe: "hour",
|
|
903
|
-
aggregate: "4",
|
|
904
|
-
seconds: 14400
|
|
905
|
-
},
|
|
906
|
-
"1d": {
|
|
907
|
-
timeframe: "day",
|
|
908
|
-
aggregate: "1",
|
|
909
|
-
seconds: 86400
|
|
910
|
-
}
|
|
911
|
-
}[resolution];
|
|
912
|
-
};
|
|
913
|
-
const fillGaps = (prices, start, end, intervalMs) => {
|
|
914
|
-
if (prices.length === 0) return [];
|
|
915
|
-
const priceMap = /* @__PURE__ */ new Map();
|
|
916
|
-
for (const point of prices) {
|
|
917
|
-
const alignedTime = Math.floor(point.timestamp.getTime() / intervalMs) * intervalMs;
|
|
918
|
-
priceMap.set(alignedTime, point);
|
|
919
|
-
}
|
|
920
|
-
const filled = [];
|
|
921
|
-
let currentTime = Math.floor(prices[0].timestamp.getTime() / intervalMs) * intervalMs;
|
|
922
|
-
let lastKnownPrice = null;
|
|
923
|
-
while (currentTime <= end.getTime()) {
|
|
924
|
-
const existing = priceMap.get(currentTime);
|
|
925
|
-
if (existing) {
|
|
926
|
-
filled.push(existing);
|
|
927
|
-
lastKnownPrice = existing;
|
|
928
|
-
} else if (lastKnownPrice) filled.push({
|
|
929
|
-
timestamp: new Date(currentTime),
|
|
930
|
-
price: lastKnownPrice.price
|
|
931
|
-
});
|
|
932
|
-
currentTime += intervalMs;
|
|
933
|
-
}
|
|
934
|
-
return filled;
|
|
935
|
-
};
|
|
936
|
-
const getPriceHistory = async (poolAddress, resolution, start, end) => {
|
|
937
|
-
const network = "monad-testnet";
|
|
938
|
-
const { timeframe, aggregate, seconds } = getResolutionConfig(resolution);
|
|
939
|
-
if (end.getTime() > Date.now()) end = new Date(Date.now());
|
|
940
|
-
const startSecs = Math.floor(start.getTime() / 1e3);
|
|
941
|
-
const endSecs = Math.floor(end.getTime() / 1e3);
|
|
942
|
-
const diffSeconds = endSecs - startSecs;
|
|
943
|
-
const url = `https://api.geckoterminal.com/api/v2/networks/${network}/pools/${poolAddress}/ohlcv/${timeframe}?aggregate=${aggregate}&limit=${Math.min(Math.ceil(diffSeconds / seconds), 1e3)}&token=quote¤cy=usd&before_timestamp=${endSecs}`;
|
|
944
|
-
const res = await fetch(url, { headers: { Accept: "application/json" } });
|
|
945
|
-
if (!res.ok) throw new Error(`Failed to fetch price history: ${res.statusText}`);
|
|
946
|
-
return fillGaps((await res.json()).data.attributes.ohlcv_list.map(([timestamp, , , , close]) => ({
|
|
947
|
-
timestamp: /* @__PURE__ */ new Date(timestamp * 1e3),
|
|
948
|
-
price: close
|
|
949
|
-
})).sort((a, b) => a.timestamp.getTime() - b.timestamp.getTime()), start, end, seconds * 1e3).filter((point) => point.timestamp.getTime() / 1e3 >= startSecs && point.timestamp.getTime() / 1e3 <= endSecs);
|
|
950
|
-
};
|
|
951
|
-
|
|
952
877
|
//#endregion
|
|
953
878
|
//#region src/hooks/pool/usePriceHistory.ts
|
|
954
879
|
const usePriceHistory = (pool, resolution, startTimestamp, endTimestamp) => {
|