Skip to content

Commit

Permalink
feat: range validation for factor setters
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Feb 19, 2024
1 parent cc1200b commit ae7a082
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/market/external.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ fn set_collateral_factor(
) {
ownable::assert_only_owner(@self);

// Checks collateral_factor range
assert(
Into::<_, u256>::into(collateral_factor) <= safe_decimal_math::SCALE_U256,
errors::COLLATERAL_FACTOR_RANGE
);

internal::assert_reserve_exists(@self, token);
self.reserves.write_collateral_factor(token, collateral_factor);
self
Expand All @@ -271,6 +277,12 @@ fn set_collateral_factor(
fn set_borrow_factor(ref self: ContractState, token: ContractAddress, borrow_factor: felt252) {
ownable::assert_only_owner(@self);

// Checks borrow_factor range
assert(
Into::<_, u256>::into(borrow_factor) <= safe_decimal_math::SCALE_U256,
errors::BORROW_FACTOR_RANGE
);

internal::assert_reserve_exists(@self, token);
self.reserves.write_borrow_factor(token, borrow_factor);
self
Expand Down

0 comments on commit ae7a082

Please sign in to comment.