Skip to content

fix: support reflection tokens in deal() via checked_write transforms#841

Open
ndavd wants to merge 5 commits intofoundry-rs:masterfrom
ndavd:feat/storage-transforms
Open

fix: support reflection tokens in deal() via checked_write transforms#841
ndavd wants to merge 5 commits intofoundry-rs:masterfrom
ndavd:feat/storage-transforms

Conversation

@ndavd
Copy link
Copy Markdown

@ndavd ndavd commented Mar 29, 2026

Problem

Reflection tokens (e.g. BabyDoge) store balances as _rOwned[account] = balance * rate, which causes deal() to hang because stdstore.find() searches for a slot where storedValue == balanceOf().

Solution

  • Adds a transform parameter to find/checked_write in stdStorage. Instead of checking callResult == storedValue, it checks transform(callResult) == storedValue. When no transform is passed, it defaults to the identity transform $f(x) = x$, keeping it backward compatible.
  • deal() now detects reflection tokens via reflectionFromToken(uint256,bool) (which returns the rate if called with 1,false).
  • If it's a reflection token, it passes a transform of give * rate so the correct slot is found and written correctly.

Solves #740

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