Skip to content

enable swaps for buy orders#30

Merged
cinnabarhorse merged 7 commits intomasterfrom
feat/swapAndPlaceBuyOrders
Oct 7, 2025
Merged

enable swaps for buy orders#30
cinnabarhorse merged 7 commits intomasterfrom
feat/swapAndPlaceBuyOrders

Conversation

@Timidan
Copy link
Contributor

@Timidan Timidan commented Sep 24, 2025

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enables token swapping functionality for buy orders by introducing a new BuyOrderSwapFacet that allows users to swap tokens for GHST and place ERC721/ERC1155 buy orders in a single transaction.

  • Adds new BuyOrderSwapFacet with swap-and-place functions for both ERC721 and ERC1155 buy orders
  • Refactors existing buy order facets to use shared validation and order placement logic from LibBuyOrder
  • Includes comprehensive integration tests for the new swap functionality

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
contracts/Aavegotchi/facets/BuyOrderSwapFacet.sol New facet providing swap-and-place functionality for buy orders
contracts/Aavegotchi/libraries/LibBuyOrder.sol Adds shared validation and order placement functions, moves events from facets
contracts/Aavegotchi/facets/ERC721BuyOrderFacet.sol Refactored to use shared LibBuyOrder functions, removes duplicate validation logic
contracts/Aavegotchi/facets/ERC1155BuyOrderFacet.sol Refactored to use shared LibBuyOrder functions, removes duplicate validation logic
test/swapAndPlaceERC721BuyOrder.test.ts Integration test for ERC721 swap-and-place functionality
test/swapAndPlaceERC1155BuyOrder.test.ts Integration test for ERC1155 swap-and-place functionality
scripts/upgrades/upgrade-addSwapAndBuyOrders.ts Upgrade script to deploy the new BuyOrderSwapFacet

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines 83 to 84
// require(_priceInWei >= 1e18, "ERC721BuyOrder: price should be 1 GHST or larger");

Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

[nitpick] Remove commented out code instead of leaving it in place. The validation has been moved to LibBuyOrder.validateERC721Params.

Suggested change
// require(_priceInWei >= 1e18, "ERC721BuyOrder: price should be 1 GHST or larger");

Copilot uses AI. Check for mistakes.
// Refund any excess GHST to the recipient using shared library, leave totalCost in the diamond
LibTokenSwap.refundExcessGHST(params.recipient, initialBalance + totalCost);

emit SwapAndPlaceERC1155BuyOrder(msg.sender, params.buyOrderId, params.tokenIn, ghstReceived);
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The buyOrderId parameter is used in the event emission but it's not set during the function execution. The actual buyOrderId is generated inside LibBuyOrder._placeERC1155BuyOrder and LibBuyOrder._placeERC721BuyOrder functions, but those values are not returned or captured here.

Copilot uses AI. Check for mistakes.
// Refund any excess GHST to the recipient using shared library, leave totalCost in the diamond
LibTokenSwap.refundExcessGHST(params.recipient, initialBalance + totalCost);

emit SwapAndPlaceERC721BuyOrder(msg.sender, params.buyOrderId, params.tokenIn, ghstReceived);
Copy link

Copilot AI Sep 24, 2025

Choose a reason for hiding this comment

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

The buyOrderId parameter is used in the event emission but it's not set during the function execution. The actual buyOrderId is generated inside LibBuyOrder._placeERC1155BuyOrder and LibBuyOrder._placeERC721BuyOrder functions, but those values are not returned or captured here.

Copilot uses AI. Check for mistakes.
@openzeppelin-code
Copy link

openzeppelin-code bot commented Oct 6, 2025

enable swaps for buy orders

Generated at commit: b50fba4c96a7676ab33eac3a190cb07263f9a7d3

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
4
2
0
12
43
61
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@cinnabarhorse cinnabarhorse merged commit d606d19 into master Oct 7, 2025
0 of 2 checks passed
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