Merge pull request #330 from Instadapp/fix-payback

Fix payback
This commit is contained in:
Shriya Tyagi 2024-02-17 18:04:18 +05:30 committed by GitHub
commit f72bc33e30
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 10 deletions

View File

@ -263,7 +263,13 @@ abstract contract AaveResolver is Events, Helpers {
TokenInterface tokenContract = TokenInterface(_token); TokenInterface tokenContract = TokenInterface(_token);
_amt = _amt == uint256(-1) ? getPaybackBalance(_token, rateMode) : _amt; if (_amt == uint256(-1)) {
uint256 _amtDSA = isEth
? address(this).balance
: tokenContract.balanceOf(address(this));
uint256 _amtDebt = getPaybackBalance(_token, rateMode);
_amt = _amtDSA > _amtDebt ? _amtDebt : _amtDSA;
}
if (isEth) convertEthToWeth(isEth, tokenContract, _amt); if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
@ -351,9 +357,17 @@ abstract contract AaveResolver is Events, Helpers {
TokenInterface tokenContract = TokenInterface(_token); TokenInterface tokenContract = TokenInterface(_token);
_amt = _amt == uint256(-1) if (_amt == uint256(-1)) {
? getOnBehalfOfPaybackBalance(_token, rateMode, onBehalfOf) uint256 _amtDSA = isEth
: _amt; ? address(this).balance
: tokenContract.balanceOf(address(this));
uint256 _amtDebt = getOnBehalfOfPaybackBalance(
_token,
rateMode,
onBehalfOf
);
_amt = _amtDSA > _amtDebt ? _amtDebt : _amtDSA;
}
if (isEth) convertEthToWeth(isEth, tokenContract, _amt); if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
@ -517,5 +531,5 @@ abstract contract AaveResolver is Events, Helpers {
} }
contract ConnectV2AaveV3 is AaveResolver { contract ConnectV2AaveV3 is AaveResolver {
string public constant name = "AaveV3-v1.1"; string public constant name = "AaveV3-v1.2";
} }

View File

@ -262,7 +262,14 @@ abstract contract SparkConnector is Events, Helpers {
address _token = isEth ? wethAddr : token; address _token = isEth ? wethAddr : token;
TokenInterface tokenContract = TokenInterface(_token); TokenInterface tokenContract = TokenInterface(_token);
_amt = _amt == uint256(-1) ? getPaybackBalance(_token, rateMode) : _amt;
if (_amt == uint256(-1)) {
uint256 _amtDSA = isEth
? address(this).balance
: tokenContract.balanceOf(address(this));
uint256 _amtDebt = getPaybackBalance(_token, rateMode);
_amt = _amtDSA > _amtDebt ? _amtDebt : _amtDSA;
}
if (isEth) convertEthToWeth(isEth, tokenContract, _amt); if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
@ -350,9 +357,17 @@ abstract contract SparkConnector is Events, Helpers {
TokenInterface tokenContract = TokenInterface(_token); TokenInterface tokenContract = TokenInterface(_token);
_amt = _amt == uint256(-1) if (_amt == uint256(-1)) {
? getOnBehalfOfPaybackBalance(_token, rateMode, onBehalfOf) uint256 _amtDSA = isEth
: _amt; ? address(this).balance
: tokenContract.balanceOf(address(this));
uint256 _amtDebt = getOnBehalfOfPaybackBalance(
_token,
rateMode,
onBehalfOf
);
_amt = _amtDSA > _amtDebt ? _amtDebt : _amtDSA;
}
if (isEth) convertEthToWeth(isEth, tokenContract, _amt); if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
@ -511,5 +526,5 @@ abstract contract SparkConnector is Events, Helpers {
} }
contract ConnectV2Spark is SparkConnector { contract ConnectV2Spark is SparkConnector {
string public constant name = "Spark-v1.0"; string public constant name = "Spark-v1.1";
} }