Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@clober/v2-sdk",
"version": "1.0.0-beta.34",
"version": "1.0.0-beta.35",
"description": "🛠 An SDK for building applications on top of Clober V2",
"files": [
"dist"
Expand Down
16 changes: 11 additions & 5 deletions src/entities/pool/apis/snapshot.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { formatUnits, getAddress } from 'viem'
import { formatUnits, getAddress, isAddressEqual } from 'viem'
import BigNumber from 'bignumber.js'

import { CHAIN_IDS } from '../../../constants/chain-configs/chain'
import { Currency, PoolSnapshot } from '../../../types'
import { Subgraph } from '../../../constants/chain-configs/subgraph'
import { getContractAddresses } from '../../../views'
import { UserPoolPosition } from '../types'
import { STABLE_COINS } from '../../../constants/chain-configs/currency'

type PoolDto = {
id: string
Expand Down Expand Up @@ -114,17 +115,22 @@ export const fetchPoolSnapshotFromSubgraph = async (
BigInt(pool.initialTokenBAmount),
Number(pool.tokenB.decimals),
)
const isQuoteStable = (STABLE_COINS[chainId] ?? []).some((stableCoin) =>
isAddressEqual(stableCoin.address, currencyB.address),
)
const initialTotalSupply = formatUnits(BigInt(pool.initialTotalSupply), 18)
const performanceHistories = poolDayDatas
.map((poolDayData, index) => {
const priceAUSD =
index === 0 && currencyAPrice
const priceAUSD = isQuoteStable
? '1'
: index === 0 && currencyAPrice
? currencyAPrice.toString()
: pool.tokenA.tokenDayData.find(
({ date }) => date === poolDayData.date,
)?.priceUSD ?? '0'
const priceBUSD =
index === 0 && currencyBPrice
const priceBUSD = isQuoteStable
? poolDayData.priceB
: index === 0 && currencyBPrice
? currencyBPrice.toString()
: pool.tokenB.tokenDayData.find(
({ date }) => date === poolDayData.date,
Expand Down
Loading