From 91bb5ea57c0c5db9bb2605c51f840761bff523c0 Mon Sep 17 00:00:00 2001 From: Richa-iitr Date: Fri, 2 Sep 2022 22:56:08 +0530 Subject: [PATCH] error --- contracts/mainnet/connectors/compound/v3/main.sol | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/contracts/mainnet/connectors/compound/v3/main.sol b/contracts/mainnet/connectors/compound/v3/main.sol index 5be82956..335bdd4c 100644 --- a/contracts/mainnet/connectors/compound/v3/main.sol +++ b/contracts/mainnet/connectors/compound/v3/main.sol @@ -226,9 +226,15 @@ abstract contract CompoundV3Resolver is Events, Helpers { if (token_ == getBaseToken(market)) { uint256 balance = CometInterface(market).balanceOf(address(this)); + //if there are supplies, ensure withdrawn amount is not greater than supplied i.e can't borrow using withdraw. if (balance > 0) { require(amt_ <= balance, "withdraw-amt-greater-than-supplies"); } + //if borrow balance > 0, there are no supplies so no withdraw, borrow instead. + require( + CometInterface(market).borrowBalanceOf(address(this)) == 0, + "withdraw-disabled-for-zero-supplies" + ); } CometInterface(market).withdraw(token_, amt_);