Skip to content

Commit

Permalink
fix: renaming _safeTransfer for ICA
Browse files Browse the repository at this point in the history
  • Loading branch information
0xmikko committed May 11, 2023
1 parent 55eda2b commit ee2ad63
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
10 changes: 5 additions & 5 deletions contracts/credit/CreditManagerV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard
}

// Transfers the due funds to the pool
ICreditAccount(creditAccount)._safeTransfer(underlying, pool, amountToPool); // F:[CM-10,11,12,13]
ICreditAccount(creditAccount).transfer(underlying, pool, amountToPool); // F:[CM-10,11,12,13]

// Signals to the pool that debt has been repaid. The pool relies
// on the Credit Manager to repay the debt correctly, and does not
Expand Down Expand Up @@ -443,7 +443,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard
}

// Pays the amount back to the pool
ICreditAccount(creditAccount)._safeTransfer(underlying, pool, amount); // F:[CM-21]
ICreditAccount(creditAccount).transfer(underlying, pool, amount); // F:[CM-21]
{
uint256 amountToRepay;
uint256 profit;
Expand Down Expand Up @@ -888,12 +888,12 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard
internal
{
if (convertToETH && token == wethAddress) {
ICreditAccount(creditAccount)._safeTransfer(token, wethGateway, amount); // F:[CM-45]
ICreditAccount(creditAccount).transfer(token, wethGateway, amount); // F:[CM-45]
IWETHGateway(wethGateway).depositFor(to, amount); // F:[CM-45]
} else {
try ICreditAccount(creditAccount).safeTransfer(token, to, amount) { // F:[CM-45]
} catch {
uint256 delivered = ICreditAccount(creditAccount).safeTransferDeliveredBalanceControl(
uint256 delivered = ICreditAccount(creditAccount).transferDeliveredBalanceControl(
token, address(withdrawalManager), amount
);
withdrawalManager.addImmediateWithdrawal(to, token, delivered);
Expand Down Expand Up @@ -1249,7 +1249,7 @@ contract CreditManagerV3 is ICreditManagerV3, SanityCheckTrait, ReentrancyGuard
uint256 tokenMask = getTokenMaskOrRevert(token);

uint256 delivered =
ICreditAccount(creditAccount).safeTransferDeliveredBalanceControl(token, address(withdrawalManager), amount);
ICreditAccount(creditAccount).transferDeliveredBalanceControl(token, address(withdrawalManager), amount);

withdrawalManager.addScheduledWithdrawal(creditAccount, token, delivered, tokenMask.calcIndex());

Expand Down
14 changes: 6 additions & 8 deletions contracts/libraries/CreditAccountHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,16 @@ library CreditAccountHelper {
return false;
}

function _safeTransfer(ICreditAccount creditAccount, address token, address to, uint256 amount) internal {
function transfer(ICreditAccount creditAccount, address token, address to, uint256 amount) internal {
ICreditAccount(creditAccount).safeTransfer(token, to, amount);
}

function safeTransferDeliveredBalanceControl(
ICreditAccount creditAccount,
address token,
address to,
uint256 amount
) internal returns (uint256 delivered) {
function transferDeliveredBalanceControl(ICreditAccount creditAccount, address token, address to, uint256 amount)
internal
returns (uint256 delivered)
{
uint256 balanceBefore = IERC20Helper.balanceOf(token, to);
_safeTransfer(creditAccount, token, to, amount);
transfer(creditAccount, token, to, amount);
delivered = IERC20Helper.balanceOf(token, to) - balanceBefore;
}
}

0 comments on commit ee2ad63

Please sign in to comment.