Skip to content

Latest commit

 

History

History
212 lines (149 loc) · 5.09 KB

File metadata and controls

212 lines (149 loc) · 5.09 KB

LiYield Development

Monorepo Layout

  • packages/contracts: Foundry contracts
  • packages/server: Hono + TypeScript backend
  • apps/web: Next.js frontend

Ways To Run The Project

Recommended: full local demo

npm install
npm run demo

npm run demo automatically:

  • starts anvil
  • deploys local contracts
  • exports the local development environment variables
  • starts the server
  • starts the web app

Use this when you want the full local flow without manual setup.

App-only development

npm run dev

That command only runs:

  • npm run server:dev
  • npm run web:dev

It does not start a local chain or deploy contracts.

Manual startup

anvil
export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
export LIYIELD_RPC_URL=http://127.0.0.1:8545
npm run manage -- deploy --private-key $PRIVATE_KEY --rpc-url $LIYIELD_RPC_URL
export LIYIELD_KEEPER_DEPLOYMENT_FILE=packages/contracts/deployments/contracts.local.json
npm run server:dev
npm run web:dev

Deployment File And Private Keys

Default deployment manifest

The current code defaults to:

packages/contracts/deployments/contracts.base.json

For local anvil development, you will usually want:

export LIYIELD_KEEPER_DEPLOYMENT_FILE=packages/contracts/deployments/contracts.local.json

Private-key fallback rules

  • keeper: LIYIELD_KEEPER_PRIVATE_KEY -> PRIVATE_KEY
  • oracle: LIYIELD_ORACLE_PRIVATE_KEY -> LIYIELD_KEEPER_PRIVATE_KEY -> PRIVATE_KEY
  • term manager: LIYIELD_TERM_MANAGER_PRIVATE_KEY -> LIYIELD_KEEPER_PRIVATE_KEY -> PRIVATE_KEY

The simplest local setup is:

export PRIVATE_KEY=0xyour_private_key

Default Background Services

When the server boots, it can start these schedulers:

  • ETF snapshot and price refresh
  • Earn snapshot persistence
  • keeper scheduler
  • oracle valuation scheduler
  • market oracle scheduler
  • term lifecycle scheduler

These are enabled by default unless the corresponding LIYIELD_*_ENABLED variable is explicitly set to false.

Common Environment Variables

Chain and signing

  • PRIVATE_KEY
  • LIYIELD_KEEPER_PRIVATE_KEY
  • LIYIELD_ORACLE_PRIVATE_KEY
  • LIYIELD_TERM_MANAGER_PRIVATE_KEY
  • LIYIELD_RPC_URL
  • LIYIELD_RPC_URL_<chainId>
  • LIYIELD_KEEPER_DEPLOYMENT_FILE

Background job toggles

  • LIYIELD_AUTO_REFRESH_ENABLED
  • LIYIELD_EARN_SNAPSHOT_ENABLED
  • LIYIELD_KEEPER_SCHEDULER_ENABLED
  • LIYIELD_ORACLE_SCHEDULER_ENABLED
  • LIYIELD_MARKET_ORACLE_SCHEDULER_ENABLED
  • LIYIELD_TERM_SCHEDULER_ENABLED

Automatic on-chain publishing

  • LIYIELD_ORACLE_AUTO_PUBLISH_ENABLED
  • LIYIELD_MARKET_ORACLE_AUTO_PUBLISH_ENABLED
  • LIYIELD_TERM_AUTO_CONFIGURE_ONCHAIN_ENABLED

External data sources

  • LIFI_API_KEY
  • LIFI_API_BASE_URL
  • LIFI_EARN_API_BASE_URL

Web app

The frontend calls relative /api/... paths by default.

If you set NEXT_PUBLIC_API_BASE, the browser will call that API origin directly:

NEXT_PUBLIC_API_BASE=https://api.example.com

For local override:

cd apps/web
echo 'NEXT_PUBLIC_API_BASE=http://127.0.0.1:8787' > .env.local

If NEXT_PUBLIC_API_BASE is not set, the frontend does not default to localhost. In that case, /api must be handled by your external reverse proxy on the same origin.

The web dev server port is controlled by WEB_PORT and defaults to 3030. This is intentionally separate from the backend PORT env var, so a deployment environment that sets PORT=8787 does not force Next.js onto the backend port.

cd apps/web
echo 'WEB_PORT=3030' >> .env.local

If you open the page on http://localhost:3030 without NEXT_PUBLIC_API_BASE, browser requests should appear as /api/... on the web origin. If you set NEXT_PUBLIC_API_BASE=http://127.0.0.1:8787, browser requests will go directly to http://127.0.0.1:8787/api/....

Main Server Responsibilities

  • maintain ETF, strategy, and target registries
  • build ETF snapshots and price history
  • wrap LI.FI Earn data
  • generate and execute keeper allocation and rebalance flows
  • generate valuation, settlement, and market-state data
  • manage term lifecycle

Main API Groups

ETF / Index

  • GET /api/etfs
  • GET /api/index
  • GET /api/etfs/:etfId/price
  • GET /api/etfs/:etfId/price/history

Earn

  • GET /api/earn/targets
  • GET /api/earn/vaults
  • GET /api/earn/portfolio/:address
  • GET /api/earn/snapshots

Keeper

  • POST /api/keeper/allocation-plan
  • POST /api/keeper/execute-allocation-plan
  • POST /api/keeper/execute-rebalance
  • POST /api/keeper/reconcile-runs
  • GET /api/keeper/runs

Oracle / Term

  • POST /api/oracle/valuation-report
  • POST /api/oracle/auto-valuation
  • POST /api/oracle/market-state
  • GET /api/oracle/market-states
  • GET /api/oracle/term-apy-curve
  • GET /api/oracle/term-status
  • POST /api/oracle/settlement-report
  • POST /api/oracle/settlement-from-valuations
  • POST /api/oracle/auto-settlement

Admin

  • POST /api/admin/refresh
  • POST /api/admin/earn-snapshot

Related Docs