Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#oak-19 #1193

Open
wants to merge 2 commits into
base: v0.9.90-audit
Choose a base branch
from
Open

#oak-19 #1193

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
2 changes: 1 addition & 1 deletion pallets/lend-market/src/interest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ impl<T: Config> Pallet<T> {
Ok(Ratio::from_rational(borrows, total))
}

/// The exchange rate should be greater than 0.02 and less than 1
/// The exchange rate should be greater or equal than 0.02 and less than 1
pub(crate) fn ensure_valid_exchange_rate(exchange_rate: Rate) -> DispatchResult {
ensure!(
exchange_rate >= Rate::from_inner(MIN_EXCHANGE_RATE) &&
Expand Down
4 changes: 2 additions & 2 deletions pallets/lend-market/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ pub mod pallet {
/// The sender liquidates the borrower's collateral.
///
/// - `borrower`: the borrower to be liquidated.
/// - `liquidation_asset_id`: the assert to be liquidated.
/// - `liquidation_asset_id`: the asset to be liquidated.
/// - `repay_amount`: the amount to be repaid borrow.
/// - `collateral_asset_id`: The collateral to seize from the borrower.
#[pallet::call_index(17)]
Expand Down Expand Up @@ -1891,7 +1891,7 @@ impl<T: Config> Pallet<T> {
Ok(FixedU128::from_inner(underlying_amount)
.checked_div(&exchange_rate)
.map(|r| r.into_inner())
.ok_or(ArithmeticError::Underflow)?)
.ok_or(ArithmeticError::Overflow)?)
}

fn get_total_cash(asset_id: AssetIdOf<T>) -> BalanceOf<T> {
Expand Down
8 changes: 4 additions & 4 deletions pallets/lend-market/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ fn mint_must_return_err_when_overflows_occur() {
// Verify token balance first
assert_noop!(
LendMarket::mint(RuntimeOrigin::signed(CHARLIE), DOT, OVERFLOW_DEPOSIT),
ArithmeticError::Underflow
ArithmeticError::Overflow
);

// Deposit OVERFLOW_DEPOSIT DOT for CHARLIE
Expand All @@ -140,7 +140,7 @@ fn mint_must_return_err_when_overflows_occur() {
// Underflow is used here redeem could also be 0
assert_noop!(
LendMarket::mint(RuntimeOrigin::signed(CHARLIE), DOT, OVERFLOW_DEPOSIT),
ArithmeticError::Underflow
ArithmeticError::Overflow
);

// Exchange rate must ge greater than zero
Expand Down Expand Up @@ -297,7 +297,7 @@ fn redeem_must_return_err_when_overflows_occur() {
// Underflow is used here redeem could also be 0
assert_noop!(
LendMarket::redeem(RuntimeOrigin::signed(ALICE), DOT, u128::MAX),
ArithmeticError::Underflow,
ArithmeticError::Overflow,
);
})
}
Expand Down Expand Up @@ -778,7 +778,7 @@ fn calc_collateral_amount_works() {
assert_eq!(LendMarket::calc_collateral_amount(1000, exchange_rate).unwrap(), 3333);
assert_eq!(
LendMarket::calc_collateral_amount(u128::MAX, exchange_rate),
Err(DispatchError::Arithmetic(ArithmeticError::Underflow))
Err(DispatchError::Arithmetic(ArithmeticError::Overflow))
);

// relative test: prevent_the_exchange_rate_attack
Expand Down
4 changes: 2 additions & 2 deletions pallets/leverage-staking/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ pub mod pallet {
#[pallet::error]
pub enum Error<T> {
ArgumentsError,
NotSupportTokenType,
NotSupportedTokenType,
}

#[pallet::event]
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<T: Config> Pallet<T> {
let who = ensure_signed(origin)?;

let vtoken_id = T::CurrencyIdConversion::convert_to_vtoken(asset_id)
.map_err(|_| Error::<T>::NotSupportTokenType)?;
.map_err(|_| Error::<T>::NotSupportedTokenType)?;

let deposits = AccountDeposits::<T>::get(vtoken_id, &who);
if !deposits.is_collateral {
Expand Down
Loading