Skip to content

Fix stack accounting and order flow#28

Merged
phroi merged 7 commits intomasterfrom
prelim/stack-review-followups
May 6, 2026
Merged

Fix stack accounting and order flow#28
phroi merged 7 commits intomasterfrom
prelim/stack-review-followups

Conversation

@phroi
Copy link
Copy Markdown
Member

@phroi phroi commented May 6, 2026

Why

The stack had several follow-up correctness issues after the CCC migration work landed. The main problems were around liquidity accounting, DAO readiness, order-lineage resolution, and interface preview behavior. This PR fixes those runtime issues first, adds the matching tests at the owning layers, and then separates live behavior docs from future implementation ideas.

Changes

  • fix state reads so typed and data-bearing cells are excluded from plain CKB accounting
  • tighten receipt parsing, DAO readiness, and withdrawal request invariants
  • fix order descendant resolution to prefer progressed and minted candidates correctly
  • derive SDK pool maturity from live deposits, counting ready deposits as available CKB
  • tighten interface preview selection, threshold errors, and app test coverage
  • simplify the bot rebalancing policy contract while preserving broader future-improvement docs
  • separate live behavior docs from future snapshot and rebalancing ideas, and drop the stack PR template

@phroi phroi force-pushed the prelim/stack-review-followups branch from af8da47 to 5c1756b Compare May 6, 2026 18:11
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refines the iCKB stack by correcting DAO withdrawal readiness logic, enhancing order resolution to prefer newly minted states, and transitioning the SDK to direct deposit scans for maturity estimation. It introduces a shared isPlainCapacityCell utility, optimizes the interface's deposit selection algorithm, and updates documentation for the bot's rebalancing policy. Additionally, the PR expands test coverage and updates the Node.js engine requirement to version 22. I have no feedback to provide.

@phroi phroi force-pushed the prelim/stack-review-followups branch 2 times, most recently from e889f09 to e111913 Compare May 6, 2026 18:26
@phroi phroi force-pushed the prelim/stack-review-followups branch from e111913 to c14c72f Compare May 6, 2026 18:33
@phroi
Copy link
Copy Markdown
Member Author

phroi commented May 6, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request formalizes the bot rebalancing policy and refines the handling of deposit capacities and maturity estimates across the stack. Significant updates include transitioning the SDK from snapshot-based estimation to direct deposit scanning, optimizing the selectReadyDeposits algorithm using a subset-sum approach, and ensuring receipts track free capacity rather than total capacity. Documentation was updated to reflect current runtime behaviors versus archived improvement ideas. Review feedback identifies several improvement opportunities: optimizing performance by reducing sequential RPC calls in loops, removing redundant manual filters that are already covered by API query parameters, and preferring native Math functions over custom utility helpers to simplify the codebase.

Comment thread packages/sdk/src/sdk.ts
Comment thread apps/bot/src/index.ts
Comment thread apps/bot/src/index.ts
Comment thread apps/tester/src/cells.ts
@phroi
Copy link
Copy Markdown
Member Author

phroi commented May 6, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the bot rebalancing policy, updates documentation, and transitions the SDK from pool snapshots to direct deposit scans for maturity estimation. It also introduces a more sophisticated subset selection algorithm for ready deposits and centralizes cell validation logic. A critical issue was identified in the ReceiptData prefix decoding, where the hex slice length is insufficient to capture the required 24 bytes of data, which will likely cause decoding failures.

Comment thread packages/core/src/entities.ts
@phroi
Copy link
Copy Markdown
Member Author

phroi commented May 6, 2026

LGTM

Phroi %150

@phroi phroi merged commit 2963b11 into master May 6, 2026
1 check passed
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