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

Vault1 and Vault2 completed #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

divergio
Copy link

some rough edges, expecting feedback

require(vaultBalances[msg.sender] >= _amount, "Insufficient balance in vault");

vaultBalances[msg.sender] -= _amount;
token.transferFrom(address(this), msg.sender, _amount);
Copy link
Collaborator

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");
Copy link
Collaborator

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);
Copy link
Collaborator

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");
Copy link
Collaborator

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

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.

2 participants