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.35",
"version": "1.0.0-beta.36",
"description": "🛠 An SDK for building applications on top of Clober V2",
"files": [
"dist"
Expand Down
29 changes: 16 additions & 13 deletions src/entities/pool/apis/snapshot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,28 @@ export const fetchPoolSnapshotFromSubgraph = async (
Number(pool.tokenB.decimals),
)
const isQuoteStable = (STABLE_COINS[chainId] ?? []).some((stableCoin) =>
isAddressEqual(stableCoin.address, currencyB.address),
isAddressEqual(stableCoin.address, currencyA.address),
)
const initialTotalSupply = formatUnits(BigInt(pool.initialTotalSupply), 18)
const performanceHistories = poolDayDatas
.map((poolDayData, index) => {
const priceAUSD = isQuoteStable
? '1'
: index === 0 && currencyAPrice
const priceAUSD =
index === 0 && currencyAPrice
? currencyAPrice.toString()
: pool.tokenA.tokenDayData.find(
({ date }) => date === poolDayData.date,
)?.priceUSD ?? '0'
const priceBUSD = isQuoteStable
? poolDayData.priceB
: index === 0 && currencyBPrice
: isQuoteStable
? '1'
: pool.tokenA.tokenDayData.find(
({ date }) => date === poolDayData.date,
)?.priceUSD ?? '0'

const priceBUSD =
index === 0 && currencyBPrice
? currencyBPrice.toString()
: pool.tokenB.tokenDayData.find(
({ date }) => date === poolDayData.date,
)?.priceUSD ?? '0'
: isQuoteStable
? poolDayData.priceB
: pool.tokenB.tokenDayData.find(
({ date }) => date === poolDayData.date,
)?.priceUSD ?? '0'

const onHoldUSDValuePerLp = new BigNumber(initialTokenAAmount)
.multipliedBy(priceAUSD)
Expand Down
Loading