@typesol/cli 0.49.0 → 0.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/CHANGELOG.md +541 -0
  2. package/NOTICE +9 -0
  3. package/README.md +34 -15
  4. package/SECURITY.md +6 -3
  5. package/dist/cli.js +36 -5
  6. package/dist/compiler/analyze.d.ts +10 -1
  7. package/dist/compiler/analyze.js +234 -20
  8. package/dist/compiler/diagnostics.d.ts +4 -0
  9. package/dist/compiler/diagnostics.js +5 -1
  10. package/dist/compiler/emit/base.d.ts +35 -4
  11. package/dist/compiler/emit/base.js +46 -4
  12. package/dist/compiler/emit/borsh.js +8 -8
  13. package/dist/compiler/emit/calls.d.ts +6 -0
  14. package/dist/compiler/emit/calls.js +98 -18
  15. package/dist/compiler/emit/cpi-core.d.ts +3 -0
  16. package/dist/compiler/emit/cpi-core.js +11 -5
  17. package/dist/compiler/emit/cpi.js +6 -4
  18. package/dist/compiler/emit/create.js +9 -9
  19. package/dist/compiler/emit/expressions.d.ts +9 -1
  20. package/dist/compiler/emit/expressions.js +77 -0
  21. package/dist/compiler/emit/function.d.ts +2 -0
  22. package/dist/compiler/emit/function.js +71 -15
  23. package/dist/compiler/emit/outline.d.ts +35 -0
  24. package/dist/compiler/emit/outline.js +547 -0
  25. package/dist/compiler/emit/program.js +19 -4
  26. package/dist/compiler/emit/rbtree.js +1 -1
  27. package/dist/compiler/emit/shared.d.ts +69 -4
  28. package/dist/compiler/emit/shared.js +44 -9
  29. package/dist/compiler/emit/statements.d.ts +36 -2
  30. package/dist/compiler/emit/statements.js +332 -29
  31. package/dist/compiler/emit/storage.d.ts +16 -0
  32. package/dist/compiler/emit/storage.js +134 -13
  33. package/dist/compiler/emit/views.js +1 -1
  34. package/dist/compiler/hints.d.ts +1 -1
  35. package/dist/compiler/hints.js +9 -1
  36. package/dist/compiler/idl.js +1 -1
  37. package/dist/compiler/index.d.ts +30 -2
  38. package/dist/compiler/index.js +94 -16
  39. package/dist/compiler/model.d.ts +13 -1
  40. package/dist/compiler/stack.d.ts +71 -0
  41. package/dist/compiler/stack.js +309 -0
  42. package/dist/compiler/toolchain.d.ts +87 -5
  43. package/dist/compiler/toolchain.js +384 -19
  44. package/dist/keys.d.ts +12 -1
  45. package/dist/keys.js +57 -7
  46. package/dist/workspace.d.ts +9 -0
  47. package/dist/workspace.js +91 -16
  48. package/docker/deps/0.50.0.lock.json +1206 -0
  49. package/docker/deps/0.51.0.lock.json +1206 -0
  50. package/docs/architecture.md +1 -1
  51. package/docs/audit.md +16 -13
  52. package/docs/case-study-escrow.md +1 -1
  53. package/docs/case-study-jito-mev.md +14 -14
  54. package/docs/case-study-marginfi.md +127 -127
  55. package/docs/case-study-multisig.md +16 -4
  56. package/docs/case-study-raydium-clmm.md +44 -28
  57. package/docs/case-study-raydium-cp-swap.md +18 -18
  58. package/docs/cli.md +5 -4
  59. package/docs/glossary.md +2 -1
  60. package/docs/language-accounts.md +16 -10
  61. package/docs/language-basics.md +29 -2
  62. package/docs/language-builtins.md +4 -2
  63. package/docs/language-cpi.md +34 -0
  64. package/docs/language-native.md +50 -4
  65. package/docs/language-pdas.md +6 -2
  66. package/docs/language-statements.md +103 -12
  67. package/docs/language-types.md +93 -8
  68. package/docs/runtime.md +20 -3
  69. package/docs/security-model.md +6 -3
  70. package/docs/stability.md +10 -5
  71. package/docs/testing.md +6 -2
  72. package/docs/troubleshooting.md +45 -1
  73. package/lib/typesol.d.ts +25 -3
  74. package/llms-full.txt +403 -54
  75. package/package.json +1 -1
  76. package/releases/0.49.0.json +857 -0
  77. package/releases/0.50.0.json +874 -0
  78. package/runtime/typesol_builtins.c +47 -2
  79. package/runtime/typesol_rt.h +254 -54
@@ -109,7 +109,7 @@ representation in between. We reviewed this on 2026-10-30 and kept it that way f
109
109
  named in the source, see `alias.ts`), a second backend (SBF without clang), and optimizations clang cannot see
110
110
  because they depend on account semantics (dropping a repeated check, packing a `@layout borsh` account only where
111
111
  it changed).
112
- - **What it would cost now:** rewriting most of the compiler's 20,000 lines, and losing the property every release
112
+ - **What it would cost now:** rewriting most of the compiler's 23,000 lines, and losing the property every release
113
113
  relies on: programs that do not use a change compile to the same binaries. Audit scope and differential results
114
114
  would start over.
115
115
  - **What we have instead:** the layers above, each owning one concern; `Ref` / `Value` as the typed place and value
package/docs/audit.md CHANGED
@@ -7,23 +7,23 @@ with TypeSOL are out of scope; their authors audit them.
7
7
 
8
8
  ## Scope
9
9
 
10
- In order of priority. Line counts at 0.49.0 (November 2026).
10
+ In order of priority. Line counts at 0.51.0 (November 2026).
11
11
 
12
12
  | Priority | Component | Files | Lines | Why |
13
13
  | --- | --- | --- | ---: | --- |
14
- | 1 | C runtime | `runtime/typesol_rt.h` | 3,273 | In every program: input parsing, account checks, checked arithmetic, PDAs, system and token CPIs, account creation, resizing and closing, oracles, signature checks, the heap |
15
- | 1 | Compiler builtins | `runtime/typesol_builtins.c` | 484 | Compiled and linked with every program (0.45.0): the functions clang calls for 128-bit multiplication, division and shifts and signed 64-bit division (`__multi3`, `__udivti3`, `__divti3`, `__divdi3`, …), in place of platform-tools' compiler-builtins |
16
- | 1 | Instruction prologue and constraints | `src/compiler/emit/function.ts` | 886 | Which checks each account parameter gets, and their order |
17
- | 1 | Account data, Vecs and assignment | `src/compiler/emit/alias.ts`, `storage.ts`, `statements.ts`, `base.ts` | 4,027 | Reads and writes of account data, growable Vec layout and resizing, references and aliasing, closure and helper expansion |
18
- | 1 | Calls and CPIs | `src/compiler/emit/calls.ts`, `cpi-core.ts`, `cpi.ts`, `create.ts`, `token.ts` | 5,781 | Built-ins, remaining accounts, `invoke` / `invokeInstruction` and their account flags, signer seeds, token CPIs, account creation |
14
+ | 1 | C runtime | `runtime/typesol_rt.h` | 3,473 | In every program: input parsing, account checks, checked arithmetic, PDAs, system and token CPIs, account creation, resizing and closing, oracles, signature checks, the heap |
15
+ | 1 | Compiler builtins | `runtime/typesol_builtins.c` | 529 | Compiled and linked with every program (0.45.0): the functions clang calls for 128-bit multiplication, division and shifts and signed 64-bit division (`__multi3`, `__udivti3`, `__divti3`, `__divdi3`, …), in place of platform-tools' compiler-builtins |
16
+ | 1 | Instruction prologue and constraints | `src/compiler/emit/function.ts` | 948 | Which checks each account parameter gets, and their order |
17
+ | 1 | Account data, Vecs and assignment | `src/compiler/emit/alias.ts`, `storage.ts`, `statements.ts`, `base.ts` | 4,494 | Reads and writes of account data, growable Vec layout and resizing, references and aliasing, closure and helper expansion |
18
+ | 1 | Calls and CPIs | `src/compiler/emit/calls.ts`, `cpi-core.ts`, `cpi.ts`, `create.ts`, `token.ts` | 5,884 | Built-ins, remaining accounts, `invoke` / `invokeInstruction` and their account flags, signer seeds, token CPIs, account creation |
19
19
  | 1 | Raw views and the red-black tree | `src/compiler/emit/views.ts`, `rbtree.ts` | 655 | Accounts read without a discriminator at run-time offsets (`loadRaw`, `loadRawAt`, `rawArrayAt`, `BigVec`), their bounds, and the red-black tree's node indexes (`rbTreeAt`) |
