-
Notifications
You must be signed in to change notification settings - Fork 66
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
Vault1 and Vault2 completed #24
base: master
Are you sure you want to change the base?
Conversation
require(vaultBalances[msg.sender] >= _amount, "Insufficient balance in vault"); | ||
|
||
vaultBalances[msg.sender] -= _amount; | ||
token.transferFrom(address(this), msg.sender, _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.
You can call the transfer
function directly when transferring to user
|
||
function deposit(uint _amount) external { | ||
require(_amount > 0, "Invalid deposit amount"); | ||
require(token.balanceOf(msg.sender) >= _amount, "Insufficient balance"); |
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.
This check is already taken care of in transferFrom
function
function mint(uint _amount) public payable { | ||
require(_amount > 0, "Can't mint zero"); | ||
require(msg.value == _amount*(1 ether), "Mint amount differs from sent amount"); | ||
super._mint(msg.sender, msg.value); |
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.
You can directly call _mint
without using the super keyword
|
||
function mint(uint _amount) public payable { | ||
require(_amount > 0, "Can't mint zero"); | ||
require(msg.value == _amount*(1 ether), "Mint amount differs from sent 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.
msg.value
is in wei so better to consume _amount
also in wei rather than ether
some rough edges, expecting feedback