-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Migrate and fix token transfers #4521
Comments
fyi @henrystats @tomfutago @primatepngs @lajarre we are looking to standardize these spells, with a consistent approach across evm chains leveraging macros. first step, as noted in the issue, fix transfers. then we can look into balances. |
I've always been a bit confused as to what the purpose is for these transfers models. |
yeah @0xRobin I believe that's the main goal, plus that's how folks build balances on dune itself. We have an aggregate table to get the sum value of transactions within an hour/day for a wallet_address, so that can be negative or positive, and since there are two columns we need to look at (both "from" & "to") we need to dedupe the aggregation. It seems easier to do that at the transfers level before doing the sum. We never used the transfers.erc20 table for anything other than building the balances spell... Also, I have a couple of pr's open for other chains (all of them actually except celo) lmk if I should close them. I was going to edit and use macros for them. |
@henrystats yeah I noticed that shortly after writing this. I think unit256 is the way to go but will investigate. |
regarding the purpose, yes this is a intermediary table originally but happens to be exposed now. I suspect we don’t need as many intermediary tables/views for balances (the agg + rolling, maybe we don’t need both) anymore since we will materialize and performance is much better |
oke then... |
Had a look at the types for Polygon to use |
Could we make this less ambiguous and find a more suitable name instead of
maybe something in the line of |
@0xRobin this is a very good point. erc20 transfers could then just be a view of |
ouuuu awesome! |
|
Looks good! Part of my PR #4074 is already suggesting some changes to macros:
But finally it seems we are awaiting #4522 to be done first. Shall I rather suggest these changes to be added to #4522 @aalan3 ? Also, I realized my PR and #4420 from @henrystats are dupes. My PR suggests fixes to tests already (thanks @Hosuke for the help!). But I'd happily contribute to whichever PR moves the needle faster.
Interesting analysis but trying to have in mind the expectations that a Dune user would have about data, it sounds like casting |
@lajarre thank you for the input. We've received a ton of feedback in the past about precision in balances it becomes worse when you sum things together.
This assumes that token contracts mostly use a total supply close to 2^256 which I don't think is the case. I looked at the 4k rows and it was mostly spam tokens. Either way I will forward this feedback internally to see if there's something we can do to fix these values as well. |
Ok, makes sense. I guess then that properly documenting the limitation would already help mitigate the potential issues from the users point of view. |
I've updated this a bit based on the changes for the balances issue. |
@hildobby this is based on fungible, I'll have a PR up shortly for ethereum so we can see what it looks like. One question is, should we add WETH-like deposits and withdraws to transfers as well? Did you plan on adding it and do you think it makes sense? It's needed to get balances right eventually. |
What do you mean? Like ETH <> WETH mints & burns? Those should be included afaik, right? |
Btw there are a lot of tokens which supports staking option and there are no easy way to properly determine balance of them. For example stETH (which is huge) E.g. for |
@grkhr I'm not sure how we can support those in balances given their implementation (which deviates from the ERC20 standard). Maybe we could do a |
I have no idea too, just adding some context :) Also it'd be nearly impossible to handle staking logic for top 10-20 tokens as it can be too sophisticated (1inch for example) |
I believe stETH is a rebase token and those were filtered from the balances spell originally, and still are, stETH just wasn't added to the rebase tokens list hence why it's still showing up. Getting stETH balances is a very long process, even on dune itself, I've not seen any query that gets the balances completely accurate (i.e the correct exact balance at the time), there has been some workaround that the stETH team created themselves, Hildobby also worked on one and that seems to be the approach to getting stETH balances for non contract addresses. I'd advise we filter them for now.. cc @grkhr @aalan3. I've also been inactive for a few weeks now as I was trying to deal with some personal issue.... I'm back working now, please do let me know how I can be of help here. |
@henrystats @grkhr I opened an issue to continue the discussion and organize the work #4735 since I think this is potentially separate from transfers (because there are not always transfers as mentioned above). |
We have transfers for all chains! The tables are queryable but not yet exposed in the data explorer. There's still some work left in getting gas fees in and wrapped tokens might be missing for some chains. |
With #4987 we now have a transfers table |
woohoo @aalan3 niceeeee... Thank you very much ser. These tables and the balances tables are going to very very important once they're live. I've been off spellbook for a while now and only just recently resumed, pls let me know if there's any way I can be of help. I'll check out the pr nowww! |
Nice, ty! Do those include nft transfers too? ![]() I can't seem to pull the table on Dune, are native token transfers included in there too? Joining ERC20s with native transfers is the most annoying thing to do in every query revolving around fungible tokens rn |
unfortunately, we had to revert the cross-chain token transfers :( the prod cluster had an issue trying to build it. it's been escalated to the engine team. |
Ah sorry I missed that the table was reverted 🤦♂️
@hildobby it's not included atm we just wanted to first finish the non nfts first. But we could add nft transfers pretty easily because it would basically just be reading what's in nft.transfers. I can create a new issue for this. |
looked through the reverted PR. it tries to join prices for all chains and materialize to one table as i'm not surprised that the prod cluster failed 😄 |
Also note that #4911 is still open, if someone has any input on how to include gas fees please provide it in the PR. |
@grkhr yeah we could also union the |
hmm sounds good, but ideally the end result is |
That's a good point. What I was thinking was that we can partition the table by token_standard (and blockchain), so if you'd like to query only nfts or skip native transfers for example you should still get almost the same performance as if it was a separate table. |
great point! i was naively trying to push that out quick & went against the new sector design 🤦♂️ i will try to take the correct approach this afternoon and see how that runs if it runs fine, we can revisit the points here on naming standards |
@jeff-dude already tried with BNB as the biggest one, CI seems fine you can try to merge it and see if it'll run well on prod. if yes, so releasing by chain in 3-4 PRs will pass easily. |
For nfts, I've already been using Also, how would the two joined work here? prices aren't really obtained at a transfer level for nfts currently afaik |
Prices would not be available for nfts just like they are not available for a lot of erc20 tokens. The table would be normalized and unioned together with existing transfers |
considering this done for now, as 13 chains are built and live we can start new issues to track enhancements and/or bug fixes |
Problem
We have a bunch of issues with
erc20.transfers
at the moment and we have been neglecting the fixes due to the migration. Right now the transfers tables are a bit all over the place with how they work and types, specially aroundamount_raw
. We want to clean these up so that we can fix balances.This issue exists to fix and migrate the spells and discuss the way forward.
Goal
The goal is for all evms to have a working transfers table that includes both ERC20 and native tokens (naming of table TBD) using a macro, so that implementation is the same (as much as possible) across chains.
We want to fix these so that we can then start to fix token balances and bring it back.
How
We want to base our implementation on the
fungible_transfers
which include native and ERC20 transfers.The main difference is that we want to build a base model which is materialized without metadata (prices and
erc20.tokens
), which we then enrich with metadata via a view. We still also want to have a main model that has all the chains as well.For each chain:
base_model
(materialized) -> metadata enrichment view (prices, erc20)JOIN on the transactions table
Right now we are forced to join on the transactions table to include
tx_from/to
andtx_index
since these are not available on the decoded tables. These columns are planned in the future and will be added for future blockchains. For example forbase
we already havetx_from/to
available on the events and for the next chain that's releasedtx_index
will also be available from the start.Related
Some bug issues:
#3431 - "from" is show literally as
from
instead of the actual address#3108 - Types are wrong but I think this one might be fixed?
There are also more than a few PRs open that addresses the transfers tables.
Plan
Might add more things to this.
The text was updated successfully, but these errors were encountered: