comments and nits

This commit is contained in:
Noah Khamliche 2022-05-18 11:25:25 -04:00 committed by Noah Khamliche
parent 49b0e32129
commit 177c00463a

View File

@ -4,7 +4,6 @@ pragma experimental ABIEncoderV2;
import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol"; import "@0x/contracts-erc20/contracts/src/v06/LibERC20TokenV06.sol";
import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol"; import "@0x/contracts-erc20/contracts/src/v06/IERC20TokenV06.sol";
import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol"; import "@0x/contracts-utils/contracts/src/v06/LibSafeMathV06.sol";
import "../IBridgeAdapter.sol";
interface IPlatypusRouter { interface IPlatypusRouter {
@ -45,8 +44,8 @@ contract MixinPlatypus {
assembly { path := _path } assembly { path := _path }
} }
//connect to the ptp router
router = IPlatypusRouter(_router); router = IPlatypusRouter(_router);
//corresponding platypus asset pool for the ERC20's in the path
require(path.length >= 2, "MixinPlatypus/PATH_LENGTH_MUST_BE_AT_LEAST_TWO"); require(path.length >= 2, "MixinPlatypus/PATH_LENGTH_MUST_BE_AT_LEAST_TWO");
require( require(
@ -56,12 +55,13 @@ contract MixinPlatypus {
// Grant the Platypus router an allowance to sell the first token. // Grant the Platypus router an allowance to sell the first token.
path[0].approveIfBelow(address(router), sellAmount); path[0].approveIfBelow(address(router), sellAmount);
//keep track of the previous balance to confirm amount out
uint256 beforeBalance = buyToken.balanceOf(address(this)); uint256 beforeBalance = buyToken.balanceOf(address(this));
(uint256 amountOut, uint256 haircut) = router.swapTokensForTokens( (uint256 amountOut, uint256 haircut) = router.swapTokensForTokens(
// Convert to `buyToken` along this path. // Convert to `buyToken` along this path.
_path, _path,
// // pool to swap on
_pool, _pool,
// Sell all tokens we hold. // Sell all tokens we hold.
sellAmount, sellAmount,
@ -70,8 +70,9 @@ contract MixinPlatypus {
// Recipient is `this`. // Recipient is `this`.
address(this), address(this),
block.timestamp + 10000 block.timestamp + 1
); );
//calculate the buy amount from the tokens we recieved
boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance); boughtAmount = buyToken.balanceOf(address(this)).safeSub(beforeBalance);
return boughtAmount; return boughtAmount;
} }