Commit graph

470 commits

Author SHA1 Message Date
openhands
bce4059de9 fix: Get KRK: inline swap widget for local dev, Uniswap link for production (#136)
- Add `VITE_ENABLE_LOCAL_SWAP` env var to config.ts (defaults false)
- Create LocalSwapWidget.vue: inline ETH→KRK swap (wrap→approve→exactInputSingle)
- GetKrkView.vue: show LocalSwapWidget when VITE_ENABLE_LOCAL_SWAP=true, Uniswap link otherwise
- docker-compose.yml: set VITE_ENABLE_LOCAL_SWAP=true for webapp service

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 06:55:41 +00:00
johba
9341673a1a Merge pull request 'fix: Ponder: fix mintNextHourProjected divisor, dead param, dead code (#308)' (#333) from fix/issue-308 into master 2026-02-27 07:20:02 +01:00
johba
00037dc713 Merge pull request 'fix: Backtesting #2: Foundry script skeleton + Uniswap V3 shadow pool deployment (#316)' (#332) from fix/issue-316 into master 2026-02-27 06:48:19 +01:00
openhands
a4a3a85fdc fix: Ponder: fix mintNextHourProjected divisor, dead param, dead code (#308) 2026-02-27 05:47:51 +00:00
openhands
70e49b2546 fix: suppress compiler warnings in BacktestRunner (#316)
- Add `view` to _parseSqrtPriceFromFile and _resolveSqrtPrice
- Remove unused IUniswapV3Pool import

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 05:12:45 +00:00
openhands
96b06bd9fe fix: Backtesting #2: Foundry script skeleton + Uniswap V3 shadow pool deployment (#316)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-27 05:08:27 +00:00
johba
c540d56d08 Merge pull request 'fix: Backtesting #1: Event fetcher (Infura → JSON Lines cache) (#315)' (#331) from fix/issue-315 into master 2026-02-27 00:12:51 +01:00
openhands
c33bdbaad5 fix: address review feedback on fetch-events.ts (#315)
- Replace hardcoded Infura API key with INFURA_API_KEY env var; fail fast
  with a helpful message if unset and no --rpc-url is given
- Add onchain/script/backtesting/.gitignore (cache/) instead of relying on
  the opaque root pattern; remove force-tracked cache/.gitkeep (mkdirSync
  creates the directory at runtime)
- Document resume constraint: reliable only when both --start-block and
  --end-block are explicit, or --output is set
- Fix batch-number display: derive batchNum inside the loop from the actual
  `from` block so it stays correct when resumeFromBlock isn't BATCH_SIZE-aligned
- Guard log.logIndex === null consistently with blockNumber/transactionHash
- console.warn on decode errors instead of silently discarding them

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 22:45:40 +00:00
openhands
df89b8c2da fix: Backtesting #1: Event fetcher (Infura → JSON Lines cache) (#315)
Add onchain/script/backtesting/fetch-events.ts — a tsx script that:
- Fetches Swap/Mint/Burn events from a Uniswap V3 pool via Infura (Base mainnet)
- Batches eth_getLogs in 2 000-block chunks with 100 ms inter-batch delay
- Decodes each log with viem and writes one JSON Line per event
- Supports resume: reads last block from existing cache file on re-run
- Retries with exponential back-off on 429 / rate-limit errors
- Prints per-batch progress: "Fetching blocks X-Y... N events (B/T batches)"

Also adds package.json, tsconfig.json, and cache/.gitkeep.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 22:04:43 +00:00
johba
52411e881a Merge pull request 'revert: Remove premature backtesting code (#320)' (#328) from revert/backtesting-320 into master
Reviewed-on: https://codeberg.org/johba/harb/pulls/328
2026-02-26 22:21:37 +01:00
johba
50f985ef6f Merge pull request 'fix: CollapseActive: null guard on total computed + remove redundant BigInt casts (#309)' (#327) from fix/issue-309 into master 2026-02-26 22:04:51 +01:00
openhands
4a6256b941 Revert "Merge pull request 'fix: Backtesting #6: Baseline strategies (HODL, full-range, fixed-width) + reporting (#320)' (#322) from fix/issue-320 into master"
This reverts commit 1e5ac0de80, reversing
changes made to 6526928b67.
2026-02-26 20:45:19 +00:00
openhands
63ddf14a5c fix: CollapseActive: null guard on total computed + remove redundant BigInt casts (#309)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 20:42:17 +00:00
johba
c73f0e8bc1 Merge pull request 'fix: Remove dead Optimizer V2/V3 — Push3 is the active optimizer (#312)' (#321) from fix/issue-312 into master 2026-02-26 20:57:52 +01:00
openhands
2a7afbf6d2 fix: Increase test stake amount to 1000 — base Optimizer wider anchor raises minStake 2026-02-26 19:37:12 +00:00
openhands
2d25200582 fix: Update E2E tests for Optimizer (base) — drop OptimizerV3 bear-market constants
- 01-acquire-and-stake: replace flat 3 s wait with a 30 s polling loop so
  Ponder indexing lag no longer causes a spurious positions.length=0 failure.

- 05-optimizer-integration test 1: replace hard-coded OptimizerV3 bear-market
  constants (anchorShare=3e17, anchorWidth=100, discoveryDepth=3e17) with
  Optimizer.sol invariant checks:
    capitalInefficiency + anchorShare == 1e18
    discoveryDepth == anchorShare
    anchorWidth ∈ [10, 80]

- 05-optimizer-integration test 2: decouple bootstrap-position assertion from
  current optimizer state.  Earlier tests change staking state, so the current
  optimizer anchorWidth differs from the one used at bootstrap time.  Instead,
  reverse-calculate the implied anchorWidth from the observed anchor spread and
  verify it lies within [10, 80].

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 19:37:12 +00:00
openhands
d9bfedcfcc ci: retrigger after infra failure 2026-02-26 19:37:12 +00:00
openhands
99d9c563d6 fix: Use Optimizer (base) in deploy scripts — Push3 lacks initialize/getLiquidityParams
OptimizerV3Push3 is an equivalence-proof contract with only isBullMarket().
It cannot serve as an ERC1967Proxy implementation because it has no initialize()
or getLiquidityParams(). The CI bootstrap was failing because the proxy
deployment reverted when calling initialize() on the Push3 implementation.

Switch deploy scripts to Optimizer.sol (the base UUPS contract) which has the
full interface required by ERC1967Proxy and LiquidityManager.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 19:37:12 +00:00
openhands
e925538309 fix: Remove dead Optimizer V2/V3 — Push3 is the active optimizer (#312)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 19:37:12 +00:00
johba
1e5ac0de80 Merge pull request 'fix: Backtesting #6: Baseline strategies (HODL, full-range, fixed-width) + reporting (#320)' (#322) from fix/issue-320 into master 2026-02-26 18:02:54 +01:00
openhands
9061f8e8f6 fix: Address AI review findings for backtesting baseline strategies (#320)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 16:39:47 +00:00
openhands
5205ea6f4a fix: Backtesting #6: Baseline strategies (HODL, full-range, fixed-width) + reporting (#320)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 16:11:15 +00:00
johba
6526928b67 Merge pull request 'fix: Landing copy: fix immutable overclaim + sync Mixed variant floor copy (#310)' (#311) from fix/issue-310 into master 2026-02-26 15:02:46 +01:00
openhands
143d6b202a fix: Landing copy: fix immutable overclaim + sync Mixed variant floor copy (#310)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 13:40:34 +00:00
johba
ed24a166ab Merge pull request 'fix: Test coverage: Kraiken + VWAPTracker to 100% (#283)' (#303) from fix/issue-283 into master 2026-02-26 06:34:08 +01:00
openhands
e9370c143e fix: Test coverage: Kraiken + VWAPTracker to 100% (#283)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 05:12:48 +00:00
johba
2baa913435 Merge pull request 'fix: Test coverage: Stake.sol to 100% (#284)' (#298) from fix/issue-284 into master 2026-02-26 05:54:53 +01:00
openhands
cff95a3670 fix: Test coverage: Stake.sol to 100% (#284) 2026-02-26 04:28:47 +00:00
openhands
93ddd28978 fix: Test coverage: Stake.sol to 100% (#284)
Add 11 new targeted tests in Stake.t.sol to cover all reachable
uncovered branches and the untested permitAndSnatch() function:

- testRevert_TaxRateOutOfBounds_InSnatch: taxRate >= TAX_RATES.length in snatch()
- testRevert_PositionNotFound_NonLastInLoop: PositionNotFound inside the multi-position loop
- testRevert_TaxTooLow_NonLastInLoop: TaxTooLow inside the multi-position loop
- testSnatch_ExitLastPosition: _exitPosition() path for last snatched position
- testRevert_ExceededAvailableStake: no available stake, no positions provided
- testRevert_TooMuchSnatch_AvailableExceedsNeed: post-exit excess stake check
- testRevert_PositionNotFound_InChangeTax: changeTax() on non-existent position
- testRevert_TaxTooLow_InChangeTax: changeTax() with same/lower tax rate
- testRevert_NoPermission_InExitPosition: exitPosition() by non-owner
- testRevert_PositionNotFound_InPayTax: payTax() on non-existent position
- testPermitAndSnatch: EIP-712 permit + snatch in one transaction

Coverage achieved:
  Lines:     99.33% (148/149)
  Statements: 99.40% (167/168)
  Branches:  93.55% (29/31)  — 2 unreachable dead-code branches remain
  Functions: 100.00% (15/15)

The 2 uncovered branches are dead code: the require() failure in
_shrinkPosition (caller always guards sharesToTake < pos.share) and
the PositionNotFound guard in exitPosition() (unreachable because
owner and creationTime are always set/cleared together, so
pos.owner==msg.sender implies pos.creationTime!=0 for any live caller).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 03:59:20 +00:00
johba
a7947c64c8 Merge pull request 'fix: Test coverage: LiquidityManager + Optimizer + OptimizerV3 to 100% (#285)' (#296) from fix/issue-285 into master 2026-02-26 04:07:11 +01:00
openhands
9cce524b8a fix: Test coverage: LiquidityManager + Optimizer + OptimizerV3 to 100% (#285)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 02:41:02 +00:00
johba
b161b4ecfb Merge pull request 'fix: kraiken-lib: fix broken tests + raise coverage to 95% (#286)' (#293) from fix/issue-286 into master 2026-02-26 02:32:27 +01:00
openhands
dc95b2d22e fix: kraiken-lib: fix broken tests + raise coverage to 95% (#286)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 01:09:55 +00:00
openhands
2aa85f5a03 fix: CI failure in run-e2e-tests (#286) 2026-02-26 00:42:32 +00:00
openhands
e5bd4f29f7 fix: kraiken-lib: fix broken tests + raise coverage to 95% (#286)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 00:42:21 +00:00
openhands
baa4ee2404 fix: CI failure in bootstrap (#286) 2026-02-26 00:27:23 +00:00
openhands
f23f6b81a6 fix: kraiken-lib: fix broken tests + raise coverage to 95% (#286)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 00:27:12 +00:00
openhands
15b0c0e97b fix: kraiken-lib: fix broken tests + raise coverage to 95% (#286) 2026-02-26 00:11:20 +00:00
openhands
26a9645b1f fix: kraiken-lib: fix broken tests + raise coverage to 95% (#286)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-26 00:10:45 +00:00
johba
cc064faa29 Merge pull request 'fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287)' (#288) from fix/issue-287 into master 2026-02-26 00:55:20 +01:00
openhands
16dc1827c9 fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287)
- vitest.config.ts: add statements/functions/branches thresholds alongside
  lines so the coverage gate catches regressions in all four dimensions
- tests/stats.test.ts: replace weak "> 0n" / "toBeDefined()" assertions with
  exact expected values derived from the ring buffer algebra:
  - hour-advanced path: mintedLastWeek=480n, mintedLastDay=220n,
    burnedLastWeek=240n, burnedLastDay=110n, mintNextHourProjected=68n,
    burnNextHourProjected=34n, netSupplyChangeDay=110n,
    netSupplyChangeWeek=240n
  - same-hour projection path: mintNextHourProjected=140n (elapsed-seconds
    scaling verified), burnNextHourProjected=0n (medium=0 fallback path)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 23:28:25 +00:00
openhands
76560fd26b fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287)
- Add vitest ^2 + @vitest/coverage-v8 ^2 as devDependencies
- Add `test` and `test:coverage` scripts to package.json
- Create vitest.config.ts with resolve.alias to mock ponder virtual modules
  (ponder:schema, ponder:registry) and point kraiken-lib/version to source
- Add coverage/ to .gitignore
- Add tests/**/* and vitest.config.ts to tsconfig.json include
- Create tests/__mocks__/ponder-schema.ts and ponder-registry.ts stubs
- Create tests/stats.test.ts — 48 tests covering ring buffer logic,
  segment updates, hourly advancement, projections, ETH reserve snapshots,
  all exported async helpers with mock Ponder contexts
- Create tests/version.test.ts — 14 tests covering isCompatibleVersion,
  getVersionMismatchError, and validateContractVersion (compatible / mismatch /
  error paths, existing-meta upsert path)
- Create tests/abi.test.ts — 6 tests covering validateAbi and validateContractAbi

Tests placed at tests/ (not src/tests/) so Ponder's Vite build does not
attempt to execute test files as event handlers on startup.

Result: 68 tests pass, 100% line/statement/function coverage on all helpers
(stats.ts, version.ts, abi.ts, logger.ts) — exceeds 95% target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 22:53:01 +00:00
openhands
ad0670f8ae fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287) 2026-02-25 22:30:24 +00:00
openhands
e49938bd0a fix: Ponder: add test infrastructure + coverage for helpers (target 95%) (#287)
- Add vitest ^2 + @vitest/coverage-v8 ^2 as devDependencies
- Add `test` and `test:coverage` scripts to package.json
- Create vitest.config.ts with resolve.alias to mock ponder virtual modules
  (ponder:schema, ponder:registry) and point kraiken-lib/version to source
- Add coverage/  to .gitignore
- Add vitest.config.ts to tsconfig.json include so eslint project-aware rules apply
- Create src/tests/__mocks__/ponder-schema.ts and ponder-registry.ts stubs
- Create src/tests/stats.test.ts — 48 tests covering ring buffer logic,
  segment updates, hourly advancement, projections, ETH reserve snapshots,
  all exported async helpers with mock Ponder contexts
- Create src/tests/version.test.ts — 14 tests covering isCompatibleVersion,
  getVersionMismatchError, and validateContractVersion (compatible / mismatch /
  error paths, existing-meta upsert path)
- Create src/tests/abi.test.ts — 6 tests covering validateAbi and
  validateContractAbi

Result: 68 tests pass, 100% line/statement/function coverage on all helpers
(stats.ts, version.ts, abi.ts, logger.ts) — exceeds 95% target.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 22:29:57 +00:00
johba
24b3cf2836 Merge pull request 'fix: Consolidate redundant/broken gitignore node_modules entries (#204)' (#279) from fix/issue-204 into master 2026-02-25 22:42:30 +01:00
openhands
dd2e2ec25c fix: Consolidate redundant/broken gitignore node_modules entries (#204)
Remove redundant `node_modules/` entries from sub-directory .gitignore
files. The root `.gitignore` already has `**/node_modules/` which covers
all nested directories, making these per-package entries unnecessary.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 21:13:16 +00:00
johba
352b31e10a Merge pull request 'fix: Fix false claims on landing: "cant go to zero" + "open source" (#269)' (#275) from fix/issue-269 into master 2026-02-25 22:01:43 +01:00
openhands
56d15a40f6 fix: Fix false claims on landing: "cant go to zero" + "open source" (#269)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 20:33:01 +00:00
openhands
04e9d04df5 fix: Fix false claims on landing: "cant go to zero" + "open source" (#269) 2026-02-25 20:02:15 +00:00
openhands
ede53a9dd3 fix: Fix false claims on landing: "cant go to zero" + "open source" (#269)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-25 20:02:02 +00:00