rippled icon indicating copy to clipboard operation
rippled copied to clipboard

Replicate OfferCreate functionality in Payments to Self

Open donovanhide opened this issue 1 year ago • 2 comments

Summary

I want to use Payments to condense multiple OfferCreates into a single Payment to self, i.e. a Payment where Account and Destination are the same. To do this I need to have a LimitAmount which exceeds the Amount of the Payment. If I were to consume the same chain of offers using OfferCreate no such LimitAmount would be required and in fact, no existing TrustLine/RippleState is required.

Motivation

To reduce transaction counts for arbitrage, by using fewer Payment transactions than OfferCreate transactions and to avoid unnecessary TrustSet transactions.

Solution

Remove the check for a LimitAmount exceeding Amount for Payments to self.

donovanhide avatar Aug 02 '24 17:08 donovanhide

Relevant code is here: https://github.com/XRPLF/rippled/blob/e5aa605742befe585309cb380796fa6d56bb6f04/src/xrpld/app/paths/detail/DirectStep.cpp#L403-L457

I'd argue, once the Auth and NoRipple checks are passed, if Payment's Account is equal to Destination, the line should be created, if it does not exist, and the LimitAmount ignored.

donovanhide avatar Aug 02 '24 20:08 donovanhide

I have previously written code that allows a Payment transaction (to self) to create a trustline automatically in the same way as OfferCreate. If necessary, you can use this code.

https://github.com/tequdev/rippled/pull/3/files

tequdev avatar Aug 19 '24 04:08 tequdev