Skip to content

feat(stablecoin): implement generate_debt to mint stablecoin against a position #132

@gravityblast

Description

@gravityblast

open_position currently deposits collateral and leaves Position.debt_amount = 0; no stablecoin is ever minted.
Add a generate_debt instruction that, given an existing position and a stablecoin token definition, mints amount stablecoin to the caller's holding and increases Position.debt_amount by the same amount.

Accounts:

Owner (authorized)
Position (initialized, owned by stablecoin program)
Stablecoin token definition
User's stablecoin holding (recipient of the mint)
Behavior:

Re-derive the position PDA from (owner, Position.collateral_definition_id) to bind the caller as owner.
Chain Token::Mint { amount } under the stablecoin program's PDA authority into the user's holding.
Update Position.debt_amount += amount.
Out of scope (separate tickets): stability-fee accrual (#97) and collateralization-ratio check before minting.

Unblocks the stablecoin_definition_id validation TODOs in repay_debt and the debt precondition in withdraw_collateral.

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions