feat: end-to-end multi-token (SEP-41) deposit support (Closes #255) - #256
Open
waterWang wants to merge 1 commit into
Open
feat: end-to-end multi-token (SEP-41) deposit support (Closes #255)#256waterWang wants to merge 1 commit into
waterWang 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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