Merge pull request 'move ponder' (#7) from move-ponder into master
Reviewed-on: https://codeberg.org/johba/harb/pulls/7
This commit is contained in:
commit
2be1e9d520
22 changed files with 50 additions and 14 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
## System Map
|
||||
- `onchain/`: Foundry workspace for Kraiken token, Harberger staking, Optimizer, and LiquidityManager logic. Deployment scripts live in `script/`, tests in `test/`, fuzzing toolchain in `analysis/`. Use `.secret.local` mnemonic for local scripts.
|
||||
- `ponder/`: New indexer replacing The Graph. `ponder.config.ts` selects network/contracts, `src/` holds TypeScript event handlers, `ponder.schema.ts` defines tables, `README.md` documents usage. Generated artifacts in `generated/` are auto-created by Ponder.
|
||||
- `services/ponder/`: New indexer replacing The Graph. `ponder.config.ts` selects network/contracts, `src/` holds TypeScript event handlers, `ponder.schema.ts` defines tables, `README.md` documents usage. Generated artifacts in `generated/` are auto-created by Ponder.
|
||||
- `subgraph/base_sepolia/`: Legacy AssemblyScript implementation kept for reference during migration. Do not modify unless syncing schema changes between stacks.
|
||||
- `landing/`: Vue 3 app (Vite + TypeScript) for the public launch site and forthcoming staking UI. See `src/views/` for pages, `env.d.ts` for injected globals.
|
||||
- `services/txnBot/`: Node service that consumes the Ponder GraphQL API to trigger `recenter()` and `payTax()` on-chain when profitable.
|
||||
|
|
@ -70,9 +70,9 @@
|
|||
- `./scripts/local_env.sh start` boots Anvil+contracts+ponder+frontend+txnBot; stop with Ctrl+C or `./scripts/local_env.sh stop`.
|
||||
|
||||
## Refactor Backlog
|
||||
- Replace the temporary `any` shims in `ponder/src/kraiken.ts` and `ponder/src/stake.ts` by importing the official 0.13 handler types instead of stubbing `ponder-env.d.ts`.
|
||||
- Replace the temporary `any` shims in `services/ponder/src/kraiken.ts` and `services/ponder/src/stake.ts` by importing the official 0.13 handler types instead of stubbing `ponder-env.d.ts`.
|
||||
- Drop the custom `ponder:api` / `ponder:registry` module declarations once the generator emits them; if it cannot, declare precise interfaces rather than `any` to keep autocomplete and future upgrades safe.
|
||||
- Convert the JSON ABI imports in `ponder/ponder.config.ts` to typed loaders (e.g., `satisfies Abi`) so config drift is caught at compile time instead of via `as Abi` casts.
|
||||
- Convert the JSON ABI imports in `services/ponder/ponder.config.ts` to typed loaders (e.g., `satisfies Abi`) so config drift is caught at compile time instead of via `as Abi` casts.
|
||||
- Move the snatch-selection logic out of `web-app/src/components/StakeHolder.vue` into a dedicated composable that both the stake form and charts can reuse, and memoise the `assetsToShares` conversions there.
|
||||
- Split `kraiken-lib/src/helpers.ts` into focused modules (ids, tax rates, snatch selection) so consumers can tree-shake and each helper stays small and testable.
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ WEBAPP_LOG="$LOG_DIR/webapp.log"
|
|||
TXNBOT_LOG="$LOG_DIR/txnBot.log"
|
||||
SETUP_LOG="$LOG_DIR/setup.log"
|
||||
TXNBOT_ENV_FILE="$STATE_DIR/txnBot.env"
|
||||
MNEMONIC_FILE="$ROOT_DIR/onchain/.secret.local"
|
||||
|
||||
FORK_URL=${FORK_URL:-"https://sepolia.base.org"}
|
||||
ANVIL_RPC="http://127.0.0.1:8545"
|
||||
|
|
@ -29,8 +30,10 @@ FORGE="$FOUNDRY_BIN/forge"
|
|||
CAST="$FOUNDRY_BIN/cast"
|
||||
ANVIL="$FOUNDRY_BIN/anvil"
|
||||
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"}
|
||||
DEPLOYER_ADDR="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
||||
DEFAULT_DEPLOYER_PK="0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
|
||||
DEFAULT_DEPLOYER_ADDR="0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-$DEFAULT_DEPLOYER_PK}
|
||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
||||
FEE_DEST="0xf6a3eef9088A255c32b6aD2025f83E57291D9011"
|
||||
WETH="0x4200000000000000000000000000000000000006"
|
||||
SWAP_ROUTER="0x94cC0AaC535CCDB3C01d6787D6413C739ae12bc4"
|
||||
|
|
@ -108,6 +111,29 @@ wait_for_http() {
|
|||
return 1
|
||||
}
|
||||
|
||||
set_deployer_credentials() {
|
||||
if [[ -n "$DEPLOYER_PK" && -n "$DEPLOYER_ADDR" ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ -f "$MNEMONIC_FILE" ]]; then
|
||||
local mnemonic
|
||||
mnemonic="$(tr -d '\n\r' < "$MNEMONIC_FILE")"
|
||||
if [[ -n "$mnemonic" ]]; then
|
||||
local derived_pk
|
||||
derived_pk="$("$CAST" wallet private-key --mnemonic "$mnemonic" \
|
||||
--mnemonic-derivation-path "m/44'/60'/0'/0/0")"
|
||||
local derived_addr
|
||||
derived_addr="$("$CAST" wallet address --private-key "$derived_pk")"
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-$derived_pk}
|
||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$derived_addr}
|
||||
fi
|
||||
fi
|
||||
|
||||
DEPLOYER_PK=${DEPLOYER_PK:-$DEFAULT_DEPLOYER_PK}
|
||||
DEPLOYER_ADDR=${DEPLOYER_ADDR:-$DEFAULT_DEPLOYER_ADDR}
|
||||
}
|
||||
|
||||
ensure_tools() {
|
||||
for cmd in "$ANVIL" "$FORGE" "$CAST" jq npm curl; do
|
||||
if ! command -v "$cmd" >/dev/null 2>&1; then
|
||||
|
|
@ -122,9 +148,9 @@ start_directories() {
|
|||
}
|
||||
|
||||
ensure_dependencies() {
|
||||
if [[ ! -d "$ROOT_DIR/ponder/node_modules" ]]; then
|
||||
if [[ ! -d "$ROOT_DIR/services/ponder/node_modules" ]]; then
|
||||
log "Installing ponder dependencies"
|
||||
pushd "$ROOT_DIR/ponder" >/dev/null
|
||||
pushd "$ROOT_DIR/services/ponder" >/dev/null
|
||||
npm install >>"$SETUP_LOG" 2>&1
|
||||
popd >/dev/null
|
||||
fi
|
||||
|
|
@ -151,9 +177,18 @@ start_anvil() {
|
|||
fi
|
||||
|
||||
log "Starting Anvil (forking $FORK_URL)"
|
||||
"$ANVIL" --fork-url "$FORK_URL" --chain-id 31337 --block-time 1 \
|
||||
--host 127.0.0.1 --port 8545 \
|
||||
>"$ANVIL_LOG" 2>&1 &
|
||||
local anvil_args=("--fork-url" "$FORK_URL" "--chain-id" 31337 "--block-time" 1 \
|
||||
"--host" 127.0.0.1 "--port" 8545)
|
||||
|
||||
if [[ -f "$MNEMONIC_FILE" ]]; then
|
||||
local mnemonic
|
||||
mnemonic="$(tr -d '\n\r' < "$MNEMONIC_FILE")"
|
||||
if [[ -n "$mnemonic" ]]; then
|
||||
anvil_args+=("--mnemonic" "$mnemonic")
|
||||
fi
|
||||
fi
|
||||
|
||||
"$ANVIL" "${anvil_args[@]}" >"$ANVIL_LOG" 2>&1 &
|
||||
echo $! >"$ANVIL_PID_FILE"
|
||||
|
||||
wait_for_rpc "$ANVIL_RPC"
|
||||
|
|
@ -194,7 +229,7 @@ extract_addresses() {
|
|||
deploy_block="$(jq -r '.receipts[0].blockNumber' "$run_file" | xargs printf "%d")"
|
||||
|
||||
# Create .env.local for Ponder with deployed addresses
|
||||
cat > "$ROOT_DIR/ponder/.env.local" <<EOF
|
||||
cat > "$ROOT_DIR/services/ponder/.env.local" <<EOF
|
||||
# Auto-generated by local_env.sh
|
||||
PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK
|
||||
KRAIKEN_ADDRESS=$KRAIKEN
|
||||
|
|
@ -310,7 +345,7 @@ start_ponder() {
|
|||
fi
|
||||
|
||||
log "Starting Ponder indexer"
|
||||
pushd "$ROOT_DIR/ponder" >/dev/null
|
||||
pushd "$ROOT_DIR/services/ponder" >/dev/null
|
||||
PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK npm run dev >"$PONDER_LOG" 2>&1 &
|
||||
popd >/dev/null
|
||||
echo $! >"$PONDER_PID_FILE"
|
||||
|
|
@ -335,6 +370,7 @@ start_frontend() {
|
|||
|
||||
start_environment() {
|
||||
ensure_tools
|
||||
set_deployer_credentials
|
||||
start_directories
|
||||
ensure_dependencies
|
||||
start_anvil
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
PONDER_NETWORK=BASE_SEPOLIA_LOCAL_FORK
|
||||
KRAIKEN_ADDRESS=0x56186c1e64ca8043def78d06aff222212ea5df71
|
||||
STAKE_ADDRESS=0x056e4a859558a3975761abd7385506bc4d8a8e60
|
||||
START_BLOCK=31438430
|
||||
START_BLOCK=31441844
|
||||
# Use PostgreSQL connection
|
||||
DATABASE_URL=postgresql://ponder:ponder_local@localhost/ponder_local
|
||||
DATABASE_SCHEMA=ponder_local_31438430
|
||||
DATABASE_SCHEMA=ponder_local_31441844
|
||||
Loading…
Add table
Add a link
Reference in a new issue