hive-engine/steemsmartcontracts

NFTMarket and Auction contract settlement operations do not have final price

Closed this issue · 1 comments

The final NFT sale transaction op reports market fee and agent fee for the entire transaction. If multiple NFTs are sold in the same transaction you have to caculate what portion of the fee is for each NFT sold to come up with the final sell price of the NFTs. This is impossible when two or more NFTs of the same symbol are sold in the same transaction and have different market fees. While this is rare it is entirely possible, for example a user puts a punk for sale on Hive Punks website that uses a 5% market fee, but then another punk is put for sale on another market that uses a 10% fee, then a user buys them both on TribalDex OpenHive in a single transaction. In my opinion, the final NFTMarket Sale transaction object should include a finalPrice field not just a field that shows wwhat is paid to seller.

If at all possible, it would be nice to have a way to see all market history for a particular NFT token as well, currently it is limited to the last 24 hours with no way to go back. Due to the above situation, you can't walk the history manually and build it either as the settlement operations do not have all the data required to do so.

Sample effect log from such a sale in one instance case:

{
  "events": [
    {
      "contract": "tokens",
      "event": "transfer",
      "data": {
        "from": "nazavzhdy",
        "to": "blockheadgames",
        "symbol": "SWAP.HIVE",
        "quantity": "0.56000000"
      }
    },
    {
      "contract": "tokens",
      "event": "transfer",
      "data": {
        "from": "nazavzhdy",
        "to": "blockheadgames",
        "symbol": "SWAP.HIVE",
        "quantity": "0.14000000"
      }
    },
    {
      "contract": "tokens",
      "event": "transfer",
      "data": {
        "from": "nazavzhdy",
        "to": "yannh",
        "symbol": "SWAP.HIVE",
        "quantity": "13.30000000"
      }
    },
    {
      "contract": "nft",
      "event": "transfer",
      "data": {
        "from": "nftmarket",
        "fromType": "c",
        "to": "nazavzhdy",
        "toType": "u",
        "symbol": "PUNK",
        "id": "1552"
      }
    },
    {
      "contract": "nftmarket",
      "event": "hitSellOrder",
      "data": {
        "symbol": "PUNK",
        "priceSymbol": "SWAP.HIVE",
        "account": "nazavzhdy",
        "ownedBy": "u",
        "sellers": [
          {
            "account": "yannh",
            "ownedBy": "u",
            "nftIds": [
              "1552"
            ],
            "paymentTotal": "13.30000000"
          }
        ],
        "paymentTotal": "13.30000000",
        "marketAccount": "blockheadgames",
        "feeTotal": "0.56000000",
        "agentAccount": "blockheadgames",
        "agentFeeTotal": "0.14000000"
      }
    }
  ]
}

Will also find another example with multiple.

Need to work out a better format for the events, whether to change existing hitSellOrder or just emit additional event per nft with exactly price information split out. But it seems the existing hitSellOrder is not useful as is and would be better if we reformatted the event itself to split out per nft info