Trivial complexity — 100 pts
Summary
Stellar requires every account to maintain a minimum XLM balance (base reserve = 0.5 XLM × (2 + number of trustlines)). If a user tries to send an amount that would drop them below this minimum, the transaction fails with op_underfunded. StellarFlow should warn users before they attempt the transaction.
Files to Modify
- Modify:
src/lib/stellar.ts — add calculateMinimumReserve and getSpendableBalance
- Modify:
src/pages/SendPage.tsx — add reserve warning and fix Max button
- Modify:
src/pages/DashboardPage.tsx — optionally show spendable balance vs total
Implementation Notes
In stellar.ts:
export function calculateMinimumReserve(numTrustlines: number): number {
return (2 + numTrustlines) * 0.5;
}
export function getSpendableBalance(xlmBalance: string, numTrustlines: number): string {
const total = parseFloat(xlmBalance);
const reserve = calculateMinimumReserve(numTrustlines);
return Math.max(0, total - reserve - 0.001).toFixed(4);
}
In SendPage: count non-XLM balances for trustline count, show AlertTriangle warning when amount > spendable, update Max button to use getSpendableBalance when asset === 'XLM'.
Acceptance Criteria
Screen Recording Requirements
- Account with ~2 XLM and one USDC trustline (min reserve = 1.5 XLM, spendable ≈ 0.5 XLM)
- Enter an amount above the spendable balance → yellow warning appears
- Click Max → field fills with the spendable amount, not the total balance
- Enter a valid amount below spendable → warning disappears
Trivial complexity — 100 pts
Summary
Stellar requires every account to maintain a minimum XLM balance (base reserve = 0.5 XLM × (2 + number of trustlines)). If a user tries to send an amount that would drop them below this minimum, the transaction fails with
op_underfunded. StellarFlow should warn users before they attempt the transaction.Files to Modify
src/lib/stellar.ts— addcalculateMinimumReserveandgetSpendableBalancesrc/pages/SendPage.tsx— add reserve warning and fix Max buttonsrc/pages/DashboardPage.tsx— optionally show spendable balance vs totalImplementation Notes
In
stellar.ts:In
SendPage: count non-XLM balances for trustline count, showAlertTrianglewarning when amount > spendable, update Max button to usegetSpendableBalancewhenasset === 'XLM'.Acceptance Criteria
calculateMinimumReservecorrectly accounts for the number of existing trustlinesScreen Recording Requirements