-
Notifications
You must be signed in to change notification settings - Fork 6
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
Batch buy #18
Batch buy #18
Conversation
376a19a
to
0a0a1ee
Compare
contracts/JoepegExchange.sol
Outdated
function _transferWAVAXIfNeeded(uint256 cost) internal { | ||
// If not enough AVAX to cover the cost, use WAVAX | ||
if (cost > msg.value) { | ||
IERC20(WAVAX).safeTransferFrom( | ||
msg.sender, | ||
address(this), | ||
(cost - msg.value) | ||
); | ||
} else { | ||
require(cost == msg.value, "Order: Msg.value too high"); | ||
} | ||
} |
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.
I moved the transfer WAVAX logic outside of _matchAskWithTakerBidUsingAVAXAndWAVAX
because of require(takerBid.price == msg.value, "Order: Msg.value too high");
When you use batch buy with AVAX, you send more AVAX than the price of a single order so takerBid.price < 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.
Also moved IWAVAX(WAVAX).deposit{value: msg.value}();
for the same reason: you can only deposit msg.value once so it reverted in the batch buy for loop
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.
LGTM
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.
awesome!
We want to let users buy multiple NFTs in a single transaction. This PR adds a simple function to JoepegExchange to execute multiple match orders call in a for loop.
Another option could be to use a payable multicall but i'm not sure to get all the security issues that may arise :gem smart contracts : https://etherscan.io/address/0x83c8f28c26bf6aaca652df1dbbe0e1b56f8baba2#code