From 6b0879e59a3e5156fde88f4c90d0029aa31b3786 Mon Sep 17 00:00:00 2001 From: kree-dotcom Date: Thu, 15 Dec 2022 18:51:15 +0000 Subject: [PATCH] partial loan payback under minOpeningMargin --- contracts/Vault_Synths.sol | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contracts/Vault_Synths.sol b/contracts/Vault_Synths.sol index 3557494..958962a 100644 --- a/contracts/Vault_Synths.sol +++ b/contracts/Vault_Synths.sol @@ -212,7 +212,7 @@ contract Vault_Synths 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 uint256 collateralLeft = collateralPosted[_collateralAddress][msg.sender] - _collateralToUser; uint256 colInUSD = priceCollateralToUSD(currencyKey, collateralLeft); uint256 borrowMargin = (outstandingisoUSD * minOpeningMargin) / LOAN_SCALE;