Skip to content

Commit

Permalink
renaming quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
lemunozm committed May 24, 2023
1 parent fa0b176 commit e4f1eee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 additions & 3 deletions pallets/loans-ref/src/pricing/external.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub struct ExternalPricing<T: Config> {
/// Id of an external price
pub price_id: T::PriceId,

/// Number of items associated to the price id
pub quantity: T::Balance,
/// Maximum number of items associated to the price id
pub max_borrow_quantity: T::Balance,
}

impl<T: Config> ExternalPricing<T> {
Expand Down Expand Up @@ -75,7 +75,10 @@ impl<T: Config> ExternalActivePricing<T> {

pub fn max_borrow_amount(&self) -> Result<T::Balance, DispatchError> {
let price = self.calculate_price()?;
let available = self.info.quantity.ensure_sub(self.outstanding_quantity)?;
let available = self
.info
.max_borrow_quantity
.ensure_sub(self.outstanding_quantity)?;
Ok(available.ensure_mul(price)?)
}

Expand Down
4 changes: 2 additions & 2 deletions pallets/loans-ref/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ mod util {
collateral: ASSET_AA,
pricing: Pricing::External(ExternalPricing {
price_id: REGISTER_PRICE_ID,
quantity: QUANTITY,
max_borrow_quantity: QUANTITY,
}),
restrictions: LoanRestrictions {
borrows: BorrowRestrictions::NoWrittenOff,
Expand Down Expand Up @@ -369,7 +369,7 @@ mod create_loan {
let loan = LoanInfo {
pricing: Pricing::External(ExternalPricing {
price_id: UNREGISTER_PRICE_ID,
quantity: QUANTITY,
max_borrow_quantity: QUANTITY,
}),
..util::base_external_loan()
};
Expand Down

0 comments on commit e4f1eee

Please sign in to comment.