Skip to content

feat: Save CU by removing parsing/validation of the token program account args - #144

Draft
kaze-cow wants to merge 2 commits into
kaze/sc-153-token-2022-settlefrom
kaze/sc-153-token-2022-optimize
Draft

feat: Save CU by removing parsing/validation of the token program account args#144
kaze-cow wants to merge 2 commits into
kaze/sc-153-token-2022-settlefrom
kaze/sc-153-token-2022-optimize

Conversation

@kaze-cow

@kaze-cow kaze-cow commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

No description provided.

kaze-cow and others added 2 commits September 8, 2026 18:00
Every token-moving instruction still names its token program — a CPI can
only dispatch to a program its own instruction names — but nothing reads
those accounts any more. The program a transfer targets is the one owning
the account it moves, which the account itself says, so the slots are
skipped positionally and dropped from the parsed inputs.

`BeginSettle` pulls against the sell account's owner and `FinalizeSettle`
pushes against the destination's owner; `CreateBuffer` creates each buffer
under its mint's owner and `ReclaimBuffer` closes each one through the
program that owns it. That takes ~110-170 CU off every settlement, and
costs ~35 CU per buffer in the two batch instructions, which resolve once
per buffer rather than once per instruction.

`TokenProgramNotProvided` went with the slot validation: a settlement that
leaves out a program its accounts live under is now refused by the runtime
as a missing account. `PushDestinationInvalid` takes its code, both being
new on this stack.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@linear-code

linear-code Bot commented Sep 8, 2026

Copy link
Copy Markdown

SC-153

@kaze-cow kaze-cow changed the title Kaze/sc 153 token 2022 optimize feat: Save CU by removing parsing/validation of the token program account args Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant