mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-06-30 12:09:30 +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"
|
name = "stablecoin_core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"alloy-primitives",
|
||||||
"borsh",
|
"borsh",
|
||||||
"nssa_core",
|
"nssa_core",
|
||||||
"risc0-zkvm",
|
"risc0-zkvm",
|
||||||
|
"ruint",
|
||||||
"serde",
|
"serde",
|
||||||
"spel-framework-macros",
|
"spel-framework-macros",
|
||||||
"twap_oracle_core",
|
"twap_oracle_core",
|
||||||
|
|||||||
@ -6,7 +6,11 @@ edition = "2021"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
nssa_core = { git = "https://github.com/logos-blockchain/logos-execution-zone.git", tag = "v0.2.0-rc3", features = ["host"] }
|
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"] }
|
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"] }
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
twap_oracle_core = { path = "../../twap_oracle/core" }
|
twap_oracle_core = { path = "../../twap_oracle/core" }
|
||||||
risc0-zkvm = { version = "=3.0.5", default-features = false }
|
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
|
//! `u128` integers scaled by [`FIXED_POINT_ONE`], so the integer `1.0` is
|
||||||
//! `10^27`. Multiplications use `U256` intermediates to avoid overflow.
|
//! `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.
|
/// 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
|
quotient
|
||||||
} else {
|
} else {
|
||||||
quotient
|
quotient
|
||||||
.checked_add(U256::one())
|
.checked_add(U256::ONE)
|
||||||
.expect("mul_div_ceil: ceil increment overflows U256")
|
.expect("mul_div_ceil: ceil increment overflows U256")
|
||||||
};
|
};
|
||||||
ceiled
|
ceiled
|
||||||
@ -70,9 +70,8 @@ pub fn mul_div_ceil(a: u128, b: u128, c: u128) -> u128 {
|
|||||||
///
|
///
|
||||||
/// # Overflow
|
/// # Overflow
|
||||||
/// NOT self-bounding. For any `per_millisecond_rate > FIXED_POINT_ONE` this
|
/// NOT self-bounding. For any `per_millisecond_rate > FIXED_POINT_ONE` this
|
||||||
/// eventually overflows `u128` as `milliseconds_elapsed` grows — the §8 rate
|
/// eventually overflows `u128` as `milliseconds_elapsed` grows. Callers MUST
|
||||||
/// bound alone does not prevent it. Callers MUST clamp the elapsed window to
|
/// clamp the elapsed window to a bounded maximum before calling.
|
||||||
/// `MAXIMUM_COMPOUNDING_WINDOW_MILLISECONDS` (spec §5.3) before calling.
|
|
||||||
#[must_use]
|
#[must_use]
|
||||||
pub fn compound_rate(per_millisecond_rate: u128, milliseconds_elapsed: u64) -> u128 {
|
pub fn compound_rate(per_millisecond_rate: u128, milliseconds_elapsed: u64) -> u128 {
|
||||||
if milliseconds_elapsed == 0 {
|
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"
|
name = "stablecoin_core"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"alloy-primitives",
|
||||||
"borsh",
|
"borsh",
|
||||||
"nssa_core",
|
"nssa_core",
|
||||||
"risc0-zkvm",
|
"risc0-zkvm",
|
||||||
|
"ruint",
|
||||||
"serde",
|
"serde",
|
||||||
"spel-framework-macros",
|
"spel-framework-macros",
|
||||||
"twap_oracle_core",
|
"twap_oracle_core",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user