Synthetic stocks + perps. Mint/redeem on-chain, trade gasless via Yellow. Equinox protocol.
Equinox is a full-stack DeFi protocol for synthetic assets and perpetuals, with trading focused on Yellow Network. Mint & Redeem: Users deposit USDC into a Vault contract (Sepolia) to mint synthetic tokens (sTSLA, sAAPL) or redeem them for USDC. The protocol hedges new exposure by opening positions in the on-chain PerpEngine. Mint and redeem use a ChainlinkManager for prices and fee logic. Trading (Yellow only): Users trade perpetuals via the Yellow Channel. They connect their wallet, send USDC once to the backend (on-chain tx), then open/increase/reduce/close positions through the Trade ⚡ Yellow UI. Each action is an API call—no per-trade gas. A Yellow Backend (yellowB) keeps an off-chain balance ledger and position engine, applies the same fee/leverage/funding logic as the on-chain PerpEngine, and syncs state to Yellow Network via Nitrolite (ClearNode WebSocket, app sessions, submit_app_state, close_app_session). A settlement loop runs periodically: applies funding and borrowing fees, builds final app state, submits it to Yellow, closes the app session, then opens a new one so trading can continue. Liquidity: Users can deposit/withdraw/claim from a LiquidityPool on Sepolia. In short: Equinox lets you mint and redeem synthetic stocks (sTSLA, sAAPL) with USDC and trade perpetuals gaslessly via Yellow’s state-channel layer, with canonical state and settlement on Yellow Network.
Frontend: Next.js 15 (App Router), React 19, RainbowKit + wagmi + viem for wallet connection and contract calls, Tailwind CSS, Framer Motion, TanStack Query. Pages: /mint, /redeem, /trade-yellow, /yellow (dashboard), /liquidity (deposit/withdraw/claim). The UI talks to the Yellow backend over REST (e.g. POST /trade/open, /trade/close, /yellow/deposit) and uses viem for the one-off USDC transfer to the backend wallet. Contracts: Solidity 0.8.x, Hardhat, OpenZeppelin (ReentrancyGuard, Math, IERC20). Chainlink: Functions (TSLA/AAPL/MarketStatus oracles calling Alpha Vantage), CCIP (VaultContractSender, ReceiverContract for cross-chain), ChainlinkManager aggregating oracles and DEX prices for the Vault and PerpEngine. Core contracts: Vault (mint/redeem, buffer + hedge collateral, openVaultHedge to PerpEngine), PerpEngine (margin, positions, liquidations, fees), LiquidityPool, sTSLA/sAAPL assets. Deployed on Sepolia with a Chainlink Functions subscription. Yellow backend (yellowB): Node.js, Express 5, TypeScript (ESM, ts-node with --loader). Uses @erc7824/nitrolite for Yellow: WebSocket client to ClearNode (sandbox), EIP-712 auth, payment channel (create/resize), app sessions (create, get, submit state, close session). viem for Sepolia RPC (e.g. reading transaction receipts). Structure: engine/ — balances.ts (ledger), positions.ts (DB + PnL, net exposure), trading.ts (open/increase/reduce/close, fees, liquidations), oracle.ts (Alpha Vantage for TSLA/AAPL/ETH/BTC, same scale as PerpEngine), settlement.ts (funding model, PsiXAppState build, serializeAppState, submitAppState + closeAppSession, interval ~5 min). Deposit flow: User sends USDC to a fixed backend wallet; frontend sends txHash to POST /yellow/deposit; backend uses viem to get the receipt and parses Transfer logs for the USDC contract to verify amount and recipient, then credits the balance ledger (idempotent by txHash). State: Positions and balances stored in JSON files and in Yellow via PsiXAppState (positions, globalNetDelta, totalMarginLocked) signed with the session key and sent with submit_app_state / close_app_session. Notable / hacky: (1) Off-chain oracle parity: Yellow engine uses Alpha Vantage directly so execution and funding prices match what the on-chain oracles (Chainlink Functions → Alpha Vantage) would see. (2) Deposit verification: No custom events—we parse the standard ERC20 Transfer(from, to, value) from the receipt logs and enforce to === backendWallet and value > 0. (3) Session lifecycle: One active app session; after each settlement we call close_app_session then lazily ensureAppSession on the next trade so Yellow has a clear final state per interval. (4) Same economics on- and off-chain: Fee and leverage logic in yellowB is aligned with PerpEngine.sol so mint/redeem hedging and Yellow trading are consistent. Monorepo: Single repo with frontend-V1, new-cont, yellowB; root uses Turbo for build/dev/lint.

