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

[Feature] Declarative Calls Feedback #5445

Open
1 of 2 tasks
melotik opened this issue May 28, 2024 · 4 comments
Open
1 of 2 tasks

[Feature] Declarative Calls Feedback #5445

melotik opened this issue May 28, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@melotik
Copy link

melotik commented May 28, 2024

Description

I spent some time trying to add declarative calls (#5264) to messari's compound v3 subgraph as it uses a lot of eth_calls. I wasn't able to fully test any of this yet due to this blocker (#5444), however I had some feedback or requests for use cases that showed up when I was working to cut over the subgraph to use declarative calls.

  • Using an eth_call as input for another eth_call, here is a real example:
const utilization = cometContract.getUtilization();
const borrowRate = cometContract.getBorrowRate(utilization).toBigDecimal();
const supplyRate = cometContract.getSupplyRate(utilization).toBigDecimal();
  • Multiple calls on one handler for the same function call with different input:
calls:
	Comet.totalsBasic: Comet[event.address].totalsBasic(event.params.liquidator)
	Come.totalsBasic: Comet[event.address].totalsBasic(event.params.borrower)

Note: This may be possible to do already, but I am not sure

Are you aware of any blockers that must be resolved before implementing this feature? If so, which? Link to any relevant GitHub issues.

#5444

Some information to help us out

  • Tick this box if you plan on implementing this feature yourself.
  • I have searched the issue tracker to make sure this issue is not a duplicate.
@melotik melotik added the enhancement New feature or request label May 28, 2024
@juanmardefago
Copy link

I've been playing a bit with declarative eth_calls too, and while doing so I also got into a similar situation, not entirely the same, but close.

Due to the limitations on what you can declare (only event.address or event.params.), I couldn't get my refactor to work, since the value I want to use for the contract address part isn't in the event.address or the params, but rather as either a field in a particular entity at that moment in time, or (by doing some workarounds) as a hardcoded value).

I'm thinking it's virtually the same issue described here in the first bullet point, even if the value to be used isn't really a response from a previous contract, but rather a hardcoded value/value from an already existing entity.

@azf20
Copy link
Contributor

azf20 commented May 30, 2024

Thanks both this is great feedback.
@lutter what do you think on the "dependent calls" case?
@juanmardefago can you share a link to the existing handler so we can take a look at the "entity field input" example?

@lutter
Copy link
Collaborator

lutter commented Jun 3, 2024

It's already possible to have multiple calls on the same event handler. Just give it different labels, and that works; something like

calls:
        totalsBasicLiquidator: Comet[event.address].totalsBasic(event.params.liquidator)
        totalsBasicBorrower: Comet[event.address].totalsBasic(event.params.borrower)

The things that are not supported yet are:

  1. Using the result of one call as the input for another
  2. Using a fixed value (Contract['0xdeadbeef'].function())
  3. Accessing more data than just the event, like entities from the database. This one might be pretty complicated. @juanmardefago could you sketch out in more detail what exactly you need to access there, like where does the id for the entity you need to look up come from?

@juanmardefago
Copy link

An example of why we would want to have either hardcoded values or dynamic values would be this one
In this case, we take the value from an internal constant (so it could be hardcoded) but it could also be taken from the entity itself, so there might be some potential use cases where the value isn't always potentially hardcoded, as it might change over time, but it's not part of the event, but rather stored in an entity, and by the time the call needs to be done, the address to be used in the call needs to be retrieved from that entity.

Currently, you can't do declarative calls if it happens to have any of those two cases unfortunately (the core network subgraph's most used eth_call is the first example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants