From fa345da4fc8f84982bb5d8fbce2bb4ceab03432c Mon Sep 17 00:00:00 2001 From: Richa-iitr Date: Fri, 2 Sep 2022 21:08:24 +0530 Subject: [PATCH] modifications --- .../mainnet/connectors/compound/v3/main.sol | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/contracts/mainnet/connectors/compound/v3/main.sol b/contracts/mainnet/connectors/compound/v3/main.sol index 21573be1..5be82956 100644 --- a/contracts/mainnet/connectors/compound/v3/main.sol +++ b/contracts/mainnet/connectors/compound/v3/main.sol @@ -502,12 +502,10 @@ abstract contract CompoundV3Resolver is Events, Helpers { ? CometInterface(market).borrowBalanceOf(address(this)) : amt_; - uint256 borrowBal = CometInterface(market).borrowBalanceOf( + uint256 supplyBalance_ = CometInterface(market).balanceOf( address(this) ); - if (borrowBal > 0) { - require(amt_ <= borrowBal, "repay-amt-greater-than-debt"); - } + require(supplyBalance_ == 0, "cannot-repay-when-supplied"); convertEthToWeth(isEth, tokenContract, amt_); approve(tokenContract, market, amt_); @@ -557,10 +555,8 @@ abstract contract CompoundV3Resolver is Events, Helpers { ? CometInterface(market).borrowBalanceOf(to) : amt_; - uint256 borrowBal = CometInterface(market).borrowBalanceOf(to); - if (borrowBal > 0) { - require(amt_ <= borrowBal, "repay-amt-greater-than-debt"); - } + uint256 supplyBalance_ = CometInterface(market).balanceOf(to); + require(supplyBalance_ == 0, "cannot-repay-when-supplied"); convertEthToWeth(isEth, tokenContract, amt_); approve(tokenContract, market, amt_); @@ -618,12 +614,8 @@ abstract contract CompoundV3Resolver is Events, Helpers { Action.REPAY ); - uint256 borrowBal = CometInterface(market).borrowBalanceOf(to); - if (borrowBal > 0) { - require(amt_ <= borrowBal, "repay-amt-greater-than-debt"); - } - - approve(tokenContract, market, amt_); + uint256 supplyBalance_ = CometInterface(market).balanceOf(to); + require(supplyBalance_ == 0, "cannot-repay-when-supplied"); CometInterface(market).supplyFrom(from, to, token_, amt_);