Skip to content

DEV->STG - #64

Merged
shev-titan merged 244 commits into
stgfrom
dev
Sep 20, 2026
Merged

shev-titan merged 244 commits into
stgfrom
dev

Conversation

@lsheva

@lsheva lsheva commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Summary

Promotes dev → stg (232 commits). This repo had no stg branch; it was created from main (9d82ff02, 2026-04-30: Vault 1.0.1, PME 1.0.0) so this PR can follow the same dev → stg cut as the other venues.

dev is CollateralVault 1.1.0 and PortfolioMarginEngine 2.1.0, plus the unified keeper, portfolio market maker, and points subgraph that staging CI already expects on push to stg.

Contracts

  • Portfolio margin engine 2.1.0: portfolio-wide order stress, PnL netting, shared margin model with Futures/Perps (isLiquidatable lives here). Venue integrations converged in refactor: converge portfolio risk and venue integrations #59.
  • Vault 1.1.0: token resolved through the vault; no HashpriceUSD unit rebase in keeper/MM.
  • Points program: Points / PointsHook / PointsRedeemer + leaderboard subgraph (hpow-points). Maker price-improvement multiplier.
  • Delivery disabled on the vault/keeper path (cash-settled venues).

Keeper (replaces perps-only keeper)

  • Unified cross-venue liquidator (perps + futures + vault/PME) on ECS.
  • Liquidate-to-IM-buffer; submits via updateOrders; expiry-scoped futures discovery; startup liveness endpoint.
  • HashpriceUSD 1 PH/s·day (no oracle rebase). Bedrock scaffolding + GHA deploy to dev / stg / main.

Market maker

  • One portfolio MM quotes perps and every selected futures expiry on a shared signer/vault (legacy perps MM in derivatives-marketplace is off).
  • Limit LOB (drop exact-match), updateOrders + reduce-only amends, geometric-taper / expiry size decay, band+size allowances to cut requote churn, self-match cancel, human health endpoint.

Indexer / ABI / CI

  • Collateral-vault subgraph + points subgraph deploys.
  • @hashpower/collateral-abi with semver-aware CI (OIDC) and hashpower.io rebuild dispatch.
  • pnpm 11.22, Biome, Hardhat 3.9.1, Node 24 Actions.

Upgrade / cutover notes

  • First stg branch. Creating it from main may have queued keeper/MM/subgraph workflows against the April snapshot; cancel those if they are still running, then merge this PR (or workflow_dispatch with environment=stg) so STG gets current dev.
  • Confirm Vault 1.1.0 and PME 2.1.0 after upgrade. Pair with futures-marketplace #287 and derivatives-marketplace dev→stg (Perps 6.5.0) — keeper/MM ABIs target those venues.
  • Point STG GitHub environment vars at stg vault/PME/perps/futures/HASHPRICE_USD_ADDRESS.
  • Rebuild vault + points subgraphs from the new start blocks.

Test plan

  • cd contracts && pnpm test
  • Keeper + MM unit/image tests; cancel any accidental April-snapshot STG deploys
  • Staging upgrade (or fresh deploy): Vault 1.1.0, PME 2.1.0
  • Goldsky: collateral-vault + points subgraphs healthy
  • Keeper health/liveness on stg; discovers both venues; dry-run then live liquidations
  • Portfolio MM quotes both sides on perps and selected futures expiries; no self-match leftover
  • Deposit/withdraw via vault (permit path on the UI) updates PME health

shev-titan and others added 30 commits May 1, 2026 12:34
Adds an ERC-2612 permit entry point to CollateralVault so callers can
deposit on behalf of any recipient in a single tx without a prior
approve, mirroring the pattern previously living on HashPowerPerpsDEX.
Also opens up depositFor to the public so non-authorized callers can
fund recipients.

Covered by 5 new tests: happy path, distinct recipient, expired
deadline, signature/sender mismatch, and replay protection.
Adds a standalone subgraph that indexes the CollateralVault contract:
deposits, withdrawals, the insurance fund, and internal transfers
(bucketed into PERPS / OPTIONS / OTHER via dataSource.context()).

