Conversation
…loses #418) Several Venus vTokens on BSC are deployed behind upgradeable proxies that return 96 bytes (3 32-byte words) where the ABI declares a single uint256 — the leading word carries the value, the trailing 64 bytes are zero padding (likely a Diamond fallback / proxy quirk). alloy's sol!-generated decoder is strict and rejects the surplus bytes with SolTypes(ReserveMismatch), which surfaced as `borrowBalanceStored failed err=AbiError(SolTypes(ReserMismatch))` on every (vToken × seed-borrower) pair. Result: tracked=N returned=0, the bot scanned every block but never emitted an opportunity, even when the seed borrowers were genuinely liquidatable on mainnet. Add `read_uint256_view` helper that issues the eth_call ourselves, takes the first 32 bytes, and decodes as U256 — matching cast's lenient policy. Use the helper for `borrowBalanceStored`, `balanceOf`, and `exchangeRateStored` in fetch_position. The oracle `getUnderlyingPrice` path stays on the typed call because no padding issue has been observed there. Local validation: replay against block 91323624 with the four documented seed borrowers now reports `tracked=4 returned=4 liquidatable=4` (was `returned=0` on main).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Several Venus vTokens on BSC are deployed behind upgradeable proxies that return 96 bytes (3 32-byte words) where the ABI declares a single `uint256` — leading word carries the value, trailing 64 bytes are zero padding (Diamond fallback / proxy quirk). `alloy`'s `sol!`-generated decoder rejects the surplus with `SolTypes(ReserveMismatch)`, surfaced as `borrowBalanceStored failed err=AbiError(SolTypes(ReserMismatch))` on every (vToken × seed-borrower) pair. Result on main: `tracked=N returned=0`, no opportunity ever emitted.
Fix
Add `read_uint256_view` helper that issues the `eth_call` ourselves, takes the first 32 bytes, decodes as `U256` — matching `cast call ... '(uint256)'`'s lenient policy. Use it for `borrowBalanceStored`, `balanceOf`, `exchangeRateStored` in `fetch_position`. Oracle `getUnderlyingPrice` stays on the typed call (no padding observed there).
Test plan