chore(stablecoin): use alloy primitives

This commit is contained in:
Andrea Franz 2026-06-25 15:18:52 +02:00
parent 3eab96a217
commit e93db419c4
4 changed files with 13 additions and 6 deletions

2
Cargo.lock generated
View File

@ -3654,9 +3654,11 @@ dependencies = [
name = "stablecoin_core"
version = "0.1.0"
dependencies = [
"alloy-primitives",
"borsh",
"nssa_core",
"risc0-zkvm",
"ruint",
"serde",
"spel-framework-macros",
"twap_oracle_core",

View File

@ -6,7 +6,11 @@ edition = "2021"
[dependencies]
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.0-rc3", features = ["host"] }
borsh = { version = "1.5", features = ["derive"] }
primitive-types = { version = "0.13", default-features = false }
alloy-primitives = { version = "1", default-features = false }
# Pin ruint (transitive via alloy-primitives) below 1.18, which raised its MSRV to rustc 1.90.
# The risc0 guest toolchain ships rustc 1.88, so 1.18+ fails the guest build. 1.17.0 (MSRV 1.85)
# is the newest compatible release. Remove this pin once the risc0 toolchain advances past 1.90.
ruint = { version = "=1.17.0", default-features = false }
serde = { version = "1.0", features = ["derive"] }
twap_oracle_core = { path = "../../twap_oracle/core" }
risc0-zkvm = { version = "=3.0.5", default-features = false }

View File

@ -4,7 +4,7 @@
//! `u128` integers scaled by [`FIXED_POINT_ONE`], so the integer `1.0` is
//! `10^27`. Multiplications use `U256` intermediates to avoid overflow.
use primitive_types::U256;
use alloy_primitives::U256;
/// The value `1.0` in our 27-decimal fixed-point representation.
///
@ -50,7 +50,7 @@ pub fn mul_div_ceil(a: u128, b: u128, c: u128) -> u128 {
quotient
} else {
quotient
.checked_add(U256::one())
.checked_add(U256::ONE)
.expect("mul_div_ceil: ceil increment overflows U256")
};
ceiled
@ -70,9 +70,8 @@ pub fn mul_div_ceil(a: u128, b: u128, c: u128) -> u128 {
///
/// # Overflow
/// NOT self-bounding. For any `per_millisecond_rate > FIXED_POINT_ONE` this
/// eventually overflows `u128` as `milliseconds_elapsed` grows — the §8 rate
/// bound alone does not prevent it. Callers MUST clamp the elapsed window to
/// `MAXIMUM_COMPOUNDING_WINDOW_MILLISECONDS` (spec §5.3) before calling.
/// eventually overflows `u128` as `milliseconds_elapsed` grows. Callers MUST
/// clamp the elapsed window to a bounded maximum before calling.
#[must_use]
pub fn compound_rate(per_millisecond_rate: u128, milliseconds_elapsed: u64) -> u128 {
if milliseconds_elapsed == 0 {

View File

@ -3551,9 +3551,11 @@ dependencies = [
name = "stablecoin_core"
version = "0.1.0"
dependencies = [
"alloy-primitives",
"borsh",
"nssa_core",
"risc0-zkvm",
"ruint",
"serde",
"spel-framework-macros",
"twap_oracle_core",