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

[Bug]: Cannot have a buy offer and sell offer at the same time #778

Open
viyer28 opened this issue Sep 29, 2022 · 3 comments
Open

[Bug]: Cannot have a buy offer and sell offer at the same time #778

viyer28 opened this issue Sep 29, 2022 · 3 comments
Assignees

Comments

@viyer28
Copy link

viyer28 commented Sep 29, 2022

Which package is this bug report for?

auction-house

Which Type of Package is this bug report for?

Rust Contract

Issue description

We've built a secondary marketplace for semi-fungible tokens, i.e. SPL tokens linked to the same metadata. A common use case we've seen in the secondary marketplace is to create listings, but still create bids at lower prices to accumulate more of a particular item. Unfortunately, those bids are un-executable because of this particular error in execute_sale: https://github.com/metaplex-foundation/metaplex-program-library/blob/master/auction-house/program/src/execute_sale/mod.rs#L1722-L1724

Steps to reproduce (need two accounts A and B):

  1. Create a sell offer for an item using account A.
  2. Create a buy offer for that same item using account A.
  3. Create a matching sell offer and execute the sale (as two instructions in the same transaction) from account B.

Result:
Error 0x1785 (6021) BuyerATACannotHaveDelegate

I understand why the Seller's ATA shouldn't have a delegate that's not the auction house in this case, but why shouldn't the Buyer's ATA have a delegate? Is there a way to get around this for this particular use case?

Edit: Another common use case is to create a sell offer and then purchase someone else's sell offer at a lower price. This results in the same issue as both a sell offer and a buy offer are needed for that same item.

Steps to reproduce:

  1. Create a sell offer for an item using account A.
  2. From account A, create a matching buy offer and execute the sale on account B's item.

Relevant log output

Error: failed to send transaction: Transaction simulation failed: Error processing Instruction 2: custom program error: 0x1785

Priority this issue should have

High (immediate attention needed)

@viyer28 viyer28 added the bug label Sep 29, 2022
@viyer28
Copy link
Author

viyer28 commented Nov 7, 2022

@samuelvanderwaal @blockiosaurus I believe this has to do with the fact that "Fungible Assets" aka semi-fungible tokens use one token account for all tokens owned by a specific holder.

The issue with the following lines of code in execute_sale is that they don't account for when people have listed some of the other tokens in that token account.

if seller_rec_acct.delegate.is_some() {
return Err(AuctionHouseError::SellerATACannotHaveDelegate.into());
}

if buyer_rec_acct.delegate.is_some() {
return Err(AuctionHouseError::BuyerATACannotHaveDelegate.into());
}

My proposed solution would be to not simply check whether a delegate exists on the account, but if a delegate exists, also look at the delegated_amount with respect to the token_size and amount in the token account.

This is a very important issue for using Auction House with SFTs.

@samuelvanderwaal samuelvanderwaal self-assigned this Nov 22, 2022
@blockiosaurus blockiosaurus self-assigned this Nov 30, 2022
@johnsonchau-bulb
Copy link

@viyer28 has there been any updates on this?

@viyer28
Copy link
Author

viyer28 commented Jan 28, 2023

No updates yet!

KirillLykov pushed a commit to KirillLykov/metaplex-program-library that referenced this issue Jul 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants