#math #soroban #stellar #smart-contracts #rust

soroban-math

Fixed-Point Math Library for soroban smart contracts with advanced math and high precision

13 releases

new 0.2.2 May 1, 2024
0.2.1 Apr 10, 2024
0.2.0 Mar 31, 2024
0.1.9 Mar 30, 2024
0.1.1 Dec 30, 2023

#2193 in Magic Beans

Download history 18/week @ 2024-02-08 91/week @ 2024-02-15 46/week @ 2024-02-22 162/week @ 2024-02-29 15/week @ 2024-03-07 11/week @ 2024-03-14 94/week @ 2024-03-21 535/week @ 2024-03-28 101/week @ 2024-04-04 48/week @ 2024-04-11

744 downloads per month

Apache-2.0

22KB
495 lines

Soroban-Math

Crates.io Crates.io Crates.io crate publish workflow

A high-precision fixed-point math library for Soroban smart contracts on the Stellar blockchain.

This project aims to empower Soroban developers with precise mathematical operations and advanced functions while minimizing precision loss. It is currently under development and subject to enhancements and optimizations.

Quickstart

Add this to your Cargo.toml:

[dependencies]
soroban-math = "0.2.2"

And this to your code:

use soroban_math::*;

Features

  1. High-Precision Arithmetic: Perform calculations with numbers using the i128 type, ensuring precision and accuracy.
  2. Advanced Math Functions: Access advanced mathematical functions like logarithms, exponentiation, and more.
  3. Ergonomic API: An intuitive API for easy integration into Soroban smart contracts.
  4. Minimized Rounding Losses: Specialized techniques to reduce rounding errors during calculations.
  5. Security: Audit-ready code to ensure the safety and correctness of calculations.

Use Cases

Soroban-Math is essential for any Soroban-based project that requires high-precision mathematical calculations, for example:

  1. DEX protocols
  2. Stablecoins
  3. Lending Protocols

Authors

Rahul Soshte (Twitter)

Dependencies

~13MB
~282K SLoC