feat: end-to-end multi-token (SEP-41) deposit support (Closes #255) - #256
feat: end-to-end multi-token (SEP-41) deposit support (Closes #255)#256waterWang wants to merge 1 commit into
Conversation
- lib/deposit-token.ts: pure decimals/amount math, token-selection validation, balance checks and fee computation (shared by UI + API) - unit tests: 14 cases covering conversion, selection, balance, fees - /api/pools/deposit: accept tokenSymbol/tokenDecimals/tokenAmount and record token-denominated amounts with per-asset precision validation - group-actions: pass pool token into deposit activity logging
Coordination: duplicates #257 (both close #255)Nice implementation — the integer-exact SEP-41 amount maths and the shared PR #257 is currently the more complete of the two (it adds the No issues with the code itself — happy to approve if this is the one we keep, but only one of the two can merge. |
Summary
Implements end-to-end multi-token (SEP-41) deposit support for pools, per issue #255. The contract already exposes
set_supported_tokens/get_supported_tokens; this PR wires the token-aware amount maths and activity recording that the deposit flow was missing.What changed
frontend/lib/deposit-token.ts— new dependency-free pure-logic module (mirroringdeposit-calendar.ts/batch-deposit.ts) shared by the deposit UI and API:normalizeDecimals/humanToBaseUnits/baseUnitsToHuman/trimHumanAmount— exact human ↔ base-units (stroops) conversion per asset decimals, immune to floating-point error ("0.07" @ 7 decimals→ exactly700000)validateTokenSelection— checks a chosen token against the pool's supported set (empty list = unrestricted), with clear per-pool errorscheckSufficientBalance— validates a human amount against an on-chain base-units balance in the correct unitcomputeDepositFee— treasury + relayer bps fee computed in the settlement token's own unitfrontend/lib/deposit-token.test.ts— 14 unit tests covering decimals conversion, token selection, balance checks and fee maths.frontend/app/api/pools/deposit/route.ts— token-aware deposit route:tokenSymbol,tokenDecimals,tokenAmounttokenAmounthas at most the asset's supported precision (rejects e.g. 8 decimals for a 7-decimal asset)token_amount(token-denominated) alongsideamountso deposit history can be broken out by currencyfrontend/components/group/group-actions.tsx— passes the pool'stokenSymbolthrough to the deposit logging route.frontend/package.json—test:unitincludes the newdeposit-token.test.ts.Verification
batch-deposit.test.tsx12/12,group-actions.test.tsx8/8 passtsc --noEmit— no new errors from changed files (73 pre-existing unrelated errors untouched)Closes #255