VVEKTRA®DOCUMENTATIONOpen swap ↗
VEKTRA RESEARCH / 10

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.

a=A10d∈Z,0<a≤2256−1a=A10^d\in\mathbb Z,\qquad0<a\le2^{256}-1
A is human input, d decimals and a raw amount. Scientific notation, negatives and trailing decimal points are invalid.

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.

Δy=y Δx(1−f)x+Δx(1−f)\Delta y=\frac{y\,\Delta x(1-f)}{x+\Delta x(1-f)}
x/y are input/output reserves, Δx > 0 input, f fee fraction and Δy output. Units must be consistent. Gas is separate.

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.

S=sqrtPriceX96296,Praw=S2,Phuman=S2 10d0−d1S=\frac{\mathrm{sqrtPriceX96}}{2^{96}},\quad P_{\mathrm{raw}}=S^2,\quad P_{\mathrm{human}}=S^2\,10^{d_0-d_1}
d₀/d₁ are token0/token1 decimals. P_human is human token1 units per human token0 unit.
xv=L/S,yv=LS,S′=(1/S+aeff/L)−1,Δy=L(S−S′)x_v=L/S,\quad y_v=LS,\quad S'=\left(1/S+a_{\mathrm{eff}}/L\right)^{-1},\quad\Delta y=L(S-S')
Token0 input: a_eff is fee-adjusted raw input. Virtual reserves are not total pool balances.
S′=S+beff/L,Δx=L(1/S−1/S′)S'=S+b_{\mathrm{eff}}/L,\qquad\Delta x=L(1/S-1/S')
Token1 input: b_eff is fee-adjusted raw input, Δx raw token0 output. Assumes constant active liquidity.

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.

b=round⁡(100s),m=⌊q(10000−b)10000⌋,0.1≤s≤3b=\operatorname{round}(100s),\qquad m=\left\lfloor\frac{q(10000-b)}{10000}\right\rfloor,\quad0.1\le s\le3
s is percentage, b integer basis points, q raw output and m raw minimum. Gas is separate.

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.

qspot={⌊aQ2/2192⌋token0 input⌊a2192/Q2⌋token1 inputq_{\mathrm{spot}}=\begin{cases}\lfloor aQ^2/2^{192}\rfloor&\text{token0 input}\\\lfloor a2^{192}/Q^2\rfloor&\text{token1 input}\end{cases}
All operands are raw units. Q must be positive for a valid price.
I%=trunc⁡(106(qspot−q)/qspot)104I_{\%}=\frac{\operatorname{trunc}\left(10^6(q_{\mathrm{spot}}-q)/q_{\mathrm{spot}}\right)}{10^4}
Defined for q_spot > 0. trunc is toward zero, including negative values. Result is percent, not fraction.

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.

Glimit=⌊120Gest/100⌋,Cbuffer=⌊125Glimitp/100⌋G_{\mathrm{limit}}=\lfloor120G_{\mathrm{est}}/100\rfloor,\quad C_{\mathrm{buffer}}=\lfloor125G_{\mathrm{limit}}p/100\rfloor
G_est is gas units, p wei/gas and C_buffer wei. Require native balance ≥ value + buffered fee.
Qnet=q10dout−CETHPETH→outQ_{\mathrm{net}}=\frac{q}{10^{d_{\mathrm{out}}}}-C_{\mathrm{ETH}}P_{\mathrm{ETH}\rightarrow\mathrm{out}}
Conceptual only: C_ETH is gas cost in ETH and P converts to human output-token units. Without conversion this subtraction is invalid.

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.

A=(tserved−tcreated)+(treceived−tstarted),0≤A<30000 msA=(t_{\mathrm{served}}-t_{\mathrm{created}})+(t_{\mathrm{received}}-t_{\mathrm{started}}),\quad0\le A<30000\ \mathrm{ms}
Each subtraction uses one clock. Invalid/negative timing is rejected. Local created is browser now minus A.
D=Tquote+60,Thead<D≤Thead+60D=T_{\mathrm{quote}}+60,\qquad T_{\mathrm{head}}<D\le T_{\mathrm{head}}+60
Chain seconds. Also quote block ≤ head block and T_quote ≤ T_head. Router deadline is enforced independently.

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.

SOURCE-BASED SPECIFICATION / 26 OCT 2026
Public execution. Explicit limits. Wallet release not cleared.