Skip to content

AMMVote: applyVote writes sfDiscountedFee to expired auction slot #6664

@mvadari

Description

@mvadari

Issue Description

In AMMVote::applyVote (src/libxrpl/tx/transactors/dex/AMMVote.cpp, lines 181–203), the sfDiscountedFee field on the auction slot is unconditionally updated without checking whether the auction slot has expired:

if (ammSle->isFieldPresent(sfAuctionSlot))
{
    auto& auctionSlot = ammSle->peekFieldObject(sfAuctionSlot);
    if (auto const discountedFee = fee / AUCTION_SLOT_DISCOUNTED_FEE_FRACTION)
    {
        auctionSlot.setFieldU16(sfDiscountedFee, discountedFee);
    }
    // ...
}

The read side (getTradingFee in AMMUtils.cpp) correctly checks the auction slot's sfExpiration before applying the discounted fee. So the stale write is never actually used during swaps. However, it is unnecessary state pollution — writing a field that will never be read until the slot is re-bid.

Steps to Reproduce

  1. Create an AMM with an auction slot.
  2. Let the auction slot expire.
  3. Submit an AMMVote transaction.
  4. Observe that sfDiscountedFee is written to the expired auction slot.

Expected Result

applyVote should check the auction slot's sfExpiration before writing sfDiscountedFee. If the slot is expired, the discounted fee write should be skipped.

Actual Result

sfDiscountedFee is unconditionally written to the auction slot, even when expired.

Environment

All versions with AMM support (XLS-30).

Supporting Files

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI TriageBugs and fixes that have been triaged via AI initiatives

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions