Mathematical foundations
Integer execution bounds and concentrated-liquidity observations. Every model has a stated domain.
Implemented arithmetic + labeled conceptual models
01Token units and precision
A human amount A maps to raw integer a for a token with d decimals. Conversion must be exact, positive and fit uint256. Excess decimals are rejected, not truncated. ETH/WETH have eighteen decimals; USDG has six.
BigInt division truncates toward zero. For positive numbers this is floor. Signed formulas explicitly name truncation. Display rounding never changes encoded amounts.
02Constant product: a limited comparison model
For a two-reserve constant-product AMM, effective input is input after trading fee. This gives the continuous expression below. It is an explanatory V2-style model, not the algorithm for live VEKTRA V3 quotes.
Assume positive reserves, 0 ≤ f < 1, unchanged reserves, no transfer taxes, hooks or external fees. Contracts add integer rounding. This is not a universal model for V3, V4 or aggregated routing.
03Concentrated liquidity within one interval
V3 sqrtPriceX96 encodes the square root of raw token1/token0 price. Decimal scaling converts to human units. In one active interval with constant positive liquidity L, virtual reserves satisfy the local relations below.
Token0 input decreases square-root price; token1 input increases it. These formulas require remaining inside one tick interval. Actual quotes come from QuoterV2 simulation including tick crossings, changing liquidity and rounding, not these browser-side simplified formulas.
04Fees, slippage and minimum output
Fee fraction is feeTier / 1,000,000. Slippage s is percent, converted to basis points b by rounding 100s. Market minimum uses integer floor; wrapping minimum equals input.
At s = 0.5%, b = 50; q = 1,000,000 yields m = 995,000. This allows worse execution up to the bound, not a promise of q. Require m > 0 and bind it into reviewed calldata.
05Implemented price-impact arithmetic
Q is sqrtPriceX96 and a raw input. Spot output uses pool token ordering and no fee deduction; quoter output includes fees and traversal. Displayed impact therefore includes fee effects.
Signed truncation mirrors BigInt arithmetic. Zero spot yields a 100% blocking sentinel, not a market measurement. Accepted impact is −1% through 5%, inclusive. No independent market price is provided.
06Gas and a conceptual net objective
Preparation inflates gas by 20%, then buffers fee by another 25%, flooring each stage. The approximately 1.5 multiplier is an estimate, not measured cost. An approval stage estimates approval only; swap gas is checked after approval.
Receipt cost would be gasUsed × effectiveGasPrice. A gas-adjusted output also needs reliable ETH/output conversion. This objective and an external price oracle are not implemented; routing maximizes raw output.
07Quote expiration and deadlines
Created and served-at timestamps share the server clock. Start and receipt share the browser clock. Cache age plus browser elapsed time is charged against thirty-second lifetime, conservatively including request latency.
Onchain deadline is reference timestamp plus sixty seconds. Preparation checks latest block number/timestamp against quote reference and deadline. Browser freshness does not replace chain checks.
08Execution and monitoring invariants
Execution binds chain, pair, amount, fee, router, recipient, minimum and deadline. All nine checks plus the release gate must pass; preparation and session checks repeat before send. These are deterministic conditions, not probabilities of economic safety.
Routing maximizes raw output among successful direct pools. Proposed Monitor thresholds, hysteresis and deduplication appear on its page; they do not describe an operating service. Simulation cannot guarantee profit, inclusion or confidentiality.