bobcat-maths

Crates.iobobcat-maths
lib.rsbobcat-maths
version0.7.19
created_at2025-10-13 07:20:43.879386+00
updated_at2026-01-23 10:08:37.170303+00
descriptionbobcat-sdk utilities performing codesize efficient math on Arbitrum Stylus.
homepagehttps://bobcat.so
repositoryhttps://github.com/stylus-developers-guild/bobcat-sdk
max_upload_size
id1880122
size83,557
Bayge (af-afk)

documentation

README

Gas and codesize implications of the muldiv functions

Gas test results

At arbos-forge release 5e956b7586b924778ff3b6117afb9153d47a18ce (1.4.4):

Name Gas cost
Ruint 8673
Muldiv Uniswap 12674
Widening then truncating 587751

9lives and storage

Anecdotally, the order of costs for the various muldiv functions look like this, when we used it in the 9lives repo for our DPPM code:

Name Codesize cost
Widening then truncating Cheap
Muldiv Uniswap Moderate
Ruint Expensive

Takeaway

So, you should make a decision based on the context of what you're working on when your main focus is codesize, since there's undoubtably some reuse of code here. Do some experimentation yourself. Ruint works with 64 bit words, then branches to pick different algorithms. 9lives uses muldiv for fee taking operations, with numbers of either 1e6, 1000, and 1e12. You need to enable ruint with ruint-enabled. It might be more appropriate to use ruint if you're already using U256 from alloy, given the amount of code reuse presumably.

Commit count: 389

cargo fmt