From 161da3fb83c37c60cf45894ffba6a9003b9d4c86 Mon Sep 17 00:00:00 2001 From: Michael Wang <44713145+mzywang@users.noreply.github.com> Date: Thu, 9 May 2024 13:24:42 -0400 Subject: [PATCH 1/2] update mainnet minimum_eth_locked --- .prettierrc | 6 ++++++ package.json | 5 ----- src/utils/pricing.ts | 9 ++++++--- 3 files changed, 12 insertions(+), 8 deletions(-) create mode 100644 .prettierrc diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..82e09f45 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "semi": false, + "singleQuote": true, + "printWidth": 120, + "trailingComma": "all" +} diff --git a/package.json b/package.json index 14867ded..975967ca 100644 --- a/package.json +++ b/package.json @@ -27,10 +27,5 @@ "npm-run-all": "^4.1.5", "prettier": "^1.18.2", "typescript": "^3.5.2" - }, - "prettier": { - "printWidth": 120, - "semi": false, - "singleQuote": true } } diff --git a/src/utils/pricing.ts b/src/utils/pricing.ts index bf9c49e6..1496054a 100644 --- a/src/utils/pricing.ts +++ b/src/utils/pricing.ts @@ -42,13 +42,16 @@ const STABLE_COINS: string[] = [ '0x4dd28568d05f09b02220b09c2cb307bfd837cb95', ] -const MINIMUM_ETH_LOCKED = BigDecimal.fromString('60') +const MINIMUM_ETH_LOCKED = BigDecimal.fromString('20') 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] @@ -132,7 +135,7 @@ export function getTrackedAmountUSD( tokenAmount0: BigDecimal, token0: Token, tokenAmount1: BigDecimal, - token1: Token + token1: Token, ): BigDecimal { const bundle = Bundle.load('1')! const price0USD = token0.derivedETH.times(bundle.ethPriceUSD) From 1b15d503c3cf3cbd34c5e9d693e3d5c85e1ba20b Mon Sep 17 00:00:00 2001 From: mzywang Date: Thu, 9 May 2024 17:25:32 +0000 Subject: [PATCH 2/2] fix(lint): auto-fix [ci] --- src/mappings/pool/collect.ts | 2 +- src/mappings/pool/swap.ts | 2 +- src/utils/pricing.ts | 5 +---- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/mappings/pool/collect.ts b/src/mappings/pool/collect.ts index cc4e8080..af71d561 100644 --- a/src/mappings/pool/collect.ts +++ b/src/mappings/pool/collect.ts @@ -35,7 +35,7 @@ export function handleCollect(event: CollectEvent): void { collectedAmountToken0, token0 as Token, collectedAmountToken1, - token1 as Token + token1 as Token, ) // Reset tvl aggregates until new amounts calculated diff --git a/src/mappings/pool/swap.ts b/src/mappings/pool/swap.ts index 1743b261..f20d680a 100644 --- a/src/mappings/pool/swap.ts +++ b/src/mappings/pool/swap.ts @@ -48,7 +48,7 @@ export function handleSwap(event: SwapEvent): void { // get amount that should be tracked only - div 2 because cant count both input and output as volume const amountTotalUSDTracked = getTrackedAmountUSD(amount0Abs, token0 as Token, amount1Abs, token1 as Token).div( - BigDecimal.fromString('2') + BigDecimal.fromString('2'), ) const amountTotalETHTracked = safeDiv(amountTotalUSDTracked, bundle.ethPriceUSD) const amountTotalUSDUntracked = amount0USD.plus(amount1USD).div(BigDecimal.fromString('2')) diff --git a/src/utils/pricing.ts b/src/utils/pricing.ts index 1496054a..1f53c9d7 100644 --- a/src/utils/pricing.ts +++ b/src/utils/pricing.ts @@ -48,10 +48,7 @@ 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]