diff --git a/contracts/CToken.sol b/contracts/CToken.sol index b7bc82d57..9d909cd3c 100644 --- a/contracts/CToken.sol +++ b/contracts/CToken.sol @@ -538,16 +538,6 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { // EFFECTS & INTERACTIONS // (No safe failures beyond this point) - /* - * We call `doTransferIn` for the minter and the mintAmount. - * Note: The cToken must handle variations between ERC-20 and ETH underlying. - * `doTransferIn` reverts if anything goes wrong, since we can't be sure if - * side-effects occurred. The function returns the amount actually transferred, - * in case of a fee. On success, the cToken holds an additional `actualMintAmount` - * of cash. - */ - vars.actualMintAmount = doTransferIn(minter, mintAmount); - /* * We get the current exchange rate and calculate the number of cTokens to be minted: * mintTokens = actualMintAmount / exchangeRate @@ -569,6 +559,16 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { totalSupply = vars.totalSupplyNew; accountTokens[minter] = vars.accountTokensNew; + /* + * We call `doTransferIn` for the minter and the mintAmount. + * Note: The cToken must handle variations between ERC-20 and ETH underlying. + * `doTransferIn` reverts if anything goes wrong, since we can't be sure if + * side-effects occurred. The function returns the amount actually transferred, + * in case of a fee. On success, the cToken holds an additional `actualMintAmount` + * of cash. + */ + vars.actualMintAmount = doTransferIn(minter, mintAmount); + /* We emit a Mint event, and a Transfer event */ emit Mint(minter, vars.actualMintAmount, vars.mintTokens); emit Transfer(address(this), minter, vars.mintTokens); @@ -909,15 +909,6 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { // EFFECTS & INTERACTIONS // (No safe failures beyond this point) - /* - * We call doTransferIn for the payer and the repayAmount - * Note: The cToken must handle variations between ERC-20 and ETH underlying. - * On success, the cToken holds an additional repayAmount of cash. - * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. - * it returns the amount actually transferred, in case of a fee. - */ - vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount); - /* * We calculate the new borrower and total borrow balances, failing on underflow: * accountBorrowsNew = accountBorrows - actualRepayAmount @@ -934,6 +925,15 @@ contract CToken is CTokenInterface, Exponential, TokenErrorReporter { accountBorrows[borrower].interestIndex = borrowIndex; totalBorrows = vars.totalBorrowsNew; + /* + * We call doTransferIn for the payer and the repayAmount + * Note: The cToken must handle variations between ERC-20 and ETH underlying. + * On success, the cToken holds an additional repayAmount of cash. + * doTransferIn reverts if anything goes wrong, since we can't be sure if side effects occurred. + * it returns the amount actually transferred, in case of a fee. + */ + vars.actualRepayAmount = doTransferIn(payer, vars.repayAmount); + /* We emit a RepayBorrow event */ emit RepayBorrow(payer, borrower, vars.actualRepayAmount, vars.accountBorrowsNew, vars.totalBorrowsNew);