From 7b113eaf19c126db796190f271d85bc5c2cba865 Mon Sep 17 00:00:00 2001 From: kree-dotcom Date: Thu, 15 Dec 2022 18:58:32 +0000 Subject: [PATCH] Extend partial loan payback fix to Vault Velo and Lyra --- contracts/Vault_Lyra.sol | 2 +- contracts/Vault_Velo.sol | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/Vault_Lyra.sol b/contracts/Vault_Lyra.sol index f7a0345..41f983e 100644 --- a/contracts/Vault_Lyra.sol +++ b/contracts/Vault_Lyra.sol @@ -221,7 +221,7 @@ contract Vault_Lyra is Vault_Base_ERC20{ _USDToVault = isoUSDdebt; } uint256 outstandingisoUSD = isoUSDdebt - _USDToVault; - if(outstandingisoUSD > 0){ //check for leftover debt + if((outstandingisoUSD > 0) && (_collateralToUser > 0)){ //check for leftover debt //check for frozen or paused collateral _checkIfCollateralIsActive(currencyKey); uint256 collateralLeft = collateralPosted[_collateralAddress][msg.sender] - _collateralToUser; diff --git a/contracts/Vault_Velo.sol b/contracts/Vault_Velo.sol index f94c89f..864498b 100644 --- a/contracts/Vault_Velo.sol +++ b/contracts/Vault_Velo.sol @@ -550,7 +550,7 @@ contract Vault_Velo is RoleControl(VAULT_VELO_TIME_DELAY), Pausable { } uint256 outstandingisoUSD = isoUSDdebt - _USDToVault; uint256 colInUSD = _calculateProposedReturnedCapital(_collateralAddress, _loanNFTs, _partialPercentage); - if(outstandingisoUSD > 0){ //check for leftover debt + if((outstandingisoUSD > 0) && (_colInUSD > 0)){ //check for leftover debt uint256 collateralLeft = totalCollateralValue(_collateralAddress, msg.sender) - colInUSD; uint256 borrowMargin = (outstandingisoUSD * minOpeningMargin) / LOAN_SCALE; require(collateralLeft >= borrowMargin , "Remaining debt fails to meet minimum margin!");