Commit c0e28e2
authored
feat(ENG-279): Add vault account creation to INIT-VAULT (#50)
# Changes
1. Extend INIT-VAULT to create vault token accounts via
CreateAccount CPI, with Token 2022 support via a
GetAccountDataSize CPI to determine account size at
runtime (falls back to the fixed 165-byte SPL Token
account size for non-2022 programs)
2. Add `sol_get_return_data` syscall for reading the token
account size returned by GetAccountDataSize
3. Add duplicate and data-length checks for base and quote
vault accounts before initialization, with four new error
codes (`BaseVaultIsDuplicate`, `BaseVaultHasData`,
`QuoteVaultIsDuplicate`, `QuoteVaultHasData`)
4. Store `system_program_id` pointer on the frame and use it
in both INIT-MARKET-PDA and INIT-VAULT for CreateAccount
CPI program ID (previously set directly on `sol_instruction`)
5. Add `program_id`, `lamports_per_byte`, `mint`,
`token_account_data_size`, `get_return_data_program_id`,
and `get_account_data_size_data` fields to
`RegisterMarketFrame` for vault creation state
6. Derive vault PDAs from the program ID instead of the token
program ID
7. Add `interface/src/token.rs` module with SPL Token constants
(`ACCOUNT_SIZE`, `GET_ACCOUNT_DATA_SIZE_DISC`)
8. Add `common/token.s` assembly file with injected token
constants
9. Update INIT-MARKET-PDA to save `lamports_per_byte` on the
frame and populate `signers_seeds` in its ensure contract
10. Update all three algorithm specs (REGISTER-MARKET,
INIT-MARKET-PDA, INIT-VAULT) with new require/ensure
annotations and vault creation pseudocode
11. Add `check_vault!` macro to integration tests for verifying
vault owner, data length, and rent exemption after
successful registration
12. Add six new test cases for vault duplicate and data-length
error paths (`BaseVaultIsDuplicate`, `BaseVaultHasData`,
`QuoteVaultIsDuplicate{Dup,NonDup}`,
`QuoteVaultHasData{Dup,NonDup}`)
13. Wire `mollusk-svm-programs-token` and `spl-token-interface`
into the test harness for real token program execution
14. Update `layout.md` directory tree and add Token constants
section1 parent 5568181 commit c0e28e2
21 files changed
Lines changed: 866 additions & 86 deletions
File tree
- docs
- algorithms
- src/program
- interface/src
- program/src/dropset
- common
- market
- tests
- src
- tests/cases
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
| 22 | + | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
| |||
68 | 73 | | |
69 | 74 | | |
70 | 75 | | |
| 76 | + | |
71 | 77 | | |
72 | 78 | | |
73 | 79 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | | - | |
| 21 | + | |
19 | 22 | | |
| 23 | + | |
20 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
21 | 33 | | |
22 | 34 | | |
23 | 35 | | |
| |||
27 | 39 | | |
28 | 40 | | |
29 | 41 | | |
30 | | - | |
| 42 | + | |
31 | 43 | | |
32 | 44 | | |
33 | 45 | | |
| |||
39 | 51 | | |
40 | 52 | | |
41 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
42 | 137 | | |
43 | 138 | | |
44 | 139 | | |
0 commit comments