Skip to content

Bug: Fix tiny token amounts #169

@murderteeth

Description

@murderteeth

When showing token amounts Seafood currently rounds out tokens that are very small against usd. For example Seafood shows 0.00 assets for this USDR vault when the correct value us 0.00000806.

https://seafood.yearn.watch/vault/0x531fDb1C8429F404116932226D487db94471C4b7
image

Update Seafood to work like this instead:
image

Tasks

  • Update formatNumber to include compact forms for numbers less than zero using greek si units for milli, micro, nano, and pico. For numbers greater than zero change the logic to use an uppercase unit. For numbers less than zero use lowercase. Here's formatNumber:

    function formatNumber(number, decimals = 2, nonFinite = '∞', compact = false) {

  • Add tests here to demonstrate the new formats work:
    https://github.com/yearn/seafood/blob/main/src/utils/utils.test.js

  • Update the Tokens component to support hover and click features. Use a localstorage value to store the user's current preference (unclicked vs clicked, ie compact vs expanded):

    export function Tokens(

Metadata

Metadata

Labels

bugSomething isn't workinggood first issueGood for newcomers

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions