Skip to content

Bug: Inconsistent XLM/stroops conversion between BidForm and AuctionCard #374

@gboigwe

Description

@gboigwe

Description

In frontend/src/components/auction/BidForm.tsx (lines 22-26) and frontend/src/components/auction/AuctionCard.tsx (line ~60), there's an inconsistency in how floor_price and winning_bid are treated:

BidForm.tsx:

const floorXlm = stroopsToXlm(auction.floor_price);   // Treats as stroops
const currentBidXlm = auction.winning_bid
  ? stroopsToXlm(auction.winning_bid)                  // Treats as stroops
  : null;

AuctionCard.tsx:

BigInt(auction.floor_price)  // Used directly as BigInt — unclear if stroops or XLM

BidForm submission (line ~75):

const amountStroops = Math.round(parseFloat(bidAmount) * 1e7);  // Converts XLM input to stroops

Problem

If the contract returns floor_price in XLM (not stroops), then stroopsToXlm() divides by 1e7, making the floor price appear 10 million times smaller than intended. Conversely, if the contract returns stroops, the BigInt() usage in AuctionCard displays raw stroops to the user.

The same data field is handled differently in two components with no shared type definition or documentation of the expected unit.

Impact

  • Bid floor prices could be displayed as effectively zero (if already in XLM but converted again)
  • Users could place bids that are 10 million times too low or too high
  • Real money (XLM) is at stake — wrong conversions mean lost funds

Suggested Fix

  1. Define a clear Auction type with documented units:
interface Auction {
  floor_price: bigint;    // Always in stroops (1 XLM = 10,000,000 stroops)
  winning_bid: bigint;    // Always in stroops
}
  1. Use consistent conversion across all components
  2. Add unit tests for bid amount conversions

Files Affected

  • frontend/src/components/auction/BidForm.tsx
  • frontend/src/components/auction/AuctionCard.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfrontendNextjs frontend

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions