mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-06-28 19:19:25 +00:00
chore(stablecoin): use alloy primitives
This commit is contained in:
parent
3eab96a217
commit
e93db419c4
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -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",
|
||||
|
||||
@ -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 }
|
||||
|
||||
@ -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 {
|
||||
|
||||
2
programs/stablecoin/methods/guest/Cargo.lock
generated
2
programs/stablecoin/methods/guest/Cargo.lock
generated
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user