Skip to content

Commit

Permalink
fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
mzywang committed Apr 24, 2024
1 parent b81a7ed commit d1e1ec3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/utils/pricing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,32 @@ import { ONE_BD, ZERO_BD, ZERO_BI } from './constants'
const WETH_ADDRESS = '0x4200000000000000000000000000000000000006'
const USDC_WETH_05_POOL = '0x4c36388be6f416a29c8d8eee81c771ce6be14b18'

const USDC_ADDRESS = '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913'

// token where amounts should contribute to tracked volume and liquidity
// usually tokens that many tokens are paired with s
export const WHITELIST_TOKENS: string[] = [
WETH_ADDRESS, // WETH
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', // USDC
]
export const WHITELIST_TOKENS: string[] = [WETH_ADDRESS, USDC_ADDRESS]

const STABLE_COINS: string[] = [
'0x833589fcd6edb6e08f4c7c32d4f71b54bda02913', // USDC
]
const STABLE_COINS: string[] = [USDC_ADDRESS]

const MINIMUM_ETH_LOCKED = BigDecimal.fromString('1')

const Q192 = BigInt.fromI32(2).pow(192 as u8)
export function sqrtPriceX96ToTokenPrices(sqrtPriceX96: BigInt, token0: Token, token1: Token): BigDecimal[] {
const num = sqrtPriceX96.times(sqrtPriceX96).toBigDecimal()
const denom = BigDecimal.fromString(Q192.toString())
const price1 = num.div(denom).times(exponentToBigDecimal(token0.decimals)).div(exponentToBigDecimal(token1.decimals))
const price1 = num
.div(denom)
.times(exponentToBigDecimal(token0.decimals))
.div(exponentToBigDecimal(token1.decimals))

const price0 = safeDiv(BigDecimal.fromString('1'), price1)
return [price0, price1]
}

export function getEthPriceInUSD(): BigDecimal {
// fetch eth prices for each stablecoin
const usdcPool = Pool.load(USDC_WETH_05_POOL) // dai is token0
const usdcPool = Pool.load(USDC_WETH_05_POOL) // usdc is token1
if (usdcPool !== null) {
return usdcPool.token1Price
} else {
Expand Down

0 comments on commit d1e1ec3

Please sign in to comment.