enrich balancer_v3 trades on dex.trades #7350
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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