Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Utilize on chain data for token price pool graph #2356

Merged
merged 4 commits into from
Aug 21, 2024

Conversation

kattylucy
Copy link
Collaborator

@kattylucy kattylucy commented Aug 8, 2024

Description

  • Utilize on chain data for token price & nav
  • Keep only months on graph regarding data length to maintain consistency
  • Show only one month per internal, do not repeat month or skip months

#2312
#2310

Approvals

  • Dev

Copy link

github-actions bot commented Aug 8, 2024

PR deployed in Google Cloud
URL: https://app-pr2356.k-f.dev
Commit #: b3404ab
To access the functions directly check the corresponding deploy Action

Copy link

github-actions bot commented Aug 8, 2024

PR deployed in Google Cloud
URL: https://pr2356-app-ff-production.k-f.dev
Commit #: b3404ab
To access the functions directly check the corresponding deploy Action

Copy link
Collaborator

@sophialittlejohn sophialittlejohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there still seems to be a discrepancy between the token prices displayed - I'm seeing three different token prices on the page (above the chart, in the chart tooltip for today, underneath the chart in the blue box).I think it would help to replace the last day of the subquery data in the chart with chain data from today?

@kattylucy
Copy link
Collaborator Author

Hmmm that's weird. I will double check. It seems we want to move away from the subquery for this one.

Thank you for checking!! @sophialittlejohn

@kattylucy kattylucy force-pushed the use_onchain_data_for_token_price branch 2 times, most recently from feb8bc7 to 695abdd Compare August 13, 2024 16:40
@kattylucy kattylucy requested review from sophialittlejohn and removed request for onnovisser August 13, 2024 19:41
Copy link
Collaborator

@sophialittlejohn sophialittlejohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest a slightly different approach:

  const todayPrice = pool?.tranches[pool.tranches.length - 1].tokenPrice?.toDecimal().toNumber() || null
  const todayNav = pool.nav.total.toDecimal().toNumber()

  const isSingleTranche = pool?.tranches.length === 1
  const data: ChartData[] = React.useMemo(
    () =>
      truncatedPoolStates?.map((day) => {
        const nav = day.poolState.netAssetValue.toDecimal().toNumber()
        const price = (isSingleTranche && Object.values(day.tranches)[0].price?.toFloat()) || null
        // Replace the data as it's being created for the chart so that data stays consistent with the UI
        if (day.timestamp && new Date(day.timestamp).toDateString() === new Date().toDateString()) {
          return { day: new Date(day.timestamp), nav: todayNav, price: todayPrice }
        }
        return { day: new Date(day.timestamp), nav, price }
      }) || [],
    [isSingleTranche, truncatedPoolStates]
  )

@kattylucy kattylucy force-pushed the use_onchain_data_for_token_price branch from 695abdd to 295db3a Compare August 20, 2024 13:38
Copy link
Collaborator

@sophialittlejohn sophialittlejohn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@kattylucy kattylucy merged commit b6f242d into main Aug 21, 2024
13 checks passed
@kattylucy kattylucy deleted the use_onchain_data_for_token_price branch August 21, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants