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

Batch buy #18

Merged
merged 11 commits into from
Jul 22, 2022
Merged

Batch buy #18

merged 11 commits into from
Jul 22, 2022

Conversation

Max-3-7
Copy link
Contributor

@Max-3-7 Max-3-7 commented Jul 13, 2022

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

Base automatically changed from feature/multicall to main July 14, 2022 09:13
Comment on lines 263 to 274
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");
}
}
Copy link
Contributor Author

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

Copy link
Contributor Author

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

@Max-3-7 Max-3-7 changed the title [WIP] Batch buy Batch buy Jul 19, 2022
contracts/JoepegExchange.sol Show resolved Hide resolved
contracts/JoepegExchange.sol Outdated Show resolved Hide resolved
contracts/JoepegExchange.sol Outdated Show resolved Hide resolved
contracts/JoepegExchange.sol Outdated Show resolved Hide resolved
contracts/JoepegExchange.sol Outdated Show resolved Hide resolved
contracts/JoepegExchange.sol Show resolved Hide resolved
Copy link
Contributor

@LouisMeMyself LouisMeMyself left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@0xnivek 0xnivek left a comment

Choose a reason for hiding this comment

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

awesome!

contracts/JoepegExchange.sol Outdated Show resolved Hide resolved
@Max-3-7 Max-3-7 merged commit 7689eb8 into main Jul 22, 2022
@Max-3-7 Max-3-7 deleted the feature/batch-buy branch July 22, 2022 16:54
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.

3 participants