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

Make Ponder the source for truth #6

Open
carletex opened this issue Jan 17, 2025 · 4 comments
Open

Make Ponder the source for truth #6

carletex opened this issue Jan 17, 2025 · 4 comments
Assignees

Comments

@carletex
Copy link
Contributor

carletex commented Jan 17, 2025

Currently, we have 2 sources that we use for cohorts / withdrawal data.

  1. Ponder (this repo)

  2. A custom indexer we created for BGv3.

BGv3 saves the data like this:

Image


So I'd like to use this Ponder as the source of truth and sunset the BGv3 indexer. Then move any "client" that is using the BGv3 indexer to GraphQL requests to Ponder.

For that, we would need to store a few things:

  • Name + URL
  • Balance (update whenever someone withdraws?)

I haven't explored what's the best way to go about it in Ponder, but would love to hear options!

@damianmarti
Copy link
Member

We can add a new table to the Ponder schema for cohort information, using the cohortContractAddress as the primary key and foreign key to the builders.

The cohort name and URL may be saved manually (or using a UI) to this table.

And then we can get that information from the same Ponder GraphQL endpoint.

I'm checking the Ponder doc to see if there is a better option...

@carletex The balance is the balance from the cohort contract, right? We can add a call to read the balance when indexing a new withdrawal and update a balance in the cohorts table. We have to listen to transfers to the contract too, Ponder has a new feature for this (https://ponder.sh/docs/accounts)

@damianmarti
Copy link
Member

Or we can create a Ponder API endpoint returning the same format used by the current BGv3 indexer, and get the cohort information from a JSON (since we need to add each cohort address to Ponder config to be indexed, we can add the name and the URL too).

@carletex
Copy link
Contributor Author

I think I like the option of creating a new table definition in the schema more since it seems that it'd be better integrated, and we can compose better queries from the clients

And yeah, maybe we have to manually insert the data. Asked the same in #5 , but maybe there is a Ponder way of doing some seeding/migration scripts/etc.

@damianmarti
Copy link
Member

There is a custom setup event that can be used like a seeding but it's not exactly what we need https://ponder.sh/docs/api-reference/indexing-functions#setup-event

I think that a fancy way to add the cohort name and url is to have a contract and some owners can add cohorts there, the contract throws an event with the cohort address, name, and url, and Ponder indexes this event.

Maybe we can get the cohorts' addresses from this contract too, and we avoid having to add this on ponder config manually.

What do you think?

@damianmarti damianmarti self-assigned this Jan 17, 2025
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

No branches or pull requests

2 participants