Skip to content

Commit

Permalink
feat: include tickValue in liquidity pool - this is the eth price for…
Browse files Browse the repository at this point in the history
… the current tick
  • Loading branch information
jackmellis committed Feb 1, 2024
1 parent efdd975 commit 0d44ee8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const createStub = ({
name: `${vault.token.symbol} ${feePercentage * 100}% Pool`,
periodFees: { '1m': Zero, '24h': Zero, '7d': Zero, '1y': Zero },
tick: Zero,
tickValue: Zero,
tokens: [
{ ...vault.token, balance: Zero },
{ id: wethAddress, name: 'Wrapped Ether', symbol: 'WETH', balance: Zero },
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/pools/fetchLiquidityPools/transformPool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
} from '@nftx/utils';
import { parseEther } from 'viem';
import calculateAprs from './calculateAprs';
import { calculatePriceFromTick } from '../../univ3-helpers';

type Pool = LiquidityPoolsResponse['liquidityPools'][0];

Expand Down Expand Up @@ -57,6 +58,7 @@ const transformPool = (
const activeLiquidity = BigInt(pool.activeLiquidity ?? '0');
const totalLiquidity = BigInt(pool.totalLiquidity ?? '0');
const tick = BigInt(pool.tick ?? '0');
const tickValue = calculatePriceFromTick(tick);
const feePercentage = Number(
pool.fees.find((fee) => fee.feeType === 'FIXED_TRADING_FEE')
?.feePercentage ?? 0
Expand Down Expand Up @@ -138,6 +140,7 @@ const transformPool = (
name: pool.name ?? '',
periodFees,
tick,
tickValue,
tokens,
totalLiquidity,
vaultAddress: vault.id,
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/pools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ export type LiquidityPool = {
}[];
/** The current tick that the pool is operating at */
tick: bigint;
/** The current tick price */
tickValue: bigint;
totalLiquidity: bigint;
activeLiquidity: bigint;
inRangeLiquidity: bigint;
Expand Down

0 comments on commit 0d44ee8

Please sign in to comment.