Skip to content

feat(minter): check the deposit address balance and charge cycles in deposit_sol - #211

Draft
gregorydemay wants to merge 3 commits into
feat/deposit-sol-queue-statefrom
feat/deposit-sol-balance-check
Draft

gregorydemay wants to merge 3 commits into
feat/deposit-sol-queue-statefrom
feat/deposit-sol-balance-check

Conversation

@gregorydemay

@gregorydemay gregorydemay commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Third PR of the balance-sweep deposit stack (#207, #208, #210). deposit_sol now does what section 3.1.3 of the design describes up to queueing: it requires the attached cycles, reserves the account for the duration of the call, rejects a second call while a deposit for the account is in flight with that deposit's id, reads the balance of the deposit address at finalized commitment, computes the sweepable amount as the balance minus the rent exemption threshold, rejects it below the minimum deposit amount while charging only the balance read, and otherwise queues the deposit, charges the read plus the consolidation fee, refunds the rest and returns the id. deposit_status reports the queued deposit with its sweepable amount.

Nothing is swept yet; that is the next PR. Covered by unit tests with self-validating cycle assertions, PocketIC tests of every outcome including concurrent and duplicate calls, and a test against solana-test-validator that queues a real transfer.

🤖 Generated with Claude Code

@gregorydemay
gregorydemay added this pull request to stack #209 September 23, 2026 08:47
@gregorydemay gregorydemay changed the title feat/deposit sol balance check feat(minter): check the deposit address balance and charge cycles in deposit_sol Sep 23, 2026
gregorydemay and others added 3 commits September 23, 2026 09:35
…deposit_sol

`deposit_sol` now requires the process deposit cycles, rejects an account
with a deposit in flight without contacting the SOL RPC canister, reads
the balance of the deposit address at the `finalized` commitment and
queues the sweepable amount, i.e. the balance minus the rent exemption
threshold, if it reaches the minimum deposit amount. The caller pays the
balance read and, when the deposit is queued, the deposit consolidation
fee; the rest is refunded. A dedicated guard rejects a concurrent call
for the same account.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
…idator

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`deposit_sol` reads the next deposit id from the state and records the
`QueuedDeposit` event like every other event. The guard set reserving an
account for the duration of a `deposit_sol` call lives in this branch
together with the guard that uses it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@gregorydemay
gregorydemay force-pushed the feat/deposit-sol-balance-check branch from 6b300cc to df25706 Compare September 23, 2026 09:40
Copilot AI lite review requested due to automatic review settings September 23, 2026 09:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

No unresolved blocking issues were identified.

Review effort: Lite
Findings: None

What changed in this PR

Implements the balance-sweep deposit_sol flow through queueing, including finalized balance checks, cycle accounting, concurrency protection, and status reporting.

Changes:

  • Adds finalized balance retrieval and sweepable amount calculation.
  • Adds guards, queued deposit state, and cycle charging/refunds.
  • Expands unit, PocketIC, and Solana validator test coverage.
File Description
minter/​src/​state/​tests.rs Initializes request guard state.
minter/​src/​state/​mod.rs Stores guards and queued deposit state.
minter/​src/​rpc/​tests.rs Tests balance RPC behavior.
minter/​src/​rpc/​mod.rs Adds finalized balance retrieval.
minter/​src/​main.rs Wires the asynchronous endpoint.
minter/​src/​guard/​tests.rs Tests deposit guards.
minter/​src/​guard/​mod.rs Adds deposit guards and error mapping.
minter/​src/​deposit/​sweep/​tests.rs Tests queueing, errors, cycles, and status.
minter/​src/​deposit/​sweep/​mod.rs Implements balance checking and queueing.
minter/​src/​constants.rs Defines balance RPC cycle requirements.
libs/​types-internal/​src/​event.rs Enables event equality assertions.
integration_tests/​tests/​tests.rs Adds PocketIC deposit flow tests.
integration_tests/​tests/​solana_test_validator.rs Tests queueing against Solana test validator.
integration_tests/​src/​lib.rs Adds cycle-aware test helpers.
integration_tests/​src/​fixtures.rs Adds balance RPC mocks and fixtures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

2 participants