Skip to content

feat: multi-token (SEP-41) deposit support for pools (Closes #255) - #257

Open
devJaja wants to merge 2 commits into
JointSave-org:mainfrom
devJaja:feat/multi-token-deposit
Open

feat: multi-token (SEP-41) deposit support for pools (Closes #255)#257
devJaja wants to merge 2 commits into
JointSave-org:mainfrom
devJaja:feat/multi-token-deposit

Conversation

@devJaja

@devJaja devJaja commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Implements end-to-end multi-token (SEP-41) deposit support for pools, per issue #255. The rotational contracts already expose set_supported_tokens / get_supported_tokens; this PR wires the frontend admin configuration, token-aware deposit route and amount maths around them.

What changed

frontend/lib/deposit-token.ts — new dependency-free pure-logic module (mirroring deposit-calendar.ts / batch-deposit.ts) shared by the deposit UI and API:

  • humanToBaseUnits / baseUnitsToHuman / trimHumanAmount — exact human ↔ base-units conversion per asset decimals, immune to float error ("0.07" @ 7 → exactly 700000)
  • validateTokenSelection — checks a chosen token against the pool's supported set (empty list = unrestricted)
  • checkSufficientBalance — validates a human amount against an on-chain base-units balance in the correct unit
  • computeDepositFee — treasury + relayer bps fee computed in the settlement token's own unit

frontend/lib/deposit-token.test.ts — 24 unit tests covering decimals conversion, token selection, balance checks and fee maths.

frontend/app/api/pools/deposit/route.ts — token-aware deposit route:

  • Accepts optional tokenSymbol, tokenDecimals, tokenAmount, treasuryFeeBps, relayerFeeBps
  • Validates that tokenAmount has at most the asset's supported precision (rejects e.g. 8 decimals for a 7-decimal asset)
  • Records token_amount and a computed fee_charged alongside amount so deposit history can be broken out by currency

frontend/app/api/pools/tokens/route.ts — admin-only route to persist a pool's supported_tokens allowlist to Supabase (mirrors contract set_supported_tokens replace semantics), logging to admin_actions.

Admin config UIfrontend/components/group/supported-tokens-settings.tsx + useSetSupportedTokens / fetchSupportedTokens hooks that write the allowlist on-chain via the wallet and save it; wired into the group admin controls.

Deposit UI token pickerfrontend/components/group/deposit-token-picker.tsx lists supported assets, shows per-token balances (own decimals) and validates selection before deposit.

Trackingset_supported_tokens registered as a tracked pending-transaction type (lib/pending-transactions.ts, lib/tx-retry.ts).

Schemapools.supported_tokens JSONB column via supabase/migrations/20260827000000_multi_token_deposits.sql, reflected in the typed client (lib/supabase.ts).

Verification

  • 268/268 unit tests pass (24 new)
  • 121/121 component tests pass across 19 files
  • ESLint clean, Prettier formatted, tsc --noEmit reports no new errors from changed files (pre-existing unrelated errors untouched)

Closes #255

devJaja and others added 2 commits August 27, 2026 19:05
…e-org#255)

- Add pure-logic deposit-token module (human<->base-units per asset
  decimals, token-selection validation, balance checks, fee math) with full
  unit test coverage.
- Extend POST /api/pools/deposit to accept token selection, validate the
  token amount against the asset's precision, and record token_amount +
  computed fee alongside the numeric amount.
- Add POST /api/pools/tokens admin route to persist a pool's supported-token
  allowlist (admin-only), and a SupportedTokensSettings admin UI that writes
  the allowlist on-chain via set_supported_tokens and saves it to Supabase.
- Add useSetSupportedTokens/fetchSupportedTokens contract hooks and register
  set_supported_tokens as a tracked pending-transaction type.
- Introduce a DepositTokenPicker on the deposit panel that lists supported
  assets, shows per-token balances, and validates selection.
- Add pools.supported_tokens column via migration and update the typed
  Supabase client.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] End-to-end multi-token (SEP-41) deposit support for pools

1 participant