mirror of
https://github.com/Instadapp/dsa-connectors.git
synced 2024-07-29 22:37:00 +00:00
lint fix
This commit is contained in:
parent
51f4b1b9f4
commit
09bcc1b8f7
|
@ -267,7 +267,7 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
bool isAvax = tokens[i] == avaxAddr;
|
||||
address _token = isAvax ? wavaxAddr : tokens[i];
|
||||
address _token = isAvax ? wavaxAddr : tokens[i];
|
||||
|
||||
if (getCollateralBalance(_token) > 0 && !getIsColl(_token)) {
|
||||
aave.setUserUseReserveAsCollateral(_token, true);
|
||||
|
@ -278,28 +278,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 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());
|
||||
/**
|
||||
* @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, uint256 currentRateMode)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
|
||||
bool isAVAX = token == avaxAddr;
|
||||
address _token = isAVAX ? wavaxAddr : token;
|
||||
|
||||
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||
}
|
||||
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||
}
|
||||
|
||||
_eventName = "LogSwapRateMode(address,uint256)";
|
||||
_eventParam = abi.encode(token, currentRateMode);
|
||||
}
|
||||
_eventName = "LogSwapRateMode(address,uint256)";
|
||||
_eventParam = abi.encode(token, currentRateMode);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2AaveV2Avalanche is AaveResolver {
|
||||
|
|
|
@ -13,162 +13,182 @@ import { Events } from "./events.sol";
|
|||
import { AaveInterface } from "./interface.sol";
|
||||
|
||||
abstract contract AaveResolver is Events, Helpers {
|
||||
/**
|
||||
* @dev Deposit ETH/ERC20_Token.
|
||||
* @notice Deposit a token to Aave v2 for lending / collaterization.
|
||||
* @param token The address of the token to deposit.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to deposit. (For max: `uint256(-1)`)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens deposited.
|
||||
*/
|
||||
function deposit(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
/**
|
||||
* @dev Deposit ETH/ERC20_Token.
|
||||
* @notice Deposit a token to Aave v2 for lending / collaterization.
|
||||
* @param token The address of the token to deposit.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to deposit. (For max: `uint256(-1)`)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens deposited.
|
||||
*/
|
||||
function deposit(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
||||
if (isEth) {
|
||||
_amt = _amt == uint(-1) ? address(this).balance : _amt;
|
||||
convertEthToWeth(isEth, tokenContract, _amt);
|
||||
} else {
|
||||
_amt = _amt == uint(-1) ? tokenContract.balanceOf(address(this)) : _amt;
|
||||
}
|
||||
if (isEth) {
|
||||
_amt = _amt == uint256(-1) ? address(this).balance : _amt;
|
||||
convertEthToWeth(isEth, tokenContract, _amt);
|
||||
} else {
|
||||
_amt = _amt == uint256(-1)
|
||||
? tokenContract.balanceOf(address(this))
|
||||
: _amt;
|
||||
}
|
||||
|
||||
approve(tokenContract, address(aave), _amt);
|
||||
approve(tokenContract, address(aave), _amt);
|
||||
|
||||
aave.deposit(_token, _amt, address(this), referralCode);
|
||||
aave.deposit(_token, _amt, address(this), referralCode);
|
||||
|
||||
if (!getIsColl(_token)) {
|
||||
aave.setUserUseReserveAsCollateral(_token, true);
|
||||
}
|
||||
if (!getIsColl(_token)) {
|
||||
aave.setUserUseReserveAsCollateral(_token, true);
|
||||
}
|
||||
|
||||
setUint(setId, _amt);
|
||||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogDeposit(address,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, getId, setId);
|
||||
}
|
||||
_eventName = "LogDeposit(address,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Withdraw ETH/ERC20_Token.
|
||||
* @notice Withdraw deposited token from Aave v2
|
||||
* @param token The address of the token to withdraw.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to withdraw. (For max: `uint256(-1)`)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens withdrawn.
|
||||
*/
|
||||
function withdraw(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
/**
|
||||
* @dev Withdraw ETH/ERC20_Token.
|
||||
* @notice Withdraw deposited token from Aave v2
|
||||
* @param token The address of the token to withdraw.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to withdraw. (For max: `uint256(-1)`)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens withdrawn.
|
||||
*/
|
||||
function withdraw(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
||||
uint initialBal = tokenContract.balanceOf(address(this));
|
||||
aave.withdraw(_token, _amt, address(this));
|
||||
uint finalBal = tokenContract.balanceOf(address(this));
|
||||
uint256 initialBal = tokenContract.balanceOf(address(this));
|
||||
aave.withdraw(_token, _amt, address(this));
|
||||
uint256 finalBal = tokenContract.balanceOf(address(this));
|
||||
|
||||
_amt = sub(finalBal, initialBal);
|
||||
_amt = sub(finalBal, initialBal);
|
||||
|
||||
convertWethToEth(isEth, tokenContract, _amt);
|
||||
|
||||
setUint(setId, _amt);
|
||||
convertWethToEth(isEth, tokenContract, _amt);
|
||||
|
||||
_eventName = "LogWithdraw(address,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, getId, setId);
|
||||
}
|
||||
setUint(setId, _amt);
|
||||
|
||||
/**
|
||||
* @dev Borrow ETH/ERC20_Token.
|
||||
* @notice Borrow a token using Aave v2
|
||||
* @param token The address of the token to borrow.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to borrow.
|
||||
* @param rateMode The type of borrow debt. (For Stable: 1, Variable: 2)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens borrowed.
|
||||
*/
|
||||
function borrow(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 rateMode,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
_eventName = "LogWithdraw(address,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, getId, setId);
|
||||
}
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
/**
|
||||
* @dev Borrow ETH/ERC20_Token.
|
||||
* @notice Borrow a token using Aave v2
|
||||
* @param token The address of the token to borrow.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to borrow.
|
||||
* @param rateMode The type of borrow debt. (For Stable: 1, Variable: 2)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens borrowed.
|
||||
*/
|
||||
function borrow(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 rateMode,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
|
||||
aave.borrow(_token, _amt, rateMode, referralCode, address(this));
|
||||
convertWethToEth(isEth, TokenInterface(_token), _amt);
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
|
||||
setUint(setId, _amt);
|
||||
aave.borrow(_token, _amt, rateMode, referralCode, address(this));
|
||||
convertWethToEth(isEth, TokenInterface(_token), _amt);
|
||||
|
||||
_eventName = "LogBorrow(address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, getId, setId);
|
||||
}
|
||||
setUint(setId, _amt);
|
||||
|
||||
/**
|
||||
* @dev Payback borrowed ETH/ERC20_Token.
|
||||
* @notice Payback debt owed.
|
||||
* @param token The address of the token to payback.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to payback. (For max: `uint256(-1)`)
|
||||
* @param rateMode The type of debt paying back. (For Stable: 1, Variable: 2)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens paid back.
|
||||
*/
|
||||
function payback(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 rateMode,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _amt = getUint(getId, amt);
|
||||
_eventName = "LogBorrow(address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, getId, setId);
|
||||
}
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
/**
|
||||
* @dev Payback borrowed ETH/ERC20_Token.
|
||||
* @notice Payback debt owed.
|
||||
* @param token The address of the token to payback.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
* @param amt The amount of the token to payback. (For max: `uint256(-1)`)
|
||||
* @param rateMode The type of debt paying back. (For Stable: 1, Variable: 2)
|
||||
* @param getId ID to retrieve amt.
|
||||
* @param setId ID stores the amount of tokens paid back.
|
||||
*/
|
||||
function payback(
|
||||
address token,
|
||||
uint256 amt,
|
||||
uint256 rateMode,
|
||||
uint256 getId,
|
||||
uint256 setId
|
||||
)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _amt = getUint(getId, amt);
|
||||
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
||||
if (_amt == uint(-1)) {
|
||||
uint _amtDSA = isEth ? address(this).balance : tokenContract.balanceOf(address(this));
|
||||
uint _amtDebt = getPaybackBalance(_token, rateMode);
|
||||
_amt = _amtDSA <= _amtDebt ? _amtDSA : _amtDebt;
|
||||
}
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
|
||||
if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
||||
approve(tokenContract, address(aave), _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;
|
||||
}
|
||||
|
||||
aave.repay(_token, _amt, rateMode, address(this));
|
||||
if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
|
||||
|
||||
setUint(setId, _amt);
|
||||
approve(tokenContract, address(aave), _amt);
|
||||
|
||||
_eventName = "LogPayback(address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, getId, setId);
|
||||
}
|
||||
aave.repay(_token, _amt, rateMode, address(this));
|
||||
|
||||
/**
|
||||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogPayback(address,uint256,uint256,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, getId, setId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Payback borrowed ETH/ERC20_Token on behalf of a user.
|
||||
* @notice Payback debt owed on behalf os a user.
|
||||
* @param token The address of the token to payback.(For ETH: 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE)
|
||||
|
@ -199,9 +219,15 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
||||
if (_amt == uint(-1)) {
|
||||
uint _amtDSA = isEth ? address(this).balance : tokenContract.balanceOf(address(this));
|
||||
uint _amtDebt = getOnBehalfOfPaybackBalance(_token, rateMode, onBehalfOf);
|
||||
if (_amt == uint256(-1)) {
|
||||
uint256 _amtDSA = isEth
|
||||
? address(this).balance
|
||||
: tokenContract.balanceOf(address(this));
|
||||
uint256 _amtDebt = getOnBehalfOfPaybackBalance(
|
||||
_token,
|
||||
rateMode,
|
||||
onBehalfOf
|
||||
);
|
||||
_amt = _amtDSA <= _amtDebt ? _amtDSA : _amtDebt;
|
||||
}
|
||||
|
||||
|
@ -214,59 +240,69 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogPaybackOnBehalfOf(address,uint256,uint256,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, onBehalfOf, getId, setId);
|
||||
_eventParam = abi.encode(
|
||||
token,
|
||||
_amt,
|
||||
rateMode,
|
||||
onBehalfOf,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dev Enable collateral
|
||||
* @notice Enable an array of tokens as collateral
|
||||
* @param tokens Array of tokens to enable collateral
|
||||
*/
|
||||
function enableCollateral(
|
||||
address[] calldata tokens
|
||||
) external payable returns (string memory _eventName, bytes memory _eventParam) {
|
||||
uint _length = tokens.length;
|
||||
require(_length > 0, "0-tokens-not-allowed");
|
||||
/**
|
||||
* @dev Enable collateral
|
||||
* @notice Enable an array of tokens as collateral
|
||||
* @param tokens Array of tokens to enable collateral
|
||||
*/
|
||||
function enableCollateral(address[] calldata tokens)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
uint256 _length = tokens.length;
|
||||
require(_length > 0, "0-tokens-not-allowed");
|
||||
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
|
||||
for (uint i = 0; i < _length; i++) {
|
||||
bool isEth = tokens[i] == ethAddr;
|
||||
address _token = isEth ? wethAddr : tokens[i];
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
bool isEth = tokens[i] == ethAddr;
|
||||
address _token = isEth ? wethAddr : tokens[i];
|
||||
|
||||
if (getCollateralBalance(_token) > 0 && !getIsColl(_token)) {
|
||||
aave.setUserUseReserveAsCollateral(_token, true);
|
||||
}
|
||||
}
|
||||
if (getCollateralBalance(_token) > 0 && !getIsColl(_token)) {
|
||||
aave.setUserUseReserveAsCollateral(_token, true);
|
||||
}
|
||||
}
|
||||
|
||||
_eventName = "LogEnableCollateral(address[])";
|
||||
_eventParam = abi.encode(tokens);
|
||||
}
|
||||
_eventName = "LogEnableCollateral(address[])";
|
||||
_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 ETH: 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());
|
||||
/**
|
||||
* @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 currentRateMode Current Rate mode. (Stable = 1, Variable = 2)
|
||||
*/
|
||||
function swapBorrowRateMode(address token, uint256 currentRateMode)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
|
||||
bool isEth = token == ethAddr;
|
||||
address _token = isEth ? wethAddr : token;
|
||||
|
||||
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||
}
|
||||
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||
}
|
||||
|
||||
_eventName = "LogSwapRateMode(address,uint256)";
|
||||
_eventParam = abi.encode(token, currentRateMode);
|
||||
}
|
||||
_eventName = "LogSwapRateMode(address,uint256)";
|
||||
_eventParam = abi.encode(token, currentRateMode);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2AaveV2 is AaveResolver {
|
||||
string constant public name = "AaveV2-v1.2";
|
||||
string public constant name = "AaveV2-v1.2";
|
||||
}
|
||||
|
|
|
@ -224,7 +224,14 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogBorrowOnBehalfOf(address,uint256,uint256,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, onBehalfOf, getId, setId);
|
||||
_eventParam = abi.encode(
|
||||
token,
|
||||
_amt,
|
||||
rateMode,
|
||||
onBehalfOf,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -344,7 +351,9 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
|
||||
TokenInterface tokenContract = TokenInterface(_token);
|
||||
|
||||
_amt = _amt == uint256(-1) ? getOnBehalfOfPaybackBalance(_token, rateMode, onBehalfOf) : _amt;
|
||||
_amt = _amt == uint256(-1)
|
||||
? getOnBehalfOfPaybackBalance(_token, rateMode, onBehalfOf)
|
||||
: _amt;
|
||||
|
||||
if (isEth) convertEthToWeth(isEth, tokenContract, _amt);
|
||||
|
||||
|
@ -355,10 +364,16 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogPaybackOnBehalfOf(address,uint256,uint256,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, onBehalfOf, getId, setId);
|
||||
_eventParam = abi.encode(
|
||||
token,
|
||||
_amt,
|
||||
rateMode,
|
||||
onBehalfOf,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @dev Enable collateral
|
||||
* @notice Enable an array of tokens as collateral
|
||||
|
@ -463,8 +478,14 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
setUint(setId, _amt);
|
||||
|
||||
_eventName = "LogDelegateBorrow(address,uint256,uint256,address,uint256,uint256)";
|
||||
_eventParam = abi.encode(token, _amt, rateMode, delegateTo, getId, setId);
|
||||
|
||||
_eventParam = abi.encode(
|
||||
token,
|
||||
_amt,
|
||||
rateMode,
|
||||
delegateTo,
|
||||
getId,
|
||||
setId
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -267,7 +267,7 @@ abstract contract AaveResolver is Events, Helpers {
|
|||
|
||||
for (uint256 i = 0; i < _length; i++) {
|
||||
bool isMatic = tokens[i] == maticAddr;
|
||||
address _token = isMatic ? wmaticAddr : tokens[i];
|
||||
address _token = isMatic ? wmaticAddr : tokens[i];
|
||||
|
||||
if (getCollateralBalance(_token) > 0 && !getIsColl(_token)) {
|
||||
aave.setUserUseReserveAsCollateral(_token, true);
|
||||
|
@ -278,28 +278,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 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());
|
||||
/**
|
||||
* @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, uint256 currentRateMode)
|
||||
external
|
||||
payable
|
||||
returns (string memory _eventName, bytes memory _eventParam)
|
||||
{
|
||||
AaveInterface aave = AaveInterface(aaveProvider.getLendingPool());
|
||||
|
||||
bool isMatic = token == maticAddr;
|
||||
address _token = isMatic ? wmaticAddr : token;
|
||||
|
||||
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||
}
|
||||
if (getPaybackBalance(_token, currentRateMode) > 0) {
|
||||
aave.swapBorrowRateMode(_token, currentRateMode);
|
||||
}
|
||||
|
||||
_eventName = "LogSwapRateMode(address,uint256)";
|
||||
_eventParam = abi.encode(token, currentRateMode);
|
||||
}
|
||||
_eventName = "LogSwapRateMode(address,uint256)";
|
||||
_eventParam = abi.encode(token, currentRateMode);
|
||||
}
|
||||
}
|
||||
|
||||
contract ConnectV2AaveV2Polygon is AaveResolver {
|
||||
|
|
Loading…
Reference in New Issue
Block a user