fix: token lending; repay and liquidate should set deposited collateral tokens (#1383)
This commit is contained in:
parent
27c94293ce
commit
f24d375b75
|
@ -115,9 +115,10 @@ impl Obligation {
|
|||
}
|
||||
|
||||
/// Liquidate part of obligation
|
||||
pub fn liquidate(&mut self, settle_amount: Decimal, withdraw_amount: u64) -> ProgramResult {
|
||||
self.borrowed_liquidity_wads = self.borrowed_liquidity_wads.try_sub(settle_amount)?;
|
||||
self.deposited_collateral_tokens
|
||||
pub fn liquidate(&mut self, repay_amount: Decimal, withdraw_amount: u64) -> ProgramResult {
|
||||
self.borrowed_liquidity_wads = self.borrowed_liquidity_wads.try_sub(repay_amount)?;
|
||||
self.deposited_collateral_tokens = self
|
||||
.deposited_collateral_tokens
|
||||
.checked_sub(withdraw_amount)
|
||||
.ok_or(LendingError::MathOverflow)?;
|
||||
Ok(())
|
||||
|
@ -147,12 +148,7 @@ impl Obligation {
|
|||
obligation_token_supply,
|
||||
)?;
|
||||
|
||||
self.borrowed_liquidity_wads =
|
||||
self.borrowed_liquidity_wads.try_sub(decimal_repay_amount)?;
|
||||
self.deposited_collateral_tokens = self
|
||||
.deposited_collateral_tokens
|
||||
.checked_sub(collateral_withdraw_amount)
|
||||
.ok_or(LendingError::MathOverflow)?;
|
||||
self.liquidate(decimal_repay_amount, collateral_withdraw_amount)?;
|
||||
|
||||
Ok(RepayResult {
|
||||
decimal_repay_amount,
|
||||
|
|
Loading…
Reference in New Issue