mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-05-18 23:19:30 +00:00
Adds the `open_position` instruction to the Stablecoin Program. The instruction
claims a per-owner `Position` PDA, initializes a collateral vault token holding
via a chained `Token::InitializeAccount` under the vault's PDA authority, and
moves `collateral_amount` from the user's holding into the vault with a chained
`Token::Transfer`. `Position` is persisted with `collateral_amount` and
`debt_amount = 0`; the debt path is deferred to `generate_debt`.
- Add `Position` struct, `OpenPosition` instruction variant, and
`compute_position_pda{,_seed}` / `compute_position_vault_pda{,_seed}` helpers
in `stablecoin_core` with domain-separated PDA seeds.
- Implement `open_position::open_position` mirroring the ATA `create` and AMM
`new_definition` patterns: authorization and uninitialized-state asserts, PDA
verification, and same-transaction chained `InitializeAccount` + `Transfer`.
- Wire the new instruction through the SPEL guest and regenerate the stablecoin
IDL artifact.
- Cover the happy path, all assertion paths, and PDA determinism /
non-collision in 11 new unit tests.
65 lines
1.2 KiB
JSON
65 lines
1.2 KiB
JSON
{
|
|
"version": "0.1.0",
|
|
"name": "stablecoin",
|
|
"instructions": [
|
|
{
|
|
"name": "noop",
|
|
"accounts": [
|
|
{
|
|
"name": "account",
|
|
"writable": false,
|
|
"signer": false,
|
|
"init": false
|
|
}
|
|
],
|
|
"args": []
|
|
},
|
|
{
|
|
"name": "open_position",
|
|
"accounts": [
|
|
{
|
|
"name": "owner",
|
|
"writable": false,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "position",
|
|
"writable": false,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "vault",
|
|
"writable": false,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "user_holding",
|
|
"writable": false,
|
|
"signer": false,
|
|
"init": false
|
|
},
|
|
{
|
|
"name": "token_definition",
|
|
"writable": false,
|
|
"signer": false,
|
|
"init": false
|
|
}
|
|
],
|
|
"args": [
|
|
{
|
|
"name": "stablecoin_program_id",
|
|
"type": "program_id"
|
|
},
|
|
{
|
|
"name": "collateral_amount",
|
|
"type": "u128"
|
|
}
|
|
]
|
|
}
|
|
],
|
|
"instruction_type": "stablecoin_core::Instruction"
|
|
}
|