20
20
  | 1 | Metaplex CPIs | `src/compiler/emit/metaplex.ts` | 1,465 | Token Metadata, Core and Bubblegum instruction layouts and their account lists |
21
- | 1 | Expressions | `src/compiler/emit/expressions.ts`, `shared.ts`, `borsh.ts` | 2,170 | Checked arithmetic and casts, Borsh encoding of arguments and `@layout borsh` accounts |
22
- | 2 | Front end | `src/compiler/analyze.ts`, `model.ts` | 3,545 | What the language accepts; constraints and account types as parsed from the source |
21
+ | 1 | Expressions | `src/compiler/emit/expressions.ts`, `shared.ts`, `borsh.ts` | 2,339 | Checked arithmetic and casts, Borsh encoding of arguments and `@layout borsh` accounts |
22
+ | 2 | Front end | `src/compiler/analyze.ts`, `model.ts` | 3,785 | What the language accepts; constraints and account types as parsed from the source |
23
23
  | 2 | Interface | `src/compiler/idl.ts`, `src/tools/clientgen.ts` | 2,460 | The IDL and the generated client must describe the program exactly (a mismatch can make clients sign the wrong thing) |
24
- | 3 | Build and tooling | `src/compiler/toolchain.ts`, `src/cli.ts`, `src/workspace.ts`, `src/tools/` | | Build flags, deploy and verification commands |
24
+ | 3 | Build and tooling | `src/compiler/toolchain.ts`, `src/compiler/stack.ts`, `src/cli.ts`, `src/workspace.ts`, `src/tools/` | | Build flags, the stack limits and the layout of a program that does not fit them, deploy and verification commands |
25
25
 
26
- The language surface is `lib/typesol.d.ts` (2,671 lines): every type and built-in a program can use, with its
26
+ The language surface is `lib/typesol.d.ts` (2,693 lines): every type and built-in a program can use, with its
27
27
  documented behavior. [docs/language.md](language.md) is the reference; [docs/architecture.md](architecture.md) maps
28
28
  the code, [docs/runtime.md](runtime.md) the runtime's conventions.
29
29
 
@@ -66,11 +66,14 @@ CHANGELOG.
66
66
 
67
67
  ### Not reviewed: 0.45.0 and later
68
68
 
