timelock-sdk 0.0.21 → 0.0.23
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 +15 -4
- package/dist/client.cjs.map +1 -1
- package/dist/client.d.cts +56 -56
- package/dist/client.d.ts +56 -56
- package/dist/client.js +15 -4
- package/dist/client.js.map +1 -1
- package/dist/{index-B7b3c8cu.d.cts → index-B20z73_3.d.ts} +2 -2
- package/dist/{index-CRhFaRiq.d.ts → index-CA5kB-yT.d.cts} +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
|
@@ -166,11 +166,14 @@ const useCurrentMarket = () => {
|
|
|
166
166
|
const useTimelockConfig = () => {
|
|
167
167
|
const context = (0, react.useContext)(TimelockMarketContext);
|
|
168
168
|
if (context === void 0) throw new Error("useConfig must be used within a TimelockMarketProvider");
|
|
169
|
+
const graphqlClient = (0, react.useMemo)(() => {
|
|
170
|
+
if (context.envioGraphqlUrl) return getSdk(new graphql_request.GraphQLClient(context.envioGraphqlUrl));
|
|
171
|
+
}, [context.envioGraphqlUrl]);
|
|
169
172
|
return {
|
|
170
173
|
lensAddr: context.lensAddr,
|
|
171
174
|
uniswapMathLensAddr: context.uniswapMathLensAddr,
|
|
172
175
|
envioGraphqlUrl: context.envioGraphqlUrl,
|
|
173
|
-
graphqlClient
|
|
176
|
+
graphqlClient
|
|
174
177
|
};
|
|
175
178
|
};
|
|
176
179
|
|
|
@@ -384,18 +387,26 @@ const useOptionPnl = (optionData) => {
|
|
|
384
387
|
const { marketAddr, optionType, entryTick, positionSizeCurrent } = optionData;
|
|
385
388
|
const { pool, optionAssetIsToken0, payoutAssetDecimals } = useMarketData(marketAddr);
|
|
386
389
|
const { exact: currentTick } = useCurrentTick(pool);
|
|
390
|
+
const entrySize = (0, react.useMemo)(() => {
|
|
391
|
+
if (optionAssetIsToken0 === void 0) return;
|
|
392
|
+
return optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, entryTick) : require_numberUtils.token1ToToken0(positionSizeCurrent, entryTick);
|
|
393
|
+
}, [
|
|
394
|
+
optionAssetIsToken0,
|
|
395
|
+
positionSizeCurrent,
|
|
396
|
+
entryTick
|
|
397
|
+
]);
|
|
387
398
|
const { displayPnl, unrealizedPayout } = (0, react.useMemo)(() => {
|
|
388
|
-
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals) return {};
|
|
389
|
-
const delta = optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, currentTick)
|
|
399
|
+
if (optionAssetIsToken0 === void 0 || currentTick === void 0 || !positionSizeCurrent || !payoutAssetDecimals || !entrySize) return {};
|
|
400
|
+
const delta = (optionAssetIsToken0 ? require_numberUtils.token0ToToken1(positionSizeCurrent, currentTick) : require_numberUtils.token1ToToken0(positionSizeCurrent, currentTick)) - entrySize;
|
|
390
401
|
const displayPnl$1 = require_numberUtils.wrapAmount(optionType === "CALL" ? delta : -delta, payoutAssetDecimals);
|
|
391
402
|
return {
|
|
392
403
|
unrealizedPayout: require_numberUtils.wrapAmount(displayPnl$1.scaled < 0 ? 0n : displayPnl$1.scaled, payoutAssetDecimals),
|
|
393
404
|
displayPnl: displayPnl$1
|
|
394
405
|
};
|
|
395
406
|
}, [
|
|
407
|
+
entrySize,
|
|
396
408
|
optionType,
|
|
397
409
|
optionAssetIsToken0,
|
|
398
|
-
entryTick,
|
|
399
410
|
currentTick,
|
|
400
411
|
positionSizeCurrent,
|
|
401
412
|
payoutAssetDecimals
|