interledger / open-payments

Protocol to setup payments between entities on the Web based on GNAP
https://openpayments.dev
Apache License 2.0
204 stars 34 forks source link

Return `estimatedExchangeRate` for quotes #491

Open mkurapov opened 4 months ago

mkurapov commented 4 months ago

Context

Originally from @raducristianpopa particularly in the WM context, there is no good way to determine what is the minimum debitAmount for a quote that will satisfy at least a minimum one unit of value for the receiving wallet address:

What would be the best way to check what is the minimum amount that can be sent in a cross-currency scenario - debitAmount? When sending from USD to EUR, in most cases $0.01 is not going to equal 0.01EUR. I thought about using receiveAmount but this will not work - the grant will need the limits in the receiver’s asset. Probe through quoting - create quotes until one is created successfully? - For WM this will lead to some delays in the flow Probe through quoting with an exponential increase for the amount? If the sender’s asset is ZAR and the receiver’s asset is USD we will probably have to make around 16-18 quote requests (depends on the exchange rate as well): 0.01 ZAR = 0.00… USD 0.19 ZAR = 0.01 USD In the example above, the extension will have to make 18 quote requests until it reaches an amount that can be represented in USD.

What we came up with in the Open Payments catch up call is to expose an estimatedExchangeRate on the quote POST & GET response.

Todos

raducristianpopa commented 2 months ago

Should the ILP specific fields be removed as well in this PR?

Related to: https://github.com/interledger/rafiki/issues/2856.

Edit: I just noticed that these fields are not returned for Open Payments.