Skip to content
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

[BUG] token_mint_address in tokens_solana.transfers is different on solscan #6690

Open
0xroll opened this issue Sep 8, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@0xroll
Copy link
Contributor

0xroll commented Sep 8, 2024

Description

token_mint_address in tokens_solana.transfers is different on solscan .

some examples in the discord thread https://discord.com/channels/757637422384283659/1281025587405787177/1282371830186774651

Current behavior

token_mint_address showing a different address

Expected behavior

addresses should match with solana explorers

Impacted model(s)

https://github.com/duneanalytics/spellbook/blob/main/dbt_subprojects/solana/models/tokens/solana/tokens_solana_transfers.sql#L66

Possible solution

havnt thought of a solution yet, just creating this issue to track

@0xroll 0xroll added the bug Something isn't working label Sep 8, 2024
@tentabs00
Copy link

here are two specific transactions with a different dune token address than what solscan shows:

Transaction 1

  • transaction signature: 2tjLmmksKz636jKacMoNnGKTvUdBCSWsUtzuswGskXae8PNa9Gr1Qb2XZdRtK5ne4BR7oB8mryV2RN6t8bqiULCP
  • token contract address per solscan: MNDEFzGvMt87ueuHvVU9VcTqsAP5b3fTGPsHuuPA5ey
  • token mint address per dune: DriFtupJYLTosbwoN8koMbEYSx54aFAVLddWsbksjwg7
  • dune query showing incorrect token mint address:
from tokens_solana.transfers t
where t.block_date = cast('2024-07-21' as date) -- date filter to improve performance
and t.tx_id = '2tjLmmksKz636jKacMoNnGKTvUdBCSWsUtzuswGskXae8PNa9Gr1Qb2XZdRtK5ne4BR7oB8mryV2RN6t8bqiULCP' 

Transaction 2

  • transaction signature: 47JfrTa9NaPQJmzQM1sJ8JcUbsSDAycjuABV1GxT3bZNQesQSNamtEWWyKFYt81SvEqP9gkvgEyw1KNGaxHsteLk
  • token contract address per solscan: MNDEFzGvMt87ueuHvVU9VcTqsAP5b3fTGPsHuuPA5ey
  • token mint address per dune: EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
  • dune query showing incorrect token mint address:
select *
from tokens_solana.transfers t
where t.block_date = cast('2024-04-15' as date) -- date filter to improve performance
and t.tx_id = '47JfrTa9NaPQJmzQM1sJ8JcUbsSDAycjuABV1GxT3bZNQesQSNamtEWWyKFYt81SvEqP9gkvgEyw1KNGaxHsteLk'

Query to retrieve negative balances

here is a dune query showing all negative balances for the MNDE solana token, you can remove the token filter in the first CTE to assess all tokens

-- filtering to only a set of tokens to improve performance
-- you can remove this to see the results for all tokens
with transfers_filtered as (
    select *
    from tokens_solana.transfers t
    where t.token_mint_address in (
        'MNDEFzGvMt87ueuHvVU9VcTqsAP5b3fTGPsHuuPA5ey'
    )
),
-- aggregate wallet-level transfers by counting transfers in as positive and transfers out as negative
wallet_transfers as (
    select 'solana' as chain
    ,t.block_time
    ,t.from_token_account as wallet_address
    ,-t.amount as transfer_amount
    ,token_mint_address
    from transfers_filtered t
    
    union all
    
    select 'solana' as chain
    ,t.block_time
    ,t.to_token_account as wallet_address
    ,t.amount as transfer_amount
    ,token_mint_address
    from transfers_filtered t
),

-- calculate wallet balances by summing net transfers over time for each wallet
wallet_balances as (
    select chain
    ,block_time
    ,wallet_address
    ,token_mint_address
    ,transfer_amount
    ,sum(transfer_amount) over (partition by chain,wallet_address,token_mint_address order by block_time asc) as balance
    from wallet_transfers
)

select chain
,token_mint_address
,wallet_address
,min(balance) as lowest_balance
from wallet_balances

-- filter to balances below -1 rather than 0 to filter any rounding errors
where balance < -1
group by 1,2,3
order by 1,2,4 desc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants