SVG sparkline of an A * x^N bonding-curve price function. Renders the
price-vs-supply curve from supply 0 to a chosen max, with optional markers
for the current spot price and floor price.
Web3.Ui.BondingCurve.sparkline
{ coeffA = curve.coeffA
, exponent = 1.1
, supply = curve.supply
, maxSupply = maxSupply
, floorPrice = Just curve.floorPrice
, decimals = 18
, width = 320
, height = 80
}The component is generic for any curve of shape price = A * supply^N,
which covers x^1.1, classic x^2, and any sub-/super-linear
issuance model. coeffA, floorPrice and supply are all scaled by
10 ^ decimals, which used to be hardcoded to 18 -- on a 6-decimal token the
floor line was drawn 1e12 out of place.
supply / maxSupply is divided in BigInt space and the curve is plotted from
that bounded ratio, so no uint256 is converted to a Float; the floor line is
placed from Decimal.log10 magnitudes, which stay exact in the exponent
however large the inputs are. The remaining Float work is the caller's
fractional exponent, which has no integer equivalent. The chart is purely
visual -- do not consume the rendered points for on-chain calculation.
CSS classes: web3-bondingcurve, web3-bondingcurve__path,
web3-bondingcurve__spot, web3-bondingcurve__floor. Stroke colors come
from CSS.
Render the sparkline.