Zilliqa / marketplace-contracts

GNU General Public License v3.0
2 stars 4 forks source link

Ending an auction with no buy order #24

Closed bb111189 closed 2 years ago

bb111189 commented 2 years ago

If an auction end with no buy order, it should just finalize it without any buyer. Currently, if there is no buyer, the exception is thrown and an auction cannot be ended.

transition End(
  token_address: ByStr20 with contract 
    field royalty_recipient: ByStr20, 
    field royalty_fee_bps: Uint128, 
    field spenders: Map Uint256 ByStr20, 
    field token_owners: Map Uint256 ByStr20 
  end,
  token_id: Uint256
  )
  RequireNotPaused;

  (* Check the sell order does exist *)
  maybe_sell_order <- sell_orders[token_address][token_id];
  match maybe_sell_order with 
  | None =>
    (* Sell order doesn't exist *)
    error = SellOrderNotFoundError;
    Throw error
  | Some (SellOrder seller expiration_bnum payment_token_address start_amount)  => 
    (* Check the sell order is expired *)
    (* Seller or buyer can end the auction only after the sell order has been expired. *)
    RequireExpired expiration_bnum;

    (* Check the buy order does exist *)
    maybe_buy_order <- buy_orders[token_address][token_id];
    match maybe_buy_order with 
    | None =>
      (* Buy order doesn't exist *)
      error = BuyOrderNotFoundError;
      Throw error
bb111189 commented 2 years ago

Seller cannot cancel such auction too

procedure CancelAuction(
  token_address: ByStr20 with contract 
    field royalty_recipient: ByStr20, 
    field royalty_fee_bps: Uint128, 
    field spenders: Map Uint256 ByStr20, 
    field token_owners: Map Uint256 ByStr20 
  end,
  token_id: Uint256
  )
  (* Check the sell order does exist *)
  maybe_sell_order <- sell_orders[token_address][token_id];
  match maybe_sell_order with 
  | None =>
    (* Sell order doesn't exist *)
    error = SellOrderNotFoundError;
    Throw error
  | Some (SellOrder seller expiration_bnum payment_token_address start_amount)  => 
    (* Check the sell order is not expired *)
    (* An auction cannot be cancelled once it has been expired. *)
    RequireNotExpired expiration_bnum;
    (* Only seller must be able to cancel the sell order *)
    RequireAccessToCancel seller;

So the auction might be "stuck"

ghost commented 2 years ago

Yes, the seller should be able to end it to get the asset back. Nice catch!