timelock-sdk 0.0.60 → 0.0.62

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.
@@ -1,4 +1,4 @@
1
- import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-DS1i63oR.js";
1
+ import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-Ddy91uWa.js";
2
2
  import * as viem0 from "viem";
3
3
  import { Address, Client, GetContractReturnType, PublicClient } from "viem";
4
4
  import Big from "big.js";
@@ -32098,4 +32098,4 @@ declare const liquiditiesToAmount1: (liquidities: bigint[], startTick: number, t
32098
32098
  declare const liquiditiesToAmounts: (liquidities: bigint[], startTick: number, currentTick: number, tickSpacing: number) => bigint[];
32099
32099
  //#endregion
32100
32100
  export { getTimelockLens as A, wrapPriceUnscaled as C, TimelockMarketData as D, TimelockMarket as E, getUniswapMathLens as M, timelockLenses as N, UniswapMathLens as O, uniswapMathLenses as P, wrapPrice as S, TimelockLens as T, scalePrice as _, liquiditiesToAmount1 as a, wrapAmount as b, roundTickUp as c, Amount as d, formatAmount as f, scaleAmount as g, formatVagueAmount as h, liquiditiesToAmount0 as i, getTimelockMarket as j, getErc20 as k, token0ToToken1 as l, formatUSD as m, getPriceAtTick as n, liquiditiesToAmounts as o, formatCondensed as p, getTickAtPrice as r, roundTickDown as s, PRICE_PRECISION as t, token1ToToken0 as u, unscaleAmount as v, zero as w, wrapAmountUnscaled as x, unscalePrice as y };
32101
- //# sourceMappingURL=index-Ct8jAxHT.d.ts.map
32101
+ //# sourceMappingURL=index-BIkdgG3y.d.ts.map
@@ -1,4 +1,4 @@
1
- import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-Dd_BqyEk.cjs";
1
+ import { n as optionsMarketAbi, r as lensAbi, t as uniswapMathLensAbi } from "./uniswapMathLens-D3iSMTdz.cjs";
2
2
  import * as viem0 from "viem";
3
3
  import { Address, Client, GetContractReturnType, PublicClient } from "viem";
4
4
  import Big from "big.js";
@@ -32098,4 +32098,4 @@ declare const liquiditiesToAmount1: (liquidities: bigint[], startTick: number, t
32098
32098
  declare const liquiditiesToAmounts: (liquidities: bigint[], startTick: number, currentTick: number, tickSpacing: number) => bigint[];
32099
32099
  //#endregion
32100
32100
  export { getTimelockLens as A, wrapPriceUnscaled as C, TimelockMarketData as D, TimelockMarket as E, getUniswapMathLens as M, timelockLenses as N, UniswapMathLens as O, uniswapMathLenses as P, wrapPrice as S, TimelockLens as T, scalePrice as _, liquiditiesToAmount1 as a, wrapAmount as b, roundTickUp as c, Amount as d, formatAmount as f, scaleAmount as g, formatVagueAmount as h, liquiditiesToAmount0 as i, getTimelockMarket as j, getErc20 as k, token0ToToken1 as l, formatUSD as m, getPriceAtTick as n, liquiditiesToAmounts as o, formatCondensed as p, getTickAtPrice as r, roundTickDown as s, PRICE_PRECISION as t, token1ToToken0 as u, unscaleAmount as v, zero as w, wrapAmountUnscaled as x, unscalePrice as y };
32101
- //# sourceMappingURL=index-DgBdLHRl.d.cts.map
32101
+ //# sourceMappingURL=index-CDYUCwzA.d.cts.map
@@ -21,7 +21,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  }) : target, mod));
22
22
 
23
23
  //#endregion
24
- const require_optionsMarket = require('./optionsMarket-C5z_ZrhG.cjs');
24
+ const require_optionsMarket = require('./optionsMarket-D192aXEZ.cjs');
25
25
  let viem = require("viem");
26
26
  viem = __toESM(viem);
27
27
  let viem_chains = require("viem/chains");
@@ -420,4 +420,4 @@ Object.defineProperty(exports, 'zero', {
420
420
  return zero;
421
421
  }
422
422
  });
423
- //# sourceMappingURL=numberUtils-DaQ_5dq6.cjs.map
423
+ //# sourceMappingURL=numberUtils-CmVB4kX7.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"numberUtils-DaQ_5dq6.cjs","names":["erc20Abi","optionsMarketAbi","uniswapMathLensAbi","lensAbi","timelockLenses: Record<number, Address>","monadTestnet","uniswapMathLenses: Record<number, Address>","TickMath","JSBI","Big","SqrtPriceMath","zero: Amount","Big"],"sources":["../src/lib/contracts.ts","../src/lib/liquidityUtils.ts","../src/lib/numberUtils.ts"],"sourcesContent":["import type {Address, Client, PublicClient, GetContractReturnType} from 'viem';\nimport {getContract} from 'viem';\nimport {monadTestnet} from 'viem/chains';\n\nimport {erc20Abi} from '~/abis/erc20';\nimport {lensAbi} from '~/abis/lens';\nimport {uniswapMathLensAbi} from '~/abis/uniswapMathLens';\nimport {optionsMarketAbi} from '~/abis/optionsMarket';\n\nexport type TimelockMarket = GetContractReturnType<\n typeof optionsMarketAbi,\n Client,\n Address\n>;\nexport type TimelockLens = GetContractReturnType<\n typeof lensAbi,\n Client,\n Address\n>;\nexport type UniswapMathLens = GetContractReturnType<\n typeof uniswapMathLensAbi,\n Client,\n Address\n>;\n\nexport type TimelockMarketData = Awaited<\n ReturnType<TimelockLens['read']['getMarketData']>\n> & {address: Address};\n\nexport const getErc20 = (address: Address, client: Client) =>\n getContract({abi: erc20Abi, address, client});\n\nexport const getTimelockMarket = (\n address: Address,\n client: Client,\n): TimelockMarket => {\n return getContract({abi: optionsMarketAbi, address, client});\n};\n\nexport const getUniswapMathLens = (client: Client | PublicClient) =>\n getContract({\n abi: uniswapMathLensAbi,\n address: uniswapMathLenses[client.chain!.id],\n client,\n });\n\nexport const getTimelockLens = (client: Client | PublicClient) =>\n getContract({\n abi: lensAbi,\n address: timelockLenses[client.chain!.id],\n client,\n });\n\nexport const timelockLenses: Record<number, Address> = {\n [monadTestnet.id]: '0xe5e1Df4B781D4162702F6a28a38a0f441A86f9Fa',\n};\nexport const uniswapMathLenses: Record<number, Address> = {\n [monadTestnet.id]: '0x4C8375D1F6D5F452e92e211C1D3E7a44F78dFc95',\n};\n","import {SqrtPriceMath, TickMath} from '@uniswap/v3-sdk';\nimport Big from 'big.js';\nimport JSBI from 'jsbi';\n\nexport const PRICE_PRECISION = BigInt(1e18);\n\nexport const getPriceAtTick = (tick: number) => {\n const sqrtRatioX96 = BigInt(TickMath.getSqrtRatioAtTick(tick).toString());\n\n const priceX192 = sqrtRatioX96 * sqrtRatioX96;\n const price = (priceX192 * PRICE_PRECISION) / BigInt(2 ** 192);\n\n return price;\n};\n\nexport const getTickAtPrice = (price: bigint) => {\n const priceX192 = (price * BigInt(2 ** 192)) / PRICE_PRECISION;\n const sqrtPriceX96 = JSBI.BigInt(\n new Big(priceX192.toString()).sqrt().toFixed(0),\n );\n return TickMath.getTickAtSqrtRatio(sqrtPriceX96);\n};\n\nexport const roundTickDown = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem >= 0) return tick - rem;\n return tick - rem - spacing;\n};\n\nexport const roundTickUp = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem === 0) return tick;\n if (rem > 0) return tick - rem + spacing;\n return tick - rem;\n};\n\nexport const token0ToToken1 = (amount0: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount0 * price) / PRICE_PRECISION;\n};\n\nexport const token1ToToken0 = (amount1: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount1 * PRICE_PRECISION) / price;\n};\n\nexport const liquiditiesToAmount0 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount0 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount0Delta = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(amount0Delta.toString());\n }\n return amount0;\n};\n\nexport const liquiditiesToAmount1 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount1 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount1Delta = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(amount1Delta.toString());\n }\n return amount1;\n};\n\nexport const liquiditiesToAmounts = (\n liquidities: bigint[],\n startTick: number,\n currentTick: number,\n tickSpacing: number,\n) => {\n let amount0 = 0n;\n let amount1 = 0n;\n\n const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(currentTick);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n if (currentTick < tickLower) {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n } else if (currentTick >= tickUpper) {\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(delta1.toString());\n } else {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n amount1 += BigInt(delta1.toString());\n }\n }\n return [amount0, amount1];\n};\n","import Big from 'big.js';\n\nexport type Amount = {\n scaled: bigint;\n unscaled: Big;\n decimals: number;\n formatted: string;\n};\n\nexport const zero: Amount = {\n scaled: 0n,\n unscaled: Big(0),\n decimals: 18,\n formatted: '0',\n};\n\nexport const wrapAmount = (scaled: bigint, decimals: number): Amount => {\n const unscaled = unscaleAmount(scaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapAmountUnscaled = (\n unscaled: Big | number | string,\n decimals: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scaleAmount(unscaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapPrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n): Amount => {\n const unscaled = unscalePrice(scaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const wrapPriceUnscaled = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scalePrice(unscaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const unscaleAmount = (scaled: bigint, decimals: number) => {\n return new Big(scaled.toString()).div(new Big(10).pow(decimals));\n};\n\nexport const scaleAmount = (\n unscaled: Big | number | string,\n decimals: number,\n) => {\n return BigInt(\n Big(unscaled).mul(new Big(10).pow(decimals)).round().toFixed(0),\n );\n};\n\nexport const unscalePrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return new Big(scaled.toString())\n .mul(new Big(10).pow(decimals0))\n .div(new Big(10).pow(decimals1))\n .div(new Big(10).pow(precision));\n};\n\nexport const scalePrice = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return BigInt(\n Big(unscaled)\n .mul(new Big(10).pow(precision))\n .mul(new Big(10).pow(decimals1))\n .div(new Big(10).pow(decimals0))\n .round()\n .toFixed(0),\n );\n};\n\nexport const formatAmount = (value?: Big | number | string) => {\n if (value === undefined) return '-';\n // return value < 1 ? value.toPrecision(2) : value.toFixed(2);\n return formatCondensed(Big(value).toFixed(100));\n};\n\nexport const formatVagueAmount = (value: number | bigint) => {\n value = Number(value);\n if (value === 0) return '0';\n\n const formatted = value.toExponential(2);\n return formatted.replace(/\\.?0+e/, 'e').replace(/e\\+/, 'e');\n};\n\nexport const formatCondensed = (\n input: string | number,\n decimals = 2,\n): string => {\n const str = (typeof input === 'number' ? input.toFixed(20) : input)\n .replace(/(\\.\\d*?)0+$/, '$1')\n .replace(/\\.$/, '');\n\n const [whole, decimal] = str.split('.');\n\n const formattedWhole = whole.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n if (!decimal) return formattedWhole;\n\n const leadingZeroMatch = decimal.match(/^(0{3,})/);\n\n if (leadingZeroMatch) {\n const zeroCount = leadingZeroMatch[1].length;\n const subscript = toSubscript(zeroCount.toString());\n const remaining = decimal.slice(zeroCount);\n\n const twoDigits = remaining.slice(0, decimals);\n return `${formattedWhole}.0${subscript}${twoDigits}`;\n } else {\n // No subscript needed, find first 2 significant digits\n const nonZeroStart = decimal.search(/[1-9]/); // Find first non-zero digit\n\n if (nonZeroStart === -1) {\n return formattedWhole; // All zeros\n }\n const significantPart = decimal.slice(nonZeroStart);\n const twoDigits = significantPart.slice(0, decimals);\n const leadingZeros = decimal.slice(0, nonZeroStart);\n\n return `${formattedWhole}.${leadingZeros}${twoDigits}`;\n }\n};\n\nconst toSubscript = (input: string) => {\n return input.replace(/[0-9]/g, m => '₀₁₂₃₄₅₆₇₈₉'[+m]);\n};\n\nexport const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B,KAAI,UAAU,EAAG,QAAO;AAGxB,QADkB,MAAM,cAAc,EAAE,CACvB,QAAQ,UAAU,IAAI,CAAC,QAAQ,OAAO,IAAI;;AAG7D,MAAa,mBACX,OACA,WAAW,MACA;CAKX,MAAM,CAAC,OAAO,YAJD,OAAO,UAAU,WAAW,MAAM,QAAQ,GAAG,GAAG,OAC1D,QAAQ,eAAe,KAAK,CAC5B,QAAQ,OAAO,GAAG,CAEQ,MAAM,IAAI;CAEvC,MAAM,iBAAiB,MAAM,QAAQ,yBAAyB,IAAI;AAClE,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,mBAAmB,QAAQ,MAAM,WAAW;AAElD,KAAI,kBAAkB;EACpB,MAAM,YAAY,iBAAiB,GAAG;AAKtC,SAAO,GAAG,eAAe,IAJP,YAAY,UAAU,UAAU,CAAC,GACjC,QAAQ,MAAM,UAAU,CAEd,MAAM,GAAG,SAAS;QAEzC;EAEL,MAAM,eAAe,QAAQ,OAAO,QAAQ;AAE5C,MAAI,iBAAiB,GACnB,QAAO;EAGT,MAAM,YADkB,QAAQ,MAAM,aAAa,CACjB,MAAM,GAAG,SAAS;AAGpD,SAAO,GAAG,eAAe,GAFJ,QAAQ,MAAM,GAAG,aAAa,GAER;;;AAI/C,MAAM,eAAe,UAAkB;AACrC,QAAO,MAAM,QAAQ,WAAU,MAAK,aAAa,CAAC,GAAG;;AAGvD,MAAa,aAAa,UAAyC;AACjE,QAAO,MAAM,aAAa,MAAM"}
1
+ {"version":3,"file":"numberUtils-CmVB4kX7.cjs","names":["erc20Abi","optionsMarketAbi","uniswapMathLensAbi","lensAbi","timelockLenses: Record<number, Address>","monadTestnet","uniswapMathLenses: Record<number, Address>","TickMath","JSBI","Big","SqrtPriceMath","zero: Amount","Big"],"sources":["../src/lib/contracts.ts","../src/lib/liquidityUtils.ts","../src/lib/numberUtils.ts"],"sourcesContent":["import type {Address, Client, PublicClient, GetContractReturnType} from 'viem';\nimport {getContract} from 'viem';\nimport {monadTestnet} from 'viem/chains';\n\nimport {erc20Abi} from '~/abis/erc20';\nimport {lensAbi} from '~/abis/lens';\nimport {uniswapMathLensAbi} from '~/abis/uniswapMathLens';\nimport {optionsMarketAbi} from '~/abis/optionsMarket';\n\nexport type TimelockMarket = GetContractReturnType<\n typeof optionsMarketAbi,\n Client,\n Address\n>;\nexport type TimelockLens = GetContractReturnType<\n typeof lensAbi,\n Client,\n Address\n>;\nexport type UniswapMathLens = GetContractReturnType<\n typeof uniswapMathLensAbi,\n Client,\n Address\n>;\n\nexport type TimelockMarketData = Awaited<\n ReturnType<TimelockLens['read']['getMarketData']>\n> & {address: Address};\n\nexport const getErc20 = (address: Address, client: Client) =>\n getContract({abi: erc20Abi, address, client});\n\nexport const getTimelockMarket = (\n address: Address,\n client: Client,\n): TimelockMarket => {\n return getContract({abi: optionsMarketAbi, address, client});\n};\n\nexport const getUniswapMathLens = (client: Client | PublicClient) =>\n getContract({\n abi: uniswapMathLensAbi,\n address: uniswapMathLenses[client.chain!.id],\n client,\n });\n\nexport const getTimelockLens = (client: Client | PublicClient) =>\n getContract({\n abi: lensAbi,\n address: timelockLenses[client.chain!.id],\n client,\n });\n\nexport const timelockLenses: Record<number, Address> = {\n [monadTestnet.id]: '0xe5e1Df4B781D4162702F6a28a38a0f441A86f9Fa',\n};\nexport const uniswapMathLenses: Record<number, Address> = {\n [monadTestnet.id]: '0x4C8375D1F6D5F452e92e211C1D3E7a44F78dFc95',\n};\n","import {SqrtPriceMath, TickMath} from '@uniswap/v3-sdk';\nimport Big from 'big.js';\nimport JSBI from 'jsbi';\n\nexport const PRICE_PRECISION = BigInt(1e18);\n\nexport const getPriceAtTick = (tick: number) => {\n const sqrtRatioX96 = BigInt(TickMath.getSqrtRatioAtTick(tick).toString());\n\n const priceX192 = sqrtRatioX96 * sqrtRatioX96;\n const price = (priceX192 * PRICE_PRECISION) / BigInt(2 ** 192);\n\n return price;\n};\n\nexport const getTickAtPrice = (price: bigint) => {\n const priceX192 = (price * BigInt(2 ** 192)) / PRICE_PRECISION;\n const sqrtPriceX96 = JSBI.BigInt(\n new Big(priceX192.toString()).sqrt().toFixed(0),\n );\n return TickMath.getTickAtSqrtRatio(sqrtPriceX96);\n};\n\nexport const roundTickDown = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem >= 0) return tick - rem;\n return tick - rem - spacing;\n};\n\nexport const roundTickUp = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem === 0) return tick;\n if (rem > 0) return tick - rem + spacing;\n return tick - rem;\n};\n\nexport const token0ToToken1 = (amount0: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount0 * price) / PRICE_PRECISION;\n};\n\nexport const token1ToToken0 = (amount1: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount1 * PRICE_PRECISION) / price;\n};\n\nexport const liquiditiesToAmount0 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount0 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount0Delta = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(amount0Delta.toString());\n }\n return amount0;\n};\n\nexport const liquiditiesToAmount1 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount1 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount1Delta = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(amount1Delta.toString());\n }\n return amount1;\n};\n\nexport const liquiditiesToAmounts = (\n liquidities: bigint[],\n startTick: number,\n currentTick: number,\n tickSpacing: number,\n) => {\n let amount0 = 0n;\n let amount1 = 0n;\n\n const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(currentTick);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n if (currentTick < tickLower) {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n } else if (currentTick >= tickUpper) {\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(delta1.toString());\n } else {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n amount1 += BigInt(delta1.toString());\n }\n }\n return [amount0, amount1];\n};\n","import Big from 'big.js';\n\nexport type Amount = {\n scaled: bigint;\n unscaled: Big;\n decimals: number;\n formatted: string;\n};\n\nexport const zero: Amount = {\n scaled: 0n,\n unscaled: Big(0),\n decimals: 18,\n formatted: '0',\n};\n\nexport const wrapAmount = (scaled: bigint, decimals: number): Amount => {\n const unscaled = unscaleAmount(scaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapAmountUnscaled = (\n unscaled: Big | number | string,\n decimals: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scaleAmount(unscaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapPrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n): Amount => {\n const unscaled = unscalePrice(scaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const wrapPriceUnscaled = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scalePrice(unscaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const unscaleAmount = (scaled: bigint, decimals: number) => {\n return new Big(scaled.toString()).div(new Big(10).pow(decimals));\n};\n\nexport const scaleAmount = (\n unscaled: Big | number | string,\n decimals: number,\n) => {\n return BigInt(\n Big(unscaled).mul(new Big(10).pow(decimals)).round().toFixed(0),\n );\n};\n\nexport const unscalePrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return new Big(scaled.toString())\n .mul(new Big(10).pow(decimals0))\n .div(new Big(10).pow(decimals1))\n .div(new Big(10).pow(precision));\n};\n\nexport const scalePrice = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return BigInt(\n Big(unscaled)\n .mul(new Big(10).pow(precision))\n .mul(new Big(10).pow(decimals1))\n .div(new Big(10).pow(decimals0))\n .round()\n .toFixed(0),\n );\n};\n\nexport const formatAmount = (value?: Big | number | string) => {\n if (value === undefined) return '-';\n // return value < 1 ? value.toPrecision(2) : value.toFixed(2);\n return formatCondensed(Big(value).toFixed(100));\n};\n\nexport const formatVagueAmount = (value: number | bigint) => {\n value = Number(value);\n if (value === 0) return '0';\n\n const formatted = value.toExponential(2);\n return formatted.replace(/\\.?0+e/, 'e').replace(/e\\+/, 'e');\n};\n\nexport const formatCondensed = (\n input: string | number,\n decimals = 2,\n): string => {\n const str = (typeof input === 'number' ? input.toFixed(20) : input)\n .replace(/(\\.\\d*?)0+$/, '$1')\n .replace(/\\.$/, '');\n\n const [whole, decimal] = str.split('.');\n\n const formattedWhole = whole.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n if (!decimal) return formattedWhole;\n\n const leadingZeroMatch = decimal.match(/^(0{3,})/);\n\n if (leadingZeroMatch) {\n const zeroCount = leadingZeroMatch[1].length;\n const subscript = toSubscript(zeroCount.toString());\n const remaining = decimal.slice(zeroCount);\n\n const twoDigits = remaining.slice(0, decimals);\n return `${formattedWhole}.0${subscript}${twoDigits}`;\n } else {\n // No subscript needed, find first 2 significant digits\n const nonZeroStart = decimal.search(/[1-9]/); // Find first non-zero digit\n\n if (nonZeroStart === -1) {\n return formattedWhole; // All zeros\n }\n const significantPart = decimal.slice(nonZeroStart);\n const twoDigits = significantPart.slice(0, decimals);\n const leadingZeros = decimal.slice(0, nonZeroStart);\n\n return `${formattedWhole}.${leadingZeros}${twoDigits}`;\n }\n};\n\nconst toSubscript = (input: string) => {\n return input.replace(/[0-9]/g, m => '₀₁₂₃₄₅₆₇₈₉'[+m]);\n};\n\nexport const formatUSD = (value: Big | string | number): string => {\n return '$' + formatAmount(value);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,MAAa,YAAY,SAAkB,iCAC7B;CAAC,KAAKA;CAAU;CAAS;CAAO,CAAC;AAE/C,MAAa,qBACX,SACA,WACmB;AACnB,8BAAmB;EAAC,KAAKC;EAAkB;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e,KAAK,CAC5B,QAAQ,OAAO,GAAG,CAEQ,MAAM,IAAI;CAEvC,MAAM,iBAAiB,MAAM,QAAQ,yBAAyB,IAAI;AAClE,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,mBAAmB,QAAQ,MAAM,WAAW;AAElD,KAAI,kBAAkB;EACpB,MAAM,YAAY,iBAAiB,GAAG;AAKtC,SAAO,GAAG,eAAe,IAJP,YAAY,UAAU,UAAU,CAAC,GACjC,QAAQ,MAAM,UAAU,CAEd,MAAM,GAAG,SAAS;QAEzC;EAEL,MAAM,eAAe,QAAQ,OAAO,QAAQ;AAE5C,MAAI,iBAAiB,GACnB,QAAO;EAGT,MAAM,YADkB,QAAQ,MAAM,aAAa,CACjB,MAAM,GAAG,SAAS;AAGpD,SAAO,GAAG,eAAe,GAFJ,QAAQ,MAAM,GAAG,aAAa,GAER;;;AAI/C,MAAM,eAAe,UAAkB;AACrC,QAAO,MAAM,QAAQ,WAAU,MAAK,aAAa,CAAC,GAAG;;AAGvD,MAAa,aAAa,UAAyC;AACjE,QAAO,MAAM,aAAa,MAAM"}
@@ -1,4 +1,4 @@
1
- import { i as erc20Abi$1, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-BW3qSfsm.js";
1
+ import { i as erc20Abi$1, n as uniswapMathLensAbi, r as lensAbi, t as optionsMarketAbi } from "./optionsMarket-DD4CWMqv.js";
2
2
  import { getContract } from "viem";
3
3
  import { monadTestnet } from "viem/chains";
4
4
  import { SqrtPriceMath, TickMath } from "@uniswap/v3-sdk";
@@ -213,4 +213,4 @@ const formatUSD = (value) => {
213
213
 
214
214
  //#endregion
215
215
  export { token1ToToken0 as C, getUniswapMathLens as D, getTimelockMarket as E, timelockLenses as O, token0ToToken1 as S, getTimelockLens as T, liquiditiesToAmount0 as _, scaleAmount as a, roundTickDown as b, unscalePrice as c, wrapPrice as d, wrapPriceUnscaled as f, getTickAtPrice as g, getPriceAtTick as h, formatVagueAmount as i, uniswapMathLenses as k, wrapAmount as l, PRICE_PRECISION as m, formatCondensed as n, scalePrice as o, zero as p, formatUSD as r, unscaleAmount as s, formatAmount as t, wrapAmountUnscaled as u, liquiditiesToAmount1 as v, getErc20 as w, roundTickUp as x, liquiditiesToAmounts as y };
216
- //# sourceMappingURL=numberUtils-DYkWKQ5v.js.map
216
+ //# sourceMappingURL=numberUtils-Dd7vdmeQ.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"numberUtils-DYkWKQ5v.js","names":["erc20Abi","timelockLenses: Record<number, Address>","uniswapMathLenses: Record<number, Address>","zero: Amount"],"sources":["../src/lib/contracts.ts","../src/lib/liquidityUtils.ts","../src/lib/numberUtils.ts"],"sourcesContent":["import type {Address, Client, PublicClient, GetContractReturnType} from 'viem';\nimport {getContract} from 'viem';\nimport {monadTestnet} from 'viem/chains';\n\nimport {erc20Abi} from '~/abis/erc20';\nimport {lensAbi} from '~/abis/lens';\nimport {uniswapMathLensAbi} from '~/abis/uniswapMathLens';\nimport {optionsMarketAbi} from '~/abis/optionsMarket';\n\nexport type TimelockMarket = GetContractReturnType<\n typeof optionsMarketAbi,\n Client,\n Address\n>;\nexport type TimelockLens = GetContractReturnType<\n typeof lensAbi,\n Client,\n Address\n>;\nexport type UniswapMathLens = GetContractReturnType<\n typeof uniswapMathLensAbi,\n Client,\n Address\n>;\n\nexport type TimelockMarketData = Awaited<\n ReturnType<TimelockLens['read']['getMarketData']>\n> & {address: Address};\n\nexport const getErc20 = (address: Address, client: Client) =>\n getContract({abi: erc20Abi, address, client});\n\nexport const getTimelockMarket = (\n address: Address,\n client: Client,\n): TimelockMarket => {\n return getContract({abi: optionsMarketAbi, address, client});\n};\n\nexport const getUniswapMathLens = (client: Client | PublicClient) =>\n getContract({\n abi: uniswapMathLensAbi,\n address: uniswapMathLenses[client.chain!.id],\n client,\n });\n\nexport const getTimelockLens = (client: Client | PublicClient) =>\n getContract({\n abi: lensAbi,\n address: timelockLenses[client.chain!.id],\n client,\n });\n\nexport const timelockLenses: Record<number, Address> = {\n [monadTestnet.id]: '0xe5e1Df4B781D4162702F6a28a38a0f441A86f9Fa',\n};\nexport const uniswapMathLenses: Record<number, Address> = {\n [monadTestnet.id]: '0x4C8375D1F6D5F452e92e211C1D3E7a44F78dFc95',\n};\n","import {SqrtPriceMath, TickMath} from '@uniswap/v3-sdk';\nimport Big from 'big.js';\nimport JSBI from 'jsbi';\n\nexport const PRICE_PRECISION = BigInt(1e18);\n\nexport const getPriceAtTick = (tick: number) => {\n const sqrtRatioX96 = BigInt(TickMath.getSqrtRatioAtTick(tick).toString());\n\n const priceX192 = sqrtRatioX96 * sqrtRatioX96;\n const price = (priceX192 * PRICE_PRECISION) / BigInt(2 ** 192);\n\n return price;\n};\n\nexport const getTickAtPrice = (price: bigint) => {\n const priceX192 = (price * BigInt(2 ** 192)) / PRICE_PRECISION;\n const sqrtPriceX96 = JSBI.BigInt(\n new Big(priceX192.toString()).sqrt().toFixed(0),\n );\n return TickMath.getTickAtSqrtRatio(sqrtPriceX96);\n};\n\nexport const roundTickDown = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem >= 0) return tick - rem;\n return tick - rem - spacing;\n};\n\nexport const roundTickUp = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem === 0) return tick;\n if (rem > 0) return tick - rem + spacing;\n return tick - rem;\n};\n\nexport const token0ToToken1 = (amount0: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount0 * price) / PRICE_PRECISION;\n};\n\nexport const token1ToToken0 = (amount1: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount1 * PRICE_PRECISION) / price;\n};\n\nexport const liquiditiesToAmount0 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount0 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount0Delta = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(amount0Delta.toString());\n }\n return amount0;\n};\n\nexport const liquiditiesToAmount1 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount1 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount1Delta = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(amount1Delta.toString());\n }\n return amount1;\n};\n\nexport const liquiditiesToAmounts = (\n liquidities: bigint[],\n startTick: number,\n currentTick: number,\n tickSpacing: number,\n) => {\n let amount0 = 0n;\n let amount1 = 0n;\n\n const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(currentTick);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n if (currentTick < tickLower) {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n } else if (currentTick >= tickUpper) {\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(delta1.toString());\n } else {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n amount1 += BigInt(delta1.toString());\n }\n }\n return [amount0, amount1];\n};\n","import Big from 'big.js';\n\nexport type Amount = {\n scaled: bigint;\n unscaled: Big;\n decimals: number;\n formatted: string;\n};\n\nexport const zero: Amount = {\n scaled: 0n,\n unscaled: Big(0),\n decimals: 18,\n formatted: '0',\n};\n\nexport const wrapAmount = (scaled: bigint, decimals: number): Amount => {\n const unscaled = unscaleAmount(scaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapAmountUnscaled = (\n unscaled: Big | number | string,\n decimals: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scaleAmount(unscaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapPrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n): Amount => {\n const unscaled = unscalePrice(scaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const wrapPriceUnscaled = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scalePrice(unscaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const unscaleAmount = (scaled: bigint, decimals: number) => {\n return new Big(scaled.toString()).div(new Big(10).pow(decimals));\n};\n\nexport const scaleAmount = (\n unscaled: Big | number | string,\n decimals: number,\n) => {\n return BigInt(\n Big(unscaled).mul(new Big(10).pow(decimals)).round().toFixed(0),\n );\n};\n\nexport const unscalePrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return new Big(scaled.toString())\n .mul(new Big(10).pow(decimals0))\n .div(new Big(10).pow(decimals1))\n .div(new Big(10).pow(precision));\n};\n\nexport const scalePrice = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return BigInt(\n Big(unscaled)\n .mul(new Big(10).pow(precision))\n .mul(new Big(10).pow(decimals1))\n .div(new Big(10).pow(decimals0))\n .round()\n .toFixed(0),\n );\n};\n\nexport const formatAmount = (value?: Big | number | string) => {\n if (value === undefined) return '-';\n // return value < 1 ? value.toPrecision(2) : value.toFixed(2);\n return formatCondensed(Big(value).toFixed(100));\n};\n\nexport const formatVagueAmount = (value: number | bigint) => {\n value = Number(value);\n if (value === 0) return '0';\n\n const formatted = value.toExponential(2);\n return formatted.replace(/\\.?0+e/, 'e').replace(/e\\+/, 'e');\n};\n\nexport const formatCondensed = (\n input: string | number,\n decimals = 2,\n): string => {\n const str = (typeof input === 'number' ? input.toFixed(20) : input)\n .replace(/(\\.\\d*?)0+$/, '$1')\n .replace(/\\.$/, '');\n\n const [whole, decimal] = str.split('.');\n\n const formattedWhole = whole.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n if (!decimal) return formattedWhole;\n\n const leadingZeroMatch = decimal.match(/^(0{3,})/);\n\n if (leadingZeroMatch) {\n const zeroCount = leadingZeroMatch[1].length;\n const subscript = toSubscript(zeroCount.toString());\n const remaining = decimal.slice(zeroCount);\n\n const twoDigits = remaining.slice(0, decimals);\n return `${formattedWhole}.0${subscript}${twoDigits}`;\n } else {\n // No subscript needed, find first 2 significant digits\n const nonZeroStart = decimal.search(/[1-9]/); // Find first non-zero digit\n\n if (nonZeroStart === -1) {\n return formattedWhole; // All zeros\n }\n const significantPart = decimal.slice(nonZeroStart);\n const twoDigits = significantPart.slice(0, decimals);\n const leadingZeros = decimal.slice(0, nonZeroStart);\n\n return `${formattedWhole}.${leadingZeros}${twoDigits}`;\n }\n};\n\nconst toSubscript = (input: string) => {\n return input.replace(/[0-9]/g, m => '₀₁₂₃₄₅₆₇₈₉'[+m]);\n};\n\nexport const formatUSD = (value: Big | string | number): string => {\n return '$' + formatAmount(value);\n};\n"],"mappings":";;;;;;;;AA6BA,MAAa,YAAY,SAAkB,WACzC,YAAY;CAAC,KAAKA;CAAU;CAAS;CAAO,CAAC;AAE/C,MAAa,qBACX,SACA,WACmB;AACnB,QAAO,YAAY;EAAC,KAAK;EAAkB;EAAS;EAAO,CAAC;;AAG9D,MAAa,sBAAsB,WACjC,YAAY;CACV,KAAK;CACL,SAAS,kBAAkB,OAAO,MAAO;CACzC;CACD,CAAC;AAEJ,MAAa,mBAAmB,WAC9B,YAAY;CACV,KAAK;CACL,SAAS,eAAe,OAAO,MAAO;CACtC;CACD,CAAC;AAEJ,MAAaC,iBAA0C,GACpD,aAAa,KAAK,8CACpB;AACD,MAAaC,oBAA6C,GACvD,aAAa,KAAK,8CACpB;;;;ACtDD,MAAa,kBAAkB,OAAO,kBAAK;AAE3C,MAAa,kBAAkB,SAAiB;CAC9C,MAAM,eAAe,OAAO,SAAS,mBAAmB,KAAK,CAAC,UAAU,CAAC;AAKzE,QAHkB,eAAe,eACN,kBAAmB,OAAO,KAAK,IAAI;;AAKhE,MAAa,kBAAkB,UAAkB;CAC/C,MAAM,YAAa,QAAQ,OAAO,KAAK,IAAI,GAAI;CAC/C,MAAM,eAAe,KAAK,OACxB,IAAI,IAAI,UAAU,UAAU,CAAC,CAAC,MAAM,CAAC,QAAQ,EAAE,CAChD;AACD,QAAO,SAAS,mBAAmB,aAAa;;AAGlD,MAAa,iBAAiB,MAAc,YAAoB;CAC9D,MAAM,MAAM,OAAO;AAC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>","zero: Amount"],"sources":["../src/lib/contracts.ts","../src/lib/liquidityUtils.ts","../src/lib/numberUtils.ts"],"sourcesContent":["import type {Address, Client, PublicClient, GetContractReturnType} from 'viem';\nimport {getContract} from 'viem';\nimport {monadTestnet} from 'viem/chains';\n\nimport {erc20Abi} from '~/abis/erc20';\nimport {lensAbi} from '~/abis/lens';\nimport {uniswapMathLensAbi} from '~/abis/uniswapMathLens';\nimport {optionsMarketAbi} from '~/abis/optionsMarket';\n\nexport type TimelockMarket = GetContractReturnType<\n typeof optionsMarketAbi,\n Client,\n Address\n>;\nexport type TimelockLens = GetContractReturnType<\n typeof lensAbi,\n Client,\n Address\n>;\nexport type UniswapMathLens = GetContractReturnType<\n typeof uniswapMathLensAbi,\n Client,\n Address\n>;\n\nexport type TimelockMarketData = Awaited<\n ReturnType<TimelockLens['read']['getMarketData']>\n> & {address: Address};\n\nexport const getErc20 = (address: Address, client: Client) =>\n getContract({abi: erc20Abi, address, client});\n\nexport const getTimelockMarket = (\n address: Address,\n client: Client,\n): TimelockMarket => {\n return getContract({abi: optionsMarketAbi, address, client});\n};\n\nexport const getUniswapMathLens = (client: Client | PublicClient) =>\n getContract({\n abi: uniswapMathLensAbi,\n address: uniswapMathLenses[client.chain!.id],\n client,\n });\n\nexport const getTimelockLens = (client: Client | PublicClient) =>\n getContract({\n abi: lensAbi,\n address: timelockLenses[client.chain!.id],\n client,\n });\n\nexport const timelockLenses: Record<number, Address> = {\n [monadTestnet.id]: '0xe5e1Df4B781D4162702F6a28a38a0f441A86f9Fa',\n};\nexport const uniswapMathLenses: Record<number, Address> = {\n [monadTestnet.id]: '0x4C8375D1F6D5F452e92e211C1D3E7a44F78dFc95',\n};\n","import {SqrtPriceMath, TickMath} from '@uniswap/v3-sdk';\nimport Big from 'big.js';\nimport JSBI from 'jsbi';\n\nexport const PRICE_PRECISION = BigInt(1e18);\n\nexport const getPriceAtTick = (tick: number) => {\n const sqrtRatioX96 = BigInt(TickMath.getSqrtRatioAtTick(tick).toString());\n\n const priceX192 = sqrtRatioX96 * sqrtRatioX96;\n const price = (priceX192 * PRICE_PRECISION) / BigInt(2 ** 192);\n\n return price;\n};\n\nexport const getTickAtPrice = (price: bigint) => {\n const priceX192 = (price * BigInt(2 ** 192)) / PRICE_PRECISION;\n const sqrtPriceX96 = JSBI.BigInt(\n new Big(priceX192.toString()).sqrt().toFixed(0),\n );\n return TickMath.getTickAtSqrtRatio(sqrtPriceX96);\n};\n\nexport const roundTickDown = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem >= 0) return tick - rem;\n return tick - rem - spacing;\n};\n\nexport const roundTickUp = (tick: number, spacing: number) => {\n const rem = tick % spacing;\n if (rem === 0) return tick;\n if (rem > 0) return tick - rem + spacing;\n return tick - rem;\n};\n\nexport const token0ToToken1 = (amount0: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount0 * price) / PRICE_PRECISION;\n};\n\nexport const token1ToToken0 = (amount1: bigint, tick: number) => {\n const price = getPriceAtTick(tick);\n return (amount1 * PRICE_PRECISION) / price;\n};\n\nexport const liquiditiesToAmount0 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount0 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount0Delta = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(amount0Delta.toString());\n }\n return amount0;\n};\n\nexport const liquiditiesToAmount1 = (\n liquidities: bigint[],\n startTick: number,\n tickSpacing: number,\n) => {\n let amount1 = BigInt(0);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n const amount1Delta = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(amount1Delta.toString());\n }\n return amount1;\n};\n\nexport const liquiditiesToAmounts = (\n liquidities: bigint[],\n startTick: number,\n currentTick: number,\n tickSpacing: number,\n) => {\n let amount0 = 0n;\n let amount1 = 0n;\n\n const sqrtRatioX96 = TickMath.getSqrtRatioAtTick(currentTick);\n\n for (let i = 0; i < liquidities.length; i++) {\n const liquidity = liquidities[i];\n if (liquidity === BigInt(0)) continue;\n\n const tickLower = startTick + tickSpacing * i;\n const tickUpper = tickLower + tickSpacing;\n\n const sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower);\n const sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper);\n const liquidityJSBI = JSBI.BigInt(liquidity.toString());\n\n if (currentTick < tickLower) {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n } else if (currentTick >= tickUpper) {\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n amount1 += BigInt(delta1.toString());\n } else {\n const delta0 = SqrtPriceMath.getAmount0Delta(\n sqrtRatioX96,\n sqrtRatioBX96,\n liquidityJSBI,\n false,\n );\n const delta1 = SqrtPriceMath.getAmount1Delta(\n sqrtRatioAX96,\n sqrtRatioX96,\n liquidityJSBI,\n false,\n );\n amount0 += BigInt(delta0.toString());\n amount1 += BigInt(delta1.toString());\n }\n }\n return [amount0, amount1];\n};\n","import Big from 'big.js';\n\nexport type Amount = {\n scaled: bigint;\n unscaled: Big;\n decimals: number;\n formatted: string;\n};\n\nexport const zero: Amount = {\n scaled: 0n,\n unscaled: Big(0),\n decimals: 18,\n formatted: '0',\n};\n\nexport const wrapAmount = (scaled: bigint, decimals: number): Amount => {\n const unscaled = unscaleAmount(scaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapAmountUnscaled = (\n unscaled: Big | number | string,\n decimals: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scaleAmount(unscaled, decimals);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals, formatted};\n};\n\nexport const wrapPrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n): Amount => {\n const unscaled = unscalePrice(scaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const wrapPriceUnscaled = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n): Amount => {\n unscaled = Big(unscaled);\n const scaled = scalePrice(unscaled, decimals0, decimals1);\n const formatted = formatAmount(unscaled);\n return {scaled, unscaled, decimals: 36 + decimals1 - decimals0, formatted};\n};\n\nexport const unscaleAmount = (scaled: bigint, decimals: number) => {\n return new Big(scaled.toString()).div(new Big(10).pow(decimals));\n};\n\nexport const scaleAmount = (\n unscaled: Big | number | string,\n decimals: number,\n) => {\n return BigInt(\n Big(unscaled).mul(new Big(10).pow(decimals)).round().toFixed(0),\n );\n};\n\nexport const unscalePrice = (\n scaled: bigint,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return new Big(scaled.toString())\n .mul(new Big(10).pow(decimals0))\n .div(new Big(10).pow(decimals1))\n .div(new Big(10).pow(precision));\n};\n\nexport const scalePrice = (\n unscaled: Big | number | string,\n decimals0: number,\n decimals1: number,\n precision = 18,\n) => {\n return BigInt(\n Big(unscaled)\n .mul(new Big(10).pow(precision))\n .mul(new Big(10).pow(decimals1))\n .div(new Big(10).pow(decimals0))\n .round()\n .toFixed(0),\n );\n};\n\nexport const formatAmount = (value?: Big | number | string) => {\n if (value === undefined) return '-';\n // return value < 1 ? value.toPrecision(2) : value.toFixed(2);\n return formatCondensed(Big(value).toFixed(100));\n};\n\nexport const formatVagueAmount = (value: number | bigint) => {\n value = Number(value);\n if (value === 0) return '0';\n\n const formatted = value.toExponential(2);\n return formatted.replace(/\\.?0+e/, 'e').replace(/e\\+/, 'e');\n};\n\nexport const formatCondensed = (\n input: string | number,\n decimals = 2,\n): string => {\n const str = (typeof input === 'number' ? input.toFixed(20) : input)\n .replace(/(\\.\\d*?)0+$/, '$1')\n .replace(/\\.$/, '');\n\n const [whole, decimal] = str.split('.');\n\n const formattedWhole = whole.replace(/\\B(?=(\\d{3})+(?!\\d))/g, ',');\n if (!decimal) return formattedWhole;\n\n const leadingZeroMatch = decimal.match(/^(0{3,})/);\n\n if (leadingZeroMatch) {\n const zeroCount = leadingZeroMatch[1].length;\n const subscript = toSubscript(zeroCount.toString());\n const remaining = decimal.slice(zeroCount);\n\n const twoDigits = remaining.slice(0, decimals);\n return `${formattedWhole}.0${subscript}${twoDigits}`;\n } else {\n // No subscript needed, find first 2 significant digits\n const nonZeroStart = decimal.search(/[1-9]/); // Find first non-zero digit\n\n if (nonZeroStart === -1) {\n return formattedWhole; // All zeros\n }\n const significantPart = decimal.slice(nonZeroStart);\n const twoDigits = significantPart.slice(0, decimals);\n const leadingZeros = decimal.slice(0, nonZeroStart);\n\n return `${formattedWhole}.${leadingZeros}${twoDigits}`;\n }\n};\n\nconst toSubscript = (input: string) => {\n return input.replace(/[0-9]/g, m => '₀₁₂₃₄₅₆₇₈₉'[+m]);\n};\n\nexport const formatUSD = (value: Big | string | number): string => {\n return '$' + formatAmount(value);\n};\n"],"mappings":";;;;;;;;AA6BA,MAAa,YAAY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X,OACA,WAAW,MACA;CAKX,MAAM,CAAC,OAAO,YAJD,OAAO,UAAU,WAAW,MAAM,QAAQ,GAAG,GAAG,OAC1D,QAAQ,eAAe,KAAK,CAC5B,QAAQ,OAAO,GAAG,CAEQ,MAAM,IAAI;CAEvC,MAAM,iBAAiB,MAAM,QAAQ,yBAAyB,IAAI;AAClE,KAAI,CAAC,QAAS,QAAO;CAErB,MAAM,mBAAmB,QAAQ,MAAM,WAAW;AAElD,KAAI,kBAAkB;EACpB,MAAM,YAAY,iBAAiB,GAAG;AAKtC,SAAO,GAAG,eAAe,IAJP,YAAY,UAAU,UAAU,CAAC,GACjC,QAAQ,MAAM,UAAU,CAEd,MAAM,GAAG,SAAS;QAEzC;EAEL,MAAM,eAAe,QAAQ,OAAO,QAAQ;AAE5C,MAAI,iBAAiB,GACnB,QAAO;EAGT,MAAM,YADkB,QAAQ,MAAM,aAAa,CACjB,MAAM,GAAG,SAAS;AAGpD,SAAO,GAAG,eAAe,GAFJ,QAAQ,MAAM,GAAG,aAAa,GAER;;;AAI/C,MAAM,eAAe,UAAkB;AACrC,QAAO,MAAM,QAAQ,WAAU,MAAK,aAAa,CAAC,GAAG;;AAGvD,MAAa,aAAa,UAAyC;AACjE,QAAO,MAAM,aAAa,MAAM"}
@@ -2096,6 +2096,11 @@ const optionsMarketAbi = [
2096
2096
  type: "function",
2097
2097
  name: "mintOption",
2098
2098
  inputs: [
2099
+ {
2100
+ name: "owner",
2101
+ type: "address",
2102
+ internalType: "address"
2103
+ },
2099
2104
  {
2100
2105
  name: "optionType",
2101
2106
  type: "uint8",
@@ -2204,6 +2209,16 @@ const optionsMarketAbi = [
2204
2209
  name: "canTransfer",
2205
2210
  type: "bool",
2206
2211
  internalType: "bool"
2212
+ },
2213
+ {
2214
+ name: "canMint",
2215
+ type: "bool",
2216
+ internalType: "bool"
2217
+ },
2218
+ {
2219
+ name: "spendingApproval",
2220
+ type: "uint256",
2221
+ internalType: "uint256"
2207
2222
  }
2208
2223
  ],
2209
2224
  stateMutability: "view"
@@ -2304,6 +2319,16 @@ const optionsMarketAbi = [
2304
2319
  name: "canTransfer",
2305
2320
  type: "bool",
2306
2321
  internalType: "bool"
2322
+ },
2323
+ {
2324
+ name: "canMint",
2325
+ type: "bool",
2326
+ internalType: "bool"
2327
+ },
2328
+ {
2329
+ name: "spendingApproval",
2330
+ type: "uint256",
2331
+ internalType: "uint256"
2307
2332
  }
2308
2333
  ],
2309
2334
  outputs: [],
@@ -2511,22 +2536,6 @@ const optionsMarketAbi = [
2511
2536
  ],
2512
2537
  anonymous: false
2513
2538
  },
2514
- {
2515
- type: "event",
2516
- name: "FeesWithdrawn",
2517
- inputs: [{
2518
- name: "fees0",
2519
- type: "uint256",
2520
- indexed: false,
2521
- internalType: "uint256"
2522
- }, {
2523
- name: "fees1",
2524
- type: "uint256",
2525
- indexed: false,
2526
- internalType: "uint256"
2527
- }],
2528
- anonymous: false
2529
- },
2530
2539
  {
2531
2540
  type: "event",
2532
2541
  name: "MintOption",
@@ -2653,6 +2662,18 @@ const optionsMarketAbi = [
2653
2662
  type: "bool",
2654
2663
  indexed: false,
2655
2664
  internalType: "bool"
2665
+ },
2666
+ {
2667
+ name: "canMint",
2668
+ type: "bool",
2669
+ indexed: false,
2670
+ internalType: "bool"
2671
+ },
2672
+ {
2673
+ name: "spendingApproval",
2674
+ type: "uint256",
2675
+ indexed: false,
2676
+ internalType: "uint256"
2656
2677
  }
2657
2678
  ],
2658
2679
  anonymous: false
@@ -2719,6 +2740,11 @@ const optionsMarketAbi = [
2719
2740
  name: "NotEnoughPayout",
2720
2741
  inputs: []
2721
2742
  },
2743
+ {
2744
+ type: "error",
2745
+ name: "OperatorBlacklisted",
2746
+ inputs: []
2747
+ },
2722
2748
  {
2723
2749
  type: "error",
2724
2750
  name: "OptionExpired",
@@ -2813,4 +2839,4 @@ Object.defineProperty(exports, 'uniswapMathLensAbi', {
2813
2839
  return uniswapMathLensAbi;
2814
2840
  }
2815
2841
  });
2816
- //# sourceMappingURL=optionsMarket-C5z_ZrhG.cjs.map
2842
+ //# sourceMappingURL=optionsMarket-D192aXEZ.cjs.map