Skip to content

Commit 95006d5

Browse files
ncitronrichardliang
authored andcommitted
audit fixes (#108)
1 parent 9898112 commit 95006d5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

contracts/product/AMMSplitter.sol

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pragma solidity 0.6.10;
2020
pragma experimental "ABIEncoderV2";
2121

2222
import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
23+
import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
2324
import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
2425

2526
import { IUniswapV2Factory } from "../interfaces/external/IUniswapV2Factory.sol";
@@ -38,6 +39,7 @@ import { PreciseUnitMath } from "../lib/PreciseUnitMath.sol";
3839
*/
3940
contract AMMSplitter {
4041

42+
using SafeERC20 for IERC20;
4143
using SafeMath for uint256;
4244
using PreciseUnitMath for uint256;
4345

@@ -133,7 +135,7 @@ contract AMMSplitter {
133135
_checkPath(_path);
134136

135137
IERC20 inputToken = IERC20(_path[0]);
136-
inputToken.transferFrom(msg.sender, address(this), _amountIn);
138+
inputToken.safeTransferFrom(msg.sender, address(this), _amountIn);
137139

138140
TradeInfo memory tradeInfo = _getTradeSizes(_path, _amountIn);
139141

@@ -191,7 +193,7 @@ contract AMMSplitter {
191193
require(totalInput <= _amountInMax, "AMMSplitter: INSUFFICIENT_INPUT_AMOUNT");
192194

193195
IERC20 inputToken = IERC20(_path[0]);
194-
inputToken.transferFrom(msg.sender, address(this), totalInput);
196+
inputToken.safeTransferFrom(msg.sender, address(this), totalInput);
195197

196198
_checkApprovals(expectedUniInput, expectedSushiInput, inputToken);
197199

@@ -328,7 +330,7 @@ contract AMMSplitter {
328330
*
329331
* This equation is derived using several assumptions. First, it assumes that the price impact is equal to 2T / P where T is
330332
* equal to the trade size, and P is equal to the pool size. This approximation holds given that the price impact is a small percentage.
331-
* The second approximation made is that when executing trades that utilize multiple hops, total price impact is the sum of the each
333+
* The second approximation made is that when executing trades that utilize multiple hops, total price impact is the sum of each
332334
* hop's price impact (not accounting for the price impact of the prior trade). This approximation again holds true under the assumption
333335
* that the total price impact is a small percentage. The full derivation of this equation can be viewed in STIP-002.
334336
*

0 commit comments

Comments
 (0)