Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions aave-core/aave-math/sources/math_utils.move
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,16 @@ module aave_math::math_utils {
(numerator + denominator - 1) / denominator
}

/// @notice Finds the minimum of two u256 values
/// @dev This function returns the smaller of the two provided u256 values
/// @param a The first value
/// @param b The second value
/// @return The result of the minimum value between a and b
public fun min(a: u256, b: u256): u256 {
if (a <= b) { a }
else { b }
}

/// @dev Returns the seconds per year value
/// @return Seconds per year constant
public fun get_seconds_per_year(): u256 {
Expand Down
6 changes: 5 additions & 1 deletion aave-core/aave-oracle/sources/oracle.move
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,14 @@ module aave_oracle::oracle {
let underlying_asset_price = assets_prices[0];
let asset_base_ratio = assets_prices[1];
let underlying_asset_timestamp = assets_timestamps[0];
let asset_base_timestamp = assets_timestamps[1];
let (underlying_asset_capped_price, _) = get_capped_susde_price(
underlying_asset_price, asset_base_ratio, &cap_info
);
(underlying_asset_capped_price, underlying_asset_timestamp)
(
underlying_asset_capped_price,
math_utils::min(underlying_asset_timestamp, asset_base_timestamp)
)
},
AdapterType::STABLE => {
let (underlying_asset_price, underlying_asset_timestamp) = get_asset_price_internal(
Expand Down
Loading