# Minimum-deposit fix — implemented

**Status: implemented in Gyro, 2026-09-12.**
Always display the real vault minimum beside the deposit input. Give a clear
below-minimum hint. No transaction hash is required to fix this known preview
gap. Do not prefill an amount or change the contract's minimum.

Report: “10 USDC kept reverting; 11 USDC worked.” Site, chain, asset, mode and
transaction hash were requested; the user does not have the team's transaction.
The exact failed transaction is not identified. Do not call fees the proven
cause without that evidence.

## Concrete source gap

Gyro `fetchDepositSinglePreview()` obtains the router split and aggregator output,
estimates shares with Lens.previewDeposit, then enables Deposit. It does not read
or check the vault's minDepositValue. The dual-deposit reader understands
DepositTooSmall, but that does not supply the missing single-token precheck.
Eiko's fork carries the same single-token flow.

WheelVault._depositCore checks:

`baseToQuote(baseAmt, getTwapPrice()) + quoteAmt >= minDepositValue`

For a router single-token deposit these are the resulting amounts AFTER the
conversion, not the gross input typed. Swap fees, rounding, market impact and
spot/TWAP differences can leave a nominal 10-USDC input below a 10-USDC value
floor. This is consistent with the report, not a decoded-revert confirmation.

## Implementation

1. Read the configured vault's real minimum, quote decimals and valuation price;
   invalidate on chain/asset/strike context changes, do not hardcode $10 or $11.
2. Show the minimum beside the input by default. Suggested short wording:
   “Minimum: 10 USDC value after swap” when that is the measured minimum.
3. Check the quoted resulting amounts with the same units/valuation before
   enabling Deposit. For execution, account for swap minimum output, not only
   optimistic quoted output; use the existing simulation/freshness boundary.
4. If too small, keep the button disabled and give a useful increase/requote
   action. Any suggested input amount must be quoted again; a fixed 10% buffer
   is not an exact minimum and is not proposed as a protocol change.
5. Do not silently prefill a spend amount. “Show min by default” is interpreted
   as a visible hint unless the user explicitly chooses prefilling.

Tests should cover just below/equal/above the floor, token decimals, swap output
rounding, TWAP/spot difference, stale quotes, failed minimum reads and switches.
The frontend now performs these checks in single and dual deposit previews.
Single execution forces a fresh read before approval. The floor is decoded from the actual
Kyber V2 calldata, not inferred from the optimistic route estimate; unknown
routers/selectors or partial-fill routes cannot enable a single deposit.
The conversion math exactly matches `ConversionLib.baseToQuote` and
`WheelVault._depositCore`, including integer floors and token decimals.

The minimum and TWAP are read at the same block from a provider checked against
the selected chain. A ten-second same-context cache keeps typing responsive;
selection changes cannot reuse another vault's value or late response.
The label says “after swap” in single-token mode. No automatic spend prefill,
fixed dollar buffer, or contract change was introduced.

Related input correction: single amounts now use the same exact decimal parser
as dual deposits. Above-balance inputs are rejected instead of silently capped;
MAX supplies the exact balance, including all token decimals.

## Evidence

Live read-only Ethereum WBTC 65k test: minimum `10000000` raw USDC (10 USDC),
read at block 25,959,422. A nominal 10-USDC single deposit was rejected by the
post-swap precheck; 11 USDC produced a valid quote with a decoded floor. No
transaction was sent. This reproduces the reported pattern, not the missing
original transaction.

Tests: `test-deposit-minimum`, `test-kyber-min-output`,
`test-deposit-minimum-panel`, and expanded single/dual deposit UI tests.
Coverage includes equality, just-below minimum, optimistic output vs guaranteed
floor, beneficial conversion, missing data, stale/ABA contexts, wrong networks,
precision, above-balance refusal, and minimum changes before approval.

Sources: [Kyber V2 verified source](https://hyperevmscan.io/address/0x6131B5fae19EA4f9D964eAc0408E4408b66337b5#code),
[Kyber API schema](https://raw.githubusercontent.com/KyberNetwork/kyberswap-documentation/main/.gitbook/assets/KyberSwapAggregator_EVMAPIs_v2.13.0.yaml).
The built output amount supplies the estimate; decoded `minReturnAmount`
supplies the floor. Existing withdrawal quote behavior remains supported.
