How do receiver determine if the exchange rate is reasonable?

I have read from ILPv4 documentation and Stream protocol 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.

Hi @calvinlauco,

Good question! The STREAM response packet actually includes the amount that was received. In the original request packet, the Prepare Amount 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 and here 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

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?


@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?

Adding destination denomination to SPSP response seems like a good approach. There was also a suggestion here 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.

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

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.

Higher level protocols may include the asset in their communication details, though STREAM also has a ConnectionAssetDetails frame for this purpose.

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.

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.

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

1 Like

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?


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.


  • 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.