What problem does it solve?
This Skill addresses the critical need for accurate and secure financial calculations within decentralized finance (DeFi) applications on the MultiversX blockchain, preventing common vulnerabilities arising from precision loss and rounding errors.
Core Features & Use Cases
- Precision Management: Defines and utilizes standard precision levels (BPS, PPM, WAD, RAY) for financial operations.
- Safe Arithmetic: Implements half-up rounding for multiplication and division to prevent systematic value loss and potential exploits.
- Secure Rescaling: Provides a safe method for converting values between different precision levels.
- Percentage Calculations: Offers utilities for applying fees and percentages using BPS and PPM.
- Use Case: When developing a lending protocol, use this Skill's
RAY precision and half-up rounding for interest calculations to ensure fairness and prevent exploits.
Quick Start
Use the mvx_defi_math skill to calculate a 2.5% fee on a principal amount of 1000 WAD using half-up rounding.