Skip to content

feat(ramps): poll neo-bank deposits and emit status notifications - #10108

Closed
saustrie-consensys wants to merge 2 commits into
saustrie/neobank-pix-service-methodsfrom
saustrie/ramps-deposit-polling
Closed

feat(ramps): poll neo-bank deposits and emit status notifications#10108
saustrie-consensys wants to merge 2 commits into
saustrie/neobank-pix-service-methodsfrom
saustrie/ramps-deposit-polling

Conversation

@saustrie-consensys

@saustrie-consensys saustrie-consensys commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Explanation

Part of the MM Neobank MVP0 (Brazil 🇧🇷) onramp flow. When a user funds a Money Account via Pix, the partner (Iron) pays out mUSD on Monad, and Core needs to notice those deposits so the app can react.

This adds emit-only deposit polling to RampsController (TRAM-3898, "poll for deposit and notifications"). The vault "sweep" (the original step 3) was removed from the ticket, so this PR only detects and reports: it takes no on-chain action, and vault sweeping stays with the backend.

How it works, reusing the existing autoramp/order patterns already in this package:

  • NeoBankService.getAutorampTransactions(autorampId) fetches a partner's deposit/transaction records, mapped via the exported mapNeoBankTransactionToRemoteSnapshot (accepts a bare array or a { transactions } envelope; rejects items missing id/status).
  • moneyAccountDeposit.ts is a thin local clone model mirroring autorampAccount.ts: a status enum plus a pure applyDepositRemoteStatus diff returning statusChanged / shouldNotify.
  • A sibling poll loop (startDepositPolling / stopDepositPolling, plus refreshDeposits for app-load catch-up) reuses the order poller's 30s interval and error backoff. Each cycle upserts a persisted state.deposits array and publishes RampsController:depositStatusChanged on status transitions. Only Approved autoramps (or ones with an in-flight local deposit) are polled, so an in-flight deposit keeps being tracked even if its route later goes terminal.
  • markDepositAsNotified dedupes repeat notifications for the same status; removeDeposit lets consumers prune the persisted list.

Note: the proxy route (GET /neobank/autoramps/{id}/transactions) and the payout-hash field are assumed pending the proxy contract (onramp-api #1124 / #1125); they are mocked in the unit tests here.

Hosts must delegate NeoBankService:getAutorampTransactions (added to RAMPS_CONTROLLER_REQUIRED_SERVICE_ACTIONS), or startDepositPolling / refreshDeposits reject with a messenger "handler has not been delegated" error.

Base / stacking

Stacked on saustrie/neobank-pix-service-methods (#9851), which provides NeoBankService and the autoramp model. Review the top commit only; retarget to main once #9851 lands. Lint/coverage red on shared files is pre-existing #9851 draft debt on unchanged code, not from this PR.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Add emit-only Money Account deposit polling to RampsController for the MM
Neobank onramp flow (TRAM-3898, "poll for deposit and notifications"). A
sibling poll loop fetches each pollable autoramp's deposit/transaction records
from the neo-bank proxy, keeps a persisted state.deposits clone, and publishes
RampsController:depositStatusChanged on status transitions so the app can show
a toast or refresh the account screen. The poller takes no on-chain action;
vault sweeping stays with the backend.

- Add NeoBankService.getAutorampTransactions and the matching messenger action,
  mapping proxy transactions (bare array or a { transactions } envelope) via the
  exported mapNeoBankTransactionToRemoteSnapshot. Rejects items missing id/status.
- Add the moneyAccountDeposit model: MoneyAccountDeposit, MoneyAccountDepositStatus,
  the pure applyDepositRemoteStatus diff, and helpers, mirroring autorampAccount.
- Add startDepositPolling / stopDepositPolling / refreshDeposits, plus
  markDepositAsNotified (notify dedupe) and removeDeposit (prune persisted state),
  a persisted state.deposits array, and the depositStatusChanged event, reusing
  the order poller's 30s interval and error backoff.
- Poll only Approved autoramps, or ones with an in-flight local deposit, so an
  in-flight deposit keeps being tracked even if its route later goes terminal.
@saustrie-consensys

Copy link
Copy Markdown
Contributor Author

Superseded by #10120, which is correctly based on main (this one was mistakenly stacked on the stale hackathon branch #9851). Same feature, fully green on main.

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.

1 participant