@stake-dao/reader 0.2.20 → 0.2.21

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stake-dao/reader",
3
3
  "description": "",
4
- "version": "0.2.20",
4
+ "version": "0.2.21",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
7
7
  "type": "git",
@@ -1,4 +1,4 @@
1
- import { formatEther } from 'viem'
1
+ import { formatUnits } from 'viem'
2
2
 
3
3
  import { graphql } from '../../utils.js'
4
4
  import { SDCAKE_AIRDROP_GLOBAL_QUERY, SDCAKE_AIRDROP_GRAPH_URL } from './endpoints.js'
@@ -23,7 +23,7 @@ export const getCherriesLeaderBoard = async () => {
23
23
  )
24
24
  return {
25
25
  ...user,
26
- currentPoints: Number(formatEther(currentPoints)),
26
+ currentPoints: Number(formatUnits(currentPoints, 18)),
27
27
  }
28
28
  })
29
29
 
@@ -1,6 +1,6 @@
1
1
  import { ONE_YEAR, tokenWithId } from '@stake-dao/constants'
2
2
  import { chunk, uniqBy } from 'lodash-es'
3
- import { encodeAbiParameters, formatEther, formatUnits, parseAbiParameters, zeroAddress } from 'viem'
3
+ import { encodeAbiParameters, formatUnits, parseAbiParameters, zeroAddress } from 'viem'
4
4
  import { mainnet } from 'viem/chains'
5
5
  import { LLAMA_API_URL } from '../../../../endpoints.js'
6
6
  import { getLlamaTokenPrefix, getPricesFromCurve } from '../../../../prices.js'
@@ -125,7 +125,7 @@ export const getCurveApiData = async (rpc: string, chainId: number, gaugesWeight
125
125
  })
126
126
 
127
127
  const usdTotal = coinsWithUsdBalance.reduce((total: number, x) => (total += x.usdBalance), 0)
128
- const lpPriceInUsd = p.totalSupply > BigInt(0) ? usdTotal / Number(formatEther(p.totalSupply)) : 0
128
+ const lpPriceInUsd = p.totalSupply > BigInt(0) ? usdTotal / Number(formatUnits(p.totalSupply, 18)) : 0
129
129
 
130
130
  let gaugeFromPool = CUSTOM_GAUGES[p.lp] ? CUSTOM_GAUGES[p.lp] : p.gauge
131
131
  const gaugeData = gauges.find((g) => equalTlc(g.gauge, gaugeFromPool) || equalTlc(g.lpToken, p.lp))
@@ -139,9 +139,9 @@ export const getCurveApiData = async (rpc: string, chainId: number, gaugesWeight
139
139
  const active = gaugeData && gaugeWeightData && !gaugeData.isKilled
140
140
 
141
141
  if (active) {
142
- const inflationRate = Number(formatEther(BigInt(gaugeWeightData.inflationRate)))
143
- const relativeWeight = Number(formatEther(BigInt(gaugeWeightData.relativeWeight)))
144
- const workingSupply = Number(formatEther(gaugeData.workingSupply))
142
+ const inflationRate = Number(formatUnits(BigInt(gaugeWeightData.inflationRate), 18))
143
+ const relativeWeight = Number(formatUnits(BigInt(gaugeWeightData.relativeWeight), 18))
144
+ const workingSupply = Number(formatUnits(gaugeData.workingSupply, 18))
145
145
 
146
146
  if (lpPriceInUsd && lpPriceInUsd > 0 && workingSupply > 0) {
147
147
  minCrvApr =
@@ -185,7 +185,7 @@ export const getCurveApiData = async (rpc: string, chainId: number, gaugesWeight
185
185
  isLending,
186
186
  lp: p.lp,
187
187
  pool: p.pool,
188
- totalSupply: formatEther(p.totalSupply),
188
+ totalSupply: formatUnits(p.totalSupply, 18),
189
189
  coins: coinsWithUsdBalance,
190
190
  underlyingCoins: p.underlyingCoins,
191
191
  usdTotal,
@@ -1,5 +1,5 @@
1
1
  import { chunk } from 'lodash-es'
2
- import { formatEther, formatUnits } from 'viem'
2
+ import { formatUnits } from 'viem'
3
3
 
4
4
  import { ONE_YEAR, yearnStrats } from '@stake-dao/constants'
5
5
  import multicallYearnStratsAbi from '../../../abis/yearnVaultsMulticall.js'
@@ -163,7 +163,7 @@ export const fetchYearn = async ({
163
163
  ]
164
164
 
165
165
  const sdGaugeTotalSupply = chunkedRawData[index][10].result
166
- const tvl = Number(formatEther(sdGaugeTotalSupply)) * lpPriceInUsd
166
+ const tvl = Number(formatUnits(sdGaugeTotalSupply, s.lpToken.decimals)) * lpPriceInUsd
167
167
 
168
168
  const rewardsData: RewardsData[] = s.rewards.map((rewardToken: any) => {
169
169
  const fetchedRewardData = rewardsRawData.shift().result