Converts an amount to another currency at rate, rounding down. A rate is an integer scaled by
10^scale, so the result is floor(minor * rate / 10^scale) — a true floor for either sign,
named as the mode at the division. Use it where rounding down is the safe direction, such as
paying a seller out: the sub-cent remainder stays with the platform instead of being minted.
Throws AMOUNT_OVERFLOW when the result leaves the 64-bit range; the multiply itself runs
through an unbounded intermediate, so it cannot overflow silently.
// cash out at a $0.005-per-credit CREDIT-to-USD rate: 5/10^3 USD minor per CREDIT minor constrate = { rate:5n, scale:3, rateId:'cashout-example' }; convertFloor(toAmount('CREDIT', 2_000_100n), rate, 'USD'); // 10_000n minor: the exact $100.005 floors to $100.00
Converts an amount to another currency at
rate, rounding down. A rate is an integer scaled by10^scale, so the result isfloor(minor * rate / 10^scale)— a true floor for either sign, named as the mode at the division. Use it where rounding down is the safe direction, such as paying a seller out: the sub-cent remainder stays with the platform instead of being minted. Throws AMOUNT_OVERFLOW when the result leaves the 64-bit range; the multiply itself runs through an unbounded intermediate, so it cannot overflow silently.