Attention All Monster Market Developers - Breaking Change Coming!

in steemmonsters •  6 years ago 

We have a breaking change coming to the Monster Market DEX Protocol that all marketplace or bot developers will need to support if they want their purchase transactions to go through. We plan to put this change into effect approximately one week from today (Friday, August 24th).

For anyone who is not doing market-related development, this post will probably not be relevant to you, but you're more than welcome to read it if you're interested, and your upvotes are always very much appreciated!

The Issue

Currently if two (or more) "sm_market_sale" transfers are made for the same market item at around the same time, only the transaction that appears first will be considered valid and have the cards transfered to the purchaser. Unfortunately, purchasers from the subsequent transactions have already transfered the funds but did not receive the cards, and have no way to get a refund (other than asking the seller nicely).

The Solution

In order to resolve this issue, purchasing cards through the decentralized market will need to be a two-step process. First the purchaser must obtain a lock on the market item(s) they wish to purchase. The purchaser can then check to make sure the lock was acquired before transfering the funds to the seller.

The "sm_market_sale" transfer must be sent within 20 blocks (1 minute) of the lock being obtained. After 20 blocks, if no "sm_market_sale" transfer is made with the appropriate info and amount of funds, then the lock will be released.

Once this change goes into effect, all "sm_market_sale" transfers will be considered invalid if the purchaser does not hold an active lock on the market items being purchased.

Acquiring and Checking the Locks

To acquire a lock on one or more market items, you must broadcast a transfer transaction with a sufficient amount of STEEM or SBD to purchase the indicated market items with the following memo format:

sm_market_purchase:market-item-1-id,market-item-2-id,...

When this transfer transaction is made, it will attempt to acquire a lock on all of the market items listed. To check if the locks were acquired successfully or not, you can look up the status of the transaction using the Steem Monsters API:

https://steemmonsters.com/transactions/lookup?trx_id=e750b8223a56f2e7b2ac4c7b3f6fc063d430a52e

Which returns the following response:

{
    "trx_info": {
        "id": "e750b8223a56f2e7b2ac4c7b3f6fc063d430a52e",
        "block_id": "017f723234273329e9e70f9afaebd75f66bfdbfc",
        "prev_block_id": "017f7231f533ffc70e1dc1d2448caa762791e886",
        "type": "sm_market_purchase",
        "player": "aggroedius",
        "data": "sm_market_purchase:6b8b0074cbec6e4d7db01f96918f0f4ac423a553-0",
        "success": true,
        "error": null,
        "block_num": 25129522,
        "created_date": "2018-08-16T22:11:15.539Z",
        "result": "[{\"sell_trx_id\":\"6b8b0074cbec6e4d7db01f96918f0f4ac423a553-0\",\"seller\":\"cryptkeeper17\",\"buy_price\":0.05,\"fee_percent\":200,\"payment\":0.052,\"currency\":\"SBD\",\"locked\":true,\"lock_block\":25129522}]"
    }
}

As you can see in the "result" property, it shows "locked":true which means the market item was successfully locked by this transaction. This means that the purchaser can send the "sm_market_sale" transfer within the next 20 blocks in order to purchase the cards.

For Market Developers

