diff --git a/contracts/Migrator.sol b/contracts/Migrator.sol index 5a98a37..c76f8eb 100644 --- a/contracts/Migrator.sol +++ b/contracts/Migrator.sol @@ -29,16 +29,18 @@ contract Migrator is IMigrator { tokenSplitScalar = scalar_; } - function migrate(uint256 amount_) external override { - migrate(msg.sender, amount_); + function migrate(uint256 oldTokenAmount_) external override returns (uint256 newTokenAmount_) { + newTokenAmount_ = migrate(msg.sender, oldTokenAmount_); } - function migrate(address owner_, uint256 amount_) public override { - require(active, "M:M:INACTIVE"); - require(amount_ != uint256(0), "M:M:ZERO_AMOUNT"); + function migrate(address owner_, uint256 oldTokenAmount_) public override returns (uint256 newTokenAmount_) { + require(active, "M:M:INACTIVE"); + require(oldTokenAmount_ != uint256(0), "M:M:ZERO_AMOUNT"); - require(ERC20Helper.transferFrom(oldToken, owner_, address(this), amount_), "M:M:TRANSFER_FROM_FAILED"); - require(ERC20Helper.transfer(newToken, owner_, amount_ * tokenSplitScalar), "M:M:TRANSFER_FAILED"); + newTokenAmount_ = oldTokenAmount_ * tokenSplitScalar; + + require(ERC20Helper.transferFrom(oldToken, owner_, address(this), oldTokenAmount_), "M:M:TRANSFER_FROM_FAILED"); + require(ERC20Helper.transfer(newToken, owner_, newTokenAmount_), "M:M:TRANSFER_FAILED"); } function setActive(bool active_) external override { diff --git a/contracts/interfaces/IMigrator.sol b/contracts/interfaces/IMigrator.sol index 9e433ef..801887c 100644 --- a/contracts/interfaces/IMigrator.sol +++ b/contracts/interfaces/IMigrator.sol @@ -29,16 +29,18 @@ interface IMigrator { /** * @dev Exchange the oldToken for the same amount of newToken. - * @param amount_ The amount of oldToken to swap for newToken. + * @param oldTokenAmount_ The amount of oldToken to swap for newToken. + * @return newTokenAmount_ The amount of newToken received. */ - function migrate(uint256 amount_) external; + function migrate(uint256 oldTokenAmount_) external returns (uint256 newTokenAmount_); /** * @dev Exchange the oldToken for the same amount of newToken. - * @param owner_ The address of the owner of the oldToken. - * @param amount_ The amount of oldToken to swap for newToken. + * @param owner_ The address of the owner of the oldToken. + * @param oldTokenAmount_ The amount of oldToken to swap for newToken. + * @return newTokenAmount_ The amount of newToken received. */ - function migrate(address owner_, uint256 amount_) external; + function migrate(address owner_, uint256 oldTokenAmount_) external returns (uint256 newTokenAmount_); /** * @dev Set the migrator to active or inactive.