Repository navigation
Conversation
3esmit
added this pull request to stack #337
October 5, 2026 07:43
3esmit
marked this pull request as ready for review
October 5, 2026 13:08
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Financial arithmetic, chained mint authorization, and live-state transaction planning warrant final human review despite comprehensive coverage.
Review effort: Balanced
Findings: None
What changed in this PR
Exposes owner-signed stablecoin debt generation with live preflight validation and exact protocol arithmetic.
Changes:
- Adds the Rust FFI debt planner and C ABI export.
- Adds
generateDebtto the C++ module with live account reads and transaction submission. - Documents and extensively tests validation, arithmetic, ABI, and wallet behavior.
| File | Description |
|---|---|
modules/stablecoin/ffi/src/api/debt.rs |
Implements debt preflight and planning. |
modules/stablecoin/ffi/src/api/debt_tests.rs |
Tests protocol behavior and boundaries. |
modules/stablecoin/ffi/src/api/request.rs |
Defines the planner request. |
modules/stablecoin/ffi/src/api/mod.rs |
Exports the planner API. |
modules/stablecoin/ffi/src/lib.rs |
Re-exports the public surface. |
modules/stablecoin/ffi/src/ffi.rs |
Adds the C entry point. |
modules/stablecoin/ffi/include/stablecoin_ffi.h |
Declares the C API. |
modules/stablecoin/ffi/tests/public_api.rs |
Verifies public re-exports. |
modules/stablecoin/src/stablecoin_module_impl.cpp |
Implements generateDebt. |
modules/stablecoin/src/stablecoin_module_impl.h |
Declares and documents the method. |
modules/stablecoin/src/stablecoin_module_support.cpp |
Exposes stable borrowing errors. |
modules/stablecoin/tests/stablecoin_module_impl_test.cpp |
Tests module orchestration and failures. |
modules/stablecoin/tests/stablecoin_module_real_ffi_journey_test.cpp |
Tests real FFI borrowing journeys. |
modules/stablecoin/tests/mocks/mock_stablecoin_ffi.cpp |
Adds the planner mock. |
modules/stablecoin/README.md |
Documents debt generation semantics. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
3esmit
force-pushed
the
feat/stablecoin-module-generate-debt-391
branch
from
October 5, 2026 14:08
937a4fa to
287bde3
Compare
0x-r4bbit
force-pushed
the
feat/stablecoin-module-generate-debt-391
branch
from
October 19, 2026 12:17
287bde3 to
03f2439
Compare
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
Expose
generateDebt(request)throughstablecoin_module, with live-account preflight and owner-only signing. The destination holding can be outside the active wallet; the program authorizes its chained Token mint with the stablecoin definition's PDA.Preserve upward-rounded normalized debt, native narrow accumulator pricing, wide post-mint collateralization and oracle freshness. A fresh zero-price market oracle is accepted, while stale/future observations, frozen state, zero projected redemption price, insufficient collateral and unrepresentable arithmetic fail before submission. Zero amounts retain all validation gates.
Validate definition authority, token bindings and mint capacity, and re-read the configured oracle and parameters on every call. Tests pin the nine-account ABI, rounding and freshness boundaries, maximum-width inputs, native mint execution, live oracle rotation and wallet failures. Export the planner/module method and document the request and stable errors.
Closes #391
Validation
RISC0_DEV_MODE=1 cargo +1.94.0 test -p stablecoin_ffinix build .#stablecoin-module-tests .#stablecoin-module --no-link -L