unit test for usdc/usdt bug
this function https://github.com/Uniswap/v3-subgraph/blob/1394f592aa84970ab5c4e30e2f7d0b5a02c57b89/src/utils/pricing.ts#L139 seems to be improperly setting the amountUSD on some transactions
e.g.
query swaps {
token0: token(
id: "0xaf88d065e77c8cc2239327c5edb3a432268e5831"
block: {number: 242204912}
) {
derivedETH
decimals
name
id
symbol
}
token1: token(
id: "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
block: {number: 242204912}
) {
derivedETH
decimals
name
id
symbol
}
bundle(id: 1, block: {number: 242204912}) {
ethPriceUSD
}
txbad: transaction(
id: "0x67af911966300410dad78d13e267fdf2087324936d1908ba3f33342af6e299c1"
) {
blockNumber
swaps {
pool {
id
}
id
amount0
amount1
amountUSD
timestamp
token0 {
id
}
token1 {
id
}
}
}
txgood: transaction(
id: "0x5a6e6b99ee6301f11d5364607eb804e4268017c9ffc24f9841433fd6f78ef79f"
) {
blockNumber
swaps {
pool {
id
}
id
amount0
amount1
amountUSD
timestamp
token0 {
id
}
token1 {
id
}
}
}
}
returns
{
"data": {
"token0": {
"derivedETH": "2669.979626355292546166595518605033",
"decimals": "6",
"name": "USD Coin",
"id": "0xaf88d065e77c8cc2239327c5edb3a432268e5831",
"symbol": "USDC"
},
"token1": {
"derivedETH": "0.0003744164522094601418461514372116161",
"decimals": "6",
"name": "Tether USD",
"id": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",
"symbol": "USDT"
},
"bundle": {
"ethPriceUSD": "2670.8228073283731558117071429452"
},
"txbad": {
"blockNumber": "242204912",
"swaps": [
{
"pool": {
"id": "0xbe3ad6a5669dc0b8b12febc03608860c31e2eef6"
},
"id": "0x67af911966300410dad78d13e267fdf2087324936d1908ba3f33342af6e299c1-10",
"amount0": "-2485.252684",
"amount1": "2484.716359",
"amountUSD": "17724213458.56511027447931244914891",
"timestamp": "1723494221",
"token0": {
"id": "0xaf88d065e77c8cc2239327c5edb3a432268e5831"
},
"token1": {
"id": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
}
}
]
},
"txgood": {
"blockNumber": "250044227",
"swaps": [
{
"pool": {
"id": "0xbe3ad6a5669dc0b8b12febc03608860c31e2eef6"
},
"id": "0x5a6e6b99ee6301f11d5364607eb804e4268017c9ffc24f9841433fd6f78ef79f-22",
"amount0": "5160",
"amount1": "-5159.740061",
"amountUSD": "5159.740061",
"timestamp": "1725464839",
"token0": {
"id": "0xaf88d065e77c8cc2239327c5edb3a432268e5831"
},
"token1": {
"id": "0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"
}
}
]
}
}
}
for the bad transaction, it seems like it's taking token0's price and for the good transaction it seems to be taking token1's price even though it should only be taking token1's price based on configured list of whitelistedTokens
https://github.com/Uniswap/v3-subgraph/blob/1394f592aa84970ab5c4e30e2f7d0b5a02c57b89/src/utils/chains.ts#L90
This stack of pull requests is managed by Graphite. Learn more about stacking.
Join @mzywang and the rest of your teammates on
Graphite