Case study · Private disclosure · Credited

Migrating one second before midnight paid a full day of yield.

Ledgity Yield v2, the lyUSD and lyEUR real-world-asset yield vaults on six chains (about $2.1M TVL on DefiLlama, 16 Nov 2026). I reported this privately by email with a Foundry proof of concept. Ledgity changed its deployment and credited the report in the repository’s AUDIT.md.

Summary

The vaults grow their share price in whole-day steps. To stop someone from entering just before a step and leaving just after it, deposit() charges a maturity fee worth one day of yield. migrateLToken(), the path that turns legacy v1 LTokens into vault shares, did not charge it. A holder who migrated one second before a UTC day boundary and redeemed one second after it took a full day of yield for one second of exposure, paid for by every other holder.

Root cause

LedgityYieldVault._depositToVault() subtracts _computeMaturityImpact(assets), which is deploymentDelay days of compounding at yieldAPR, before it converts assets to shares. migrateLToken() converts the full amount:

/// @dev No maturity impact on migration since the capital stays deployed
shares = convertToShares(amount);

The comment is right about the capital: legacy LTokens are already deployed, so there is no deployment delay to pay for. But the fee had a second job. It is also the only thing that stops a boundary entry from catching the next day’s step. Skipping it for the first reason removed it for the second.

Proof of concept

A Foundry test of the real LedgityYieldVault implementation behind an ERC-1967 proxy, configured with the live Base lyEUR parameters read at a pinned block (yield APR 7.6969%), with a mock legacy token minted 1:1:

StepValue
Migrated at lastCompoundTime + 1 day − 1s100,000.000000 EURC
Redeemed at lastCompoundTime + 1 day + 1s100,021.087439 EURC
Captured+21.087439 EURC
Expected, 100,000 × 7.6969% ÷ 36521.087 EURC
Same sequence through deposit()0

The deposit() run is the control: same vault, same timing, and the maturity fee cancels the step exactly. The only difference between the two runs is the entry point.

Separately, an invariant fuzz campaign I wrote for this codebase (1,800 runs × 1,000 calls) broke a “no unearned yield” invariant on its own and shrank it to two calls: migrateLToken, then redeem.

Impact, and its honest bounds

  • Who paid. Existing vault holders. The captured yield has no revenue behind it; it dilutes everyone else’s share price by the same amount.
  • How much. One day of yield per migration: about 0.021% of the migrated amount at that APR, repeatable at each day boundary on the vaults that accept legacy tokens, which are on four of the protocol’s six chains.
  • What capped it. Only legacy tokens could take this path. While new LTokens could still be minted, capital was the only limit. Once they could not, the exposure is bounded by the legacy supply still held outside Ledgity.
  • The actual bounds, from Ledgity. At the time, the legacy supply held outside Ledgity was about $13.6k across all chains, which capped the capture near $3 a day. Ledgity reviewed every migration since the vaults launched, and none was near a day boundary.

This is not a drain. It is a fairness bug: a mechanism the vault’s designers had already guarded against on one path, open on another.

The fix

I proposed charging the same maturity fee in migrateLToken(). Ledgity chose an operational fix: it switched the legacy LTokens to withdrawal-only on every chain. No new legacy tokens can be minted, which, in Ledgity’s words, “removes the only way to scale it”. Migration stays open until the legacy tokens are retired.

I also reported that mint() mints slightly fewer shares than requested, which breaks the ERC-4626 rule that mint creates exactly the requested shares. Ledgity accepted that one as a known, documented deviation and did not change the code. It is listed under “Reviewed and accepted” in the same file, not credited, and I have no quarrel with that.

What it taught me

A fee can carry more than one purpose. The code’s own comment gave the reason this path did not need the fee and was right about it. The bug was in the purpose the comment did not mention. I now list every job a guard does before I accept a reason for skipping it.

Sources: the credit and the fix are quoted from Ledgity’s AUDIT.md at commit a48e6cb. Code references are to src/protocol-v2/LedgityYieldVault.sol at commit 0531f04, the version I reviewed. TVL from DefiLlama on 16 Nov 2026. Published with Ledgity’s written agreement.

Credit in Ledgity’s AUDIT.md ↗ Next case study: RAIN-USDR →