Rippled: [enhancement] tfBuy flag on offers

Created on 31 Jan 2018  ·  9Comments  ·  Source: ripple/rippled

Why is there a tfSell flag for OfferCreate but not a tfBuy flag, where it tries to get the complete TakerPays, and gets whatever TakerGets the market can offer?

Most helpful comment

@tuloski I think @ximinez 's answer is correct but just to elaborate on the original question:

Why is there a tfSell flag for OfferCreate but not a tfBuy flag, where it tries to get the complete TakerPays, and gets whatever TakerGets the market can offer?

This is not what tfSell does. Rather, the tfSell flag indicates that the offer should behave like a "sell" order: the TakerGets amount is the amount that you want to sell. The opposite ("tfBuy"?) would be the default behavior, where the TakerPays amount is the amount you want to buy.

In any case, none of this is related to market trades (or market orders). As described above, you can just place a generous offer in order to effectively get a market order.

All 9 comments

How exactly is that different than the way offers currently operate? If there's a distinction, I'm missing it.

Maybe it is just my trip, but this is how I understood tfSell:

Example:

  • My offer is TakerGets: 1BTC, TakerPays: 10000USD. On the market there is only an offer that gives 9000USD per BTC.
  • The tfSell basically is for someone that want to sell (sort of market trade), so even if my quality was 1:10000 it will accept the 1:9000 offer in the market, making me get only 9000 USD (sell at all cost 1BTC! with whatever quality it finds).

Now imagine I want to obtain exactly 10000 USD at all costs (at market price). I could make an offer again TakerGets 1BTC, TakerPays: 10000 USD, but I can spend more than 1BTC, so with tfBuy flag my transaction is allowed to use more than 1BTC (if I have them of course) to obtain the 10000 USD. For example there is only an offer for 2BTC: 18000USD. With tfBuy I will spend 1.11 BTC to buy 10000 USD (so I'm accepting lower quality and spending more than my original offer).

But this is only my interpretation and I think the documentation has a flaw since it says "even if it means obtaining more than the TakerPays amount in exchange." when it should be "obtaining less".

EDIT EXAMPLE

Edited example because also for tfBuy the quality has to be lower than the quality of my offer.

If I understand this right, I’m _personally_ opposes to this.

I am wary of a flag that basically allows you to place an offer that’s the equivalent of King Richard proclaiming “MY KINGDOM FOR A HORSE!”

The tfSell basically is for someone that want to sell (sort of market trade), so even if my quality was 1:10000 it will accept the 1:9000 offer in the market, making me get only 9000 USD (sell at all cost 1BTC! with whatever quality it finds).

I don't think this is correct. Let me restate to make sure I'm understanding you.

There is currently one offer on the book:

  • TakerGets: 9000USD, TakerPays: 1BTC

You want to sell 1 BTC for a price of 10000USD, so you make an Offer transaction

  • TakerGets: 1BTC, TakerPays: 10000USD

Regardless of the value of the tfSell flag, your offer WILL NOT CROSS the existing offer.
If tfSell is NOT set, then your offer is saying, "I want to get 10000USD. I am willing to give up _up to_ 1BTC for it." If an existing offer has TakerGets: 20000USD and TakerPays: 1BTC, you will get your 10000USD and be left with 0.5BTC, but that 9000:1 offer just isn't good enough. That existing offer will be left on the books with values of what is remaining.
If tfSell is set, then your offer is saying, "I want to get rid of 1BTC, and I want to get _at least_ 10000USD for it." If that existing offer still has TakerGets: 20000USD and TakerPays: 1BTC, you will get 20000USD and be left with 0BTC. Again, that 9000:1 offer isn't good enough. The existing offer will be removed from the books, because it was filled.

Now let's go back to your example:

Now imagine I want to obtain exactly 10000 USD at all costs (at market price).

You can do this right now by placing an offer without the tfSell flag set.

  • TakerGets: [your balance]BTC, TakerPays: 10000USD
    Whether it crosses will depend on your balance, but lets say you have 3BTC. (Do not take investment advice from code monkeys.) You would make your offer
  • TakerGets: 3BTC, TakerPays: 10000USD
    Your offer would cross with the 9000:1 offer. You would get 9000USD, and pay 1BTC. You would be left with 2BTC, and _your offer would stay on the book_ with TakerGets: 2BTC, TakerPays: 1000USD. At current prices, chances are someone would take that offer pretty quickly. LOL.

Therefore, there is no need for a separate tfBuy flag. If you think there's an error in the documentation, could you post a link to it?

@tuloski I think @ximinez 's answer is correct but just to elaborate on the original question:

Why is there a tfSell flag for OfferCreate but not a tfBuy flag, where it tries to get the complete TakerPays, and gets whatever TakerGets the market can offer?

This is not what tfSell does. Rather, the tfSell flag indicates that the offer should behave like a "sell" order: the TakerGets amount is the amount that you want to sell. The opposite ("tfBuy"?) would be the default behavior, where the TakerPays amount is the amount you want to buy.

In any case, none of this is related to market trades (or market orders). As described above, you can just place a generous offer in order to effectively get a market order.

Just for reference, here's the documentation for OfferCreate.

@all: thanks for the explanation. I was living with a wrong assumption on how offer as taker work (I did mainly maker).

About this:

If tfSell is NOT set, then your offer is saying, "I want to get 10000USD. I am willing to give up up to 1BTC for it." If an existing offer has TakerGets: 20000USD and TakerPays: 1BTC, you will get your 10000USD and be left with 0.5BTC

I was thinking that in that case I would pay the whole 1BTC and get the 20000 USD, while it requires the tfSell flag for that oO.

@nbougalis that is what most exchanges call market order, and yeah I'm also against it because you don't have control on the quality and how much you'll pay, but for a liquid market sometimes it's easier and useful.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nbougalis picture nbougalis  ·  3Comments

anhcao142 picture anhcao142  ·  5Comments

ximinez picture ximinez  ·  5Comments

nbougalis picture nbougalis  ·  8Comments

nixer89 picture nixer89  ·  9Comments