duneanalytics / duneanalytics/spellbook

[BUG] Incorrect token address for curve trades on metapool

Open
#8,376 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.5k
Forks
1.4k
Avg merge
3d 16h
Merged PRs (30d)
22

Description

Description

In curve metapool when the buy token(j) index is 0 the token sold is added to underlying liquidity pool and the token amount for sold token(i) reflected in the TokenExchangeUnderlying event is the amount of lp tokens that were minted when the sold token was added to liqudity pool instead of token sold amount of the actual underlying token.

Current behavior
Image `tokens_sold : 2308540548419464479212` is the number of lp token minted and not the actual amount of token sold. Actual token sold amount is `2316461131 USDC` Image https://app.blocksec.com/explorer/tx/eth/0x9f03f9982741b2f2f44c3776c26cc894acb6473f37cf2dc6b5c488f08bb3e953 Dune Query: https://dune.com/queries/5303926 Spellbook: https://github.com/duneanalytics/spellbook/blob/ca7d2804ce820b6c43064111e8710362c337e0c8/dbt_subprojects/dex/models/trades/ethereum/platforms/curve_ethereum_base_trades.sql#L24-L49
Expected behavior

The token_sold_address should be either the LP token, or token_sold_amount_raw should be the real amount of underlying tokens that were sold.
https://etherscan.io/tx/0x9f03f9982741b2f2f44c3776c26cc894acb6473f37cf2dc6b5c488f08bb3e953#eventlog

Impacted model(s)
dex.trades
Possible solution

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dbt_subprojects/dex/models/trades/ethereum/platforms/curve_ethereum_base_trades.sql around lines 24-49, then inspect the linked transaction’s TokenExchangeUnderlying event and compare it with the Dune query. Verify how buy-token index 0 is handled in Curve metapool trades and confirm that index.trades reports either the LP token address or the actual underlying token amount consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql
Domain
data-engineering
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.