2025-10-03 11:57:01 +02:00
|
|
|
#!/usr/bin/env sh
|
2025-10-03 16:51:44 +02:00
|
|
|
set -e
|
|
|
|
|
|
2025-10-07 19:26:08 +02:00
|
|
|
# Version validation - check if contract VERSION is in COMPATIBLE_CONTRACT_VERSIONS
|
|
|
|
|
# Only run if both version files exist (system may not be implemented yet)
|
|
|
|
|
if [ -f "onchain/src/Kraiken.sol" ] && [ -f "kraiken-lib/src/version.ts" ]; then
|
|
|
|
|
STAGED_FILES=$(git diff --staged --name-only)
|
|
|
|
|
if echo "$STAGED_FILES" | grep -qE "(onchain/src/Kraiken.sol|kraiken-lib/src/version.ts)"; then
|
|
|
|
|
echo "Validating version sync between contract and kraiken-lib..."
|
|
|
|
|
|
|
|
|
|
# Extract contract VERSION constant
|
|
|
|
|
CONTRACT_VERSION=$(grep -oP 'VERSION\s*=\s*\K\d+' onchain/src/Kraiken.sol | head -1)
|
|
|
|
|
|
|
|
|
|
# Only validate if VERSION constant exists in contract
|
|
|
|
|
if [ -n "$CONTRACT_VERSION" ]; then
|
|
|
|
|
# Extract library version and compatible versions
|
|
|
|
|
LIB_VERSION=$(grep -oP 'KRAIKEN_LIB_VERSION\s*=\s*\K\d+' kraiken-lib/src/version.ts)
|
|
|
|
|
COMPATIBLE=$(grep -oP 'COMPATIBLE_CONTRACT_VERSIONS\s*=\s*\[\K[^\]]+' kraiken-lib/src/version.ts)
|
|
|
|
|
|
|
|
|
|
echo " Contract VERSION: $CONTRACT_VERSION"
|
|
|
|
|
echo " Library VERSION: $LIB_VERSION"
|
|
|
|
|
echo " Compatible versions: $COMPATIBLE"
|
|
|
|
|
|
feat: OptimizerV3 with direct 2D staking-to-LP parameter mapping
Core protocol changes for launch readiness:
- OptimizerV3: binary bear/bull mapping from (staking%, avgTax) — avoids
exploitable AW 30-90 kill zone. Bear: AS=30%, AW=100, CI=0, DD=0.3e18.
Bull: AS=100%, AW=20, CI=0, DD=1e18. UUPS upgradeable with __gap[48].
- Directional VWAP: only records prices on ETH inflow (buys), preventing
sell-side dilution of price memory
- Floor formula: unified max(scarcity, mirror, clamp) — VWAP mirror uses
distance from adjusted VWAP as floor distance, no branching
- PriceOracle (M-1 fix): correct fallback TWAP divisor (60000s, not 300s)
- Access control (M-2 fix): deployer-only guard on one-time setters
- Recenter rate limit (M-3 fix): 60-second cooldown for open recenters
- Safe fallback params: recenter() optimizer-failure defaults changed from
exploitable CI=50%/AW=50 to safe bear-mode CI=0/AW=100
- Recentered event for monitoring and indexing
- VERSION bump to 2, kraiken-lib COMPATIBLE_CONTRACT_VERSIONS updated
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 18:21:18 +00:00
|
|
|
# Check if contract version is in compatible list (strip spaces for reliable matching)
|
|
|
|
|
COMPATIBLE_CLEAN=$(echo "$COMPATIBLE" | tr -d ' ')
|
|
|
|
|
if echo ",$COMPATIBLE_CLEAN," | grep -q ",$CONTRACT_VERSION,"; then
|
2025-10-07 19:26:08 +02:00
|
|
|
echo " ✓ Version sync validated"
|
|
|
|
|
else
|
|
|
|
|
echo " ❌ Version validation failed!"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "Contract VERSION ($CONTRACT_VERSION) not in COMPATIBLE_CONTRACT_VERSIONS"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "To fix:"
|
|
|
|
|
echo "1. Update COMPATIBLE_CONTRACT_VERSIONS in kraiken-lib/src/version.ts to include $CONTRACT_VERSION:"
|
|
|
|
|
echo " export const COMPATIBLE_CONTRACT_VERSIONS = [$COMPATIBLE, $CONTRACT_VERSION];"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "2. Or update KRAIKEN_LIB_VERSION if this is a breaking change:"
|
|
|
|
|
echo " export const KRAIKEN_LIB_VERSION = $CONTRACT_VERSION;"
|
|
|
|
|
echo " export const COMPATIBLE_CONTRACT_VERSIONS = [$CONTRACT_VERSION];"
|
|
|
|
|
echo ""
|
|
|
|
|
echo "See VERSION_VALIDATION.md for details."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-04 15:17:09 +02:00
|
|
|
if [ -d "onchain" ]; then
|
|
|
|
|
(cd onchain && npx lint-staged)
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-03 16:51:44 +02:00
|
|
|
if [ -d "kraiken-lib" ]; then
|
|
|
|
|
(cd kraiken-lib && npx lint-staged)
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-04 15:40:30 +02:00
|
|
|
if [ -d "services/txnBot" ]; then
|
|
|
|
|
(cd services/txnBot && npx lint-staged)
|
|
|
|
|
fi
|
|
|
|
|
|
2025-10-03 16:51:44 +02:00
|
|
|
if [ -d "web-app" ]; then
|
|
|
|
|
(cd web-app && npx lint-staged)
|
|
|
|
|
fi
|
feat(ponder): Add strict ESLint + Prettier with pre-commit hooks (#52)
- Install eslint, @typescript-eslint plugins, prettier, husky, lint-staged
- Configure ESLint flat config with TypeScript parser
- Enforce: no-explicit-any (with exceptions), no-unused-vars, naming-convention, prefer-const, no-console
- Set style: 2-space indent, 140 char max-len, disable complexity rules
- Configure Prettier: single quotes, 140 width, trailing commas
- Setup husky pre-commit hook to auto-fix and format on commit
- Replace console.log/warn with context.logger.info/warn in handlers
- Remove console.log from ponder.config.ts (replaced with comment)
- Add npm scripts: lint, lint:fix, format, format:check
- All lint rules pass without warnings
resolvel #45
Co-authored-by: johba <johba@harb.eth>
Reviewed-on: https://codeberg.org/johba/harb/pulls/52
2025-10-04 15:37:26 +02:00
|
|
|
|
|
|
|
|
if [ -d "services/ponder" ]; then
|
|
|
|
|
(cd services/ponder && npx lint-staged)
|
|
|
|
|
fi
|