# Can a trade offer be the last leg of a Ripple transaction path? If so, do transit fees apply?

I think I understand, for the most part, how rippled finds transaction paths, and how gateways can charge transit fees; but some of the edge cases have me wondering...

Let's say my wallet has XYZ from xyzGateway, and I've offered to sell 1000 XYZ for 100 USD from usdGateway. For simplicity, let's say that's the only offer on the books trading XYZ for USD.

Next, my friend Alice has over 100 USD:usdGateway in her wallet. And to settle a debt between us, she sends me 1000 XYZ.

There's a path that might work. The first leg of the path is 100 USD:usdGateway from Alice to me. The next leg is my own offer to trade 1000 XYZ:xyzGateway for 100 USD:usdGateway. I would make that trade with myself, so that afterwards my wallet contains 1000 XYZ and 100 USD.

Will ripple find the path described above? Let's call it path #1.

There's another path that might work. The first leg is Alice takes my offer, I get her USD and she gets my XYZ. The next leg of the path sends the XYZ back to my wallet.

Will ripple find this path #2? Specifically, will it be found even if Alice does not trust XYZ:xyzGateway? Does Alice's action of sending XYZ to me imply her trust of that currency?

I believe the two paths are equal in their net effect: 100 USD subtracted from Alice's wallet, and 100 USD added to my wallet. And I still have 1000 XYZ in my wallet. And my offer to sell XYZ for USD is removed from the ledger.

However, transit fees could make those two paths not equivalent. Let's say that usdGateway charges 1% in transit fees. And likewise xyzGatway charges 1%. Path #1 described above would incure 1% fee when Alice sends USD to me (she'd have to send 101 instead of 100). It's unclear to me, would the trade leg (trade with myself) would incur still more transit fees from either gateway?

And regarding path #2, there would be a 1% fee to usdGateway when Alice trades for XYZ, and a 1% fee from me to xyzGateway, and finally one more 1% fee for the leg sending XYZ from Alice to me? Am I correct that this path pays single transit fees to usdGatway and double fees to xyzGateway.

Thanks in advance for help with this. Apologies for cramming multiple questions into one post. I several questions just to understand what Ripple would do when Alice attempts to send the XYZ.

You have a slight misunderstanding about payment paths that is confusing your reasoning. When a payment path ripples through an account, that account receives an asset from the previous link in the path and issues an asset to the next link in the path, not the sender.

So the answer to your first question is that no trust is needed since Alice never holds the currency. An asset, other than XRP, can only be delivered to a person who created a trust line or an offer that agreed to accept that asset. But she never holds it.

And the answer to your second question is that there is no second transit. Alice never holds the asset because she never agreed to. The asset is delivered to the next link in the payment path.

To use a more realistic payment path, consider a case where Alice holds USD issued by Snapswap and wants to pay Bob a Bitcoin. Bob must have a trust line or this is not possible, so let's say he has a trust line to Bitstamp with a limit above his balance. The full payment path could be:

Alice/USD -> Snapswap/USD -> Order book -> Bitstamp/BTC -> Bob/BTC

Notice that only an order book can change the currency. Alice returns USD to Snapswap, and in exchange Snapswap issues USD to whoever placed offers in the order book. The offer owner in turn sends BTC back to Bitstamp who in turn issues them to Bob. Nobody ever holds an asset they didn't agree to hold.

This makes it easier to understand how transfer fees apply. If Bitstamp charges .2%, then the market maker must send 1.002 BTC back to Bitstamp in order to deliver 1 BTC to Bob.

• In my question, Bob is the offer owner. You're saying his account pays Bitstamp's fees. If Snapswap also charges fees, Alice pays them, correct? Apr 17, 2014 at 2:00
• Yes. The person who decided to hold the asset pays the transfer fee. Apr 17, 2014 at 2:01