From fce470cfb74985cd3a8a61f1d1e8330b2f38382a Mon Sep 17 00:00:00 2001 From: Hadrien Charlanes Date: Mon, 5 Jul 2021 10:03:15 +0200 Subject: [PATCH] refactor: created internal approve delegation function --- .../protocol/tokenization/base/DebtTokenBase.sol | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/contracts/protocol/tokenization/base/DebtTokenBase.sol b/contracts/protocol/tokenization/base/DebtTokenBase.sol index 4d75bc2f..11f43916 100644 --- a/contracts/protocol/tokenization/base/DebtTokenBase.sol +++ b/contracts/protocol/tokenization/base/DebtTokenBase.sol @@ -38,8 +38,7 @@ abstract contract DebtTokenBase is * force a delegator HF to go below 1) **/ function approveDelegation(address delegatee, uint256 amount) external override { - _borrowAllowances[_msgSender()][delegatee] = amount; - emit BorrowAllowanceDelegated(_msgSender(), delegatee, _getUnderlyingAssetAddress(), amount); + _approveDelegation(_msgSender(), delegatee, amount); } /** @@ -118,6 +117,15 @@ abstract contract DebtTokenBase is revert('ALLOWANCE_NOT_SUPPORTED'); } + function _approveDelegation( + address delegator, + address delegatee, + uint256 amount + ) internal { + _borrowAllowances[delegator][delegatee] = amount; + emit BorrowAllowanceDelegated(delegator, delegatee, _getUnderlyingAssetAddress(), amount); + } + function _decreaseBorrowAllowance( address delegator, address delegatee,