intrepidshape/elm-web3-ui/2.3.0

NOTE: the latest version is 4.0.0

Web3.Ui.PriceDisplay

Token price display with automatic notation selection.

Bonding curve prices span many orders of magnitude. This module picks the most readable notation automatically so each project does not reimplement the same range-checking logic.

Web3.Ui.PriceDisplay.view []
    { decimals = 18, symbol = "PLS" }
    priceWei


Web3.Ui.PriceDisplay.format 18 priceWei
--> "0.00042"   (fixed for normal range)
--> "1.23M"     (SI suffix for large)
--> "4.56e-10"  (scientific for tiny)
List (Attribute msg)
-> { decimals : Int
, symbol : String
}
-> BigInt
-> Html msg

Display a token price, automatically selecting notation.

Notation rules:

  • ≥ 1 000: SI suffix (1.23M, 45.6K)
  • 0.001 – 999.99: fixed decimal (1.23, 0.456, 0.00123)
  • < 0.001: scientific (4.56e-10)

CSS class: web3-price

format : Int -> BigInt -> String

Format a price BigInt as a human-readable string. No symbol appended.

See view for notation selection rules.