From 062029d9b4cbd5665c38a031f242763bc7cc1e25 Mon Sep 17 00:00:00 2001 From: Shriya Tyagi Date: Wed, 27 Apr 2022 18:11:52 +0400 Subject: [PATCH] updated changes-polygon --- .../polygon/connectors/aave/v3/events.sol | 22 +++++++++++++-- .../polygon/connectors/aave/v3/helpers.sol | 2 +- contracts/polygon/connectors/aave/v3/main.sol | 28 +++++++++++++------ 3 files changed, 40 insertions(+), 12 deletions(-) diff --git a/contracts/polygon/connectors/aave/v3/events.sol b/contracts/polygon/connectors/aave/v3/events.sol index 3b2513dd..32926b9a 100644 --- a/contracts/polygon/connectors/aave/v3/events.sol +++ b/contracts/polygon/connectors/aave/v3/events.sol @@ -32,10 +32,26 @@ contract Events { event LogDisableCollateral(address[] tokens); event LogSwapRateMode(address indexed token, uint256 rateMode); event LogSetUserEMode(uint8 categoryId); - event LogApproveDelegation( + event LogDelegateBorrow( address token, - uint16 debtType, + uint256 amount, + uint16 rateMode, address delegateTo, - uint256 amount + uint256 getId, + uint256 setId + ); + event LogDepositWithoutCollateral( + address token, + uint256 amt, + uint256 getId, + uint256 setId + ); + event LogBorrowOnBehalfOf( + address token, + uint256 amt, + uint256 rateMode, + address onBehalfOf, + uint256 getId, + uint256 setId ); } diff --git a/contracts/polygon/connectors/aave/v3/helpers.sol b/contracts/polygon/connectors/aave/v3/helpers.sol index 01fc3bcb..4b2d239b 100644 --- a/contracts/polygon/connectors/aave/v3/helpers.sol +++ b/contracts/polygon/connectors/aave/v3/helpers.sol @@ -70,7 +70,7 @@ abstract contract Helpers is DSMath, Basic { * @param token token address of the asset * @param rateMode Debt type: stable-1, variable-2 */ - function getDTokenAddr(address token, uint16 rateMode) + function getDTokenAddr(address token, uint256 rateMode) internal view returns(address dToken) diff --git a/contracts/polygon/connectors/aave/v3/main.sol b/contracts/polygon/connectors/aave/v3/main.sol index 30a9f8ce..35d20767 100644 --- a/contracts/polygon/connectors/aave/v3/main.sol +++ b/contracts/polygon/connectors/aave/v3/main.sol @@ -109,7 +109,7 @@ abstract contract AaveResolver is Events, Helpers { setUint(setId, _amt); - _eventName = "LogDeposit(address,uint256,uint256,uint256)"; + _eventName = "LogDepositWithoutCollateral(address,uint256,uint256,uint256)"; _eventParam = abi.encode(token, _amt, getId, setId); } @@ -223,8 +223,8 @@ abstract contract AaveResolver is Events, Helpers { setUint(setId, _amt); - _eventName = "LogBorrow(address,uint256,uint256,uint256,uint256)"; - _eventParam = abi.encode(token, _amt, rateMode, getId, setId); + _eventName = "LogBorrowOnBehalfOf(address,uint256,uint256,address,uint256,uint256)"; + _eventParam = abi.encode(token, _amt, rateMode, onBehalfOf, getId, setId); } /** @@ -410,25 +410,37 @@ abstract contract AaveResolver is Events, Helpers { * @dev Approve Delegation * @notice Gives approval to delegate debt tokens * @param token The address of token + * @param amount The amount * @param rateMode The type of borrow debt * @param delegateTo The address to whom the user is delegating - * @param amount The amount + * @param getId ID to retrieve amt. + * @param setId ID stores the amount of tokens deposited. */ - function approveDelegation(address token, uint16 rateMode, address delegateTo, uint256 amount) + function delegateBorrow( + address token, + uint256 amount, + uint256 rateMode, + address delegateTo, + uint256 getId, + uint256 setId + ) external payable returns (string memory _eventName, bytes memory _eventParam) { require(rateMode == 1 || rateMode == 2, "Invalid debt type"); + uint256 _amt = getUint(getId, amount); bool isMatic = token == maticAddr; address _token = isMatic ? wmaticAddr : token; address _dToken = getDTokenAddr(_token, rateMode); - DTokenInterface(_dToken).approveDelegation(delegateTo, amount); + DTokenInterface(_dToken).approveDelegation(delegateTo, _amt); - _eventName = "LogApproveDelegation(address,uint16,address,uint256)"; - _eventParam = abi.encode(token, rateMode, delegateTo, amount); + setUint(setId, _amt); + + _eventName = "LogDelegateBorrow(address,uint256,uint256,address,uint256,uint256)"; + _eventParam = abi.encode(token, _amt, rateMode, delegateTo, getId, setId); } }