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

Incorrect Supply Saved on Fungible Assets #200

Closed
kespinola opened this issue Jul 18, 2024 · 0 comments · Fixed by #201
Closed

Incorrect Supply Saved on Fungible Assets #200

kespinola opened this issue Jul 18, 2024 · 0 comments · Fixed by #201
Assignees
Labels
bug Something isn't working

Comments

@kespinola
Copy link
Collaborator

kespinola commented Jul 18, 2024

Issue

The column type for supply is bigint but some mints have a supply which exceeds this. There exists a as i64 to cast the supply but instead of throwing an error this sets the number to a negative value.

https://github.com/metaplex-foundation/digital-asset-rpc-infrastructure/blob/main/program_transformers/src/token/mod.rs#L113

Bonk is one such example where the supply is 9291438607932069555 outside of the range of i64.

spl-token display DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263

SPL Token Mint
  Address: DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263
  Program: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA
  Supply: 9291438607932069555
  Decimals: 5
  Mint authority: (not set)
  Freeze authority: (not set)

https://solana.fm/address/DezXAZ8z7PnrnRJjz3wXBoRgixCa6xjnB7YaB1pPB263

id                                | \xbc07c56e60ad3d3f177382eac6548fba1fd32cfd90ca02b3e7cfa185fdce7398
alt_id                            |
specification_version             | v1
specification_asset_class         | FUNGIBLE_TOKEN
owner                             |
owner_type                        | token
delegate                          |
frozen                            | f
supply                            | -9155302531447750011
supply_mint                       | \xbc07c56e60ad3d3f177382eac6548fba1fd32cfd90ca02b3e7cfa185fdce7398
compressed                        | f
compressible                      | f

The asset is indexed but when its time to query it this filter for only positive supply triggers.

https://github.com/metaplex-foundation/digital-asset-rpc-infrastructure/blob/main/digital_asset_types/src/dao/scopes/asset.rs#L384

Fix

  1. Switch numeric column type for supply.
  2. Bring in bigdecimal to handle "large" numbers
  3. Error in case of failed type conversion
@kespinola kespinola added the bug Something isn't working label Jul 18, 2024
@kespinola kespinola self-assigned this Jul 18, 2024
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

Successfully merging a pull request may close this issue.

1 participant