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

Qbay smart contract #321

Open
wants to merge 16 commits into
base: develop
Choose a base branch
from
Open

Qbay smart contract #321

wants to merge 16 commits into from

Conversation

TakaYuPP
Copy link
Contributor

@TakaYuPP TakaYuPP commented Feb 21, 2025

Qbay MarketPlace Smart Contract

  1. Technical implementation for the collection and NFT in PFP Smart Contract

    • All the collections and NFTs will be saved inside 1GB Storage that can be saved the state data and also it can be integrated in PFP MarketPlace

      The info for NFT is as follows.

      struct InfoOfNFT
      {

        id creator;                          // Identity of NFT creator
        id possesor;			     // Identity of NFT possesor
        id askUser;			     // Identity of Asked user
        id creatorOfAuction;		     // Creator of Auction
        sint64 salePrice;		     // This price should be set by possesor
        sint64 askMaxPrice;		     // This price is the max of asked prices
        uint64 currentPriceOfAuction;	     // This price is the start price of auctions
        uint32 startTimeOfAuction;	     // The start time of auction
        uint32 endTimeOfAuction;	     // The end time of auction
        uint32 royalty;			     // Percent from 0 ~ 100
        uint32 NFTidForExchange;	     // NFT Id that want to exchange
        Array<uint8, 64> URI;	             // URI for this NFT
        uint8 statusOfAuction;		     // Status of Auction(0 means that there is no auction, 1 means that tranditional Auction is started, 2 means that one user buyed the NFT in traditinoal auction)
        bit statusOfSale;		     // Status of Sale, 0 means possesor don't want to sell
        bit statusOfAsk;		     // Status of Ask
        bit paymentMethodOfAsk;		     // 0 means the asked user want to buy using $Qubic, 1 means that want to buy using $CFB
        bit statusOfExchange;		     // Status of Exchange
        bit paymentMethodOfAuction;	     // 0 means the user can buy using only $Qubic, 1 means that can buy using only $CFB
      

      };

      constexpr uint32 PFP_MAX_NUMBER_NFT = 2097152;

      Array<InfoOfNFT, PFP_MAX_NUMBER_NFT> NFTs;

      As you can see above, the max number of NFTs is 2097152. it means that this smart contrat holds the NFTs up to 2097152.
      The capacity of one NFT is 238byte and total capacity for 2097152 NFTs is less than 1GB.
      All the infos(creator, possesor, URI, status, price, ... ,) for NFT will be saved in this NFT struct.
      The implementation for collection is same with implementation of NFT. there is a struct for info of collection.

  2. All features in PFP MarketPlace

    • settingCFBAndQubicPrice procedure

      The only Marketplace owner can set the price for Qubic and CFB. it will be expressed as the amount of Qubic and CFB for 1 USD;
      If other's try to use this procedure, it will be rejected by procedure.
      If the Qubic smart contract supports the connection with Oracles in the future, this procedure would be removed and the Oracles would be connected for price of Qubic and CFB.

    • createCollection procedure

      The user can create their collection. The CFB payment is only available to create the collection.
      When the user creates the collection, he can set the type of collection weither the collection is for own or Dropping NFTs.

    • mint procedure

      The user can mint the NFT in two option(minting a single NFT or a NFT using the collection). If user want to mint the NFT using his collection, he can mint the NFT without any fee, at this time, the creator and possessor of NFT should be creator of collection.
      If user want to mint the single NFT without his collection, he need to pay the 5M $Qubic in Marketplace.

    • mintOfDrop procedure

      The user can mint the NFTs using the Drop collection.
      The user need to pay the fee(it will be set when the collection is created by the collection creator) to creator of collection. the creator of NFT would be creator of collection and the possessor would be the user who mint this NFT.

    • transfer procedure

      The user can transfer their NFT to another user without fee.

    • listInMarket procedure

      The user can list the NFT in the Market without fee when he want to sell the NFT. it means the status of sale is 1.
      The user will set the price for sale in the amount of Qubic.

    • buy procedure

      The user can buy the NFT if the status of sale for NFT is 1. the user can use the both of Qubic and CFB to pay the price of NFT.
      If the user selects the CFB to pay the price, the price will be converted and calculated as CFB.
      At this time, the fee will be distributed according to the set percent.

    • cancelSale procedure

      The user can cancel the sale without fee.

    • listInExchange procedure

      The user can list the NFT in the Exchange when he want to exchange his NFT with another NFT. it means that the status of another NFT(want to exchange) is 1;
      If the another user already asked to exchange with his NFT, the possessor of NFT will be converted each other.
      At this time, there is no fee.

    • cancelExchange procedure

      The user can cancel the status of exchange without fee. it means that the status of another NFT(wanted to exchange) is 0.

    • makeOffer procedure

      The user can make the offer with the price(he want to buy) if he want to buy the NFT. the user can use the both of Qubic and CFB to pay the price of NFT. also the price should be sent to marketplace at first.
      If the user does not pay the price, the offer can not be made.
      If another user make the offer with high price, the askUser and price will be changed with new user.
      the user need to make in high price additional QBAY_MIN_DELTA_SIZE over than previous user.
      The payment for previous user will be transferred to previous user.

    • acceptOffer procedure

      If the user want to sell to the user who made the offer, the user can accept the offer.

    • cancelOffer procedure

      If user want to cancel the Offer, he can use this proceudure. at this time, the paid amount of user who made the offer will be transferred to user who made the offer.

    • createTraditionalAuction procedure

      The user can create the auction. user need to set the method of payment for price($Qubic or $CFB). Other users must bid in set mothed of payment.
      The start and end time will be decided by creator of auction.

    • bidOnTraditionalAuction procedure

      The users can bid in auction. the user need to bid in high price additional QBAY_MIN_DELTA_SIZE over than previous user.
      The possessor of NFT will be changed whenever the user succeed in bid and the previous user receives the paid amount. and also the fee will be distributed reasonablly.

    • changeStatusOfMarketPlace procedure

      Marketplace owner need to change the status of market. The users can create the collection and mint the NFT after marketplace owner changes the status as 1.
      Marketplace owner want to create hie collection and NFT before other user creates the collection and NFT usint this smart contract.
      So other users can create the collection and mint the NFT after marketplace owner changes the status of marketplace.

    • END_EPOCH procedure

      All earnings will transfer at the end of epoch by this procedure.

  • The user can make the only one action regarding transferring the NFT. For example, the user listed the NFT in Market using listInMarket procedure, he can not use the other procedures like transfer, listInExchange, makeOffer, createTraditionalAuction regarding the transferring the NFT.
    If he want to do other action regarding trasferring the NFT, he need to cancel the made action.
  1. Fee

    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_201_1000 = 200;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_1001_2000 = 400;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_2001_3000 = 600;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_3001_4000 = 800;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_4001_5000 = 1000;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_5001_6000 = 1200;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_6001_7000 = 1400;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_7001_8000 = 1600;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_8001_9000 = 1800;
    constexpr uint32 QBAY_FEE_COLLECTION_CREATE_9001_10000 = 2000;
    constexpr uint32 QBAY_FEE_NFT_SALE_MARKET = 20;
    constexpr uint32 QBAY_FEE_NFT_SALE_SHAREHOLDERS = 10;```
    
    
  • The shareHolders fee will be calculated for only $Qubic payment. There is no shareHolders fee in payment for $CFB.
  1. Query functions

    REGISTER_USER_FUNCTION(getInfoOfNFTUserPossessed, 2);
    REGISTER_USER_FUNCTION(getInfoOfMarketplace, 3);
    REGISTER_USER_FUNCTION(getInfoOfCollectionByCreator, 4);
    REGISTER_USER_FUNCTION(getInfoOfCollectionById, 5);
    REGISTER_USER_FUNCTION(getIncomingAuctions, 6);
    REGISTER_USER_FUNCTION(getInfoOfNFTById, 7);
    REGISTER_USER_FUNCTION(getUserCreatedCollection, 8);
    REGISTER_USER_FUNCTION(getUserCreatedNFT , 9);```
    
    These query functions required for frontend.
    
    

All procedures and functions was tested by qubic-cli and google test. also the frontend was integrated in SC.

  1. Update of Quottery smart contract

    • I updated the checkValidQtryDateTime function of Quottery smart contract.
      There was some mistake to check leap year.

@TakaYuPP TakaYuPP changed the title New pfp Qbay smart contract Feb 21, 2025
@@ -390,6 +390,14 @@ struct QUOTTERY : public ContractBase
res -= (qtryGetHour(A) * 3600 + qtryGetMinute(A) * 60 + qtryGetSecond(A));
}

inline static bool isLeapYear(uint32 year)
Copy link
Contributor

Choose a reason for hiding this comment

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

year number on qubic is only 2 digits, we don't need to take care of this case

@krypdkat
Copy link
Contributor

This won't take sooner than 2 epochs to have a proper review in security.
I suggest to not do a proposal now.

@krypdkat
Copy link
Contributor

I also suggest to support any token instead of $CFB only because soon we will have other tokens such as wrapped bitcoin, ether or stablecoin

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