fix(config): drop 5 malformed addresses + add shape-guard test - #15
Merged
Conversation
Discovered 2026-05-07 during the multi-chain `status --verify` sweep
on HyperEVM: hybra.rewards_distributor was reported as `NO_CODE` even
though hybra is otherwise healthy. Inspecting the TOML revealed the
address was malformed — only 37 hex chars after `0x` (should be 40),
i.e. data-entry truncation that pre-dated the active config baseline.
A regex sweep across `ts/config/` then turned up four sibling cases
in `nest.toml` (each a per-pool `gauge` field at 39 hex chars). Nest
is currently `is_active = false` so those entries were filtered out
of `getProtocolsForChain()` before reaching `status --verify`, but
they were still ticking time bombs for the day someone re-activates.
Fix:
1. `protocols/dex/hybra.toml`: drop the orphan `rewards_distributor`
line (no adapter code referenced it; tried `rewards_distributor()`,
`rewardsDistributor()`, `distributor()`, `rewardDistributor()`
getters on the minter / voter / ve contracts — all reverted, so
re-discovering the correct address is non-trivial and out of
scope for this fix).
2. `protocols/dex/nest.toml`: drop the four malformed pool gauge
fields. The pool addresses themselves stayed valid — only the
gauge field was truncated. `PoolInfo.gauge` is optional, so the
pools remain valid TOML entries.
3. New test `src/qa/address-shape.test.ts` walks every TOML file in
`ts/config/` and rejects any `"0x..."` literal whose length is
not exactly 42 (0x + 40 hex). Also includes a self-test for the
regex so future refactors can't silently make the guard
permissive.
This is a config-only fix — no adapter behaviour changes. The
removed entries were never readable by code in the first place
(viem rejects sub-42-char addresses).
Verified:
- pnpm -C ts -r build — clean.
- pnpm -C ts -r lint — 3 packages, tsc --noEmit clean.
- pnpm -C ts -r test — defi-core 32/32, defi-protocols 43/43,
defi-cli 89/89 (+2 address-shape tests).
- The new shape-guard test passes; pre-fix it would have rejected
all 5 of the addresses removed in this commit.
Out of scope:
- Re-running `status --verify` against a live RPC after the fix.
The contract addresses left in hybra.toml are unchanged from the
prior verified-79 set; only the malformed line was removed.
Merged
4 tasks
Hiksang
added a commit
that referenced
this pull request
May 6, 2026
… in DEX adapter tests (#17) Four DEX adapter test files (uniswap_v3, algebra_v3, balancer_v3, thena_cl) constructed ProtocolEntry fixtures with `chain: "test"`, which doesn't exist in any registry. Each replacement uses a real chain that the adapter is in fact deployed on: uniswap_v3.test.ts → "hyperevm" (hyperswap-v3, project-x, ramses-cl) algebra_v3.test.ts → "hyperevm" (kittenswap) thena_cl.test.ts → "bnb" (thena-fusion-bnb) balancer_v3.test.ts → "hyperevm" (no registered protocol; chosen for consistency with the other V3-style adapters) The change is fixture-only — no registry lookups happen in these tests, so behaviour is identical. The benefit is forward-looking: any future test that crosschecks a fixture's chain against Registry.loadEmbedded() (e.g. address-shape PR #15's pattern) will find the chain and not silently skip the assertion. Verified: - pnpm -C ts -r build — clean. - pnpm -C ts -r lint — 3 packages, tsc --noEmit clean. - pnpm -C ts -r test — defi-core 32/32, defi-protocols 43/43 (unchanged), defi-cli 89/89 (unchanged).
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
defi --chain hyperevm status --verifyflaggedhybra.rewards_distributorasNO_CODEduring the 2026-05-07 multi-chain sweep. Inspecting the TOML revealed the address was malformed — 37 hex chars after0xinstead of 40 — clear data-entry truncation. A follow-up regex sweep acrossts/config/turned up 4 sibling cases innest.toml, each a per-poolgaugefield at 39 hex chars. nest isis_active = falseso the entries were silently filtered out before status verification, but they're still time bombs the next time anyone re-activates.Fix
ts/config/protocols/dex/hybra.tomlrewards_distributorline. No adapter code referenced it. Probedrewards_distributor(),rewardsDistributor(),distributor(),rewardDistributor()getters on minter / voter / ve contracts — all reverted, so re-discovering the correct address is non-trivial and out of scope here.ts/config/protocols/dex/nest.tomlgaugefields. The pool addresses themselves stayed valid;PoolInfo.gaugeis optional, so the pools remain valid TOML entries.ts/packages/defi-cli/src/qa/address-shape.test.ts(new)ts/config/and rejects any"0x..."literal whose length isn't exactly 42 (0x + 40 hex). Includes a self-test of the regex so future refactors can't silently make the guard permissive.This is a config-only fix — no adapter behaviour changes. The removed entries were never readable by code in the first place (viem rejects sub-42-char addresses).
Why a test, not a parser-level reject?
The runtime
Registry.loadProtocols()swallows malformed-TOML exceptions with a/* skip invalid protocol files */comment, so a per-addressthrowwould silently disable an entire protocol on a typo. A pre-merge unit test that lists offenders gives a much clearer signal (file:line + length diff) than a swallowed runtime crash.Test plan
pnpm -C ts -r build— clean.pnpm -C ts -r lint— 3 packages,tsc --noEmitclean.pnpm -C ts -r test— defi-core 32/32, defi-protocols 43/43, defi-cli 89/89 (+2 address-shape tests; existing 87 unchanged).nest.tomlis the right file to drop the gauge fields from, vs. trying to recover the correct addresses (nest is currently inactive so the gauge data is unreachable either way).Out of scope
status --verifyagainst a live RPC after the fix. The contract addresses left in hybra.toml are unchanged from the prior verified-79 set; only the malformed line was removed.rewards_distributoraddress. Tracked separately if/when the adapter starts using it.🤖 Generated with Claude Code