diff --git a/contracts/interfaces/IPool.sol b/contracts/interfaces/IPool.sol index 2226b1a4a..e6040a9a0 100644 --- a/contracts/interfaces/IPool.sol +++ b/contracts/interfaces/IPool.sol @@ -16,16 +16,14 @@ interface IPool { * @param user The address initiating the supply * @param onBehalfOf The beneficiary of the supply, receiving the aTokens * @param amount The amount supplied - * @param referral The referral code used - * @param useAsCollateral True if the user wants to use the supplied asset as collateral, false otherwise + * @param referralCode The referral code used **/ event Supply( address indexed reserve, address user, address indexed onBehalfOf, uint256 amount, - uint16 indexed referral, - bool useAsCollateral + uint16 indexed referralCode ); /** @@ -175,14 +173,12 @@ interface IPool { * is a different wallet * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man - * @param useAsCollateral True if the user wants to use the supplied asset as collateral, false otherwise **/ function supply( address asset, uint256 amount, address onBehalfOf, - uint16 referralCode, - bool useAsCollateral + uint16 referralCode ) external; /** @@ -196,7 +192,6 @@ interface IPool { * @param deadline The deadline timestamp that the permit is valid * @param referralCode Code used to register the integrator originating the operation, for potential rewards. * 0 if the action is executed directly by the user, without any middle-man - * @param useAsCollateral True if the user wants to use the supplied asset as collateral, false otherwise * @param permitV The V parameter of ERC712 permit sig * @param permitR The R parameter of ERC712 permit sig * @param permitS The S parameter of ERC712 permit sig @@ -207,7 +202,6 @@ interface IPool { address onBehalfOf, uint16 referralCode, uint256 deadline, - bool useAsCollateral, uint8 permitV, bytes32 permitR, bytes32 permitS diff --git a/contracts/protocol/libraries/logic/SupplyLogic.sol b/contracts/protocol/libraries/logic/SupplyLogic.sol index 7ea8f0a13..57d0bd8da 100644 --- a/contracts/protocol/libraries/logic/SupplyLogic.sol +++ b/contracts/protocol/libraries/logic/SupplyLogic.sol @@ -38,14 +38,12 @@ library SupplyLogic { address user, address indexed onBehalfOf, uint256 amount, - uint16 indexed referral, - bool useAsCollateral + uint16 indexed referralCode ); function executeSupply( mapping(address => DataTypes.ReserveData) storage reserves, DataTypes.UserConfigurationMap storage userConfig, - mapping(uint256 => address) storage reservesList, DataTypes.ExecuteSupplyParams memory params ) internal { DataTypes.ReserveData storage reserve = reserves[params.asset]; @@ -65,42 +63,12 @@ library SupplyLogic { reserveCache.nextLiquidityIndex ); - // Apply `useAsCollateral` if: - // - user supplies assets on its own - // - user supplies assets on behalf of another user and it's their first supplied assets - if (params.onBehalfOf == msg.sender || (params.onBehalfOf != msg.sender && isFirstSupply)) { - if (params.useAsCollateral) { - userConfig.setUsingAsCollateral(reserve.id, true); - emit ReserveUsedAsCollateralEnabled(params.asset, params.onBehalfOf); - } else { - // Validate HF in case its needed - if (userConfig.isUsingAsCollateral(reserve.id)) { - userConfig.setUsingAsCollateral(reserve.id, false); - if (userConfig.isBorrowingAny()) { - ValidationLogic.validateHFAndLtv( - params.asset, - params.onBehalfOf, - reserves, - userConfig, - reservesList, - params.reservesCount, - params.oracle - ); - } - } - - emit ReserveUsedAsCollateralDisabled(params.asset, params.onBehalfOf); - } + if (isFirstSupply) { + userConfig.setUsingAsCollateral(reserve.id, true); + emit ReserveUsedAsCollateralEnabled(params.asset, params.onBehalfOf); } - emit Supply( - params.asset, - msg.sender, - params.onBehalfOf, - params.amount, - params.referralCode, - params.useAsCollateral - ); + emit Supply(params.asset, msg.sender, params.onBehalfOf, params.amount, params.referralCode); } function executeWithdraw( diff --git a/contracts/protocol/libraries/types/DataTypes.sol b/contracts/protocol/libraries/types/DataTypes.sol index 96d73761f..8534dba8f 100644 --- a/contracts/protocol/libraries/types/DataTypes.sol +++ b/contracts/protocol/libraries/types/DataTypes.sol @@ -93,9 +93,6 @@ library DataTypes { uint256 amount; address onBehalfOf; uint16 referralCode; - bool useAsCollateral; - uint256 reservesCount; - address oracle; } struct ExecuteBorrowParams { diff --git a/contracts/protocol/pool/Pool.sol b/contracts/protocol/pool/Pool.sol index 13d5a7e00..c5defc3d4 100644 --- a/contracts/protocol/pool/Pool.sol +++ b/contracts/protocol/pool/Pool.sol @@ -84,21 +84,16 @@ contract Pool is VersionedInitializable, IPool, PoolStorage { address asset, uint256 amount, address onBehalfOf, - uint16 referralCode, - bool useAsCollateral + uint16 referralCode ) external override { SupplyLogic.executeSupply( _reserves, _usersConfig[onBehalfOf], - _reservesList, DataTypes.ExecuteSupplyParams( asset, amount, onBehalfOf, - referralCode, - useAsCollateral, - _reservesCount, - _addressesProvider.getPriceOracle() + referralCode ) ); } @@ -110,7 +105,6 @@ contract Pool is VersionedInitializable, IPool, PoolStorage { address onBehalfOf, uint16 referralCode, uint256 deadline, - bool useAsCollateral, uint8 permitV, bytes32 permitR, bytes32 permitS @@ -127,15 +121,11 @@ contract Pool is VersionedInitializable, IPool, PoolStorage { SupplyLogic.executeSupply( _reserves, _usersConfig[onBehalfOf], - _reservesList, DataTypes.ExecuteSupplyParams( asset, amount, onBehalfOf, - referralCode, - useAsCollateral, - _reservesCount, - _addressesProvider.getPriceOracle() + referralCode ) ); } @@ -612,15 +602,11 @@ contract Pool is VersionedInitializable, IPool, PoolStorage { SupplyLogic.executeSupply( _reserves, _usersConfig[onBehalfOf], - _reservesList, DataTypes.ExecuteSupplyParams( asset, amount, onBehalfOf, - referralCode, - true, - _reservesCount, - _addressesProvider.getPriceOracle() + referralCode ) ); } diff --git a/test-suites/helpers/actions.ts b/test-suites/helpers/actions.ts index e9f060ae8..ebffec718 100644 --- a/test-suites/helpers/actions.ts +++ b/test-suites/helpers/actions.ts @@ -581,7 +581,6 @@ export const supplyWithPermit = async ( onBehalfOf, '0', highDeadline, - useAsCollateral, v, r, s, @@ -634,7 +633,6 @@ export const supplyWithPermit = async ( onBehalfOf, '0', highDeadline, - useAsCollateral, v, r, s,