Closed gregtatcam closed 1 month ago
Attention: Patch coverage is 93.25153%
with 11 lines
in your changes are missing coverage. Please review.
Project coverage is 71.0%. Comparing base (
244ac5e
) to head (7b76a0a
).
I pushed commit, which should address all feedback. The commit message details all the updates, but the main change is that the rounding is changed to nearest
when the AMM offer matching target quality is generated.
High Level Overview of Change
Introduces
fixAMMOfferRounding
(subsequently combined with #5016 and renamed tofixAMMv1_1
) amendment to improve quality of the generated AMM offer for a single path payment when one side of the offer is XRP and there is a Limit Order Book (LOB) offer for the same asset pair on the DEX.Context of Change
A single-path AMM offer with account offer on DEX, is always generated starting with the takerPays first, which is rounded up, and then the takerGets, which is rounded down. This rounding ensures that the pool's product invariant is maintained. However, when one of the offer's side is XRP, this rounding can result in the AMM offer having a lower quality, potentially causing offer generation to fail if the quality is lower than the account's offer quality.
To address this issue, the proposed fix adjusts the offer generation process to start with the XRP side first and always rounds it down. This results in a smaller offer size, improving the offer's quality. This change still ensures the product invariant, as the other generated side is the exact result of the swap-in or swap-out equations.
Type of Change
.gitignore
, formatting, dropping support for older tooling)API Impact
libxrpl
change (any change that may affectlibxrpl
or dependents oflibxrpl
)Test Plan
A unit-test
testFixAMMOfferRounding()
is added to AMM_test to verify this amendment