57346 sc low alchemistallocator compares incompatible units asset wei vs wad percentage
Submitted on Oct 25th 2025 at 12:02:53 UTC by @teoslaf1 for Audit Comp | Alchemix V3
Report ID: #57346
Report Type: Smart Contract
Report severity: Low
Target: https://github.com/alchemix-finance/v3-poc/blob/immunefi_audit/src/AlchemistAllocator.sol
Impacts:
Protocol insolvency
Contract fails to deliver promised returns, but doesn't lose value
logic flaw in fund-management layer
Description
Summary
The AlchemistAllocator contract contains a logic error where it directly compares absoluteCap (measured in asset wei) with relativeCap (measured in WAD percentage units). This is mathematically meaningless. While the result is currently unused, it indicates broken cap enforcement logic.
Vulnerability Details
// Line 35 - In allocate():
uint256 adjusted = absoluteCap > relativeCap ? absoluteCap : relativeCap;
// Line 57 - In deallocate():
uint256 adjusted = absoluteCap < relativeCap ? absoluteCap : relativeCap;Why This Is Wrong
The comparison mixes two incompatible units:
absoluteCap - Asset amount in wei:
relativeCap - Percentage in WAD format:
Understanding WAD Units
WAD Constant Definition
Source: lib/vault-v2/src/libraries/ConstantsLib.sol
How RelativeCap Should Be Used
From Morpho VaultV2 documentation (lib/vault-v2/src/VaultV2.sol lines 46-54):
Proper enforcement (from VaultV2 line 585):
This converts relativeCap to assets: (totalAssets * relativeCap) / WAD
Impact
The allocator’s cap enforcement logic is inactive and incorrect. Although the adjusted variable is never used, leaving the logic dormant, its presence in a core fund-allocation function still has meaningful impact. It shows an unfinished or misunderstood design in a component meant to enforce per-strategy caps, causing false assumptions for operators and off-chain automation that may rely on allocator-level checks.
Allocations currently proceed without any pre-validation, relying solely on the vault’s internal limits. This can lead to unexpected reverts, wasted gas, and confusion around how caps are enforced. Even if unused today, the code represents a broken and misleading safety layer that could reintroduce risk if activated in the future.
Example Calculation
Scenario:
Vault has 1000 ETH total
absoluteCap = 200 ETHrelativeCap = 0.2e18(20%)
Correct calculation:
Wrong calculation (current code):
Recommendations
Proof of Concept
Proof of Concept
Add this to AlchemistAllocator.t.sol
Was this helpful?