Fee data for Curve is not currently available.
I’ll keep this top post updated with the status of the Curve adapter.
Fee data for Curve is not currently available.
I’ll keep this top post updated with the status of the Curve adapter.
Curve fees are quite complicated, therefore much more difficult to track than simpler AMMs like Uniswap.
First of all, fees are not only charged on swaps, but also when assets are implicitly swapped when adding/withdrawing liquidity in imbalanced amounts.
Furthermore, while older Curve pools used flat fee rates (similar to Uniswap), newer pools use dynamic fees, that are adjusted based on the balance of the pool and the assets being traded.
The bad news is that any subgraph indexing this data will probably have to re-implement some of the Curve math inside the subgraph code. But the good news is that Curve doesn’t use any really esoteric math libraries like Uniswap V3 and Yield use.
Another approach is to try to derive the total fee from the amount of the “admin fee” that was charged.
We can do this by storing the admin fee balance, and on each transaction calculating this:
tx_admin_fee = admin_fee_balance_current - admin_fee_balance_before;
tx_fee = tx_admin_fee / admin_fee_percentage