harb/onchain/script/backtesting
openhands cf8e7ee6ee fix: address review feedback on PositionTracker and StrategyExecutor
- Fix fee attribution: distribute fees only to positions whose tick range
  contains the active tick at close time (in-range weight), not by raw
  liquidity. FLOOR is priced far below current tick and rarely earns fees;
  the old approach would over-credit it and corrupt capital-efficiency and
  net-P&L numbers. Fallback to raw-liquidity weighting with a WARN log
  when no position is in range.

- Warn on first-close skip: when _closePosition finds no open record
  (first recenter, before any tracking), log [TRACKER][WARN] instead of
  silently returning so the gap is visible in reports.

- Add tick range assertion: require() that the incoming close snapshot
  tick range matches the stored open record — a mismatch would mean IL
  is computed across different ranges (apples vs oranges).

- Fix finalBlock accuracy: logSummary now calls
  tracker.logFinalSummary(tracker.lastNotifiedBlock()) instead of
  lastRecenterBlock, so the summary reflects the actual last replay block
  rather than potentially hundreds of blocks early.

- Initialize lastRecenterBlock = block.number in StrategyExecutor
  constructor to defer the first recenter attempt by recenterInterval
  blocks and document the invariant.

- Extract shared FormatLib: _str(uint256) and _istr(int256) were
  copy-pasted in both PositionTracker and StrategyExecutor. Extracted to
  FormatLib.sol internal library; both contracts now use `using FormatLib`.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 12:02:29 +00:00
..
.gitignore fix: address review feedback on fetch-events.ts (#315) 2026-02-26 22:45:40 +00:00
BacktestKraiken.sol fix: Backtesting #4: Deploy KrAIken contracts + recenter execution loop (#318) 2026-02-27 09:00:22 +00:00
BacktestRunner.s.sol fix: Backtesting #5: Position tracking + P&L metrics (#319) 2026-02-27 11:23:18 +00:00
EventReplayer.sol fix: Backtesting #5: Position tracking + P&L metrics (#319) 2026-02-27 11:23:18 +00:00
fetch-events.ts fix: address review feedback on fetch-events.ts (#315) 2026-02-26 22:45:40 +00:00
FormatLib.sol fix: address review feedback on PositionTracker and StrategyExecutor 2026-02-27 12:02:29 +00:00
KrAIkenDeployer.sol fix: Backtesting #5: Position tracking + P&L metrics (#319) 2026-02-27 11:23:18 +00:00
MockToken.sol fix: Backtesting #2: Foundry script skeleton + Uniswap V3 shadow pool deployment (#316) 2026-02-27 05:08:27 +00:00
package.json fix: Backtesting #1: Event fetcher (Infura → JSON Lines cache) (#315) 2026-02-26 22:04:43 +00:00
PositionTracker.sol fix: address review feedback on PositionTracker and StrategyExecutor 2026-02-27 12:02:29 +00:00
ShadowPoolDeployer.sol fix: Backtesting #5: Position tracking + P&L metrics (#319) 2026-02-27 11:23:18 +00:00
StrategyExecutor.sol fix: address review feedback on PositionTracker and StrategyExecutor 2026-02-27 12:02:29 +00:00
tsconfig.json fix: Backtesting #1: Event fetcher (Infura → JSON Lines cache) (#315) 2026-02-26 22:04:43 +00:00