# How do receiver determine if the exchange rate is reasonable?

**URL:** <https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794>\
**Category:** General Questions\
**Created:** [October 3, 2019, 2:21pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794 "2019-10-03T14:21:24Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![calvinlauco](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/calvinlauco/32/416_2.png) [@calvinlauco](https://forum.interledger.org/u/calvinlauco)\
**Post date:** [October 3, 2019, 2:21pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/1 "2019-10-03T14:21:24Z")

</div>

I have read from [ILPv4 documentation](https://interledger.org/rfcs/0027-interledger-protocol-4/) and [Stream protocol](https://interledger.org/rfcs/0029-stream/#34-exchange-rates) that sender will communicate a minimum acceptable amount with the receiver. The receiver will then use it to determine whether a received ILP packet has a reasonable exchange rate.

I am not quite sure how this works. For example, the sender set the minimum acceptable amount as 1XRP, but he sent 2XRP in one of his packets and after passing through connectors the amount in the prepare ILP packet becomes 1.5ETH (Assume 1XRP = 1ETH is a reasonable rate). In the fulfil packet format there isn’t any fulfilled amount as well. How does the receiver knows that 1.5ETH is the exchanged result of sending 1XRP or sending 1.5XRP or 2XRP?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [October 3, 2019, 3:10pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/2 "2019-10-03T15:10:11Z")

</div>

Hi @calvinlauco,

Good question! The STREAM response packet actually includes the amount that was received. In the original request packet, the [`Prepare Amount`](https://interledger.org/rfcs/0029-stream/#52-stream-packet) is the minimum amount the sender wants the receiver to accept. When the receiver creates the response packet, they set the Prepare Amount to the amount that they actually got.

Also, @kincaid has made some good points [here](https://github.com/interledger-rs/interledger-rs/issues/256#issuecomment-526634084) and [here](https://github.com/interledger-rs/interledger-rs/issues/255#issuecomment-526929932) about why senders should check the rate they get from STREAM probing against an external provider to make sure it’s within reasonable bounds. We will probably implement something along those lines in Interledger.rs.

---

<div class="post-metadata">

**Author:** ![adrianhopebailie](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/adrianhopebailie/32/31_2.png) [@adrianhopebailie](https://forum.interledger.org/u/adrianhopebailie)\
**Post date:** [October 3, 2019, 3:48pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/3 "2019-10-03T15:48:29Z")

</div>

Who takes responsibility for determining a “reasonable” FX rate?

The `Prepare Amount` in the prepare packet that arrives at the receiver is presumably denominated in XRP since that is the currency of the sender?

However the amount received is in ETH, so presumably the receiver must convert the ETH amount to a XRP using a “reasonable” rate to decide if it should fulfill the packet?

Then when it responds, what is the currency of the `Prepare Amount` in the fulfil packet? If it’s ETH then presumably the sender must normalize that to XRP?

---

<div class="post-metadata">

**Author:** ![calvinlauco](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/calvinlauco/32/416_2.png) [@calvinlauco](https://forum.interledger.org/u/calvinlauco)\
**Post date:** [October 3, 2019, 4:40pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/4 "2019-10-03T16:40:53Z")

</div>

@emschwartz Thanks, I overlooked the STREAM packet and missed that the amount field has multi-purpose. Now I understand now.

I have a extended question: Using my example, does sender knows before send that receiver want ETH currency (maybe communicate via SPSP beforehand?).

I think this make sense because otherwise send does not know which route to forward the packet to.

If yes where is this information store in the packet?

---

<div class="post-metadata">

**Author:** ![nhartner](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/nhartner/32/496_2.png) [@nhartner](https://forum.interledger.org/u/nhartner)\
**Post date:** [October 3, 2019, 4:50pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/5 "2019-10-03T16:50:49Z")

</div>

Adding destination denomination to SPSP response seems like a good approach. There was also a suggestion [here](https://github.com/interledger-rs/interledger-rs/issues/273#issuecomment-531295581) that the denomination be probed over STREAM by having the sender send a ConnectionNewAddress and then receiver respond with a ConnectionAssetDetails. But that’s based on a JS implementation choice not something called out in the STREAM spec.

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [October 3, 2019, 4:52pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/6 "2019-10-03T16:52:53Z")

</div>

> [@adrianhopebailie](#):
>
> The `Prepare Amount` in the prepare packet that arrives at the receiver is presumably denominated in XRP since that is the currency of the sender?

No, it’s the minimum amount that the receiver should accept, denominated in the receiver’s asset.

> [@adrianhopebailie](#):
>
> Then when it responds, what is the currency of the `Prepare Amount` in the fulfil packet? If it’s ETH then presumably the sender must normalize that to XRP?

That is also denominated in the receiver’s asset. The sender knows how much they sent so they can use the ratio of the amount they included in the original `Prepare` packet (_not_ the `Prepare Amount` field in the STREAM packet) to determine the exchange rate.

> [@calvinlauco](#):
>
> Using my example, does sender knows before send that receiver want ETH currency (maybe communicate via SPSP beforehand?).

Higher level protocols may include the asset in their communication details, though STREAM also has a [`ConnectionAssetDetails`](https://github.com/interledger/rfcs/blob/master/0029-stream/0029-stream.md#5314-connectionassetdetails-frame) frame for this purpose.

---

<div class="post-metadata">

**Author:** ![nhartner](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/nhartner/32/496_2.png) [@nhartner](https://forum.interledger.org/u/nhartner)\
**Post date:** [October 3, 2019, 4:58pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/7 "2019-10-03T16:58:27Z")

</div>

> [@emschwartz](#):
>
> No, it’s the minimum amount that the receiver should accept, denominated in the receiver’s asset.

Is this called out somewhere in the spec? If not, it probably should be. All I could find was

> Senders SHOULD judge amounts and prices only in their own units using the calculated path exchange rate, because destination units can be manipulated by the receiver (by using a connector with an exchange rate they control).

which makes it sound like senders should only talk in their own units.

---

<div class="post-metadata">

**Author:** ![nhartner](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/nhartner/32/496_2.png) [@nhartner](https://forum.interledger.org/u/nhartner)\
**Post date:** [October 3, 2019, 5:10pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/8 "2019-10-03T17:10:37Z")

</div>

Another thought. It seems problematic to send amounts in packets without a denomination. If the Stream Prepare and Fulfillment packets had an amount AND a denomination, there wouldn’t be any confusion about which units are what.

---

<div class="post-metadata">

**Author:** ![sappenin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/sappenin/32/41_2.png) [@sappenin](https://forum.interledger.org/u/sappenin)\
**Post date:** [October 3, 2019, 5:23pm UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/9 "2019-10-03T17:23:02Z")

</div>

> [@nhartner](#):
>
> If the Stream Prepare and Fulfillment packets had an amount AND a denomination, there wouldn’t be any confusion about which units are what.

I don’t think we should adjust the packet - if there’s confusion in the spec then we should clarify there.

---

<div class="post-metadata">

**Author:** ![calvinlauco](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/calvinlauco/32/416_2.png) [@calvinlauco](https://forum.interledger.org/u/calvinlauco)\
**Post date:** [October 4, 2019, 4:29am UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/11 "2019-10-04T04:29:02Z")

</div>

Is the `Prepare Amount` in the prepare packet sent from the **Sender** denominated in receiver asset? Or in sender asset?

If it is the latter, that means connectors are changing the `Prepare Amount` as well as the amount in ILP packet?

Thanks.

---

<div class="post-metadata">

**Author:** ![emschwartz](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.interledger.org/emschwartz/32/12_2.png) [@emschwartz](https://forum.interledger.org/u/emschwartz)\
**Post date:** [October 4, 2019, 6:58am UTC](https://forum.interledger.org/t/how-do-receiver-determine-if-the-exchange-rate-is-reasonable/794/12 "2019-10-04T06:58:47Z")

</div>

**ILP Packet**

- The `amount` field in the ILP Prepare packet starts as the amount the sender is sending in their asset and it is modified by each connector.

**STREAM Packet**

- The `Prepare Amount` field in a STREAM packet attached to an ILP Prepare packet is the minimum amount the receiver should accept, denominated in the receiver’s asset.
- The `Prepare Amount` field in a STREAM packet attached to an ILP Fulfill or Reject packet is the `amount` field in the ILP Prepare packet that arrived at the receiver and it is denominated in the receiver’s asset.

In both directions, the `Prepare Amount` is part of the STREAM packet that is encrypted by the sender for the receiver or vice versa, so connectors cannot see or modify it.