For anyone developing a third party market (such as https://monsters.steempeak.com/) here's what you need to do:

  1. To initiate a purchase of one or more market items through your market, an account must transfer a sufficient amount of funds using the "sm_market_purchase" memo format described above.
  2. You must then check the transaction result to see if the market items were successfully locked or not by the transaction from step 1. Note that if multiple market items were specified in the "sm_market_purchase" transfer it is possible that some were able to acquire locks and some were not.
  3. For any market items for which a lock was successfully acquired, make sure it is within 20 blocks since the lock was acquired, and you can go ahead and send the "sm_market_sale" transfer with the appropriate memo and funds to the seller(s).
  4. For any market items for which a lock was NOT acquired, or if the lock has expired, transfer the funds back to the purchaser from step 1.

For Bot Developers

For anyone developing a card trading bot (looking at you @lightningdragon!) you can do the following:

  1. Send an "sm_market_purchase" transfer to yourself using the memo format specified above.
  2. Check the result of that transaction to see if locks were acquired for the items being purchased.
  3. Only transfer funds to the seller using the "sm_market_sale" memo format if the lock was acquired and has not expired

Market Developers Discord Channel

I have created a private channel in the Steem Monsters Discord server for anyone doing market-related development to be able to discuss market-related development things. If you would like to be added to that channel please send me a direct message on Discord.


Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  

I’m glad you implemented the fix in steemmonsters.com. I wanted to buy a gold skeleton assasin card to add to my collection, for sentimental reason since his character will be part of steemmonsters.

A great deal popped up, but someone got to it before I did. The fix you had in place resulted in the return of my fund. Thanks for continuously improving the game and website.

Have a great weekend!

  ·  6 years ago (edited)

thanks for putting the info out there. We've got our market using it and look forward to seeing it utilized.
I assume steemmonsters.com interface is already using the lock.

I'm sure @asgarth our developer understands this but I thought i'd ask
I'm sure it applies to steemmonsters.com interface and the peakmonsters interface.

At what point is the lock placed? After you put in your key to steemconnect. Or some point before then?
Just checking when that 1 minute clock starts ticking.

The lock starts with the block that contains the "sm_market_purchase" transfer transaction. You have up until 20 blocks after that to broadcast the "sm_market_sale" transfer for it to be valid. @asgarth and I have talked extensively and it is implemented both in peakmonsters and steemmonsters.com already.

Hey @yabapmatt,

Is it possible for a malicious seller to list a card on the market, and then remove said card after a purchaser lock has been acquired and then receive the payment without transferring the card?

Granted, I don't know the inner workings here, but from your high-level explanation, there seems to be a window for a seller to run some bot-script and remove a card flagged for sale, before receiving the funds.

Not sure how long it takes to generate a block either... :P

For any market items for which a lock was successfully acquired, make sure it is within 20 blocks since the lock was acquired, and you can go ahead and send the "sm_market_sale" transfer with the appropriate memo and funds to the seller(s).

I guess the 'market developer' would also check at this time to ensure the card is still valid (aka flagged for market sale).

Cheers,
OFI-sig.JPG

@onefatindian - yes, I suppose they could do that. I guess sm_cancel_sell transactions should be invalid if the item is currently locked.

if there's a lock on the card the seller shouldn't be able to cancel a listing correct?

That's correct, that change will be made shortly.

So is their anyway to know if we got stiffed on our order? Or am I reading this wrong? Sometimes I go ham and buy a lot and wouldn't even know

  ·  6 years ago (edited)

It happens extremely rarely at the moment. You'd have to be going after a card the second it gets listed and competing against the bot-script primarily. Usually they just tie eachother. haha

So there's not too much to worry about.
And as soon as the bot script implements the lock system i'm sure matt can even turn on the enforcement earlier i'm guessing.

However to answer your question.

image.png

If you ever see either of these two things with a card that you tried to get (be it on yours or someone else who tried to get the same card)

Then go here: https://steemmonsters.com/cards/find?ids=
put in the Card ID after the =

That will show you who actually owns the card now.

Bam, much appreciated as always @jarvie

I can't say I'm a big fan of this solution tbh due to the complications that come along with it:

  1. Two transfers for one purchase
  2. Waiting for locks to expire

I believe a better solution would've been to have trusted sellers instead of blindly adding every broadcast to the market. How hard is it to refund someone after being paid twice? Those people should be blacklisted -- PROBLEM SOLVED. And then we would have a simple protocol again.

This new implementation also allows a malicious party to prevent a card from selling if they continually lock the item every 20 blocks. All they have to do is send a purchase order to themselves over and over ...

Sorry for the slow reply here @fulltimegeek. Regarding your first issue about two transfers for one purchase, since almost everyone purchases through a market (like Steem Monsters or Peak Monsters) there are already two transactions - one transfer to the market, and one transfer from the market to the seller - so I wasn't adding any additional transfers with this change.

I like that you don't have to trust the sellers in any way (though going through a market you do need to trust them, but that's optional).

The continual locking scenario is definitely a potential issue which I am aware of, and if it becomes a problem then we may have to update the protocol to restrict locking to only trusted markets. But the lock would still be necessary so two markets don't collide on a sale.

Hi @yabapmatt apologies for messaging on here, but not sure how else to send a message to you.

I delegated 200 steem to appreciator on steem bot tracker a few days ago, and then changed my mind, I then removed them from my delegation but it has not undone the delegation and it still sitting under delegated steem?

please advise what I should do

Delegations take 7 days to return to your account. Once the 7 days is up you should see the SP in your account again.

Ok got it,

is it a problem if I allocated the steem and then retracted the delegation even before 7days.

as in- I delegated steem about 2-3 days ago and then retracted it. does that matter?

No that doesn't matter. It will be available in your account 7 days from the time you undelegated.

Shot, Thank you so much for your speedy responses, excuse my ignorance, not too clued on the delegation thingy.

Much appreciated...

Do you know the exact block when this change went into effect?

I put up a step-by-step tutorial for buying cards, with how to get all of the relevant data from the API, here: https://steempeak.com/splinterlands/@tcpolymath/step-by-step-api-calls-for-buying-a-splinterlands-card

I found your information very interesting. I follow closely the steps of the desteemmonsters. but I'm still new to steemit I do not have to buy letters or have a capital for that. I really liked your post friend. I leave you a positive vote. @yabapmatt

Hi man @yabapmatt Thank you for this. Gotcha. Congrats on everything. We all dig it.

Hi @yabapmatt good

for me isn't relevant (yet) but I glad see people helping with this kind of problems XD

Hi @yabapmatt! We are @steem-ua, a new Steem dApp, computing UserAuthority for all accounts on Steem. We are currently in test modus upvoting quality contributions with a high UA value! Nice work!

Good content, useful for everyone those are interested .............great job

Very good article and useful information.
Thanks for share this @yabapmatt

Hey man not sure what is going on with smart steem but on your steem bot tracker it is promoted and 15% ROI is guaranteed I sent them 25 SBD but no upvotes, refund or even support. This is happening to a-lot of people too so pretty fishy just wanted to give you a little heads up.