-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Migration Contract #19
Conversation
…no longer accept eth
return (_amount * TOKEN_SWAP_RATIO) / TOKEN_SWAP_SCALING_FACTOR; | ||
} | ||
|
||
function tokenMigrationAmountToRecieve(uint256 _amount) external returns (uint256) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: receive
-> receive
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
State modifier keyword here too
uint256 amountToSwap = _tokenSwapCalculation(_amount); | ||
|
||
// transfer user's BIT tokens to this contract | ||
bool success = IERC20(BIT_TOKEN_ADDRESS).transferFrom(msg.sender, address(this), _amount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So here we enforce that the accounts involved in the transfer both exist which is good 👍
If the call returns false
it must be because of not enough tokens or out-of-gas, correct?
[I am not a Solidity expert, but if I am correct, transferring to a non-existing account returns true
so it is good to prevent this from happening.]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more comment: if the call to transferFrom
reverts, it bubbles up in Solidity and the caller reverts too.
I wonder whether it is possible to get a return value that is false
in our setting. It depends on the implementation of transferFrom
, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gonna be replacing all transfer instances with safeTransfer so shouldn't be a concern, I'll remove the errors that shouldn't be reached anymore
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So at the end of the day, the body of this function could be:
IERC20(BIT_TOKEN_ADDRESS).transferFrom(...);
IERC20(MNT_TOKEN_ADDRESS).transfer(...);
correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@afkbyte created this PR to resolve two nits, suggest merge and then lgtm main |
closes: #12 #11 #7 #6 #5 #4
TODO: add natspec comments