-
Notifications
You must be signed in to change notification settings - Fork 2
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
AMMs LP history #142
base: main
Are you sure you want to change the base?
AMMs LP history #142
Conversation
…detailed reserves
@PoloX2021 Could you fix the linting issues? |
Done. I'm not sure how to fix the linting for |
Co-authored-by: Haris Angelidakis <64154020+harisang@users.noreply.github.com>
select varbinary_substring(topic1, 1 + 12, 20) as address | ||
from {{blockchain}}.logs | ||
where ( | ||
contract_address in ( --the factory contracts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A slightly cleaner way of doing this would be to define a factory_contracts table where each row has an address and blockchain column. But i guess this is a bit of an overkill.
Co-authored-by: Haris Angelidakis <64154020+harisang@users.noreply.github.com>
Co-authored-by: Haris Angelidakis <64154020+harisang@users.noreply.github.com>
…otocol/dune-queries into amm_lp_prices_materialized
0xe0e2ba143ee5268da87d529949a2521115987302, --arbitrum | ||
0x03362f847B4fAbC12e1Ce98b6b59F94401E4588e --base | ||
) | ||
and topic0 = 0x0d03834d0d86c7f57e877af40e26f176dc31bd637535d4ba153d1ac9de88a7ea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice to have: some reference that confirms this is the topic we are looking for
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a link to an example of bind events & cow amm created events, but I've never really found the documentation about it.
(price0.blockchain = '{{blockchain}}' or price0.blockchain is null) | ||
and (price1.blockchain = '{{blockchain}}' or price0.blockchain is null) | ||
and d.day >= date_trunc('day', p.created_at) | ||
from ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks a bit strange. I don't think the "select * from (select ....) this is needed, and you should instead simply have
"select...."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't sure about how to do it efficiently. Basically, I want to filter by the final condition (where latest_first = 1
) AFTER doing all the other operations. If you add the filtering in the where statement, then it happens before which gives a different result.
If there's another way to do it I'd be glad to learn about it.
where latest_first = 1 | ||
) | ||
|
||
select * |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above
The goal of the PR is to create one materialized view which stores the historical state of CoW AMMs and competitors.
This will speed up the queries on each pool.
This first version only gets the data for CoW AMM, uniswap, pancakeswap and sushiswap. It'll be possible to add other pools later on, using the same methodology and aggregating it in the final materialized view (e.g. Balancer & Curve).
This new version also adds the weights of the pools