Skip to content

Commit 25569a9

Browse files
authored
Merge pull request #64 from aave/fix/mpsc0x/min-ts-susde
fix: using the min of USDT and sUSDe timestamps
2 parents bf6257d + 21619ff commit 25569a9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

aave-core/aave-math/sources/math_utils.move

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,16 @@ module aave_math::math_utils {
153153
(numerator + denominator - 1) / denominator
154154
}
155155

156+
/// @notice Finds the minimum of two u256 values
157+
/// @dev This function returns the smaller of the two provided u256 values
158+
/// @param a The first value
159+
/// @param b The second value
160+
/// @return The result of the minimum value between a and b
161+
public fun min(a: u256, b: u256): u256 {
162+
if (a <= b) { a }
163+
else { b }
164+
}
165+
156166
/// @dev Returns the seconds per year value
157167
/// @return Seconds per year constant
158168
public fun get_seconds_per_year(): u256 {

aave-core/aave-oracle/sources/oracle.move

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,14 @@ module aave_oracle::oracle {
310310
let underlying_asset_price = assets_prices[0];
311311
let asset_base_ratio = assets_prices[1];
312312
let underlying_asset_timestamp = assets_timestamps[0];
313+
let asset_base_timestamp = assets_timestamps[1];
313314
let (underlying_asset_capped_price, _) = get_capped_susde_price(
314315
underlying_asset_price, asset_base_ratio, &cap_info
315316
);
316-
(underlying_asset_capped_price, underlying_asset_timestamp)
317+
(
318+
underlying_asset_capped_price,
319+
math_utils::min(underlying_asset_timestamp, asset_base_timestamp)
320+
)
317321
},
318322
AdapterType::STABLE => {
319323
let (underlying_asset_price, underlying_asset_timestamp) = get_asset_price_internal(

0 commit comments

Comments
 (0)