CI: indexer-tests.yml runs codegen/build/matchstick on every PR;
deploy-subgraph.yml builds, pushes to Goldsky, rolls a per-env tag
(dev-latest / stg-latest / lmn-latest), verifies the deployment, and
notifies Slack — modeled on hashprice-oracle's deploy-subgraph workflow
and reusing its gen-tag / slack-notify composite actions.
… API key

- Replaced `ETH_NODE_ADDRESS` with `ALCHEMY_API_KEY` in various configuration files for futures and perps environments.
- Updated README and schema files to reflect changes in required environment variables.
- Adjusted pricing and risk parameters across multiple configuration files for consistency and clarity.
- Enhanced event handling in the futures and perps adapters to improve code readability and maintainability.
…et maker

Provisions perps and futures market-maker ECS services per env
(dev/stg/lmn) sharing the derivatives marketplace ECS cluster via
Terraform data lookup. Each venue gets its own ALB, target group,
Route53 record (perpsmm.{env}.hashpower.exchange and
futuresmm.{env}.hashpower.exchange), CloudWatch log group, monitoring
stack, and OIDC GitHub Actions IAM scope.

Terraform is scaffolding-only: task definitions ship a stub busybox
container with desired_count=0 and lifecycle.ignore_changes on
task_definition + container_definitions. The new deploy-col-mar-mm.yml
workflow builds the image from market-maker/, pushes to GHCR, and
registers a new task-def revision per venue with image + env vars from
GitHub Variables and secrets from GitHub Secrets. No AWS Secrets
Manager dependency.

Secrets flow into the deploy step's env block via inline ternaries
(matrix.app == 'perps' && SECRET_A || SECRET_B); they are never written
to step outputs or to disk on the runner.

DEV environment activated for both venues. STG and LMN scaffolding is
in place but services have create=false pending operator readiness.

Co-authored-by: Cursor <cursoragent@cursor.com>
feat(infra): bedrock terraform + GHA deploy for col-mar market maker
- Updated Dockerfile to use Node 24-alpine for dependencies and runtime.
- Modified docker-entrypoint.sh to include TypeScript conditions in the Node execution.
- Enhanced package.json scripts to utilize pnpm and added watch functionality for local development.
fix: update dockerfile, fix type stripping
- Updated Dockerfile to use Node 24-alpine for dependencies and runtime.
- Modified docker-entrypoint.sh to include TypeScript conditions in the Node execution.
- Enhanced package.json scripts to utilize pnpm and added watch functionality for local development.
fix: update dockerfile, fix type stripping
- Changed the dependency for `collateral-margin-contracts` to point to the GitHub repository.
- Added `@sinclair/typebox` to dependencies in `package.json`.
- Updated `pnpm-lock.yaml` to reflect the new dependency structure and versions.
- Included additional configurations for `pnpm` to manage built dependencies.
- Updated the HealthCheck implementation in both futures and perps applications to use the new sanitiseConfig function, ensuring sensitive information is redacted in the health output.
- Removed the summariseConfig function as it is no longer needed.
- Enhanced the sanitiseConfig function to redact private keys and mask RPC URLs for security.
refactor: replace config summary with sanitised version in health checks
- Introduced perps_health_url and futures_health_url outputs in the deployment workflow for enhanced health check visibility.
- Updated additional_info to include health check links in the deployment summary for better monitoring.
feat: add health URLs to deployment workflow
- Changed the formatting of additional_info in the deployment workflow to improve readability and structure.
- Ensured health check URLs are displayed more clearly in the deployment summary.
refactor: update additional_info formatting in deployment workflow
feat: hashprice subgraph integration for historical price query for v…
fix: add missing HASHPRICE_ORACLE_SUBGRAPH_URL var
shev-titan and others added 13 commits August 17, 2026 18:01
pnpm 11 stopped reading build allowances from package.json and turned ignored
build scripts into a hard install error. The allowances were moved to
market-maker/pnpm-workspace.yaml, but the deps stage only copies package.json
and pnpm-lock.yaml, so `pnpm install --frozen-lockfile --prod` still aborted
with ERR_PNPM_IGNORED_BUILDS and no image was published.

That left the dev market-maker pinned to a 10-day-old image whose futures
own-order bootstrap still calls the removed `getUserOrders`, quarantining every
futures expiry.
…pace

fix(mm): ship pnpm-workspace.yaml into the Docker deps stage
chore: adopt pnpm 11.22 at the repo root
Pass the optional startup anchor into ECS so keeper restarts can rediscover existing participants without treating an unset value as block zero.
Rebuild bounded per-expiry caches on startup so liquidation and settlement discover pre-existing Futures users without deployment-wide history scans.
feat(keeper): add expiry-scoped futures discovery
Keep ECS health checks responsive while historical indexing runs, and gate readiness until the initial sweep completes.
fix(keeper): expose liveness during startup
Load per-environment config from config/<name>.env with machine-local
override files, and wire npm scripts to --env.
Document the secret keys expected in override env files for local and CI use.
Opens the same abi-published event the site already consumes, on the matching branch (dev or main).

Co-authored-by: Cursor <cursoragent@cursor.com>
Pre-wire the npm publish workflow so a later dev→main promotion does not need a branch-filter edit.

Co-authored-by: Cursor <cursoragent@cursor.com>
ci: dispatch ABI publishes to MCP and publish from main
shev-titan and others added 5 commits September 17, 2026 21:17
NETWORK meant three different things: the keeper required base-mainnet,
the subgraph manifests and market-maker YAML used base, and the Hardhat
config declared a network literally named base-mainnet. The GitHub
environment that deploys mainnet already sets NETWORK=base, so the
keeper and Hardhat were the outliers.

Settle on base / base-sepolia / hardhat everywhere. The keeper still
accepts base-mainnet as a deprecated alias, since task definitions
registered before this change carry it, and keeps Alchemy's own
base-mainnet spelling for the RPC subdomain.
Contract addresses, start blocks and runtime knobs were duplicated
across GitHub environment variables, the deploy workflows and ad-hoc
loaders, so the same value could disagree between local runs, the
subgraphs and ECS.

Make config/dev.env and config/prd.env the single source for public
values, and have every consumer read them: the keeper and market-maker
via node --env-file, the subgraph renderers via ENV_FILE, and the
deploy workflows by sourcing the file. Secrets stay in the repo-root
.env locally and in GitHub Secrets in CI; both still win, because the
real environment takes precedence over --env-file.

The two ECS workflows built their environment block by naming each
variable four times: once in the step env, once as a jq --arg, once in
the jq object, and once more as a :- default. They now derive the block
from the keys declared in the config file and name only secrets and
computed values, so a public setting is written exactly once. Empty
values are dropped so apps apply their own defaults, which were checked
to match the defaults the workflows used to hardcode.

Also drop the market-maker's custom dotenv loader in favour of
--env-file, disable the stg deploy path, and remove a dead compose
script in points-indexer.

config/prd.env is still missing the mainnet addresses and start blocks;
they exist nowhere in GitHub either, and are marked with TODOs.
pnpm runs scripts with sh, which is dash on the CI runners. POSIX `.`
searches PATH when its operand contains no slash, so `ENV_FILE=.env.example`
failed with ".env.example: not found" while passing locally, where
/bin/sh is bash and falls back to the current directory.

Prefix a bare filename with ./ before sourcing, leaving paths that
already contain a slash untouched.
feat: single source of truth for public config in config/<env>.env
shev-titan and others added 2 commits September 17, 2026 23:04
An empty VAULT_START_BLOCK rendered as null in the manifest, which Goldsky rejects as an invalid i32.
fix(config): set subgraph start blocks so Goldsky can deploy
@shev-titan
shev-titan merged commit 1583077 into stg Sep 20, 2026
32 of 33 checks passed

This branch had an error being deployed

1 failed (outdated) and 1 active deployments
dev — 8533436d Deployed Sep 17, 2026 by shev-titan via 🚀 Deploy portfolio #40
npm-publish — df1b6f65 Deployed Sep 15, 2026 by abs2023 via 📦 Build & publish to npm #11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants