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

Updated bundle sell in secondary market #1606

Conversation

capedcrusader21
Copy link
Contributor

@capedcrusader21 capedcrusader21 commented Oct 3, 2024

Description

  • updated TSB seller role to TSB_PRIMARY_MARKET_SELLER & TSB_SECONDARY_MARKET_SELLER.

  • updated contracts for secondary market sale for bundle.

  • Allow exchange only for bundle when one side of order is ERC20 and other is Bundle.

  • fixed and added test cases according to above changes.

Copy link

openzeppelin-code bot commented Oct 3, 2024

Updated bundle sell in secondary market

Generated at commit: dee324e2b9f5f6ab1166fe429a269c65a6789456

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
3
1
0
5
30
39

For more details view the full report in OpenZeppelin Code Inspector

Copy link
Member

@wojciech-turek wojciech-turek left a comment

Choose a reason for hiding this comment

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

I think we need slight adjustments.

@@ -83,6 +83,8 @@ library LibAsset {
/// @param rightClass The asset class type of the right side of the trade.
/// @return FeeSide representing which side should bear the fee, if any.
function getFeeSide(AssetClass leftClass, AssetClass rightClass) internal pure returns (FeeSide) {
require((leftClass == AssetClass.ERC20 || rightClass == AssetClass.ERC20), "exchange not allowed");
Copy link
Member

Choose a reason for hiding this comment

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

This is doing too much, its essentially blocking ERC721 <> ERC721 trade and its out of scope for us.
We just want to make sure that if one side is BUNDLE the other is ERC20

Example:

Suggested change
require((leftClass == AssetClass.ERC20 || rightClass == AssetClass.ERC20), "exchange not allowed");
if (leftClass == AssetClass.BUNDLE || rightClass == AssetClass.BUNDLE) {
require(
((leftClass == AssetClass.BUNDLE && rightClass == AssetClass.ERC20) ||
(rightClass == AssetClass.BUNDLE && leftClass == AssetClass.ERC20)),
"exchange not allowed"
);
}
}

Comment on lines 213 to 218
if (!_isTSBSeller(nftSide.account)) {
remainder = _doTransfersWithFeesAndRoyaltiesForBundle(paymentSide, nftSide, nftSideRecipient);
} else {
// No royalties but primary fee should be paid on the total value of the bundle
remainder = _transferProtocolFees(remainder, paymentSide, fees);
}
Copy link
Member

Choose a reason for hiding this comment

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

We don't want to eliminate the _isTSBSeller check because TSB may be selling land, catalysts etc and we dont want to pay royalty ourselves.

Copy link
Member

Choose a reason for hiding this comment

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

Generally:

_isTSBSeller => forces primary market on all bundle items, skips royalties
_isTSBBundleSeller => allows selling non-primary market items in a bundle, pays royalties
regular user => can only sell items that pass _isPrimaryMarket check as true, no royalties

Copy link
Member

Choose a reason for hiding this comment

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

The names of the roles probably aren't great, I find them bit confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Roles name will be updated to

  1. TSB_PRIMARY_MARKET_SELLER
  2. TSB_SECONDARY_MARKET_SELLER

Comment on lines 268 to 276
if (quadSize > 0 && _isTSBBundleSeller(nftSide.account)) {
remainder = _processQuadBundles(paymentSide, nftSideRecipient, remainder, feePrimary, quadSize, bundle);
}
Copy link
Member

Choose a reason for hiding this comment

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

We dont need this check for isTSBBundleSeller here, users should not be able to bundle quads because it should fail on _isPrimaryMarket check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

_isPrimaryMarket isn't checked for bundled quad.
and we need only TSB_SECONDARY_MARKET_SELLER to be checked for royalties to be paid for quad.

@capedcrusader21 capedcrusader21 force-pushed the feat/added-TSB_BUNDLE_SELLER-and-non-bundle-payment-side branch from b510c64 to 90ee70f Compare October 4, 2024 12:33
@capedcrusader21 capedcrusader21 marked this pull request as ready for review October 4, 2024 12:36
@capedcrusader21 capedcrusader21 requested a review from a team as a code owner October 4, 2024 12:36
@capedcrusader21 capedcrusader21 requested review from wojciech-turek and adjisb and removed request for a team October 4, 2024 12:36
@capedcrusader21 capedcrusader21 changed the title Updated bundle royalty logic for TSB Bundle Seller Updated bundle royalty logic for secondary market Oct 4, 2024
@capedcrusader21 capedcrusader21 changed the title Updated bundle royalty logic for secondary market Updated bundle sell in secondary market Oct 4, 2024
Copy link
Member

@wojciech-turek wojciech-turek left a comment

Choose a reason for hiding this comment

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

Small typos

packages/marketplace/contracts/Exchange.sol Outdated Show resolved Hide resolved
packages/marketplace/contracts/Exchange.sol Outdated Show resolved Hide resolved
@wojciech-turek wojciech-turek merged commit fef969b into marketplace-bundle/N-06-gas-optimization Oct 4, 2024
6 checks passed
@wojciech-turek wojciech-turek deleted the feat/added-TSB_BUNDLE_SELLER-and-non-bundle-payment-side branch October 4, 2024 18:29
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