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

soroban-math

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

19 releases

0.2.8 Oct 21, 2024
0.2.6 Aug 29, 2024
0.2.3 Jun 28, 2024
0.2.0 Mar 31, 2024
0.1.1 Dec 30, 2023

#14 in #stellar

Download history 108/week @ 2024-08-25 8/week @ 2024-09-01 39/week @ 2024-09-15 1/week @ 2024-09-22 38/week @ 2024-09-29 269/week @ 2024-10-20 14/week @ 2024-10-27 52/week @ 2024-12-08

52 downloads per month

Apache-2.0

29KB
625 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.8"

And this to your code:

use soroban_math::*;

Features

  1. High-Precision Arithmetic: Perform calculations with numbers using the i128/I256 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.

Some Notes

I am monitoring and maintaining this repo closely. Writing test cases. I cannot ask you to assume that the library is 100% safe to use in all scenarios. If you need my consultation while integrating this library and implementing it as safely as possible in your project / hands-on custom implementation, I sure can do it, of course that will be come with some price tag, please DM me on Twitter or mail me here, rahul.soshte47@gmail.com.

Getting Help

Join the discord server to chat with the community!

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

~11–15MB
~315K SLoC