mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
fixed aave swapMode bug
This commit is contained in:
parent
e99ee70ead
commit
4daba04266
|
@ -276,28 +276,29 @@ abstract contract AaveResolver is Events, Helpers {
|
||||||
_eventParam = abi.encode(tokens);
|
_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) {
|
bool isAVAX = token == avaxAddr;
|
||||||
aave.swapBorrowRateMode(token, rateMode);
|
address _token = isAVAX ? wavaxAddr : token;
|
||||||
}
|
|
||||||
|
|
||||||
_eventName = "LogSwapRateMode(address,uint256)";
|
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||||
_eventParam = abi.encode(token, rateMode);
|
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_eventName = "LogSwapRateMode(address,uint256)";
|
||||||
|
_eventParam = abi.encode(token, currentRateMode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectV2AaveV2Avalanche is AaveResolver {
|
contract ConnectV2AaveV2Avalanche is AaveResolver {
|
||||||
|
|
|
@ -245,22 +245,23 @@ abstract contract AaveResolver is Events, Helpers {
|
||||||
* @dev Swap borrow rate mode
|
* @dev Swap borrow rate mode
|
||||||
* @notice Swaps user borrow rate mode between variable and stable
|
* @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 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(
|
function swapBorrowRateMode(
|
||||||
address token,
|
address token,
|
||||||
uint rateMode
|
uint currentRateMode
|
||||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
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) {
|
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||||
aave.swapBorrowRateMode(token, rateMode);
|
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventName = "LogSwapRateMode(address,uint256)";
|
_eventName = "LogSwapRateMode(address,uint256)";
|
||||||
_eventParam = abi.encode(token, rateMode);
|
_eventParam = abi.encode(token, currentRateMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -276,28 +276,28 @@ abstract contract AaveResolver is Events, Helpers {
|
||||||
_eventParam = abi.encode(tokens);
|
_eventParam = abi.encode(tokens);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Swap borrow rate mode
|
* @dev Swap borrow rate mode
|
||||||
* @notice Swaps user borrow rate mode between variable and stable
|
* @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 token The address of the token to swap borrow rate.(For MATIC: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||||
* @param rateMode Desired borrow rate mode. (Stable = 1, Variable = 2)
|
* @param currentRateMode Current Rate mode. (Stable = 1, Variable = 2)
|
||||||
*/
|
*/
|
||||||
function swapBorrowRateMode(address token, uint256 rateMode)
|
function swapBorrowRateMode(
|
||||||
external
|
address token,
|
||||||
payable
|
uint currentRateMode
|
||||||
returns (string memory _eventName, bytes memory _eventParam)
|
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||||
{
|
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||||
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) {
|
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||||
aave.swapBorrowRateMode(token, rateMode);
|
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
_eventName = "LogSwapRateMode(address,uint256)";
|
_eventName = "LogSwapRateMode(address,uint256)";
|
||||||
_eventParam = abi.encode(token, rateMode);
|
_eventParam = abi.encode(token, currentRateMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
contract ConnectV2AaveV2Polygon is AaveResolver {
|
contract ConnectV2AaveV2Polygon is AaveResolver {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user