Skip to content
Smart contracts Audit finding Intermediate

Stargateethpoolstrategy rounding mismatch freezes vaultv2 allocations

The StargateEthPoolStrategy rounds down deposits to a multiple of 1e12 but returns the unrounded amount to VaultV2, so the vault records more assets than the strategy actually deployed. When the allocator later tries to withdraw the full recorded amount, the strategy cannot supply it and reverts, permanently freezing the allocated funds.

pxng0lin Follow

Originally disclosed on Immunefi

  • Disclosed after under an hour

57526 sc medium stargateethpoolstrategy rounding mismatch freezes vaultv2 allocations

#57526 [SC-Medium] `StargateEthPoolStrategy` rounding mismatch freezes `VaultV2` allocations

Submitted on Oct 26th 2025 at 23:57:13 UTC by @pxng0lin for Audit Comp | Alchemix V3

Description

Bug Description

StargateEthPoolStrategy._allocate floors deposits to 1e12 but returns the unfloored amount. VaultV2 return value records more assets than the adapter actually deploys. On withdrawal, StargateEthPoolStrategy._deallocate cannot supply the overstated amount and reverts with "Strategy balance is less than the amount needed", permanently freezing funds.

Brief/Intro

As shown in the sequence flow, the allocator sends amount WETH through VaultV2 into StargateEthPoolStrategy. The strategy unwraps, deposits only amountRounded, yet reports the full amount back to the vault. VaultV2 records that figure as live capital, so when the allocator later requests the same amount, _deallocate can only pull amountRounded from Stargate and reverts, locking the position.

Details

  1. Allocator calls VaultV2.allocate. The vault transfers amount WETH to the adapter and invokes IAdapter.allocate.
  2. StargateEthPoolStrategy._allocate unwraps WETH, computes amountRounded = (amount / 1e12) * 1e12, deposits only amountRounded, yet returns the original amount.
  3. VaultV2.allocate adds amount to caps[id].allocation, so vault accounting now exceeds real assets.
  4. Later the allocator calls VaultV2.deallocate(..., amount). StargateEthPoolStrategy._deallocate redeems LP for amountRounded, wraps back to WETH, then checks that its balance covers amount; the check fails and the function reverts.
  5. The vault never reduces the inflated allocation, the dust remains idle on the adapter, and no withdrawals can succeed.

Sequence Diagram

MERMAID
sequenceDiagram
    participant Allocator
    participant VaultV2
    participant StargateStrategy
    participant StargatePool

    Allocator->>VaultV2: allocate(strategy, prevAlloc, amount)
    VaultV2->>StargateStrategy: allocate(data, amount)
    StargateStrategy->>StargatePool: deposit amountRounded
    StargateStrategy-->>VaultV2: return change = amount
    VaultV2->>VaultV2: allocation += amount

    Allocator->>VaultV2: deallocate(strategy, prevAlloc+amount, amount)
    VaultV2->>StargateStrategy: deallocate(data, amount)
    StargateStrategy->>StargatePool: redeem amountRounded
    StargateStrategy-->>VaultV2: revert "Strategy balance is less than the amount needed"

Impact

  • Permanent freezing of user funds: recorded allocations can never be withdrawn once dust is present (critical impact).
  • Ongoing insolvency risk: repeated allocations widen the gap between vault accounting and strategy assets.

Risk Breakdown

  • Difficulty: Low. Standard allocator operations trigger the bug.
  • Prerequisites: Allocator privileges (normal vault role).
  • User action: None; even honest deposits are vulnerable.

Recommendation

Return amountRounded from StargateEthPoolStrategy._allocate.

References

  • StargateEthPoolStrategy._allocate @src/strategies/optimism/StargateEthPoolStrategy.sol#42-53
  • StargateEthPoolStrategy._deallocate @src/strategies/optimism/StargateEthPoolStrategy.sol#55-81
  • VaultV2.allocate and VaultV2.deallocate @lib/vault-v2/src/VaultV2.sol#564-608

Proof of Concept

Proof of Concept

  • Add the test code to the existing StargateEthPoolStrategy.t.sol test file.
  • run the test with forge t --mt testStrategyAllocateDeallocate_VaultV2_reverts_permanent_freeze -vvvv (higher verbosity to see the fails as expectRevert() has been used)
  • The test allocates through the vault, leaves dust on the adapter, and shows VaultV2.deallocate reverting with "Strategy balance is less than the amount needed".

Test Code

 function testStrategyAllocateDeallocate_VaultV2_reverts_permanent_freeze(uint256 fuzzAmount) public {
        // Allocate via the real vault/allocator path with an amount that is not divisible by 1e12.
        uint256 amountToAllocate = bound(fuzzAmount, 1e12 + 1, testConfig.vaultInitialDeposit);
        uint256 dust = amountToAllocate - (amountToAllocate / 1e12) * 1e12;
        vm.assume(dust > 0);

        uint256 amountToDeposit = amountToAllocate - dust;
        bytes32 adapterId = IMYTStrategy(strategy).adapterId();
        uint256 previousAllocation = IVaultV2(vault).allocation(adapterId);

        vm.startPrank(allocator);
        console.log("allocator allocate", amountToAllocate);
        IVaultV2(vault).allocate(strategy, abi.encode(previousAllocation), amountToAllocate);
        vm.stopPrank();

        uint256 vaultRecordedAllocation = IVaultV2(vault).allocation(adapterId);
        assertEq(vaultRecordedAllocation, previousAllocation + amountToAllocate, "vault believes full amount allocated");

        uint256 initialRealAssets = IMYTStrategy(strategy).realAssets();
        assertEq(initialRealAssets, amountToDeposit, "realAssets should exclude dust");
        assertEq(address(strategy).balance, dust, "dust should remain as plain ETH");
        console.log("real assets tracked", initialRealAssets);
        console.log("dust remaining", dust);

        vm.startPrank(allocator);
        console.log("allocator deallocate", amountToAllocate);
        vm.expectRevert(bytes("Strategy balance is less than the amount needed"));
        IVaultV2(vault).deallocate(strategy, abi.encode(vaultRecordedAllocation), amountToAllocate);
        vm.stopPrank();
    }

The original report as published on Immunefi, by pxng0lin. Images and videos are our own copies; raw HTML is shown as text. View it on Immunefi.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The strategy returns the original unrounded amount instead of the rounded amount it actually deposited, causing the vault's accounting to exceed real assets.

Impact

Allocated funds become permanently frozen because the vault's inflated allocation can never be withdrawn, and repeated allocations widen the gap between accounting and real assets.

What the attacker needed

Allocator privileges; deposit amount not divisible by 1e12

The fix

The strategy should return the rounded amount from its allocate function so that the vault records only the assets actually deployed.

How it was found

  1. Allocator calls VaultV2.allocate, which transfers WETH to the strategy and invokes the strategy's allocate function.
  2. The strategy unwraps WETH, rounds the amount down to a multiple of 1e12, deposits only the rounded amount, but returns the original unrounded amount.
  3. VaultV2 records the full unrounded amount as allocated, so its accounting exceeds the strategy's real assets.
  4. Later, the allocator calls VaultV2.deallocate for the recorded amount.
  5. The strategy redeems the rounded amount, wraps it back to WETH, and checks its balance against the requested amount; the check fails and the function reverts.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A vault sends money to a strategy that invests it. The strategy rounds the amount down before investing but tells the vault it invested the full amount. Later, when the vault asks for all that money back, the strategy does not have enough and the withdrawal fails forever.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by pxng0lin

View all

4 more disclosed reports, best first.

More from Alchemix V3

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.