Skip to content
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

Merged
merged 13 commits into from
May 24, 2023
Merged

New Migration Contract #19

merged 13 commits into from
May 24, 2023

Conversation

afkbyte
Copy link
Contributor

@afkbyte afkbyte commented May 22, 2023

closes: #12 #11 #7 #6 #5 #4

TODO: add natspec comments

@afkbyte afkbyte mentioned this pull request May 22, 2023
contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
return (_amount * TOKEN_SWAP_RATIO) / TOKEN_SWAP_SCALING_FACTOR;
}

function tokenMigrationAmountToRecieve(uint256 _amount) external returns (uint256) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: receive -> receive

Copy link
Contributor

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

contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
uint256 amountToSwap = _tokenSwapCalculation(_amount);

// transfer user's BIT tokens to this contract
bool success = IERC20(BIT_TOKEN_ADDRESS).transferFrom(msg.sender, address(this), _amount);
Copy link
Contributor

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.]

Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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?

contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
contracts/Migration/MantleTokenMigrator.sol Outdated Show resolved Hide resolved
@afkbyte afkbyte requested review from franck44, aodhgan and Tri-stone May 24, 2023 02:12
Copy link
Collaborator

@Tri-stone Tri-stone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done

Copy link
Contributor

@franck44 franck44 left a 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.

@aodhgan
Copy link
Contributor

aodhgan commented May 24, 2023

@afkbyte created this PR to resolve two nits, suggest merge and then lgtm main

@afkbyte afkbyte merged commit 6e0d770 into main May 24, 2023
@afkbyte afkbyte deleted the afk/new-migration-contract branch May 24, 2023 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants