;; llm_momentum.push3 — Momentum Follower Optimizer
;;
;; Strategy: "follow the crowd, but keep a safety net."
;;
;; Philosophy:
;;   High staking % → bull: wide discovery, high anchor share
;;   Low  staking % → bear: floor-heavy, narrow anchor, minimal discovery
;;
;;   Uses smooth transitions (no hard if/else): percentageStaked directly
;;   scales all output parameters via multiplication.
;;
;;   Floor always gets at least 20% of ETH (safety net):
;;     anchorShare is capped at 0.8e18 (= percentageStaked * 0.8).
;;
;;   AnchorWidth is proportional to tax rate spread:
;;     high tax rate → volatile market → wider anchor bands.
;;
;; Inputs on DYADIC stack (slot 0 on top, slot 7 at bottom):
;;   [0] percentageStaked   (0..1e18, where 1e18 = 100%)
;;   [1] averageTaxRate     (0..1e18)
;;   [2-7] unused (normalized indicators, future use)
;;
;; Outputs (DYADIC stack at termination, bottom to top):
;;   discoveryDepth = percentageStaked              (0..1e18, direct scaling)
;;   anchorWidth    = 20 + taxRate * 80 / 1e18      (20..100 ticks)
;;   anchorShare    = percentageStaked * 0.8        (0..0.8e18, safety net)
;;   ci             = 0
;;
;;   At 0% staked:   DD=0,    AW=20,  AS=0,      CI=0  (full floor, minimal discovery)
;;   At 50% staked:  DD=0.5e18, AW=*, AS=0.4e18, CI=0
;;   At 100% staked: DD=1e18, AW=100, AS=0.8e18, CI=0  (anchor-heavy, full discovery)

(
  ;; Step 1: Bind slot 0 (percentageStaked) and slot 1 (averageTaxRate).
  PERCENTAGESTAKED DYADIC.DEFINE
  ;; Stack: [slot7, slot6, slot5, slot4, slot3, slot2, slot1]
  TAXRATE DYADIC.DEFINE
  ;; Stack: [slot7, slot6, slot5, slot4, slot3, slot2]

  ;; Step 2: Discard unused inputs (slots 2-7) — 6 pops.
  DYADIC.POP
  DYADIC.POP
  DYADIC.POP
  DYADIC.POP
  DYADIC.POP
  DYADIC.POP
  ;; Stack: []

  ;; Step 3: Push discoveryDepth = percentageStaked (0..1e18)
  ;; Momentum: high staking → full discovery; low staking → no discovery.
  PERCENTAGESTAKED
  ;; Stack: [discoveryDepth]

  ;; Step 4: Push anchorWidth = 20 + averageTaxRate * 80 / 1e18  (ticks: 20..100)
  ;; High tax spread → volatile market → wider anchor bands (bear-like).
  ;; Low  tax spread → stable market  → narrow anchor bands (bull-like).
  TAXRATE
  80 DYADIC.*
  1000000000000000000 DYADIC./
  20 DYADIC.+
  ;; Stack: [discoveryDepth, anchorWidth]

  ;; Step 5: Push anchorShare = percentageStaked * 800000000000000000 / 1e18  (0..0.8e18)
  ;; Safety net: tops out at 80%, so floor always receives >=20% of ETH.
  PERCENTAGESTAKED
  800000000000000000 DYADIC.*
  1000000000000000000 DYADIC./
  ;; Stack: [discoveryDepth, anchorWidth, anchorShare]

  ;; Step 6: Push ci = 0 (capital inefficiency — optimizer output, fixed at 0).
  0
  ;; Stack: [discoveryDepth, anchorWidth, anchorShare, ci=0]
)
