{
  "item": "b",
  "title": "Two-step continuation: retail displacement and next-opening arbitrage curvature",
  "status": "Source analysis and deterministic static calculations only; no market simulations, setup, compiler or confirmation-seed access.",
  "paired": {
    "n": 0,
    "mean_diff": null,
    "se": null,
    "worst": null
  },
  "gas": null,
  "retail_edge_delta": null,
  "arb_edge_delta": null,
  "code": {
    "kind": "offline Python prototype and Solidity pseudocode, not a deployed candidate",
    "sha256": null
  },
  "prototype": {
    "language": "Python3.10+ standard library",
    "source": "# Python 3.10+, stdlib, static deterministic quadrature. No RNG or simulator.\nfrom math import sqrt,exp,log,factorial\nfrom statistics import NormalDist\n# Pool tuple (x,y,bidFee,askFee): natural units, fractional fees.\ndef split(a,b,T,buy):\n g,h=1-a[3 if buy else 2],1-b[3 if buy else 2];z=sqrt(b[0]*b[1]*h)\n if z==0:return T\n r=sqrt(a[0]*a[1]*g)/z;A,C=(a[1],b[1]) if buy else (a[0],b[0]);d=g+r*h\n return max(0.,min(T,T/2 if d==0 else (r*(C+h*T)-A)/d))\ndef fill(a,t,buy,p):\n x,y,fb,fa=a;k=x*y\n if t<=0:return a,0.,None\n if buy:\n  yn=y+(1-fa)*t;xn=k/yn;q=x-xn;e=t-p*q;info=(False,q,t,xn,yn)\n else:\n  xn=x+(1-fb)*t;yn=k/xn;q=y-yn;e=p*t-q;info=(True,t,q,xn,yn)\n return (xn,yn,fb,fa),e,info\n\ndef arb(a,p):\n x,y,fb,fa=a;k=x*y;s=y/x\n if s<p:\n  g=1-fa;q=min(.99*x,max(0.,x-sqrt(k/(g*p))))\n  if q<=0:return 0.,a\n  t=(k/(x-q)-y)/g\n  if p*q<=t:return 0.,a\n  an,e,_=fill(a,t,True,p);return e,an\n if s>p:\n  g=1-fb;q=max(0.,(sqrt(k*g/p)-x)/g)\n  if q<=0:return 0.,a\n  an,e,_=fill(a,q,False,p);return (e,an) if e<0 else (0.,a)\n return 0.,a\n\ndef posterior(mu,v):\n # Proposed moment closure of V10 slots14/13, NOT its exact latent density.\n assert mu>0 and 0<=v<1/3\n return [(mu*(1+z*sqrt(v)),w) for z,w in [(-sqrt(3),1/6),(0.,2/3),(sqrt(3),1/6)]]\ndef shocks(sigma):\n return [(exp(-sigma*sigma/2+sigma*z),w) for z,w in [(-sqrt(3),1/6),(0.,2/3),(sqrt(3),1/6)]]\ndef sizes(M=20.,z=1.2,n=5):\n N=NormalDist() # midpoint quantile approximation, refine and account for tails\n return [(exp(log(M)-z*z/2+z*N.inv_cdf((i+.5)/n)),1/n) for i in range(n)]\ndef poisson(lam,K):\n d=[(n,exp(-lam)*lam**n/factorial(n)) for n in range(K+1)]\n return d,1-sum(w for _,w in d) # no renormalization or silent assignment to K\n\ndef hold(mem,info,timestamp,a):return a[2],a[3],mem # fixture, NOT V10\n\ndef tree(a,b,p,r,sz,sh,policy=hold,mem=(),timestamp=1,frozen=None):\n # r remaining retail then exactly one next-opening arb, no intervening arb.\n # Return current retail edge,next arb edge,E[end log spot],E[end log spot squared].\n if r==0:\n  end=a if frozen is None else (a[0],a[1],*frozen)\n  A=sum(w*arb(end,p*m)[0] for m,w in sh);u=log(a[1]/a[0]/p)\n  return 0.,A,u,u*u\n acc=[0.]*4\n for S,w in sz:\n  for buy in (False,True):\n   T=S if buy else S/p;t=split(a,b,T,buy);other=T-t;aa,bb,mm=a,b,mem;e=0.\n   if t>1e-4:\n    aa,e,info=fill(a,t,buy,p);fb,fa,mm=policy(mem,info,timestamp,aa)\n    assert 0<=fb<=.1 and 0<=fa<=.1\n    aa=(aa[0],aa[1],fb,fa)\n   if other>1e-4:bb,_,_=fill(b,other,buy,p)\n   z=tree(aa,bb,p,r-1,sz,sh,policy,mm,timestamp,frozen)\n   for j in range(4):acc[j]+=w*.5*(z[j]+(e if j==0 else 0.))\n return tuple(acc)\n\ndef integrate(atoms,sz,sh,policy=hold):\n # (weight,ownPool,opponentPool,p,r,immutableMemory), conditional on public H.\n # Caller handles normalizer opening arb still pending and conditional count law.\n ans=[0.]*4;mass=0.\n for w,a,b,p,r,mem in atoms:\n  mass+=w;z=tree(a,b,p,r,sz,sh,policy,mem)\n  for j in range(4):ans[j]+=w*z[j]\n return dict(zip(('retail','arb','mean_u','second_u'),ans)),mass\n\ndef checks():\n a=(100.,10000.,.003,.003);p=100.;k=1e6\n t=split(a,a,80.,True);assert abs(t-40)<1e-10\n z,e,_=fill(a,t,True,p);assert abs(z[0]*z[1]-k)<1e-8\n A,az=arb(z,p);assert A<0 and abs(az[1]/az[0]-p/.997)<1e-9\n d=2*log(1+.997*40/10000)\n def state(u):return sqrt(k/p)*exp(-u/2),sqrt(k*p)*exp(u/2),.003,.003\n gp=arb(state(d),p)[0];gm=arb(state(-d),p)[0];h=1e-5\n slope=(arb(state(h),p)[0]-arb(state(-h),p)[0])/(2*h)\n assert abs(gp-gm)<1e-8 and gp<0 and slope==0 and arb(a,p)[0]==0\n base=tree(a,a,p,1,[(80.,1.)],[(1.,1.)]);same=tree(a,a,p,1,[(80.,1.)],[(1.,1.)]);assert same==base\n c=(100.,10000.,.004,.004);new=tree(c,a,p,1,[(80.,1.)],[(1.,1.)])\n fr=tree(c,a,p,1,[(80.,1.)],[(1.,1.)],frozen=(.003,.003))\n mediation=fr[1]-base[1];carry=new[1]-fr[1]\n assert mediation>0 and abs(mediation+carry-(new[1]-base[1]))<1e-12\n inside=tree(a,a,p,1,[(20.,1.)],[(1.,1.)])[1];assert inside==0\n no=tree(c,a,p,0,[(80.,1.)],[(1.,1.)]);assert no[:2]==(0.,0.)\n nf=(100.,10000.,0.,0.);zz,ee,_=fill(nf,40.,True,p);aa,_=arb(zz,p);assert abs(ee+aa)<1e-9\n nodes=posterior(100.,1e-6);mean=sum(pp*w for pp,w in nodes)\n var=sum(w*(pp/mean-1)**2 for pp,w in nodes);assert abs(mean-100)<1e-12 and abs(var-1e-6)<1e-15\n pd,tail=poisson(.8,3);assert abs(sum(w for _,w in pd)+tail-1)<1e-15\n # Unconditional Poisson below is a fixture for a known opening-arb atom BEFORE retail.\n atoms=[(pw*nw,a,a,pp,n,()) for pp,pw in nodes for n,nw in pd]\n partial,mass=integrate(atoms,sizes(n=3),shocks(.00095))\n return {'assertions_passed':True,'equal_split_Y':t,'k_after':z[0]*z[1],\n  'post_arb_spot':az[1]/az[0],'d_log_spot':d,'G_prime_center':slope,\n  'G_plus_d':gp,'G_minus_d':gm,'symmetric_finite_cost':(gp+gm)/2,\n  'identity_deltas':[0.,0.],'inside_band_arb':inside,'zero_retail_center_edge':list(no[:2]),\n  'zero_fee_roundtrip_edge':ee+aa,'posterior_relative_variance':var,\n  'static_30_to_40bps':{'retail_delta':new[0]-base[0],'arb_delta':new[1]-base[1],\n   'spot_mediation':mediation,'carry_fee_effect':carry,'base':base,'candidate':new},\n  'poisson_tail':tail,'included_mass':mass,'partial_quadrature':partial}\nif __name__=='__main__':\n import json\n print(json.dumps(checks(),indent=2))\n",
    "sha256": "bd834320e93c7dc6169cf4561b5bc76f1bf8b1d2a4440b810a815a5181219109",
    "run": "Extract source verbatim to scratch or exec it in memory and call checks(). No simulator/compiler/network/seeds.",
    "limitations": "Executable central constant-k trade/router/next-arb calculation. hold is a fixture, NOT V10; production fitting needs a faithful V10 callback/slot-rounding adapter and conditional latent atoms. Size/price/posterior quadratures approximate integrals; missing Poisson mass is explicit. Offline recursion grows exponentially and never enters deployed code."
  },
  "deterministic_checks": {
    "classification": "STATIC algebra and finite quadrature, not market simulations or paired benchmark seeds. All assertions executed locally.",
    "results": {
      "assertions_passed": true,
      "equal_split_Y": 40.00000000000011,
      "k_after": 1000000.0,
      "post_arb_spot": 100.30090270812437,
      "d_log_spot": 0.007960138013748978,
      "G_prime_center": 0.0,
      "G_plus_d": -0.06148797946174156,
      "G_minus_d": -0.061487979461002595,
      "symmetric_finite_cost": -0.06148797946137208,
      "identity_deltas": [
        0.0,
        0.0
      ],
      "inside_band_arb": 0.0,
      "zero_retail_center_edge": [
        0.0,
        0.0
      ],
      "zero_fee_roundtrip_edge": 0.0,
      "posterior_relative_variance": 1.0000000000000736e-06,
      "static_30_to_40bps": {
        "retail_delta": 0.010487304395404351,
        "arb_delta": 0.031731405763753884,
        "spot_mediation": 0.011905599492813224,
        "carry_fee_effect": 0.01982580627094066,
        "base": [
          0.2784097021079859,
          -0.061487979461572806,
          1.1362438767648086e-16,
          6.336379719792953e-05
        ],
        "candidate": [
          0.28889700650339023,
          -0.029756573697818922,
          -5.594483210025203e-17,
          5.557083051767395e-05
        ]
      },
      "poisson_tail": 0.009079857800153968,
      "included_mass": 0.9909201421998459,
      "partial_quadrature": {
        "retail": 0.023454072675401425,
        "arb": -0.0010474942811387804,
        "mean_u": 4.949065526486343e-07,
        "second_u": 3.6867739741303747e-06
      }
    },
    "interpretation": "At equal reserves,30bp and fixed fair100, opposite size80Y-notional orders cancel mean log displacement but each causes about -.061488Y next arb edge. First derivative at center is zero; finite continuation penalty survives. Artificial30->40bp example changes both routing and terminal band; mediation freezes terminal fees at30bp. This is not a V10 tuning recommendation or market-gain claim. Zero-fee fixed-price retail followed by opening rebalance cancels execution edge."
  },
  "citations": {
    "engine": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/simulation/engine.rs",
      "path": "amm_sim_rs/src/simulation/engine.rs",
      "lines": "51-69 RNG seeds;79-97 initialization;136-161 event order/edge;183-204 PnL distinction"
    },
    "cfmm": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/amm/cfmm.rs",
      "path": "amm_sim_rs/src/amm/cfmm.rs",
      "lines": "119-196 quotes;199-289 reserve/fee/callback order;292-298 callback failure"
    },
    "router": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/market/router.rs",
      "path": "amm_sim_rs/src/market/router.rs",
      "lines": "35-117 splits;180-247 dust/execution;266-281 sequential orders"
    },
    "arb": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/market/arbitrageur.rs",
      "path": "amm_sim_rs/src/market/arbitrageur.rs",
      "lines": "35-46 direction;54-97 buy X;104-146 sell X"
    },
    "retail": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/market/retail.rs",
      "path": "amm_sim_rs/src/market/retail.rs",
      "lines": "43-60 distributions;73-99 count/size/side"
    },
    "price": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/market/price_process.rs",
      "path": "amm_sim_rs/src/market/price_process.rs",
      "lines": "37-49 drift/volatility;60-65 update"
    },
    "interface": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/IAMMStrategy.sol",
      "path": "contracts/src/IAMMStrategy.sol",
      "lines": "6-13 TradeInfo;17-30 fee/callback interface"
    },
    "base": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/AMMStrategyBase.sol",
      "path": "contracts/src/AMMStrategyBase.sol",
      "lines": "14-33 WAD/fees/BPS/32 slots"
    },
    "vanilla": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/contracts/src/VanillaStrategy.sol",
      "path": "contracts/src/VanillaStrategy.sol",
      "lines": "7-21 fixed30bp"
    },
    "config": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/config.py",
      "path": "amm_competition/competition/config.py",
      "lines": "25-47 baseline distributions"
    },
    "match": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_competition/competition/match.py",
      "path": "amm_competition/competition/match.py",
      "lines": "100-139 config draw order"
    },
    "gas_limit": {
      "url": "https://raw.githubusercontent.com/benedictbrady/amm-challenge/6b6921f8d463314aa7c96234e1be25a25245f704/amm_sim_rs/src/evm/strategy.rs",
      "path": "amm_sim_rs/src/evm/strategy.rs",
      "lines": "31-34 callback gas limit"
    },
    "V10": {
      "url": "https://api.imdnotdead.fun/artifacts/33f54e81f3372088e9eced52c0174f310ac348af98ef5727b73785c088679194",
      "path": "artifact.code decoded Solidity;1-based lines",
      "lines": "48-53 initialization;56-92 timing;94-153 estimators;154-242 flow/fees/writeback;248-330 posterior",
      "sha256": "cd9bdb45ab0537ad25c4fd90ca8618898cef6386de3df65f192eaef65fbca245",
      "hash_check": "Fetched decoded code and verified SHA256 equals requested value."
    },
    "rules": {
      "url": "https://api.imdnotdead.fun/artifacts/ddbbaac58282566e0505d895c83daf348487cc322e8c482e61d4d87e6e4628de",
      "path": "artifact JSON",
      "lines": "keys step_order,arb_rule,retail_split,fee_semantics,retail_size,draws,edge; independently checked pinned raw source"
    }
  },
  "context": {
    "baseline": "V10 censored_10, decoded code hash verified as cited.",
    "commit": "6b6921f8d463314aa7c96234e1be25a25245f704",
    "requester_reports_only": "V10 board519.8458(28th), top ten about+4.8. Prior shadow overlay -.0237(SE .0099,n512) vs STACK, arb+.132/retail-.156. These are provided motivation, not independently measured here. Prior overlay code was not supplied; its exact failure cannot be diagnosed.",
    "claim": "No board improvement or expected market-gain magnitude is asserted; static examples are not measured strategy deltas."
  },
  "design": {
    "proposal": "Compare small feasible perturbations around exact V10 using expected execution edge from remaining current-step retail PLUS NEXT opening arb. Retain end-spot variance, finite band crossings and callback fee persistence; distill incremental continuation gradients/curvatures into a bounded public-state polynomial.",
    "causal_mechanism": "A centered symmetric retail state can have zero mean log-spot displacement and zero first-order shadow gradient while nonzero end-spot variance causes next-opening arb loss. Changing routed volume changes that loss even when opposite directions cancel in expectation. A linear shadow-price substitution misses this second-order/band-crossing term.",
    "guardrails": "Identity remains feasible and wins ties. Include lost retail edge; arb savings alone do not establish gain. Keep V10 estimator/family intact and do not add terminal inventory valuation or double-count fees. The mechanism might be small or already implicitly captured by V10; require falsification controls.",
    "sources": [
      "engine:136-161",
      "cfmm:199-289",
      "arb:54-146",
      "router:35-117",
      "V10:174-242"
    ]
  },
  "assumptions": [
    {
      "statement": "Positive liquidity reserves, constant k=xy in real arithmetic; input fees accumulate separately, never reinvested. Callback reports gross trade amounts and post liquidity reserves.",
      "sources": [
        "cfmm:119-196,199-289",
        "interface:6-13"
      ],
      "qualification": "Simulator computes f64 and sends WAD callback values. Exact equations mean real-arithmetic source formulas; prototype uses tolerances."
    },
    {
      "statement": "Fair p fixed within step. Ours then normalizer each get one opening arb attempt, followed by all sequential retail. Successful own execution invokes callback immediately; no own execution means no callback; returned fees affect future trades only.",
      "sources": [
        "engine:136-152",
        "cfmm:206-222,237-253,268-298",
        "router:194-247,276-279"
      ]
    },
    {
      "statement": "Own opening-arb callback precedes normalizer opening arb; retail callback follows both opening attempts. First own print can be arb or retail; later same-timestamp own prints cannot be opening arb.",
      "sources": [
        "engine:140-152",
        "router:194-247"
      ],
      "qualification": "True phase is hidden. Never feed oracle labels to deployed code."
    },
    {
      "statement": "V10 slots14/13 are fast mean/relative variance from assumed-density update, not an identified exact joint posterior.",
      "sources": [
        "V10:146-153,248-330"
      ],
      "qualification": "Retain original V10 update. Offline density closure and joint hidden-state model are explicit approximations."
    },
    {
      "statement": "N~Poisson(lambda), S~LogNormal(log M-zeta^2/2,zeta), buy probability .5, S in Y notional; M in[19,21],lambda in[.6,1],zeta1.2. Next p+=p exp(-sigma^2/2+sigma Z),sigma in[.000882,.001008],Z~N(0,1),mu0,dt1.",
      "sources": [
        "retail:55-60,75-96",
        "router:194-222",
        "config:25-47",
        "price:48-49,62-65"
      ]
    },
    {
      "statement": "Own count includes arb and misses normalizer-only trades. Own flow EMAs cannot be assumed unbiased total-market count/size statistics.",
      "sources": [
        "V10:67-82,154-170",
        "router:180-247"
      ],
      "qualification": "An offline conditional residual-count/normalizer model must be supplied and stress-tested."
    }
  ],
  "exact_equations": {
    "units": "x:X,y:Y,k:X*Y,s=y/x and p:Y/X. f_b,f_a fractional fees; g_b=1-f_b,g_a=1-f_a. R,A,L:Y. T:gross input,S:Y notional. WAD1e18,1bp=1e-4 fraction=1e14 WAD,fee range[0,.1]. Sources interface:6-30;base:14-33.",
    "buy_retail": "Trader buys X,AMM isBuy=false. T=S Y,r=sqrt(k1*g_a1/(k2*g_a2)); t1=clip((r*(y2+g_a2*T)-y1)/(g_a1+r*g_a2),0,T),t2=T-t1. Our gross t gives y_new=y+g_a*t,x_new=k/y_new,q=x-x_new,R=t-p*q,s_new=s*(1+g_a*t/y)^2. Derived from router:35-74,cfmm:175-195,engine:155-159.",
    "sell_retail": "Trader sells X,AMM isBuy=true. T=S/p X,r=sqrt(k1*g_b1/(k2*g_b2)); t1=clip((r*(x2+g_b2*T)-x1)/(g_b1+r*g_b2),0,T). x_new=x+g_b*t,y_new=k/x_new,q=y-y_new,R=p*t-q,s_new=s/(1+g_b*t/x)^2. Derived from router:77-117,219-242,cfmm:119-138,engine:155-159.",
    "router_corners": "Both legs computed before callbacks; execute ours then normalizer. Input leg only executes if >.0001 in its input unit; dust skipped,not rerouted. Zero normalizer square-root term routes all to ours;zero denominator splits half. Recompute every order. Source router:35-117,180-247,266-281.",
    "arb_exact": "A<=0. If s<p:q=min(.99*x,max(0,x-sqrt(k/(g_a*p))));gross Y v=(k/(x-q)-y)/g_a;execute iff q>0,v>0,p*q-v>0;A=v-p*q. If s>p:gross X q=max(0,(sqrt(k*g_b/p)-x)/g_b);Y output v=y-k/(x+g_b*q);execute iff q>0,v>0,v-p*q>0;A=p*q-v. Otherwise A=0. Sources arb:35-146,cfmm:119-169. Use last CARRIED fees before next arb callback.",
    "log_spot_loss": "Away from .99 cap,u=log(s/p),K=sqrt(k*p) in Y. No-arb band log(g_a)<=u<=-log(g_b). L=-A=K*(exp(-u/2)+exp(u/2)/g_a-2/sqrt(g_a)) if u<log(g_a); L=K*(exp(u/2)+exp(-u/2)/g_b-2/sqrt(g_b)) if u>-log(g_b);zero inside. Derived by substitution in arb_exact. Use exact capped expression at extremes.",
    "gradient_curvature": "Lower L_u=K/2*(-exp(-u/2)+exp(u/2)/g_a);upper L_u=K/2*(exp(u/2)-exp(-u/2)/g_b). Outside band L_uu=L/4+K/(2*sqrt(g_side))>0. Boundary L=L_u=0;second derivative changes. G=E[A_next] has negative curvature where future shock mass lies outside band. These derivatives hold fixed k,future-p distribution,carry fees; complete action targets include policy and posterior-state effects.",
    "displacement": "Buy delta u=2 log(1+g_a*t/y);sell delta u=-2 log(1+g_b*t/x). Along k,dx/du=-x/2,dy/du=y/2. Continuation locally G_u E[delta u]+.5 G_uu E[(delta u)^2]. Sum sequential displacements before taking moments,including cross terms2E[delta u_i delta u_j]. Near bands/clips use finite differences. Centered equal-fee G_u(0)=0 but finite G(d)+G(-d)-2G(0)<0 when d crosses band.",
    "integration": "G(end,H)=E_bH E_Z[A(x_end,y_end,p exp(-sigma^2/2+sigma Z),f_b_end,f_a_end)]. b_H is conditional latent law given own public history. Sequential routes/callbacks determine end reserves and fees. No inventory terminal price/PnL term; gross edge already includes fees. Sources engine:140-161,183-204 plus derived continuation.",
    "bellman": "Latent z=(own reserves/slots,current p,normalizer,phase,r remaining current-step arrivals). Terminal W_0(z)=E_Z[A_next(z,Z)]. For r>0,W_r^pi(z,a)=E_S,side[R_ours(z,a,S,side)+W_(r-1)^pi(T(z,a,S,side),a_next)]. a_next=pi(H_next) only on an executed own leg;otherwise hold a and own slots. If normalizer opening pending,process it once before retail recursion. Callback Q(H,a)=E_bH[W_r(z,a)]. Initial implementation holds candidate until next own fill then resumes V10 on actual perturbed-fee history: rollout policy improvement,not oracle optimal control. Full Bellman maximization is legal only at own callbacks.",
    "correction": "a0=V10(H);Delta Q(a)=Delta R_remaining(a)+beta*Delta A_next(a). beta1 is the proposed finite-horizon edge objective;beta{0,.25,.5,1} is an ablation/robustness family,not a simulator discount. Identity difference exactly0. Never reprice the triggering trade: it already executed.",
    "mediation": "Matched latent branches/inputs: X_a,F_a=end reserves/fees under candidate;X_0,F_0 under V10. Delta A=[A(X_a,F_0)-A(X_0,F_0)]+[A(X_a,F_a)-A(X_a,F_0)]. First bracket isolates displacement at fixed terminal fees;second isolates carried-fee/band changes. Compute pathwise then average;counterfactual terminal fee freeze is not a deployed action.",
    "poisson_conditioning": "At start of retail Pr(N=n)=exp(-lambda)lambda^n/n!. Conditioning ONLY on N>=j at a known total arrival index j gives Pr(r=n-j)=Pr(N=n)/Pr(N>=j). Own callback count does not identify j and further public observations reweight this law. Integrate compatible j,unseen normalizer-only orders,phase and route likelihoods. No fresh Poisson residual by memorylessness. Unconditional Poisson applies to an identified opening-arb atom BEFORE retail.",
    "posterior_closure": "V10 moments do not identify the full joint law. Prototype p=fastHat*(1+z*sqrt(v)),z=0,+/-sqrt3,weights2/3,1/6,1/6 matches mean/relative variance with positive nodes. Explicit proposed Gaussian closure,not a true V10 posterior claim. Refine7/11 nodes or retain arb/retail mixture branches offline;normalizer/phase/count correlation with price/routes must be preserved."
  },
  "observable_state_and_order": {
    "allowed": "Only own TradeInfo,initial reserves,own slots/embedded constants at inference(interface:6-30). No true p,trader label,normalizer reserves,seed,future event/edge or simulator metadata.",
    "slots": "V10:0/1 actual last bid/ask;2 last post spot<<64|timestamp;3 direction;4 activity;5 slow pHat;6 sigmaHat;7 lambdaHat;8 sizeHat;9 toxicity;10 own-print count;11 read in disabled REVERT_U branch;12 first-print direction;13 relative posterior variance;14 fastHat. Sources V10:48-82,94-153,154-242,248-330. No extra slots needed;leave unused/reserved slots alone.",
    "order": [
      "Read actual previous fees/timestamp/post spot. Determine firstInStep exactly as V10,including initial t0;capture before count increment.",
      "Run original V10 decay,estimators,flow and fees;include compression/clamps and30/36bp cheaper-side caps to obtain a0.",
      "Build features from current post reserves,updated local V10 state,a0 and public callback. First print is not a certified arb label.",
      "Generate anchored candidates;project through original bounds/caps,deduplicate and score ACTUAL projected deltas. Identity wins ties and unsupported states.",
      "Write selected ACTUAL pair to slots0/1 and remaining original slots once. Next posterior must use perturbed pair.",
      "No timer/end-step callback exists;fees persist across silent steps. Next opening arb happens before its callback can change fees."
    ],
    "hidden_offline_only": [
      "current/next true p,normal shock,actual retail lambda/M/sigma",
      "normalizer reserves and pending opening phase(normalizer .003 fee is public constant)",
      "true total N,j,residual r,unseen order sizes/sides,arb-retail labels",
      "future latent paths and edge targets"
    ],
    "model_requirement": "Supply weighted conditional latent atoms using own public history,including censored zero-own routes. First-print phase mixture handles pending normalizer opening;later own prints still miss unseen normalizer-only orders. Synthetic states/public training histories may form this law;V10 price moments alone do not identify it. Prototype accepts atoms and adapter,not an invented calibrated belief."
  },
  "structural_alternatives": [
    {
      "id": "A0",
      "name": "V10 identity",
      "rule": "Perturbations off;exact V10 fees/state. Mandatory fallback and deterministic parity control."
    },
    {
      "id": "A1",
      "name": "Linear shadow diagnostic",
      "rule": "Delta R_remaining+G_u*Delta E[u_end],fixed carry fees;drop curvature/bands. Diagnostic control only;unavailable previous overlay code prevents equivalence claim."
    },
    {
      "id": "A2",
      "name": "Finite-band continuation",
      "rule": "Preferred:Delta R+beta Delta A through full remaining retail,finite band crossings and callback persistence;distill local fee-gradient/Hessian. Risk:conditional-belief/distillation error."
    },
    {
      "id": "A3",
      "name": "Curvature-only mediation",
      "rule": "Freeze terminal fees to matched V10;g Delta E[u]+.5h Delta E[u^2] with retail cost. Isolates displacement from fee protection. Taylor approximation unreliable near bands/clips."
    },
    {
      "id": "A4",
      "name": "Small finite-difference table",
      "rule": "Public bins:7 moneyness*3 variance*3 depth*3 own count*3 fee asymmetry=567 cells;identity+4 one-side offsets.4 actions*2 signed int16 retail/arb scores=9072 bytes plus metadata. Bounded nearest-cell lookup. Proposed capacity,no fitted table;test boundaries/action ordering."
    }
  ],
  "bounded_runtime_design": {
    "polynomial": "For each head Delta R/y and Delta A/y fit five coefficient functions g_b,g_a,h_bb,h_ba,h_aa:q=g_b db+g_a da+.5h_bb db^2+h_ba db da+.5h_aa da^2. db/da are ACTUAL projected fee perturbations divided by2bp. q is dimensionless normalized Y edge;CURRENT y common across actions. No intercept ensures identity0. Targets are finite-rollout differences,not immediate fill derivatives.",
    "public_features": "11 features[1,u,v,d,c,b,a,u^2,u*v,u*d,u*c]. u=(spot/fastHat-1)/.01,v=uncertainty/1e-5,d=(20Y/currentY)/.004,c=min(updated own count,4)/4,b=a0_bid/.01,a=a0_ask/.01.20Y is public prior center,not hidden size. Require |raw normalized inputs|<=2(v<=2),products<=4;out of support identity. Own lambdaHat/sizeHat may be separately tested features,never equated to true total-market statistics.",
    "constants_and_arithmetic": "2 heads*5 derivatives*11 features=110 signed int32 coefficients=440 packed bytes before compiler overhead. Embed immutable constants in bytecode,no external dependency/storage. Example coefficient=int32/2^24;choose scale after fitting and bound quantization error. Signed int256 checked products;bounded coefficients<2^31 and features<=4 keep finite sums far below int256. Guard positive reserves/mean,cast signed BEFORE fee subtraction. No fitted coefficients supplied.",
    "actions": "Identity plus(+1,0),(-1,0),(0,+1),(0,-1),(+1,-1),(-1,+1),(+1,+1),(-1,-1) times radius. Start1bp,test2/4bp;actual per-side deviation<=4bp,fees[0,.1]. Apply original first-print30bp and general36bp cheaper-side logic after projection,then score actual deltas in2bp units. Initialization remains exact V10.",
    "runtime_bound": "110 fixed multiply-accumulates for coefficient heads,9 constant-size quadratic evaluations,constant decoding and bounded feature operations. No additional SSTORE,quadrature,sqrt/log/exp,dynamic loops,hidden inference or recursion on-chain. Unsupported/uncertain score gives identity. Candidate count and feature loops fixed.",
    "gas_estimate": "UNMEASURED engineering estimate:+8k..25k gas for optimized arithmetic/constant decoding;not a measured total or certified bound.250000 callback limit source gas_limit:31-34. Brief214k peak is STACK,not measured V10 margin. Later compile/profile and inspect amm_sim_rs.gas_stats();ANY OutOfGas invalidates candidate,even if callback failure retains fees. Reduce feature/candidate count if necessary;static counts do not certify gas.",
    "solidity_pseudocode": "// Design pseudocode only; reuse original V10 math/local state/caps.\nfunction afterSwap(TradeInfo calldata t) external returns(uint,uint) {\n  V10Output memory v=originalV10ThroughCaps(t,slots);\n  // v.first captured before count increment; no state committed yet.\n  Pair memory a0=Pair(v.bid,v.ask); Pair memory best=a0; int bestQ=0;\n  if(inSupportedPublicDomain(t,v)) {\n    int[11] memory phi=publicFeatures(t,v);\n    int[5] memory r=evalHead(RETAIL_COEFFS,phi);\n    int[5] memory c=evalHead(CONT_COEFFS,phi);\n    for(uint i=1;i<9;++i) {\n      Pair memory a=originalCaps(clamp(a0+OFFSETS[i]*RADIUS),v.first);\n      if(maxAbsDeviation(a,a0)>4*BPS) continue;\n      int db=signedRatio(a.bid,a0.bid,2*BPS);\n      int da=signedRatio(a.ask,a0.ask,2*BPS);\n      int q=quadratic(r,db,da)+mulWad(BETA,quadratic(c,db,da));\n      if(q>bestQ && q>ERROR_MARGIN && withinScoreBound(q)) {bestQ=q;best=a;}\n    }\n  }\n  commitV10SlotsOnce(v,t,best.bid,best.ask); // slots0/1 actual chosen pair\n  return(best.bid,best.ask);\n}\n// evalHead fixed11 terms;quadratic fixed5 terms;identity wins ties.\n// ERROR_MARGIN covers fit/quantization/integration uncertainty;not a gas guard.\n"
  },
  "offline_implementation_and_search": {
    "required_inputs": [
      "Verified decoded V10 hash and pinned public simulator sources;Vanilla30bp.",
      "Faithful V10 callback adapter including fixed-point rounding and actual perturbed-fee history;compiler/EVM for later deployment validation.",
      "Public-history conditional latent atoms for phase,residual count,normalizer and current price;V10 moments alone do not supply this joint model. Synthetic states/public training histories suffice as proposed inputs,with sensitivity tests.",
      "Declared quadrature/tail tolerances and priors on public baseline nuisance ranges;no confirmation seeds for design/fitting.",
      "Later gas instrumentation/bytecode limits and benchmark harness;no runtime observations asserted here."
    ],
    "objective": "Maximize expected remaining-retail plus NEXT opening arb execution edge minus exact V10 rollout at matched public history/latent branches. Default beta1;fit retail and arb heads separately. Preserve identity;require action margin above numerical,model and distillation uncertainty. Never optimize arb savings alone.",
    "ranges": "Proposed synthetic supported domain:spot/fastHat-1[-.02,.02],posterior sd .0001..sqrt(2e-5),depth20/y .00025...008,own count1..4 plus5+ bucket,baseline fees0..100bp with30/36bp cap cells;outside support identity. Nuisance M{19,20,21},lambda{.6,.8,1},sigma{.000882,.00095,.001008},zeta1.2. Normalizer spot/phase conditioned on past opening band and later retail,not forced to fair. Radii{1,2,4}bp,beta{0,.25,.5,1},shrinkage{0,.25,.5,1}. Proposals,not measured optima.",
    "integration_and_tails": "Start3-node posterior/shock,3/5 size nodes,count cutoff3;refine7/11 price nodes,9/17 size nodes,count5/8 at sensitive cells. Include dedicated lognormal tail quadrature;midpoint quantiles miss extremes. Track omitted probability AND expected notional. Retail magnitude buy<=S+p*x,sell<=S+y;next arb magnitude<=pplus*x+y. Integrate these bounds under omitted state/count/size/price mass;do not call truncation certified until weighted bound below action margin. Conditional residual tail comes from conditional model,not unconditional Poisson. Merge similar offline children or use deterministic cubature to control tree size.",
    "fitting": "Candidate action held until own next fill,V10 thereafter using actual modified prior fees and full state. Shared latent branches and quadrature across candidates. Fit central/cross finite differences for five derivative functions per head with ridge/shrinkage. Quantize;validate finite-target sign/action ranking on held-out synthetic observable cells and at original caps. Score actual projected fees. If only identity survives error bars,report no credible mechanism rather than fit noise."
  },
  "worker_plan_55_minutes": [
    {
      "minutes": "0-7",
      "work": "Verify pinned mechanics/hash;implement V10 adapter and exact kernel/dust/caps. Gate on deterministic identity parity including t0 and silent timestamps."
    },
    {
      "minutes": "7-17",
      "work": "Build coarse conditional phase/count/normalizer atoms from public/synthetic histories;generate separate retail/arb and fixed-terminal-fee mediation targets;inspect tails."
    },
    {
      "minutes": "17-27",
      "work": "Compare identity,linear,finite-band,curvature-only families;add cross-fee actions only if cross terms survive. Refine clipped/band cells;fit small two-head polynomial."
    },
    {
      "minutes": "27-37",
      "work": "Embed bounded constants in V10,compile and validate projection/actual-fee writeback;profile adversarial callback gas and OOG. Reduce model if headroom insufficient."
    },
    {
      "minutes": "37-47",
      "work": "Future implementation task only,if experiments authorized:paired training blocks within10000..999999,each candidate alone against Vanilla in separate markets with matched configs. Measure total/retail/arb deltas and gas/OOG;freeze candidate only if total effect exceeds uncertainty and mediation survives. No experiments performed here."
    },
    {
      "minutes": "47-55",
      "work": "Run decisive ablations,repair/reject,record hashes/limitations and validate artifacts. This item never accesses confirmation seeds. A later authorized evaluation may confirm frozen candidate once against STACK on a genuinely fresh>=2000-seed block starting>=5000000,no retuning. If time insufficient return tested identity/design,never fabricated performance."
    }
  ],
  "falsification_and_ablations": [
    "Identity:disabled overlay must reproduce exact V10 fees/used slots on identical deterministic histories including t0,repeated timestamps,long silence,extremes and alternating flow. Next estimator reads actual perturbed pair.",
    "Linear vs curvature:matched action sets,drop second-moment/band terms. Symmetric centered static states have zero linear gradient yet finite cost for sufficiently large orders. If later benefit matches linear-only,the proposed distinct cause is unsubstantiated.",
    "Mediation:freeze terminal fees but permit changed end reserves;separately freeze reserves and vary fees. Benefit only in carried-fee test is band protection/persistence,not displacement alpha.",
    "Limits:fixed terminal fees and no further own flow imply zero displacement correction;total next arb can still change with chosen fees at exposed spots. Zero volatility with all end spots inside carried bands gives zero arb. Zero-fee fixed-p retail/rebalance edge cancels,catching terminal-PnL/double-fee errors.",
    "Sequence:compare full sequential retail to one-order-only and aggregate signed-notional targets;retain cancellation cross terms/callback updates. If aggregation suffices,reduce complexity.",
    "Belief:alternate density closures/arb-retail mixture,halve/double variance,change residual/phase law and normalizer band extremes. Compare full-history conditional atoms vs moments. Oracle p/opponent inputs are offline upper-bound diagnostics only;reject deployed benefit requiring them.",
    "Numerics:refine quadrature/count/size tails,route clips and .99 arb cap;require action-order stability relative to bounds. Test polynomial sign on held-out public states and after coefficient quantization.",
    "Retail cost:later report total and retail/arb changes. Lower arb loss bought with larger retail loss fails. beta0 on identical action set isolates continuation;action-frequency-matched random signs test mere extra tuning.",
    "Gas:any OOG invalidates later benchmark. Fee-retaining callback failure cannot count as valid decisions. No total gas/speed inferred from static operation counts."
  ],
  "limitations": [
    "No fitted coefficients/table or deployable Solidity strategy;requested design,pseudocode and executable central calculation supplied.",
    "No CH calibration,market benchmark,paired gain,gas or runtime measurement. paired.n=0,gas=null intentional.",
    "Joint hidden-state belief not identified by V10 price moments;implementation must supply and falsify it.",
    "Prior overlay implementation and independent board data not checked;requester-reported values are motivation only."
  ],
  "validation": {
    "json_parse": "PASS",
    "result_byte_limit": 40000,
    "embedded_prototype_hash": "PASS",
    "static_assertions_reproduced_after_JSON_roundtrip": "PASS",
    "public_source_quotes_refetched_and_matched": 14,
    "V10_decoded_sha256_rechecked": "PASS",
    "measurement_scope": "Static calculations only; no benchmark, simulation seeds or gas measurements. These local checks do not certify deployed behavior."
  }
}
