diff --git a/Cargo.lock b/Cargo.lock index 7a5f1779b3..9e7e257f21 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1650,6 +1650,7 @@ dependencies = [ "frame-support", "frame-system", "hex", + "log", "pallet-aura", "pallet-timestamp", "parity-scale-codec 3.6.9", @@ -8097,6 +8098,7 @@ dependencies = [ "frame-benchmarking", "frame-support", "frame-system", + "log", "orml-traits", "pallet-balances", "pallet-interest-accrual", diff --git a/libs/utils/Cargo.toml b/libs/utils/Cargo.toml index 31c1f028b1..68f074e4e5 100644 --- a/libs/utils/Cargo.toml +++ b/libs/utils/Cargo.toml @@ -13,6 +13,7 @@ documentation.workspace = true targets = ["x86_64-unknown-linux-gnu"] [dependencies] +log = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } hex = { workspace = true } @@ -28,28 +29,29 @@ sp-std = { workspace = true } [features] default = ["std"] std = [ - "frame-support/std", - "frame-system/std", - "sp-runtime/std", - "sp-arithmetic/std", - "sp-std/std", - "pallet-timestamp/std", - "pallet-aura/std", - "parity-scale-codec/std", - "scale-info/std", - "sp-consensus-aura/std", - "hex/std", + "frame-support/std", + "frame-system/std", + "sp-runtime/std", + "sp-arithmetic/std", + "sp-std/std", + "pallet-timestamp/std", + "pallet-aura/std", + "parity-scale-codec/std", + "scale-info/std", + "sp-consensus-aura/std", + "hex/std", + "log/std", ] runtime-benchmarks = [ - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "pallet-timestamp/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "pallet-timestamp/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", - "pallet-aura/try-runtime", - "pallet-timestamp/try-runtime", - "sp-runtime/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + "pallet-aura/try-runtime", + "pallet-timestamp/try-runtime", + "sp-runtime/try-runtime", ] diff --git a/libs/utils/src/lib.rs b/libs/utils/src/lib.rs index fc57032ca1..fc30fd44f1 100644 --- a/libs/utils/src/lib.rs +++ b/libs/utils/src/lib.rs @@ -128,8 +128,8 @@ pub mod math { x: X, ) -> Result where - X: BaseArithmetic + FixedPointOperand, - Y: BaseArithmetic + FixedPointOperand, + X: BaseArithmetic + FixedPointOperand + sp_std::fmt::Debug, + Y: BaseArithmetic + FixedPointOperand + sp_std::fmt::Debug, { // From the equation: (x - x1) / (x2 - x1) == (y - y1) / (y2 - y1) we solve y: // @@ -137,6 +137,7 @@ pub mod math { // symmetry in those axis to avoid unsigned underflows in substractions. It // means, we first "convert" the rect into an increasing rect, and in such rect, // we find the y coordinate. + log::warn!("y_coord_in_rect: x1 {x1:?}, x2 {x2:?}, y1 {y1:?}, y2 {y2:?}, x: {x:?}"); let left = if x1 <= x2 { FixedU128::ensure_from_rational(x.ensure_sub(x1)?, x2.ensure_sub(x1)?)? @@ -145,6 +146,8 @@ pub mod math { FixedU128::ensure_from_rational(x1.ensure_sub(x)?, x1.ensure_sub(x2)?)? }; + log::warn!("y_coord_in_rect: left {left:?}"); + if y1 <= y2 { left.ensure_mul_int(y2.ensure_sub(y1)?)?.ensure_add(y1) } else { diff --git a/pallets/loans/Cargo.toml b/pallets/loans/Cargo.toml index 5934cd764e..48ac1ea7ce 100644 --- a/pallets/loans/Cargo.toml +++ b/pallets/loans/Cargo.toml @@ -15,6 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"] [dependencies] parity-scale-codec = { workspace = true } scale-info = { workspace = true } +log = { workspace = true } frame-support = { workspace = true } frame-system = { workspace = true } @@ -47,41 +48,42 @@ cfg-mocks = { workspace = true, default-features = true } [features] default = ["std"] std = [ - "parity-scale-codec/std", - "scale-info/std", - "frame-support/std", - "frame-system/std", - "sp-arithmetic/std", - "sp-runtime/std", - "sp-std/std", - "cfg-primitives/std", - "cfg-traits/std", - "cfg-types/std", - "cfg-utils/std", - "frame-benchmarking/std", - "strum/std", - "orml-traits/std", + "parity-scale-codec/std", + "scale-info/std", + "frame-support/std", + "frame-system/std", + "sp-arithmetic/std", + "sp-runtime/std", + "sp-std/std", + "cfg-primitives/std", + "cfg-traits/std", + "cfg-types/std", + "cfg-utils/std", + "frame-benchmarking/std", + "strum/std", + "orml-traits/std", + "log/std", ] runtime-benchmarks = [ - "frame-benchmarking/runtime-benchmarks", - "frame-support/runtime-benchmarks", - "frame-system/runtime-benchmarks", - "sp-runtime/runtime-benchmarks", - "cfg-primitives/runtime-benchmarks", - "cfg-traits/runtime-benchmarks", - "cfg-types/runtime-benchmarks", - "cfg-utils/runtime-benchmarks", - "pallet-uniques/runtime-benchmarks", - "cfg-mocks/runtime-benchmarks", + "frame-benchmarking/runtime-benchmarks", + "frame-support/runtime-benchmarks", + "frame-system/runtime-benchmarks", + "sp-runtime/runtime-benchmarks", + "cfg-primitives/runtime-benchmarks", + "cfg-traits/runtime-benchmarks", + "cfg-types/runtime-benchmarks", + "cfg-utils/runtime-benchmarks", + "pallet-uniques/runtime-benchmarks", + "cfg-mocks/runtime-benchmarks", ] try-runtime = [ - "frame-support/try-runtime", - "frame-system/try-runtime", - "sp-runtime/try-runtime", - "cfg-primitives/try-runtime", - "cfg-traits/try-runtime", - "cfg-types/try-runtime", - "cfg-utils/try-runtime", - "cfg-mocks/try-runtime", - "sp-runtime/try-runtime", + "frame-support/try-runtime", + "frame-system/try-runtime", + "sp-runtime/try-runtime", + "cfg-primitives/try-runtime", + "cfg-traits/try-runtime", + "cfg-types/try-runtime", + "cfg-utils/try-runtime", + "cfg-mocks/try-runtime", + "sp-runtime/try-runtime", ] diff --git a/pallets/loans/src/entities/pricing/external.rs b/pallets/loans/src/entities/pricing/external.rs index 6fa54dc6ea..9f4f89de04 100644 --- a/pallets/loans/src/entities/pricing/external.rs +++ b/pallets/loans/src/entities/pricing/external.rs @@ -160,6 +160,7 @@ impl ExternalActivePricing { price: T::Balance, price_last_updated: Seconds, ) -> Result { + log::warn!("maybe_with_linear_accrual_price: Seconds {maturity:?}, price {price:?}, price_last_updated {price_last_updated:?}"); if self.info.with_linear_pricing { Ok(cfg_utils::math::y_coord_in_rect( (price_last_updated, price), @@ -187,6 +188,7 @@ impl ExternalActivePricing { maturity: Seconds, oracle: Option>, ) -> Result { + log::warn!("current_price_inner: Seconds {maturity:?}, oracle {oracle:?}"); if let Some((oracle_price, oracle_provided_at)) = oracle { self.maybe_with_linear_accrual_price( maturity,