Skip to content

SettlementForm hardcodes "USDC" as its initial and reset asset default, ignoring availableLiquidityΒ #307

Description

@Jagadeeshftw

πŸ“Œ Description

SettlementForm (src/components/SettlementForm.tsx) initializes const [asset, setAsset] = useState("USDC"); and its reset() function does setAsset("USDC"); β€” both hardcode the literal string "USDC" as the asset field's default value. The component already receives an availableLiquidity?: Record<string, number> prop (populated by SettlementsPanel from the real pool list via fetchPools) specifically enumerating the assets this deployment actually supports, but the hardcoded default never consults it. On a deployment whose pools don't include a USDC pool at all, the form's default (and every reset) presents a value that isn't actually one of the supported assets, and submitting without changing it would immediately fail the availableLiquidity liquidity check that validate() already performs for asset codes present in the record.

🧩 Requirements and context

  • The asset field's initial value and reset() default should prefer an asset that's actually known to be available (e.g. the first key of availableLiquidity when it's populated), falling back to the current "USDC" literal only when availableLiquidity is absent/empty (e.g. before pools have loaded).
  • No change to the field's free-text nature β€” the user must still be able to type any asset code regardless of the default.
  • The existing validation behavior (required field, liquidity check) must be unchanged.

πŸ› οΈ Suggested execution

  • In src/components/SettlementForm.tsx, derive a defaultAsset (e.g. Object.keys(availableLiquidity ?? {})[0] ?? "USDC") and use it both for the initial useState value and inside reset(), recomputing it if availableLiquidity changes after mount (e.g. via a useEffect that only updates the field when it still holds the previous default, so it doesn't clobber a user's in-progress edit).
  • Extend src/components/SettlementForm.test.tsx with a test supplying an availableLiquidity whose keys don't include "USDC" and asserting the field's initial/reset value is one of the actually-available assets instead.

βœ… Acceptance criteria

  • The asset field's default value reflects an actually-available asset when availableLiquidity is populated.
  • The field falls back to "USDC" when availableLiquidity is absent or empty, matching current behavior.
  • Test coverage for both cases.

πŸ”’ Security notes

No new attack surface; a client-side default-value correctness fix using data already fetched and displayed elsewhere on the page.

πŸ“‹ Guidelines

  • Minimum 95% test coverage
  • Clear documentation
  • Timeframe: 96 hours

Metadata

Metadata

Labels

GrantFox OSSIssue tracked in GrantFox OSSMaybe RewardedIssue may be eligible for a GrantFox rewardOfficial Campaign | FWC26Campaign: Official Campaign | FWC26bugSomething isn't workingfrontendFrontend / UI work

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions