Reusable mathematical patterns for financial safety in MultiversX smart contracts.
| BPS (4) | 10,000 = 100% | Fees, simple percentages, reserve factors | | PPM (6) | 1,000,000 = 100% | Fine-grained percentages, partial withdrawals | | WAD (18) | 1e18 = 1.0 | Token amounts, prices, share ratios | | RAY (27) | 1e27 = 1.0 | Interest indices, compounding rates, any math needing minimal precision loss |
Rule of thumb: Use the lowest precision that avoids rounding errors in your domain. For intermediate calculations, always use a higher precision than the final result.
Финансовые математические шаблоны для смарт-контрактов MultiversX — управление точностью, округление до половины, безопасное изменение масштаба и процентные вычисления. Используйте при создании любого контракта DeFi, который обрабатывает финансовые расчеты, комиссии, ставки или математику токенов. Источник: multiversx/mx-ai-skills.