@typesol/cli 0.49.0 → 0.50.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.
- package/CHANGELOG.md +397 -0
- package/NOTICE +9 -0
- package/README.md +25 -8
- package/SECURITY.md +4 -3
- package/dist/compiler/analyze.d.ts +2 -0
- package/dist/compiler/analyze.js +7 -1
- package/dist/compiler/emit/base.d.ts +4 -3
- package/dist/compiler/emit/base.js +9 -3
- package/dist/compiler/emit/borsh.js +8 -8
- package/dist/compiler/emit/calls.d.ts +6 -0
- package/dist/compiler/emit/calls.js +71 -12
- package/dist/compiler/emit/cpi-core.js +3 -3
- package/dist/compiler/emit/cpi.js +2 -2
- package/dist/compiler/emit/expressions.d.ts +1 -0
- package/dist/compiler/emit/expressions.js +12 -0
- package/dist/compiler/emit/function.js +12 -8
- package/dist/compiler/emit/program.js +8 -2
- package/dist/compiler/emit/rbtree.js +1 -1
- package/dist/compiler/emit/shared.d.ts +12 -2
- package/dist/compiler/emit/shared.js +26 -6
- package/dist/compiler/emit/statements.d.ts +8 -1
- package/dist/compiler/emit/statements.js +53 -5
- package/dist/compiler/emit/storage.js +12 -10
- package/dist/compiler/emit/views.js +1 -1
- package/dist/compiler/index.d.ts +15 -1
- package/dist/compiler/index.js +50 -9
- package/dist/keys.d.ts +12 -1
- package/dist/keys.js +57 -7
- package/dist/workspace.d.ts +8 -0
- package/dist/workspace.js +90 -15
- package/docker/deps/0.50.0.lock.json +1206 -0
- package/docs/architecture.md +1 -1
- package/docs/audit.md +13 -12
- package/docs/case-study-jito-mev.md +14 -14
- package/docs/case-study-marginfi.md +127 -127
- package/docs/case-study-multisig.md +16 -4
- package/docs/case-study-raydium-clmm.md +44 -28
- package/docs/case-study-raydium-cp-swap.md +18 -18
- package/docs/cli.md +4 -3
- package/docs/language-accounts.md +16 -10
- package/docs/language-basics.md +4 -1
- package/docs/language-builtins.md +4 -2
- package/docs/language-cpi.md +34 -0
- package/docs/language-native.md +50 -4
- package/docs/language-statements.md +2 -1
- package/docs/language-types.md +13 -3
- package/docs/runtime.md +19 -2
- package/docs/security-model.md +4 -3
- package/docs/stability.md +5 -4
- package/docs/testing.md +6 -2
- package/lib/typesol.d.ts +25 -3
- package/llms-full.txt +136 -31
- package/package.json +1 -1
- package/releases/0.49.0.json +857 -0
- package/runtime/typesol_builtins.c +47 -2
- package/runtime/typesol_rt.h +129 -3
package/docs/architecture.md
CHANGED
|
@@ -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
|
|
112
|
+
- **What it would cost now:** rewriting most of the compiler's 21,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.
|
|
10
|
+
In order of priority. Line counts at 0.50.0 (November 2026).
|
|
11
11
|
|
|
12
12
|
| Priority | Component | Files | Lines | Why |
|
|
13
13
|
| --- | --- | --- | ---: | --- |
|
|
14
|
-
| 1 | C runtime | `runtime/typesol_rt.h` | 3,
|
|
15
|
-
| 1 | Compiler builtins | `runtime/typesol_builtins.c` |
|
|
16
|
-
| 1 | Instruction prologue and constraints | `src/compiler/emit/function.ts` |
|
|
17
|
-
| 1 | Account data, Vecs and assignment | `src/compiler/emit/alias.ts`, `storage.ts`, `statements.ts`, `base.ts` | 4,
|
|
18
|
-
| 1 | Calls and CPIs | `src/compiler/emit/calls.ts`, `cpi-core.ts`, `cpi.ts`, `create.ts`, `token.ts` | 5,
|
|
14
|
+
| 1 | C runtime | `runtime/typesol_rt.h` | 3,399 | 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` | 890 | 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,093 | 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,839 | 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,
|
|
22
|
-
| 2 | Front end | `src/compiler/analyze.ts`, `model.ts` | 3,
|
|
21
|
+
| 1 | Expressions | `src/compiler/emit/expressions.ts`, `shared.ts`, `borsh.ts` | 2,205 | Checked arithmetic and casts, Borsh encoding of arguments and `@layout borsh` accounts |
|
|
22
|
+
| 2 | Front end | `src/compiler/analyze.ts`, `model.ts` | 3,553 | 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
24
|
| 3 | Build and tooling | `src/compiler/toolchain.ts`, `src/cli.ts`, `src/workspace.ts`, `src/tools/` | | Build flags, deploy and verification commands |
|
|
25
25
|
|
|
26
|
-
The language surface is `lib/typesol.d.ts` (2,
|
|
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,12 @@ CHANGELOG.
|
|
|
66
66
|
|
|
67
67
|
### Not reviewed: 0.45.0 and later
|
|
68
68
|
|
|
69
|
-
0.45.0 to 0.
|
|
69
|
+
0.45.0 to 0.50.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),
|
|
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)
|
|
73
|
+
`NATIVE_ACCOUNT_WRITES` (0.49.0), and `copyData`, `getReturnData()`, `PANIC_STYLE = "pinocchio"` and whole values
|
|
74
|
+
copied and zeroed by the memory syscalls (0.50.0). An external review should include them
|
|
74
75
|
with the areas the reviews below left out.
|
|
75
76
|
|
|
76
77
|
### 0.44.0 (2026-11-11)
|
|
@@ -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,
|
|
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,
|
|
134
|
-
| tip distribution `initialize` | 7,284 | 1,
|
|
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` |
|
|
138
|
-
| `close_claim_status` | 4,302 |
|
|
139
|
-
| `close_tip_distribution_account` | 5,735 | 1,
|
|
140
|
-
| `update_config` | 2,850 |
|
|
141
|
-
| `migrate_tda_merkle_root_upload_authority` | 6,467 | 1,
|
|
142
|
-
| priority fee `claim` |
|
|
143
|
-
| `transfer_priority_fee_tips`, live | 6,059 | 2,
|
|
144
|
-
| `transfer_priority_fee_tips`, not live (logs SOL) | 6,362 | 2,
|
|
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,
|
|
152
|
-
| Tip distribution | 342,432 bytes | 46,
|
|
153
|
-
| Priority fee distribution | 387,440 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,
|
|
665
|
-
| `marginfi_group_initialize` | 27,404 |
|
|
666
|
-
| `marginfi_group_configure`, five roles | 22,917 | 1,
|
|
667
|
-
| `propagate_fee_state` | 3,821 |
|
|
668
|
-
| `lending_pool_add_bank` (SPL Token) |
|
|
669
|
-
| `lending_pool_add_bank_with_seed` (Token-2022) |
|
|
670
|
-
| `lending_pool_accrue_bank_interest`, an empty bank | 4,002 | 1,
|
|
671
|
-
| `lending_pool_accrue_bank_interest`, 25% utilization over a minute | 40,135 |
|
|
672
|
-
| `lending_pool_accrue_bank_interest`, 80% utilization over a year | 41,642 |
|
|
673
|
-
| `lending_pool_accrue_bank_interest`, 98,765,432,101 / 123,456,789,012 | 42,657 |
|
|
674
|
-
| `lending_pool_configure_bank`, a new curve | 13,716 |
|
|
675
|
-
| `lending_pool_configure_bank`, circuit breaker on | 12,743 |
|
|
676
|
-
| `lending_pool_configure_bank`, circuit breaker off during a halt (accrues first) | 33,226 |
|
|
677
|
-
| `lending_pool_configure_bank`, checked against an e-mode entry | 17,282 |
|
|
678
|
-
| `lending_pool_configure_bank_interest_only`, every field | 25,668 |
|
|
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,
|
|
682
|
-
| `marginfi_account_initialize_pda` |
|
|
683
|
-
| `lending_account_deposit`, a new balance | 15,739 |
|
|
684
|
-
| `lending_account_deposit`, interest accrued first | 51,033 |
|
|
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,
|
|
687
|
-
| `lending_account_close_balance`, dust to the insurance fund | 20,
|
|
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` |
|
|
690
|
-
| `lending_account_repay`, part | 50,404 |
|
|
691
|
-
| `lending_account_repay`, all (rounded up, the balance closed) | 10,997 | 5,
|
|
692
|
-
| `lending_account_repay`, part, with a premium settled first | 52,678 |
|
|
693
|
-
| `lending_account_repay`, tokenless, by the risk admin | 25,228 |
|
|
694
|
-
| `lending_account_repay`, Token-2022 with a transfer fee | 32,985 |
|
|
695
|
-
| `lending_pool_collect_bank_fees` |
|
|
696
|
-
| `lending_pool_withdraw_fees` | 13,
|
|
697
|
-
| `lending_pool_withdraw_insurance` | 13,536 | 2,
|
|
698
|
-
| `lending_pool_withdraw_fees_permissionless` | 10,773 | 2,
|
|
699
|
-
| `lending_pool_configure_bank_oracle`, Pyth | 7,337 | 1,
|
|
700
|
-
| `lending_pool_configure_bank_oracle`, Switchboard | 7,258 | 1,
|
|
701
|
-
| `lending_pool_set_oracle_price` | 4,644 | 1,
|
|
702
|
-
| `lending_pool_pulse_bank_price_cache`, Pyth | 14,147 | 5,
|
|
703
|
-
| `lending_pool_pulse_bank_price_cache`, Switchboard | 7,755 |
|
|
704
|
-
| `lending_pool_pulse_bank_price_cache`, fixed | 3,815 |
|
|
705
|
-
| `lending_pool_pulse_bank_price_cache`, an hour of interest first | 41,299 |
|
|
706
|
-
| `lending_pool_pulse_bank_price_cache`, the breaker's reference moved | 27,267 |
|
|
707
|
-
| `lending_pool_pulse_bank_price_cache`, a tier-3 trip breaking the bank | 24,401 |
|
|
708
|
-
| `lending_account_withdraw`, part, no debt | 52,841 |
|
|
709
|
-
| `lending_account_withdraw`, healthy after, against a USDC debt | 46,485 |
|
|
710
|
-
| `lending_account_withdraw`, a stale collateral oracle skipped | 43,441 |
|
|
711
|
-
| `lending_account_withdraw`, all of it | 41,512 |
|
|
712
|
-
| `lending_account_withdraw`, e-mode lifting the collateral | 46,182 |
|
|
713
|
-
| `lending_account_withdraw`, premium rates from the collateral mix | 63,341 |
|
|
714
|
-
| `lending_account_withdraw`, Token-2022 with a transfer fee | 53,306 |
|
|
715
|
-
| `lending_account_withdraw`, in receivership, by a liquidator | 39,987 |
|
|
716
|
-
| `lending_account_withdraw`, 16 positions, the tag cleared | 538,319 |
|
|
717
|
-
| `lending_account_borrow` | 71,645 |
|
|
718
|
-
| `lending_account_borrow`, an isolated bank | 71,024 |
|
|
719
|
-
| `lending_account_borrow`, with an origination fee | 75,830 |
|
|
720
|
-
| `lending_account_borrow`, premium-active debt | 106,636 |
|
|
721
|
-
| `lending_account_borrow`, Token-2022 with a transfer fee | 77,107 |
|
|
722
|
-
| `lending_account_pulse_health`, an empty account | 7,560 |
|
|
723
|
-
| `lending_account_pulse_health`, healthy | 81,619 |
|
|
724
|
-
| `lending_account_pulse_health`, liquidatable | 74,068 |
|
|
725
|
-
| `lending_account_pulse_health`, bankrupt | 65,817 |
|
|
726
|
-
| `lending_account_pulse_health`, a stale collateral oracle | 36,258 |
|
|
727
|
-
| `marginfi_account_tag_liq_record`, liquidatable | 25,168 | 13,
|
|
728
|
-
| `marginfi_account_init_liq_record` | 10,318 | 2,
|
|
729
|
-
| `marginfi_account_close_liq_record` | 2,444 |
|
|
730
|
-
| `lending_pool_handle_bankruptcy`, insurance covering part | 91,747 |
|
|
731
|
-
| `lending_pool_handle_bankruptcy`, permissionless, covered | 69,730 |
|
|
732
|
-
| `lending_pool_handle_bankruptcy`, past the deposits | 35,143 |
|
|
733
|
-
| `lending_pool_handle_bankruptcy`, Token-2022 with a transfer fee | 97,583 |
|
|
734
|
-
| `lending_account_liquidate`, part of a collateral | 194,785 |
|
|
735
|
-
| `lending_account_liquidate`, a liquidator owing a premium | 222,725 |
|
|
736
|
-
| `lending_account_liquidate`, a fixed-price debt | 225,420 |
|
|
737
|
-
| `lending_account_liquidate`, Token-2022 | 199,
|
|
738
|
-
| a receivership: start, withdraw 1 SOL, repay 140 USDC, end | 149,945 |
|
|
739
|
-
| a receivership: start, end | 87,094 |
|
|
740
|
-
| a receivership: a close-out under $5 | 130,094 |
|
|
741
|
-
| a deleverage: start, withdraw 1 SOL, repay 150 USDC, end | 160,288 |
|
|
742
|
-
| a flash loan: start, borrow past the limit, repay it all, end | 75,214 |
|
|
743
|
-
| a flash loan: start, end | 18,114 | 10,
|
|
744
|
-
| `marginfi_account_set_freeze` | 5,368 | 1,
|
|
745
|
-
| `transfer_to_new_account`, with balances | 12,906 |
|
|
746
|
-
| `transfer_to_new_account_pda` | 15,008 |
|
|
747
|
-
| `admin_close_account` |
|
|
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,
|
|
750
|
-
| `lending_pool_configure_group_premium`, a new pair | 5,558 | 1,
|
|
751
|
-
| `lending_pool_configure_bank_emode`, three entries sorted | 79,762 |
|
|
752
|
-
| `lending_pool_close_bank` | 4,530 |
|
|
753
|
-
| `lending_pool_configure_bank_gov`, weights | 42,109 |
|
|
754
|
-
| `lending_pool_collect_bank_premium_fees` | 18,080 |
|
|
755
|
-
| `lending_pool_emissions_deposit` | 12,486 | 5,
|
|
756
|
-
| `lending_pool_init_same_asset_emode_registry` | 9,301 | 2,
|
|
757
|
-
| `lending_pool_set_bank_same_asset_emode_eligibility` | 7,346 | 1,
|
|
758
|
-
| `init_bank_metadata` |
|
|
759
|
-
| `write_bank_metadata`, ticker and description | 5,354 | 1,
|
|
760
|
-
| `write_bank_metadata_pre_init` |
|
|
761
|
-
| `marginfi_account_place_order`, stop loss |
|
|
762
|
-
| `marginfi_account_close_order` | 4,142 | 1,
|
|
763
|
-
| `marginfi_account_set_keeper_close_flags`, one bank | 3,094 | 1,
|
|
764
|
-
| `marginfi_account_keeper_close_order` | 2,709 | 1,
|
|
765
|
-
| an order executed (start, withdraw, repay, end), stop loss |
|
|
766
|
-
| `marginfi_account_place_rebalance_order` | 10,820 | 3,
|
|
767
|
-
| `marginfi_account_update_rebalance_order` | 3,980 | 1,
|
|
768
|
-
| `marginfi_account_top_up_rebalance_fee_pool` | 6,498 | 2,
|
|
769
|
-
| a rebalance (start, withdraw, deposit, end), a tip escrowed | 270,
|
|
770
|
-
| `marginfi_account_settle_rebalance_tip`, paid |
|
|
771
|
-
| `lending_pool_resize_bank_account` | 4,711 | 2,
|
|
772
|
-
| `monitor_archive_upsert_batch`, two mints | 2,741 |
|
|
773
|
-
| `init_staked_settings` |
|
|
774
|
-
| `lending_pool_add_bank_permissionless` |
|
|
775
|
-
| `lending_pool_configure_bank_oracle_scope` | 9,597 | 1,
|
|
776
|
-
| `lending_pool_add_bank_solend` |
|
|
777
|
-
| `solend_init_obligation` |
|
|
778
|
-
| `solend_deposit` | 100,
|
|
779
|
-
| `solend_withdraw` | 191,
|
|
780
|
-
| `lending_pool_add_bank_kamino` |
|
|
781
|
-
| `kamino_init_obligation` (with a farm) |
|
|
782
|
-
| `kamino_deposit` |
|
|
783
|
-
| `kamino_withdraw` | 181,565 |
|
|
784
|
-
| `propagate_kamino_market_emergency` | 2,327 |
|
|
785
|
-
| `kamino_harvest_reward` |
|
|
786
|
-
| `lending_pool_add_bank_drift` |
|
|
787
|
-
| `drift_init_user` | 106,
|
|
788
|
-
| `drift_deposit` |
|
|
789
|
-
| `drift_withdraw` (with a debt) | 157,716 |
|
|
790
|
-
| `drift_harvest_reward` |
|
|
791
|
-
| `drift_claim_bad_debt` |
|
|
792
|
-
| `lending_pool_add_bank_juplend` |
|
|
793
|
-
| `juplend_init_position` | 71,441 | 49,
|
|
794
|
-
| `juplend_deposit` |
|
|
795
|
-
| `juplend_withdraw` (with a debt) | 141,
|
|
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
|
|
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
|
|
104
|
-
|
|
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
|
|
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)
|
|
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
|
|
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` |
|
|
169
|
-
| `create_customizable_pool_v2` | 51,673 | 23,
|
|
170
|
-
| `open_position_with_token22_nft`, in range |
|
|
171
|
-
| `open_position` (Metaplex NFT) |
|
|
172
|
-
| `increase_liquidity_v2` | 39,759 |
|
|
173
|
-
| `decrease_liquidity_v2` | 40,615 |
|
|
174
|
-
| `decrease_liquidity_v2`, with a reward paid | 58,
|
|
175
|
-
| `close_position`, Metaplex NFT | 11,032 | 3,
|
|
176
|
-
| `close_position`, Token-2022 NFT (its mint closed too) |
|
|
177
|
-
| `swap_v2` | 49,023 |
|
|
178
|
-
| `swap_v2`, across tick arrays | 55,837 |
|
|
179
|
-
| `swap_v2`, dynamic fee | 58,
|
|
180
|
-
| `swap_v2`, through limit orders | 74,
|
|
181
|
-
| `swap_v2`, the mainnet USDC/CC pool | 52,677 |
|
|
182
|
-
| `swap` | 51,009 |
|
|
183
|
-
| `swap_router_base_in`, two hops | 80,365 |
|
|
184
|
-
| `swap_router_base_in`, four hops through two pools twice | 159,246 |
|
|
185
|
-
| `open_limit_order` |
|
|
186
|
-
| `settle_limit_order` | 15,682 |
|
|
187
|
-
| `initialize_reward` |
|
|
188
|
-
| `collect_protocol_fee` | 13,626 | 2,
|
|
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
|
|
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).
|
|
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
|
|
223
|
-
`
|
|
224
|
-
|
|
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` |
|
|
139
|
-
| `initialize`, Token-2022 transfer fees |
|
|
140
|
-
| `initialize_v2`, creator fee on |
|
|
141
|
-
| `initialize_with_permission` |
|
|
142
|
-
| `swap_base_input` | 24,
|
|
143
|
-
| `swap_base_output` | 24,
|
|
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,
|
|
146
|
-
| `collect_protocol_fee` | 20,205 | 4,
|
|
147
|
-
| `collect_creator_fee`, creating the creator's two token accounts |
|
|
148
|
-
| `collect_creator_fee_permissionless` |
|
|
149
|
-
| `create_permission_pda` |
|
|
150
|
-
| `create_creator_fee_share` |
|
|
151
|
-
| `create_support_mint_associated` |
|
|
152
|
-
| `close_creator_fee_share` |
|
|
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,
|
|
155
|
-
| `swap_base_output`, Token-2022 transfer fees | 32,
|
|
156
|
-
| `deposit`, Token-2022 transfer fees | 33,
|
|
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
|
|
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
|