fixed aave swapMode bug

This commit is contained in:
pradyuman-verma 2022-06-18 19:00:36 +05:30
parent e99ee70ead
commit 4daba04266
No known key found for this signature in database
GPG Key ID: E36FD6BC8923221F
3 changed files with 46 additions and 44 deletions

View File

@ -276,28 +276,29 @@ abstract contract AaveResolver is Events, Helpers {
_eventParam = abi.encode(tokens);
}
/**
* @dev Swap borrow rate mode
* @notice Swaps user borrow rate mode between variable and stable
* @param token The address of the token to swap borrow rate.(For AVAX: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param rateMode Desired borrow rate mode. (Stable = 1, Variable = 2)
*/
function swapBorrowRateMode(address token, uint256 rateMode)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
uint256 currentRateMode = rateMode == 1 ? 2 : 1;
/**
* @dev Swap borrow rate mode
* @notice Swaps user borrow rate mode between variable and stable
* @param token The address of the token to swap borrow rate.(For AVAX: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param currentRateMode Current Rate mode. (Stable = 1, Variable = 2)
*/
function swapBorrowRateMode(
address token,
uint currentRateMode
) external payable returns (string memory _eventName, bytes memory _eventParam) {
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
if (getPaybackBalance(token, currentRateMode) > 0) {
aave.swapBorrowRateMode(token, rateMode);
}
bool isAVAX = token == avaxAddr;
address _token = isAVAX ? wavaxAddr : token;
_eventName = "LogSwapRateMode(address,uint256)";
_eventParam = abi.encode(token, rateMode);
}
if (getPaybackBalance(_token, currentRateMode) > 0) {
aave.swapBorrowRateMode(_token, currentRateMode);
}
_eventName = "LogSwapRateMode(address,uint256)";
_eventParam = abi.encode(token, currentRateMode);
}
}
contract ConnectV2AaveV2Avalanche is AaveResolver {

View File

@ -245,22 +245,23 @@ abstract contract AaveResolver is Events, Helpers {
* @dev Swap borrow rate mode
* @notice Swaps user borrow rate mode between variable and stable
* @param token The address of the token to swap borrow rate.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param rateMode Desired borrow rate mode. (Stable = 1, Variable = 2)
* @param currentRateMode Current Rate mode. (Stable = 1, Variable = 2)
*/
function swapBorrowRateMode(
address token,
uint rateMode
uint currentRateMode
) external payable returns (string memory _eventName, bytes memory _eventParam) {
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
uint currentRateMode = rateMode == 1 ? 2 : 1;
bool isEth = token == ethAddr;
address _token = isEth ? wethAddr : token;
if (getPaybackBalance(token, currentRateMode) > 0) {
aave.swapBorrowRateMode(token, rateMode);
if (getPaybackBalance(_token, currentRateMode) > 0) {
aave.swapBorrowRateMode(_token, currentRateMode);
}
_eventName = "LogSwapRateMode(address,uint256)";
_eventParam = abi.encode(token, rateMode);
_eventParam = abi.encode(token, currentRateMode);
}
}

View File

@ -276,28 +276,28 @@ abstract contract AaveResolver is Events, Helpers {
_eventParam = abi.encode(tokens);
}
/**
* @dev Swap borrow rate mode
* @notice Swaps user borrow rate mode between variable and stable
* @param token The address of the token to swap borrow rate.(For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param rateMode Desired borrow rate mode. (Stable = 1, Variable = 2)
*/
function swapBorrowRateMode(address token, uint256 rateMode)
external
payable
returns (string memory _eventName, bytes memory _eventParam)
{
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
/**
* @dev Swap borrow rate mode
* @notice Swaps user borrow rate mode between variable and stable
* @param token The address of the token to swap borrow rate.(For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
* @param currentRateMode Current Rate mode. (Stable = 1, Variable = 2)
*/
function swapBorrowRateMode(
address token,
uint currentRateMode
) external payable returns (string memory _eventName, bytes memory _eventParam) {
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
uint256 currentRateMode = rateMode == 1 ? 2 : 1;
bool isMatic = token == maticAddr;
address _token = isMatic ? wmaticAddr : token;
if (getPaybackBalance(token, currentRateMode) > 0) {
aave.swapBorrowRateMode(token, rateMode);
}
if (getPaybackBalance(_token, currentRateMode) > 0) {
aave.swapBorrowRateMode(_token, currentRateMode);
}
_eventName = "LogSwapRateMode(address,uint256)";
_eventParam = abi.encode(token, rateMode);
}
_eventName = "LogSwapRateMode(address,uint256)";
_eventParam = abi.encode(token, currentRateMode);
}
}
contract ConnectV2AaveV2Polygon is AaveResolver {