mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
feat: fix payback in spark and aave v3
This commit is contained in:
parent
ca7879da10
commit
eb053692e8
|
@ -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 ? _amtDSA : _amtDebt;
|
||||||
|
}
|
||||||
|
|
||||||
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 ? _amtDSA : _amtDebt;
|
||||||
|
}
|
||||||
|
|
||||||
if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
|
if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
|
||||||
|
|
||||||
|
|
|
@ -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 ? _amtDSA : _amtDebt;
|
||||||
|
}
|
||||||
|
|
||||||
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 ? _amtDSA : _amtDebt;
|
||||||
|
}
|
||||||
|
|
||||||
if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
|
if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user