69
- 0.45.0 to 0.49.0 have had no security review. They add, among others,
69
+ 0.45.0 to 0.51.0 have had no security review. They add, among others,
70
70
  `runtime/typesol_builtins.c` (the compiler builtins as TypeSOL's own C, 0.45.0), `transferCheckedWithHook`,
71
- `EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), and `zeroData`, `log64`,
71
+ `EVENT_AUTHORITY_CHECK` and the reads of processed sibling instructions (0.48.0), `zeroData`, `log64`,
72
72
  `PANIC_STYLE = "solana-1.18"`, `executable` on remaining accounts and lamport writes on remaining accounts under
73
- `NATIVE_ACCOUNT_WRITES` (0.49.0). An external review should include them
73
+ `NATIVE_ACCOUNT_WRITES` (0.49.0), `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
74
+ copied and zeroed by the memory syscalls (0.50.0), and the base58 text of keys from a table, derivations without
75
+ the run-time seed-limit check, object-type structs, `extends`, struct spreads, labels, logical assignment and the
76
+ stack layout the build chooses for a program that does not fit (0.51.0). An external review should include them
74
77
  with the areas the reviews below left out.
75
78
 
76
79
  ### 0.44.0 (2026-11-11)
@@ -191,7 +191,7 @@ token account. A client that matches on this code needs to accept either.
191
191
  ## Cost
192
192
 
193
193
  Mean compute units per instruction in LiteSVM (21 make_offer, 10 take_offer and 10 refund_offer calls), and the
194
- program size, from typesol-lang/benchmarks (`results.json`, `official`: measured with TypeSOL 0.48.0 and Anchor 1.0.2
194
+ program size, from typesol-lang/benchmarks (`results.json`, `official`: measured with TypeSOL 0.48.0 and anchor-lang 1.2.1
195
195
  on 2026-11-14). Lower is better.
196
196
 
197
197
  | | TypeSOL | Anchor | Native Rust | Pinocchio |
@@ -127,30 +127,30 @@ Compute units per transaction, mainnet original against the port, from one run o
127
127
 
128
128
  | Instruction | Jito (mainnet) | TypeSOL | |
129
129
  | --- | ---: | ---: | ---: |
130
- | tip payment `initialize` | 60,085 | 23,628 | −61% |
130
+ | tip payment `initialize` | 60,085 | 23,632 | −61% |
131
131
  | `change_tip_receiver`, the receiver also the builder (both shares to one account) | 29,889 | 7,723 | −74% |
132
132
  | `change_block_builder`, a 7% commission paid first | 29,911 | 7,736 | −74% |
133
- | `change_tip_receiver`, a share kept in tip account 0 | 41,355 | 9,192 | −78% |
134
- | tip distribution `initialize` | 7,284 | 1,946 | −73% |
133
+ | `change_tip_receiver`, a share kept in tip account 0 | 41,511 | 9,198 | −78% |
134
+ | tip distribution `initialize` | 7,284 | 1,958 | −73% |
135
135
  | `initialize_tip_distribution_account` | 10,007 | 2,624 | −74% |
136
136
  | `upload_merkle_root` | 3,943 | 977 | −75% |
137
- | `claim` | 13,067 | 3,940 | −70% |
138
- | `close_claim_status` | 4,302 | 1,036 | −76% |
139
- | `close_tip_distribution_account` | 5,735 | 1,561 | −73% |
140
- | `update_config` | 2,850 | 645 | −77% |
141
- | `migrate_tda_merkle_root_upload_authority` | 6,467 | 1,342 | −79% |
142
- | priority fee `claim` | 12,730 | 3,933 | −69% |
143
- | `transfer_priority_fee_tips`, live | 6,059 | 2,014 | −67% |
144
- | `transfer_priority_fee_tips`, not live (logs SOL) | 6,362 | 2,673 | −58% |
137
+ | `claim` | 14,566 | 4,262 | −71% |
138
+ | `close_claim_status` | 4,302 | 995 | −77% |
139
+ | `close_tip_distribution_account` | 5,735 | 1,486 | −74% |
140
+ | `update_config` | 2,850 | 646 | −77% |
141
+ | `migrate_tda_merkle_root_upload_authority` | 6,467 | 1,341 | −79% |
142
+ | priority fee `claim` | 17,231 | 4,921 | −71% |
143
+ | `transfer_priority_fee_tips`, live | 6,059 | 2,013 | −67% |
144
+ | `transfer_priority_fee_tips`, not live (logs SOL) | 6,362 | 2,543 | −60% |
145
145
 
146
146
  `claim` and the account openings vary from run to run with the PDA bump searches of the random keys the test uses,
147
147
  in both programs alike.
148
148
 
149
149
  | Binary | Jito (mainnet, ELF without the padding) | TypeSOL |
150
150
  | --- | ---: | ---: |
151
- | Tip payment | 297,848 bytes | 47,128 bytes |
152
- | Tip distribution | 342,432 bytes | 46,848 bytes |
153
- | Priority fee distribution | 387,440 bytes | 61,432 bytes |
151
+ | Tip payment | 297,848 bytes | 47,208 bytes |
152
+ | Tip distribution | 342,432 bytes | 46,288 bytes |
153
+ | Priority fee distribution | 387,440 bytes | 59,384 bytes |
154
154
 
155
155
  ## Where they differ
156
156
 
@@ -661,138 +661,138 @@ Compute units per transaction, mainnet original against the port, from one run o
661
661
 
662
662
  | Instruction | Marginfi (mainnet) | TypeSOL | |
663
663
  | --- | ---: | ---: | ---: |
664
- | `init_global_fee_state` | 7,116 | 2,310 | −68% |
665
- | `marginfi_group_initialize` | 27,404 | 7,162 | −74% |
666
- | `marginfi_group_configure`, five roles | 22,917 | 1,232 | −95% |
667
- | `propagate_fee_state` | 3,821 | 776 | −80% |
668
- | `lending_pool_add_bank` (SPL Token) | 97,333 | 20,072 | −79% |
669
- | `lending_pool_add_bank_with_seed` (Token-2022) | 100,585 | 29,973 | −70% |
670
- | `lending_pool_accrue_bank_interest`, an empty bank | 4,002 | 1,689 | −58% |
671
- | `lending_pool_accrue_bank_interest`, 25% utilization over a minute | 40,135 | 18,696 | −53% |
672
- | `lending_pool_accrue_bank_interest`, 80% utilization over a year | 41,642 | 22,733 | −45% |
673
- | `lending_pool_accrue_bank_interest`, 98,765,432,101 / 123,456,789,012 | 42,657 | 22,853 | −46% |
674
- | `lending_pool_configure_bank`, a new curve | 13,716 | 3,389 | −75% |
675
- | `lending_pool_configure_bank`, circuit breaker on | 12,743 | 3,391 | −73% |
676
- | `lending_pool_configure_bank`, circuit breaker off during a halt (accrues first) | 33,226 | 15,453 | −53% |
677
- | `lending_pool_configure_bank`, checked against an e-mode entry | 17,282 | 5,463 | −68% |
678
- | `lending_pool_configure_bank_interest_only`, every field | 25,668 | 847 | −97% |
664
+ | `init_global_fee_state` | 7,116 | 2,325 | −67% |
665
+ | `marginfi_group_initialize` | 27,404 | 5,803 | −79% |
666
+ | `marginfi_group_configure`, five roles | 22,917 | 1,249 | −95% |
667
+ | `propagate_fee_state` | 3,821 | 779 | −80% |
668
+ | `lending_pool_add_bank` (SPL Token) | 86,833 | 17,585 | −80% |
669
+ | `lending_pool_add_bank_with_seed` (Token-2022) | 96,085 | 28,841 | −70% |
670
+ | `lending_pool_accrue_bank_interest`, an empty bank | 4,002 | 1,873 | −53% |
671
+ | `lending_pool_accrue_bank_interest`, 25% utilization over a minute | 40,135 | 15,970 | −60% |
672
+ | `lending_pool_accrue_bank_interest`, 80% utilization over a year | 41,642 | 19,738 | −53% |
673
+ | `lending_pool_accrue_bank_interest`, 98,765,432,101 / 123,456,789,012 | 42,657 | 20,020 | −53% |
674
+ | `lending_pool_configure_bank`, a new curve | 13,716 | 2,782 | −80% |
675
+ | `lending_pool_configure_bank`, circuit breaker on | 12,743 | 2,914 | −77% |
676
+ | `lending_pool_configure_bank`, circuit breaker off during a halt (accrues first) | 33,226 | 12,402 | −63% |
677
+ | `lending_pool_configure_bank`, checked against an e-mode entry | 17,282 | 3,637 | −79% |
678
+ | `lending_pool_configure_bank_interest_only`, every field | 25,668 | 780 | −97% |
679
679
  | `lending_pool_configure_bank_limits_only` | 9,043 | 461 | −95% |
680
680
  | `lending_pool_update_fees_destination_account` | 8,926 | 479 | −95% |
681
- | `marginfi_account_initialize` | 6,550 | 2,603 | −60% |
682
- | `marginfi_account_initialize_pda` | 8,670 | 3,176 | −63% |
683
- | `lending_account_deposit`, a new balance | 15,739 | 7,026 | −55% |
684
- | `lending_account_deposit`, interest accrued first | 51,033 | 25,544 | −50% |
681
+ | `marginfi_account_initialize` | 6,550 | 2,610 | −60% |
682
+ | `marginfi_account_initialize_pda` | 10,170 | 3,547 | −65% |
683
+ | `lending_account_deposit`, a new balance | 15,739 | 6,873 | −56% |
684
+ | `lending_account_deposit`, interest accrued first | 51,033 | 21,932 | −57% |
685
685
  | `lending_account_deposit`, Token-2022 with a transfer fee | 18,990 | 9,525 | −50% |
686
- | `lending_account_deposit`, up to the deposit limit | 15,170 | 7,523 | −50% |
687
- | `lending_account_close_balance`, dust to the insurance fund | 20,236 | 9,349 | −54% |
686
+ | `lending_account_deposit`, up to the deposit limit | 15,170 | 7,538 | −50% |
687
+ | `lending_account_close_balance`, dust to the insurance fund | 20,288 | 7,854 | −61% |
688
688
  | `lending_account_close_balance`, an empty balance | 6,677 | 3,055 | −54% |
689
- | `marginfi_account_close` | 7,734 | 3,383 | −56% |
690
- | `lending_account_repay`, part | 50,404 | 26,697 | −47% |
691
- | `lending_account_repay`, all (rounded up, the balance closed) | 10,997 | 5,142 | −53% |
692
- | `lending_account_repay`, part, with a premium settled first | 52,678 | 31,831 | −40% |
693
- | `lending_account_repay`, tokenless, by the risk admin | 25,228 | 12,684 | −50% |
694
- | `lending_account_repay`, Token-2022 with a transfer fee | 32,985 | 15,516 | −53% |
695
- | `lending_pool_collect_bank_fees` | 29,598 | 13,619 | −54% |
696
- | `lending_pool_withdraw_fees` | 13,558 | 2,493 | −82% |
697
- | `lending_pool_withdraw_insurance` | 13,536 | 2,527 | −81% |
698
- | `lending_pool_withdraw_fees_permissionless` | 10,773 | 2,412 | −78% |
699
- | `lending_pool_configure_bank_oracle`, Pyth | 7,337 | 1,215 | −83% |
700
- | `lending_pool_configure_bank_oracle`, Switchboard | 7,258 | 1,215 | −83% |
701
- | `lending_pool_set_oracle_price` | 4,644 | 1,133 | −76% |
702
- | `lending_pool_pulse_bank_price_cache`, Pyth | 14,147 | 5,152 | −64% |
703
- | `lending_pool_pulse_bank_price_cache`, Switchboard | 7,755 | 2,934 | −62% |
704
- | `lending_pool_pulse_bank_price_cache`, fixed | 3,815 | 997 | −74% |
705
- | `lending_pool_pulse_bank_price_cache`, an hour of interest first | 41,299 | 19,318 | −53% |
706
- | `lending_pool_pulse_bank_price_cache`, the breaker's reference moved | 27,267 | 10,648 | −61% |
707
- | `lending_pool_pulse_bank_price_cache`, a tier-3 trip breaking the bank | 24,401 | 9,115 | −63% |
708
- | `lending_account_withdraw`, part, no debt | 52,841 | 28,814 | −45% |
709
- | `lending_account_withdraw`, healthy after, against a USDC debt | 46,485 | 26,504 | −43% |
710
- | `lending_account_withdraw`, a stale collateral oracle skipped | 43,441 | 25,122 | −42% |
711
- | `lending_account_withdraw`, all of it | 41,512 | 24,821 | −40% |
712
- | `lending_account_withdraw`, e-mode lifting the collateral | 46,182 | 26,463 | −43% |
713
- | `lending_account_withdraw`, premium rates from the collateral mix | 63,341 | 37,898 | −40% |
714
- | `lending_account_withdraw`, Token-2022 with a transfer fee | 53,306 | 27,801 | −48% |
715
- | `lending_account_withdraw`, in receivership, by a liquidator | 39,987 | 16,590 | −59% |
716
- | `lending_account_withdraw`, 16 positions, the tag cleared | 538,319 | 296,477 | −45% |
717
- | `lending_account_borrow` | 71,645 | 37,550 | −48% |
718
- | `lending_account_borrow`, an isolated bank | 71,024 | 36,908 | −48% |
719
- | `lending_account_borrow`, with an origination fee | 75,830 | 42,111 | −44% |
720
- | `lending_account_borrow`, premium-active debt | 106,636 | 58,252 | −45% |
721
- | `lending_account_borrow`, Token-2022 with a transfer fee | 77,107 | 41,398 | −46% |
722
- | `lending_account_pulse_health`, an empty account | 7,560 | 6,302 | −17% |
723
- | `lending_account_pulse_health`, healthy | 81,619 | 46,772 | −43% |
724
- | `lending_account_pulse_health`, liquidatable | 74,068 | 46,374 | −37% |
725
- | `lending_account_pulse_health`, bankrupt | 65,817 | 39,377 | −40% |
726
- | `lending_account_pulse_health`, a stale collateral oracle | 36,258 | 23,831 | −34% |
727
- | `marginfi_account_tag_liq_record`, liquidatable | 25,168 | 13,904 | −45% |
728
- | `marginfi_account_init_liq_record` | 10,318 | 2,855 | −72% |
729
- | `marginfi_account_close_liq_record` | 2,444 | 636 | −74% |
730
- | `lending_pool_handle_bankruptcy`, insurance covering part | 91,747 | 48,664 | −47% |
731
- | `lending_pool_handle_bankruptcy`, permissionless, covered | 69,730 | 33,101 | −53% |
732
- | `lending_pool_handle_bankruptcy`, past the deposits | 35,143 | 19,708 | −44% |
733
- | `lending_pool_handle_bankruptcy`, Token-2022 with a transfer fee | 97,583 | 50,868 | −48% |
734
- | `lending_account_liquidate`, part of a collateral | 194,785 | 122,645 | −37% |
735
- | `lending_account_liquidate`, a liquidator owing a premium | 222,725 | 138,807 | −38% |
736
- | `lending_account_liquidate`, a fixed-price debt | 225,420 | 139,274 | −38% |
737
- | `lending_account_liquidate`, Token-2022 | 199,451 | 125,412 | −37% |
738
- | a receivership: start, withdraw 1 SOL, repay 140 USDC, end | 149,945 | 95,527 | −36% |
739
- | a receivership: start, end | 87,094 | 61,272 | −30% |
740
- | a receivership: a close-out under $5 | 130,094 | 78,290 | −40% |
741
- | a deleverage: start, withdraw 1 SOL, repay 150 USDC, end | 160,288 | 94,646 | −41% |
742
- | a flash loan: start, borrow past the limit, repay it all, end | 75,214 | 35,898 | −52% |
743
- | a flash loan: start, end | 18,114 | 10,818 | −40% |
744
- | `marginfi_account_set_freeze` | 5,368 | 1,237 | −77% |
745
- | `transfer_to_new_account`, with balances | 12,906 | 7,259 | −44% |
746
- | `transfer_to_new_account_pda` | 15,008 | 7,831 | −48% |
747
- | `admin_close_account` | 5,755 | 3,591 | −38% |
689
+ | `marginfi_account_close` | 10,734 | 2,886 | −73% |
690
+ | `lending_account_repay`, part | 50,404 | 24,079 | −52% |
691
+ | `lending_account_repay`, all (rounded up, the balance closed) | 10,997 | 5,386 | −51% |
692
+ | `lending_account_repay`, part, with a premium settled first | 52,678 | 27,862 | −47% |
693
+ | `lending_account_repay`, tokenless, by the risk admin | 25,228 | 11,615 | −54% |
694
+ | `lending_account_repay`, Token-2022 with a transfer fee | 32,985 | 13,991 | −58% |
695
+ | `lending_pool_collect_bank_fees` | 26,598 | 9,730 | −63% |
696
+ | `lending_pool_withdraw_fees` | 13,527 | 2,547 | −81% |
697
+ | `lending_pool_withdraw_insurance` | 13,536 | 2,549 | −81% |
698
+ | `lending_pool_withdraw_fees_permissionless` | 10,773 | 2,435 | −77% |
699
+ | `lending_pool_configure_bank_oracle`, Pyth | 7,337 | 1,263 | −83% |
700
+ | `lending_pool_configure_bank_oracle`, Switchboard | 7,258 | 1,269 | −83% |
701
+ | `lending_pool_set_oracle_price` | 4,644 | 1,192 | −74% |
702
+ | `lending_pool_pulse_bank_price_cache`, Pyth | 14,147 | 5,111 | −64% |
703
+ | `lending_pool_pulse_bank_price_cache`, Switchboard | 7,755 | 3,396 | −56% |
704
+ | `lending_pool_pulse_bank_price_cache`, fixed | 3,815 | 1,289 | −66% |
705
+ | `lending_pool_pulse_bank_price_cache`, an hour of interest first | 41,299 | 16,499 | −60% |
706
+ | `lending_pool_pulse_bank_price_cache`, the breaker's reference moved | 27,267 | 9,724 | −64% |
707
+ | `lending_pool_pulse_bank_price_cache`, a tier-3 trip breaking the bank | 24,401 | 8,651 | −65% |
708
+ | `lending_account_withdraw`, part, no debt | 52,841 | 26,210 | −50% |
709
+ | `lending_account_withdraw`, healthy after, against a USDC debt | 46,485 | 25,010 | −46% |
710
+ | `lending_account_withdraw`, a stale collateral oracle skipped | 43,441 | 23,516 | −46% |
711
+ | `lending_account_withdraw`, all of it | 41,512 | 23,654 | −43% |
712
+ | `lending_account_withdraw`, e-mode lifting the collateral | 46,182 | 25,056 | −46% |
713
+ | `lending_account_withdraw`, premium rates from the collateral mix | 63,341 | 35,902 | −43% |
714
+ | `lending_account_withdraw`, Token-2022 with a transfer fee | 53,306 | 25,418 | −52% |
715
+ | `lending_account_withdraw`, in receivership, by a liquidator | 39,987 | 15,516 | −61% |
716
+ | `lending_account_withdraw`, 16 positions, the tag cleared | 538,319 | 266,132 | −51% |
717
+ | `lending_account_borrow` | 71,645 | 34,921 | −51% |
718
+ | `lending_account_borrow`, an isolated bank | 71,024 | 34,700 | −51% |
719
+ | `lending_account_borrow`, with an origination fee | 75,830 | 39,211 | −48% |
720
+ | `lending_account_borrow`, premium-active debt | 106,636 | 52,610 | −51% |
721
+ | `lending_account_borrow`, Token-2022 with a transfer fee | 77,107 | 38,438 | −50% |
722
+ | `lending_account_pulse_health`, an empty account | 7,560 | 4,932 | −35% |
723
+ | `lending_account_pulse_health`, healthy | 81,619 | 44,189 | −46% |
724
+ | `lending_account_pulse_health`, liquidatable | 74,068 | 43,850 | −41% |
725
+ | `lending_account_pulse_health`, bankrupt | 65,817 | 35,340 | −46% |
726
+ | `lending_account_pulse_health`, a stale collateral oracle | 36,258 | 21,340 | −41% |
727
+ | `marginfi_account_tag_liq_record`, liquidatable | 25,168 | 13,359 | −47% |
728
+ | `marginfi_account_init_liq_record` | 10,318 | 2,864 | −72% |
729
+ | `marginfi_account_close_liq_record` | 2,444 | 391 | −84% |
730
+ | `lending_pool_handle_bankruptcy`, insurance covering part | 91,747 | 41,723 | −55% |
731
+ | `lending_pool_handle_bankruptcy`, permissionless, covered | 69,730 | 28,732 | −59% |
732
+ | `lending_pool_handle_bankruptcy`, past the deposits | 35,143 | 17,863 | −49% |
733
+ | `lending_pool_handle_bankruptcy`, Token-2022 with a transfer fee | 97,583 | 42,792 | −56% |
734
+ | `lending_account_liquidate`, part of a collateral | 194,785 | 106,086 | −46% |
735
+ | `lending_account_liquidate`, a liquidator owing a premium | 222,725 | 119,306 | −46% |
736
+ | `lending_account_liquidate`, a fixed-price debt | 225,420 | 118,315 | −48% |
737
+ | `lending_account_liquidate`, Token-2022 | 199,447 | 108,609 | −46% |
738
+ | a receivership: start, withdraw 1 SOL, repay 140 USDC, end | 149,945 | 88,560 | −41% |
739
+ | a receivership: start, end | 87,094 | 59,518 | −32% |
740
+ | a receivership: a close-out under $5 | 130,094 | 71,478 | −45% |
741
+ | a deleverage: start, withdraw 1 SOL, repay 150 USDC, end | 160,288 | 87,533 | −45% |
742
+ | a flash loan: start, borrow past the limit, repay it all, end | 75,214 | 33,819 | −55% |
743
+ | a flash loan: start, end | 18,114 | 10,305 | −43% |
744
+ | `marginfi_account_set_freeze` | 5,368 | 1,247 | −77% |
745
+ | `transfer_to_new_account`, with balances | 12,906 | 5,574 | −57% |
746
+ | `transfer_to_new_account_pda` | 15,008 | 6,146 | −59% |
747
+ | `admin_close_account` | 10,255 | 3,423 | −67% |
748
748
  | `panic_pause` | 7,188 | 863 | −88% |
749
- | `update_group_rate_limiter`, an outflow | 5,152 | 1,397 | −73% |
750
- | `lending_pool_configure_group_premium`, a new pair | 5,558 | 1,155 | −79% |
751
- | `lending_pool_configure_bank_emode`, three entries sorted | 79,762 | 10,384 | −87% |
752
- | `lending_pool_close_bank` | 4,530 | 2,498 | −45% |
753
- | `lending_pool_configure_bank_gov`, weights | 42,109 | 11,196 | −73% |
754
- | `lending_pool_collect_bank_premium_fees` | 18,080 | 7,158 | −60% |
755
- | `lending_pool_emissions_deposit` | 12,486 | 5,070 | −59% |
756
- | `lending_pool_init_same_asset_emode_registry` | 9,301 | 2,314 | −75% |
757
- | `lending_pool_set_bank_same_asset_emode_eligibility` | 7,346 | 1,677 | −77% |
758
- | `init_bank_metadata` | 8,789 | 2,541 | −71% |
759
- | `write_bank_metadata`, ticker and description | 5,354 | 1,988 | −63% |
760
- | `write_bank_metadata_pre_init` | 8,719 | 2,764 | −68% |
761
- | `marginfi_account_place_order`, stop loss | 16,332 | 6,273 | −62% |
762
- | `marginfi_account_close_order` | 4,142 | 1,355 | −67% |
763
- | `marginfi_account_set_keeper_close_flags`, one bank | 3,094 | 1,083 | −65% |
764
- | `marginfi_account_keeper_close_order` | 2,709 | 1,403 | −48% |
765
- | an order executed (start, withdraw, repay, end), stop loss | 158,349 | 70,948 | −55% |
766
- | `marginfi_account_place_rebalance_order` | 10,820 | 3,570 | −67% |
767
- | `marginfi_account_update_rebalance_order` | 3,980 | 1,610 | −60% |
768
- | `marginfi_account_top_up_rebalance_fee_pool` | 6,498 | 2,970 | −54% |
769
- | a rebalance (start, withdraw, deposit, end), a tip escrowed | 270,773 | 116,319 | −57% |
770
- | `marginfi_account_settle_rebalance_tip`, paid | 72,189 | 36,058 | −50% |
771
- | `lending_pool_resize_bank_account` | 4,711 | 2,807 | −40% |
772
- | `monitor_archive_upsert_batch`, two mints | 2,741 | 973 | −65% |
773
- | `init_staked_settings` | 17,865 | 2,786 | −84% |
774
- | `lending_pool_add_bank_permissionless` | 77,694 | 19,023 | −76% |
775
- | `lending_pool_configure_bank_oracle_scope` | 9,597 | 1,225 | −87% |
776
- | `lending_pool_add_bank_solend` | 82,881 | 19,012 | −77% |
777
- | `solend_init_obligation` | 88,717 | 66,142 | −25% |
778
- | `solend_deposit` | 100,480 | 73,502 | −27% |
779
- | `solend_withdraw` | 191,792 | 137,009 | −29% |
780
- | `lending_pool_add_bank_kamino` | 77,023 | 17,759 | −77% |
781
- | `kamino_init_obligation` (with a farm) | 206,172 | 169,852 | −18% |
782
- | `kamino_deposit` | 133,066 | 106,321 | −20% |
783
- | `kamino_withdraw` | 181,565 | 125,229 | −31% |
784
- | `propagate_kamino_market_emergency` | 2,327 | 366 | −84% |
785
- | `kamino_harvest_reward` | 120,337 | 101,049 | −16% |
786
- | `lending_pool_add_bank_drift` | 76,034 | 17,489 | −77% |
787
- | `drift_init_user` | 106,471 | 83,160 | −22% |
788
- | `drift_deposit` | 76,268 | 57,301 | −25% |
789
- | `drift_withdraw` (with a debt) | 157,716 | 113,786 | −28% |
790
- | `drift_harvest_reward` | 78,993 | 58,487 | −26% |
791
- | `drift_claim_bad_debt` | 89,488 | 66,105 | −26% |
792
- | `lending_pool_add_bank_juplend` | 81,844 | 20,279 | −75% |
793
- | `juplend_init_position` | 71,441 | 49,524 | −31% |
794
- | `juplend_deposit` | 90,443 | 62,075 | −31% |
795
- | `juplend_withdraw` (with a debt) | 141,752 | 91,212 | −36% |
749
+ | `update_group_rate_limiter`, an outflow | 5,152 | 1,123 | −78% |
750
+ | `lending_pool_configure_group_premium`, a new pair | 5,558 | 1,161 | −79% |
751
+ | `lending_pool_configure_bank_emode`, three entries sorted | 79,762 | 5,652 | −93% |
752
+ | `lending_pool_close_bank` | 4,530 | 556 | −88% |
753
+ | `lending_pool_configure_bank_gov`, weights | 42,109 | 5,936 | −86% |
754
+ | `lending_pool_collect_bank_premium_fees` | 18,080 | 5,767 | −68% |
755
+ | `lending_pool_emissions_deposit` | 12,486 | 5,198 | −58% |
756
+ | `lending_pool_init_same_asset_emode_registry` | 9,301 | 2,327 | −75% |
757
+ | `lending_pool_set_bank_same_asset_emode_eligibility` | 7,346 | 1,710 | −77% |
758
+ | `init_bank_metadata` | 7,289 | 2,222 | −70% |
759
+ | `write_bank_metadata`, ticker and description | 5,354 | 1,992 | −63% |
760
+ | `write_bank_metadata_pre_init` | 7,219 | 2,433 | −66% |
761
+ | `marginfi_account_place_order`, stop loss | 23,804 | 8,008 | −66% |
762
+ | `marginfi_account_close_order` | 4,142 | 1,258 | −70% |
763
+ | `marginfi_account_set_keeper_close_flags`, one bank | 3,094 | 1,096 | −65% |
764
+ | `marginfi_account_keeper_close_order` | 2,709 | 1,292 | −52% |
765
+ | an order executed (start, withdraw, repay, end), stop loss | 159,822 | 67,554 | −58% |
766
+ | `marginfi_account_place_rebalance_order` | 10,820 | 3,578 | −67% |
767
+ | `marginfi_account_update_rebalance_order` | 3,980 | 1,629 | −59% |
768
+ | `marginfi_account_top_up_rebalance_fee_pool` | 6,498 | 2,982 | −54% |
769
+ | a rebalance (start, withdraw, deposit, end), a tip escrowed | 270,544 | 114,547 | −58% |
770
+ | `marginfi_account_settle_rebalance_tip`, paid | 70,831 | 32,478 | −54% |
771
+ | `lending_pool_resize_bank_account` | 4,711 | 2,380 | −49% |
772
+ | `monitor_archive_upsert_batch`, two mints | 2,741 | 975 | −64% |
773
+ | `init_staked_settings` | 16,150 | 2,472 | −85% |
774
+ | `lending_pool_add_bank_permissionless` | 86,716 | 20,968 | −76% |
775
+ | `lending_pool_configure_bank_oracle_scope` | 9,597 | 1,235 | −87% |
776
+ | `lending_pool_add_bank_solend` | 103,973 | 23,492 | −77% |
777
+ | `solend_init_obligation` | 93,202 | 67,155 | −28% |
778
+ | `solend_deposit` | 100,511 | 72,777 | −28% |
779
+ | `solend_withdraw` | 191,823 | 129,900 | −32% |
780
+ | `lending_pool_add_bank_kamino` | 80,023 | 18,414 | −77% |
781
+ | `kamino_init_obligation` (with a farm) | 207,503 | 171,217 | −17% |
782
+ | `kamino_deposit` | 132,922 | 104,858 | −21% |
783
+ | `kamino_withdraw` | 181,565 | 118,064 | −35% |
784
+ | `propagate_kamino_market_emergency` | 2,327 | 370 | −84% |
785
+ | `kamino_harvest_reward` | 112,590 | 94,458 | −16% |
786
+ | `lending_pool_add_bank_drift` | 83,534 | 19,110 | −77% |
787
+ | `drift_init_user` | 106,472 | 81,991 | −23% |
788
+ | `drift_deposit` | 82,049 | 63,163 | −23% |
789
+ | `drift_withdraw` (with a debt) | 157,716 | 107,299 | −32% |
790
+ | `drift_harvest_reward` | 79,359 | 58,866 | −26% |
791
+ | `drift_claim_bad_debt` | 93,988 | 67,958 | −28% |
792
+ | `lending_pool_add_bank_juplend` | 96,844 | 23,566 | −76% |
793
+ | `juplend_init_position` | 71,441 | 49,533 | −31% |
794
+ | `juplend_deposit` | 91,589 | 62,538 | −32% |
795
+ | `juplend_withdraw` (with a debt) | 141,783 | 84,286 | −41% |
796
796
 
797
797
  Across the 125 transactions of the first file that succeed, the port uses 40–97% fewer compute units; across the 118
798
798
  refused ones, 56–93% fewer. Repayments with a premium and accrual, nearly all I80F48 arithmetic, save least (from
@@ -5,7 +5,8 @@ This page ports a program that holds real authority on mainnet:
5
5
  deployed at `msigUdDBsR4zSUYqYEDrc1LcgtmuSDDM7KxpRUXNC6U`. The port is
6
6
  [`showcase/mainnet/multisig/multisig.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/mainnet/multisig/multisig.ts). Instead of a twin built for the occasion, it is checked against the
7
7
  binary that runs on mainnet: [`showcase/test/multisig.test.ts`](https://github.com/typesol-lang/typesol/blob/main/showcase/test/multisig.test.ts) runs both under the
8
- same program id and compares every outcome and every account byte. See
8
+ same program id and compares every outcome, every byte of every account a transaction names, the inner instructions,
9
+ the return data and the log lines (apart from Anchor's instruction-name line and its error-message text). See
9
10
  [case-study-escrow.md](case-study-escrow.md) for a token program and [Migrate from Anchor](migrate-from-anchor.md) for
10
11
  the general reference.
11
12
 
@@ -100,8 +101,19 @@ existing clients and existing accounts work with the port unchanged.
100
101
 
101
102
  `test/programs/coral_multisig.so` is the program dumped from mainnet on 2026-10-29 (sha256 in
102
103
  [`test/programs/SOURCES.md`](https://github.com/typesol-lang/typesol/blob/main/test/programs/SOURCES.md)). The test loads it into one LiteSVM and the port into
103
- another, both at `msigUdDB…`, then sends each transaction to both. After each one it requires the same outcome (success,
104
- or the same error down to the code) and the same lamports, owner and data bytes for every account involved.
104
+ another, both at `msigUdDB…`, then sends each transaction to both. After each one it requires:
105
+
106
+ - the same outcome (success, or the same error down to the code);
107
+ - the same lamports, owner and data bytes for the fee payer and every account an instruction names (the program
108
+ itself left out: the two are different binaries);
109
+ - the same inner instructions (the CPI `execute_transaction` makes: program, accounts, data and stack height);
110
+ - the same return data;
111
+ - the same log lines, apart from the runtime's compute-unit lines, Anchor's `Instruction: <Name>` line (the port does
112
+ not write it) and, on a failure, the error message the program logs itself (Anchor's text against TypeSOL's, such as
113
+ `AnchorError caused by account: multisig. Error Code: ConstraintRaw. …` against `Error 2003 ConstraintRaw: …`; the
114
+ code is compared through the outcome and the runtime's `failed: custom program error` line).
115
+
116
+ No compared transaction differs in anything else.
105
117
 
106
118
  There are 55 transactions (8 in the upstream flow, 11 in the `create_multisig` refusals, 14 in the other refusals,
107
119
  12 in the owner-set changes, 7 in the payouts, 3 with the 40-owner account):
@@ -148,7 +160,7 @@ instruction it runs.
148
160
  | `execute_transaction` → System transfer | 9,961 | 3,358 | −66% |
149
161
 
150
162
  Refusals cost less too. For example, an already-initialized account costs 3,378 against 160, and a missing signature
151
- 4,229 against 177. The binary is 526,688 bytes on mainnet and 29,984 bytes for the port, 18 times smaller. Deploying it
163
+ 4,229 against 177. The binary is 526,688 bytes on mainnet and 30,056 bytes for the port, 18 times smaller. Deploying it
152
164
  needs about 3.5 SOL less rent.
153
165
 
154
166
  The original was built with Anchor 0.25; a rebuild with a current Anchor would cost less than the mainnet figures. The
@@ -107,9 +107,15 @@ and the port into another. Both use the same program id and the same clock, and
107
107
  from earlier swaps, a reward stream, a dynamic fee, limit orders on a tick, the pool status bits.
108
108
 
109
109
  **Comparison.** For each transaction, the test requires the same outcome (success, or the same error down to the
110
- code), the same lamports, owner and data for every account involved, and the same events byte for byte.
110
+ code); the same lamports, owner and data for the fee payer and every account an instruction names (programs left out:
111
+ they are different binaries); the same inner instructions (each CPI's program, accounts, data and stack height) apart
112
+ from the one pinned below; the same return data; and the same log lines, the events (`Program data:`) byte for byte,
113
+ apart from the runtime's compute-unit lines, Anchor's `Instruction: <Name>` line (the port does not write it) and, on a
114
+ failure, the error message the program logs itself (Anchor's text against TypeSOL's; the code is compared). Where the
115
+ original panics, the test requires that it fails with `ProgramFailedToComplete` and the port with a numbered error,
116
+ and compares the accounts it names (see *Where they differ*).
111
117
 
112
- There are 302 transactions:
118
+ There are 308 transactions:
113
119
 
114
120
  - **Configs and pools.**
115
121
  - `create_pool` with SPL Token and Token-2022 transfer-fee mints, the mainnet config and a pre-funded vault.
@@ -165,27 +171,27 @@ Compute units per transaction, mainnet original against the port, from one run o
165
171
 
166
172
  | Instruction | Raydium (mainnet) | TypeSOL | |
167
173
  | --- | ---: | ---: | ---: |
168
- | `create_pool` | 57,318 | 24,806 | −57% |
169
- | `create_customizable_pool_v2` | 51,673 | 23,724 | −54% |
170
- | `open_position_with_token22_nft`, in range | 115,875 | 64,208 | −45% |
171
- | `open_position` (Metaplex NFT) | 113,951 | 76,312 | −33% |
172
- | `increase_liquidity_v2` | 39,759 | 15,935 | −60% |
173
- | `decrease_liquidity_v2` | 40,615 | 16,538 | −59% |
174
- | `decrease_liquidity_v2`, with a reward paid | 58,182 | 20,302 | −65% |
175
- | `close_position`, Metaplex NFT | 11,032 | 3,366 | −69% |
176
- | `close_position`, Token-2022 NFT (its mint closed too) | 22,395 | 10,376 | −54% |
177
- | `swap_v2` | 49,023 | 22,349 | −54% |
178
- | `swap_v2`, across tick arrays | 55,837 | 27,517 | −51% |
179
- | `swap_v2`, dynamic fee | 58,924 | 29,890 | −49% |
180
- | `swap_v2`, through limit orders | 74,417 | 35,675 | −52% |
181
- | `swap_v2`, the mainnet USDC/CC pool | 52,677 | 26,536 | −50% |
182
- | `swap` | 51,009 | 20,902 | −59% |
183
- | `swap_router_base_in`, two hops | 80,365 | 39,499 | −51% |
184
- | `swap_router_base_in`, four hops through two pools twice | 159,246 | 88,746 | −44% |
185
- | `open_limit_order` | 34,220 | 9,951 | −71% |
186
- | `settle_limit_order` | 15,682 | 6,066 | −61% |
187
- | `initialize_reward` | 24,605 | 9,640 | −61% |
188
- | `collect_protocol_fee` | 13,626 | 2,355 | −83% |
174
+ | `create_pool` | 54,318 | 23,601 | −57% |
175
+ | `create_customizable_pool_v2` | 51,673 | 23,153 | −55% |
176
+ | `open_position_with_token22_nft`, in range | 108,375 | 60,788 | −44% |
177
+ | `open_position` (Metaplex NFT) | 127,451 | 79,852 | −37% |
178
+ | `increase_liquidity_v2` | 39,759 | 14,417 | −64% |
179
+ | `decrease_liquidity_v2` | 40,615 | 15,253 | −62% |
180
+ | `decrease_liquidity_v2`, with a reward paid | 58,766 | 18,599 | −68% |
181
+ | `close_position`, Metaplex NFT | 11,032 | 3,237 | −71% |
182
+ | `close_position`, Token-2022 NFT (its mint closed too) | 17,895 | 9,279 | −48% |
183
+ | `swap_v2` | 49,023 | 19,380 | −60% |
184
+ | `swap_v2`, across tick arrays | 55,837 | 22,332 | −60% |
185
+ | `swap_v2`, dynamic fee | 58,955 | 24,577 | −58% |
186
+ | `swap_v2`, through limit orders | 74,448 | 31,195 | −58% |
187
+ | `swap_v2`, the mainnet USDC/CC pool | 52,677 | 20,778 | −61% |
188
+ | `swap` | 51,009 | 19,000 | −63% |
189
+ | `swap_router_base_in`, two hops | 80,365 | 33,838 | −58% |
190
+ | `swap_router_base_in`, four hops through two pools twice | 159,246 | 75,788 | −52% |
191
+ | `open_limit_order` | 32,304 | 9,435 | −71% |
192
+ | `settle_limit_order` | 15,682 | 4,813 | −69% |
193
+ | `initialize_reward` | 23,105 | 8,916 | −61% |
194
+ | `collect_protocol_fee` | 13,626 | 2,359 | −83% |
189
195
  | `update_amm_config` | 3,028 | 491 | −84% |
190
196
 
191
197
  Opening a position is mostly the token programs', the System Program's and (for a Metaplex NFT) Token Metadata's
@@ -193,14 +199,16 @@ work: the NFT mint, its metadata, the associated token account and the transfers
193
199
  Pool and position creation also vary from run to run with the PDA bump searches of the random keys the test uses, in
194
200
  both programs alike. Refusals cost far less; a swap of nothing costs 16,665 against 1,650.
195
201
 
196
- On size, the port's binary is 552,656 bytes and the deployed original 1,700,160 bytes, for the same 37 instructions.
202
+ On size, the port's binary is 546,080 bytes and the deployed original 1,700,160 bytes, for the same 37 instructions.
197
203
 
198
204
  ## Where they differ
199
205
 
200
206
  - **Panics.** Where the original panics (an index out of range, an overflow under `overflow-checks`), it fails with
201
207
  `ProgramFailedToComplete`; the port fails with a numbered error. Examples: a position past the pool's own bitmap
202
208
  opened without the extension account (the original reads `remaining_accounts[0]` of none), more than 10 operators
203
- (`copy_from_slice` of the wrong length). The test checks only that both fail there.
209
+ (`copy_from_slice` of the wrong length). There the test requires the original's `ProgramFailedToComplete` and a
210
+ numbered error from the port, and compares the accounts the case names; it does not compare the rest of the
211
+ accounts, the inner instructions or the logs.
204
212
  - **Check order on double faults.** Anchor creates `init` accounts (a position, an order) before it checks the other
205
213
  accounts' constraints. TypeSOL does the same with the creates a body starts with (since the Marginfi port, whose
206
214
  fuzzer found a case), so a transaction breaking both gets Anchor's code there. A body that checks something before
@@ -219,8 +227,16 @@ On size, the port's binary is 552,656 bytes and the deployed original 1,700,160
219
227
  seed. The port's lists the `token_program` account (fixed to that address) in `open_position`, and nothing in
220
228
  `open_position_v2`.
221
229
  - `CollectPersonalFeeEvent`, which no instruction emits, is not in the port's IDL.
222
- - **Logs.** The original's `msg!` lines in these paths are logged the same: `exact_swap_internal, …`, the dynamic fee's
223
- `state.tick:…`, `collect reward index: …`, `current block timestamp:…`, the close_position reasons. Error messages are
224
- TypeSOL's; codes and events are the original's.
230
+ - **Logs.** The deployed original writes none of the `msg!` lines its source puts behind the `enable-log` feature
231
+ (`exact_swap_internal, …`, `amount_0:…, transfer_fee_0:…`, the dynamic fee's `state.tick:…`, `current block
232
+ timestamp:…`): its binary has none of those strings, and the port does not write them either. The ungated ones
233
+ (`collect reward index: …`, the close_position reasons) are in both; no compared transaction reaches them. Anchor's
234
+ `Instruction: <Name>` line is not written by the port. Error messages are TypeSOL's; codes and events are the
235
+ original's.
236
+ - **The Associated Token program's Create.** Where a position NFT's token account is created (`open_position*`), the
237
+ original calls the Associated Token program with data `[0]` (Create's Borsh tag); the port, through TypeSOL's
238
+ `Ata<Init<…>>`, with empty data, that program's older form of the same instruction. The accounts and the result are
239
+ the same. The test maps exactly that case (a CPI with Create's six accounts and no data) and compares every other
240
+ inner instruction as it is.
225
241
  - **Clients and big-endian seeds.** The IDL records tick array seeds as Anchor does, without the byte order, so a client
226
242
  that derives them from the IDL alone gets them wrong (with either program). Pass tick arrays explicitly.
@@ -135,30 +135,30 @@ Compute units per transaction, mainnet original against the port, from that test
135
135
 
136
136
  | Instruction | Raydium (mainnet) | TypeSOL | |
137
137
  | --- | ---: | ---: | ---: |
138
- | `initialize` | 83,559 | 39,878 | −52% |
139
- | `initialize`, Token-2022 transfer fees | 93,047 | 53,834 | −42% |
140
- | `initialize_v2`, creator fee on | 86,286 | 41,760 | −52% |
141
- | `initialize_with_permission` | 98,221 | 43,358 | −56% |
142
- | `swap_base_input` | 24,162 | 5,734 | −76% |
143
- | `swap_base_output` | 24,591 | 5,989 | −76% |
138
+ | `initialize` | 85,059 | 39,091 | −54% |
139
+ | `initialize`, Token-2022 transfer fees | 100,547 | 55,660 | −45% |
140
+ | `initialize_v2`, creator fee on | 90,786 | 41,785 | −54% |
141
+ | `initialize_with_permission` | 93,721 | 41,622 | −56% |
142
+ | `swap_base_input` | 24,176 | 5,591 | −77% |
143
+ | `swap_base_output` | 24,605 | 5,846 | −76% |
144
144
  | `deposit` | 25,007 | 6,194 | −75% |
145
- | `withdraw` | 25,214 | 6,203 | −75% |
146
- | `collect_protocol_fee` | 20,205 | 4,189 | −79% |
147
- | `collect_creator_fee`, creating the creator's two token accounts | 61,644 | 34,014 | −45% |
148
- | `collect_creator_fee_permissionless` | 28,165 | 5,887 | −79% |
149
- | `create_permission_pda` | 10,525 | 2,291 | −78% |
150
- | `create_creator_fee_share` | 8,421 | 2,067 | −75% |
151
- | `create_support_mint_associated` | 7,837 | 2,012 | −74% |
152
- | `close_creator_fee_share` | 5,169 | 767 | −85% |
145
+ | `withdraw` | 25,214 | 6,228 | −75% |
146
+ | `collect_protocol_fee` | 20,205 | 4,200 | −79% |
147
+ | `collect_creator_fee`, creating the creator's two token accounts | 70,644 | 36,531 | −48% |
148
+ | `collect_creator_fee_permissionless` | 34,165 | 7,249 | −79% |
149
+ | `create_permission_pda` | 9,025 | 1,965 | −78% |
150
+ | `create_creator_fee_share` | 12,921 | 3,093 | −76% |
151
+ | `create_support_mint_associated` | 9,337 | 2,338 | −75% |
152
+ | `close_creator_fee_share` | 9,669 | 1,718 | −82% |
153
153
  | `collect_excess_lamports`, wrapped SOL | 10,798 | 3,764 | −65% |
154
- | `swap_base_input`, Token-2022 transfer fees | 31,339 | 12,082 | −61% |
155
- | `swap_base_output`, Token-2022 transfer fees | 32,508 | 14,097 | −57% |
156
- | `deposit`, Token-2022 transfer fees | 33,203 | 14,478 | −56% |
154
+ | `swap_base_input`, Token-2022 transfer fees | 31,354 | 11,668 | −63% |
155
+ | `swap_base_output`, Token-2022 transfer fees | 32,531 | 13,140 | −60% |
156
+ | `deposit`, Token-2022 transfer fees | 33,209 | 13,670 | −59% |
157
157
 
158
158
  The Token-2022 rows include the token program's own work, which is the same in both. Refusals cost far less. For
159
159
  example, a swap through the wrong config costs 17,193 against 1,656.
160
160
 
161
- On size, the port's binary is 214,944 bytes and the deployed original is 749,848 bytes, for the same 21 instructions.
161
+ On size, the port's binary is 216,960 bytes and the deployed original is 749,848 bytes, for the same 21 instructions.
162
162
 
163
163
  Pool creation is mostly the token programs' and the System Program's own work (account creation, initialization,
164
164
  transfers), which costs the same in both. The difference is the program's part. Its cost also varies from run to run