feat(stablecoin): add deposit_collateral instruction - #345
Open
gravityblast wants to merge 2 commits into
Open
Conversation
gravityblast
force-pushed
the
feat/stablecoin-deposit-collateral
branch
from
September 1, 2026 10:40
f236348 to
103e464
Compare
gravityblast
force-pushed
the
feat/stablecoin-open-position-rebuild
branch
from
September 1, 2026 15:57
37b5082 to
ffccb26
Compare
gravityblast
force-pushed
the
feat/stablecoin-deposit-collateral
branch
from
September 1, 2026 15:57
103e464 to
3a92d45
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.
Adds
deposit_collateral(spec §10.5) — the inverse ofwithdraw_collateral,letting an owner top up an existing position.
Five accounts, one chained
Token::Transferwith no PDA seed: the sender is theuser's own holding, authorized by the witness set. (
withdraw_collateralneedsa seed because there the vault is the sender.)
Two deliberate omissions, both per spec:
is_frozencheck.protocol_parametersis read only forcollateral_definition_id. §7 keeps deleveraging available in emergencies, soa deposit works while frozen — the opposite of
open_position. Pinned by a test.reference time and can only improve the position.
14 unit tests: happy path, frozen, zero amount, debt left untouched, both
authorization paths, uninitialized/foreign-owned/wrong-address position, wrong
vault, uninitialized
ProtocolParameters, wrong Token Program, wrong collateraldefinition, and overflow.
The open/withdraw e2e test gains a deposit step between the two, so the new
instruction is exercised through the zkVM; its withdraw assertions are rebased on
the topped-up balance.
Third of eight issues in Plan 3 (#173). Stacked on #341.
closes #176