harb/onchain/src
openhands c87064dc6c fix: feat: Push3 default outputs — crash/no-output falls back to bear strategy (#634)
Three defensive layers so every Push3 program runs without reverting:

Layer A (transpiler/index.ts): assign bear defaults (CI=0, AS=0.3e18,
AW=100, DD=0.3e18) to all four outputs at the top of calculateParams.
Any output the evolved program does not overwrite keeps the safe default.

Layer B (transpiler/transpiler.ts): graceful stack underflow — dpop/bpop
return '0'/'false' instead of throwing, and the final output-pop falls
back to bear-default literals when fewer than 4 values remain on the
stack. Wrong output count no longer aborts transpilation.

Layer C (transpiler/transpiler.ts + index.ts): wrap the entire function
body in `unchecked {}` so integer overflow wraps (matching Push3), and
emit `(b == 0 ? 0 : a / b)` for every DYADIC./ (div-by-zero → 0,
matching Push3 no-op semantics).

Layer 2 (Optimizer.sol getLiquidityParams): clamp the three fraction
outputs (capitalInefficiency, anchorShare, discoveryDepth) to [0, 1e18]
after abi.decode so a buggy evolved program cannot produce out-of-range
values even if it runs without reverting.

Regenerated OptimizerV3Push3.sol with the updated transpiler; all 193
tests pass (34 Optimizer/OptimizerV3Push3 tests explicitly).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-13 03:47:49 +00:00
..
abstracts fix: Backtesting #5: Position tracking + P&L metrics (#319) 2026-02-27 11:23:18 +00:00
helpers Add Solidity linting with solhint, Foundry formatter, and pre-commit hooks (#51) 2025-10-04 15:17:09 +02:00
interfaces beautified 2025-07-08 10:33:10 +02:00
libraries feat: OptimizerV3 with direct 2D staking-to-LP parameter mapping 2026-02-13 18:21:18 +00:00
IOptimizer.sol fix: PR #551 review findings - OptimizerV3Push3.sol + Optimizer.sol 2026-03-10 23:13:57 +00:00
Kraiken.sol feat: OptimizerV3 with direct 2D staking-to-LP parameter mapping 2026-02-13 18:21:18 +00:00
LiquidityManager.sol Merge pull request 'fix: LM recenter() return semantics undocumented (#570)' (#626) from fix/issue-570 into master 2026-03-12 21:53:34 +01:00
Optimizer.sol fix: feat: Push3 default outputs — crash/no-output falls back to bear strategy (#634) 2026-03-13 03:47:49 +00:00
OptimizerV3.sol fix: OptimizerV3 — use canonical transpiler output, fix register mapping 2026-03-12 09:04:52 +00:00
OptimizerV3Push3.sol fix: feat: Push3 default outputs — crash/no-output falls back to bear strategy (#634) 2026-03-13 03:47:49 +00:00
Stake.sol fix: Stake.sol: exitPosition guard order (owner check before existence) (#307) 2026-02-27 06:33:32 +00:00
VWAPTracker.sol fix: fix: Restore proper VWAP — gas-efficient volume-weighted pricing (revert TWAP) (#603) 2026-03-12 08:50:07 +00:00