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

enrich balancer_v3 trades on dex.trades #7350

Merged
merged 9 commits into from
Dec 20, 2024

Conversation

viniabussafi
Copy link
Contributor

@viniabussafi viniabussafi commented Dec 18, 2024

Description:

Balancer V3 was launched a week ago and has 100% Boosted Pools as one of it's flagships. The complication we're facing here is, when ERC4626 tokens (see ELI5) are traded against other ERC4626 tokens, the amount_usd column in dex.trades is null.
This PR introduces the same logic currently used on balancer.trades to dex.trades, using a new macro to handle swaps on Balancer V3.
I'd hate to be the one to break dex.trades, so 100% open for suggestions here, this is just an initial idea.

ELI5 on ERC4626 tokens

the ELI5 is that these tokens are basically receipt tokens from deposits into lending protocols (like aave and morpho). This means that liquidity providers can deposit into a pool with Wrapped AAVE wstETh / Wrapped AAVE WETH. So, the path would be the LP would deposit weth and/or wsteth and get exposed to both the yields on AAVE for both tokens + swap fees on swaps happening on the pool.
These tokens are priced based on how much Wrapped AAVE WETH you get after depositing WETH (on wrap and unwrap events), multiplied by the price of WETH at that time, like we do here
That's why these tokens aren't on coinpaprika (and probably will never be).

Example of 100% Boosted Pools: https://balancer.fi/pools/ethereum/v3/0xc4ce391d82d164c166df9c8336ddf84206b2f812
Current trades where amount_usd = 0 on dex.trades: https://dune.com/queries/4445360

tagging @mendesfabio for visibility/comments

@viniabussafi viniabussafi changed the title enrich balancer_v3 trades enrich balancer_v3 trades on dex.trades Dec 18, 2024
@github-actions github-actions bot added WIP work in progress dbt: dex covers the DEX dbt subproject labels Dec 18, 2024
@viniabussafi viniabussafi marked this pull request as ready for review December 18, 2024 11:40
@github-actions github-actions bot added ready-for-review this PR development is complete, please review and removed WIP work in progress labels Dec 18, 2024
@Hosuke Hosuke self-assigned this Dec 19, 2024
@0xRobin 0xRobin self-assigned this Dec 20, 2024
Copy link
Collaborator

@0xRobin 0xRobin left a comment

Choose a reason for hiding this comment

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

We might look to build out a generic ERC4626 prices table and incorporate this in the main prices tables so we don't need separate enriching logic. For now, this workaround is sufficient.

@0xRobin 0xRobin added ready-for-merging and removed ready-for-review this PR development is complete, please review labels Dec 20, 2024
@0xRobin 0xRobin merged commit c77a2bc into duneanalytics:main Dec 20, 2024
5 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
dbt: dex covers the DEX dbt subproject ready-for-merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants