Deploy Aethr
Deploy the contracts, the API and the keepers in seven steps.
This repository is the complete backend of an Aethr on Elysium (chain id 99901): the smart contracts, the API a frontend talks to, and the keepers that run the protocol. You deploy it once; after that it runs by itself.
What's inside
| Part | What it does |
|---|---|
| Lending contracts | Supply, borrow, repay, withdraw, collateral, interest, liquidations, insurance, bad-debt accounting |
| Price + risk engine | Prices, order books and liquidity straight from HyperCore (no oracle); lowers LTVs when liquidity is thin |
| Liquidation engine | Finds unhealthy positions, sells collateral on HyperCore, repays debt with confirmed proceeds |
| Fee engine | Collects your Montra token's creator fees and splits them 40% insurance / 25% protocol liquidity / 15% supplier rewards / 10% borrower rebates / 10% liquidation fund |
| API | REST + WebSocket for the frontend: wallet sign-in, markets, positions, unsigned transactions, notifications |
Frontend work? Give your AI agent AGENTS.md and skip to step 6.
#1. What you need
- Node 22+ and pnpm (
npm i -g pnpm) - An Elysium RPC URL, e.g. from Alchemy
- A Postgres database URL, e.g. from Neon
- Four wallets with some HYPE on Elysium for gas: a deployer and three keepers (reporter, liquidator, allocator). One wallet for all three keepers also works, but separate ones are safer.
- The liquidator also needs some USDC and WHYPE on Elysium. It repays debt from this balance during liquidations, and gets the seized collateral back.
- The wallet that launched the Montra token (or whoever receives its creator fees now)
#2. Install and configure
pnpm install
pnpm contracts:compile
cp .env.example .envIn .env, set at least:
NETWORK=mainnet
RPC_URL=https://elysium-mainnet.g.alchemy.com/v2/<key>
DATABASE_URL=postgresql://…
REPORTER_PRIVATE_KEY=0x…
LIQUIDATOR_PRIVATE_KEY=0x…
ALLOCATOR_PRIVATE_KEY=0x…
MONTRA_TOKENS=0x<your Montra token address>#3. Rehearse on a copy of mainnet (recommended, free)
This runs the real deployment against a local copy of Elysium mainnet. Nothing is sent to the real chain.
pnpm chain:fork # terminal 1: local copy of mainnet on :8546
# terminal 2 (the key below is a public test key that only works on the local copy):
NETWORK=mainnet RPC_URL=http://127.0.0.1:8546 CONFIRM_MAINNET_DEPLOY=yes \
DEPLOYER_PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 \
DEPLOYMENT_FILE=/tmp/rehearsal.json pnpm deploy:contractsIf it ends with Deployment written to /tmp/rehearsal.json, the real deployment will work too.
#4. Deploy the contracts
NETWORK=mainnet CONFIRM_MAINNET_DEPLOY=yes DEPLOYER_PRIVATE_KEY=0x… pnpm deploy:contractsThis takes about a minute. It:
- deploys and wires every contract;
- lists USDC and WHYPE;
- grants your keeper wallets their roles;
- registers your Montra token as a fee source;
- writes every address to
deployments/mainnet.json.
Commit that file: the server reads it.
CONFIRM_MAINNET_DEPLOY=yes is there on purpose: the contracts have not been audited yet.
See "Before real users" below.
#5. Point the Montra creator fees at the protocol
Check where the fees go now:
pnpm montra status 0x<token>Then switch them. This is signed by the token's current fee recipient:
CREATOR_PRIVATE_KEY=0x… pnpm montra route 0x<token> # shows what it will do
CREATOR_PRIVATE_KEY=0x… pnpm montra route 0x<token> --yes # does itFrom then on the backend claims the fees automatically (in HYPE) and distributes them. The creator wallet stops receiving them. Fees that are already waiting when you switch go to the protocol too.
#6. Host the backend
It is a normal long-running server, so it needs an always-on host, not serverless. Railway is the simplest:
- New project → Deploy from GitHub repo → pick this repository. It finds the
Dockerfile. - Under Variables, add everything from your
.env, plus:NODE_ENV=production JWT_SECRET=<run: openssl rand -hex 48> SIWE_DOMAINS=yourapp.xyz # the frontend's domain CORS_ORIGINS=https://yourapp.xyz TRUST_PROXY=1 - Under Settings → Networking, generate a domain, and set the health check path to
/readyz. - Check it:
API_URL=https://aethr-api.vercel.app pnpm smoke
Fly.io, Render or any VM also work: docker build . and run it with the same variables.
Interactive API docs are at https://aethr-api.vercel.app/docs.
#7. Connect the frontend
Open the frontend project in your AI coding tool and tell it:
Read
AGENTS.mdin the backend repo and wire this frontend to the API athttps://aethr-api.vercel.app.
#Day to day
GET /v1/feesshows the Montra fees collected and where they went.GET /v1/statsshows total supply, debt, insurance and bad debt.GET /v1/admin/statusshows keeper gas balances; sign in with a wallet listed inADMIN_ADDRESSES.- Keep HYPE in the keeper wallets, and USDC and WHYPE in the liquidator.
docs/OPERATIONS.mdcovers monitoring and what to do if something goes wrong.
#Before real users
The code is tested: 280+ tests, a security review with every finding fixed, and a full rehearsal on a copy of mainnet. These items are still open:
- The contracts are not audited. Get an independent audit before other people deposit money.
- Admin keys. The deployer wallet controls everything. Move the admin roles to a multisig (e.g. Safe) before launch.
- Liquidations are simulated by default. They are priced against the real order book,
but no order is placed on HyperCore. The real-order mode (
LIQUIDATION_VENUE=hyperliquid) needs a trial with a funded HyperCore account first. - Risk settings are sensible defaults (
src/config/markets.ts). Review them for your launch.