/** * Synthetix Perps V3 — Perpetual futures on Base (Andromeda) * * Flow: USDC → wrap to sUSDC → deposit margin → commit order → settle * * Architecture: * PerpsMarketProxy handles accounts, margin, and orders * SpotMarketProxy wraps USDC into sUSDC (1:1, zero fee) * PythERC7412Wrapper provides oracle prices for settlement * TrustedMulticallForwarder batches oracle update + settle * * Contracts (Base mainnet): * PerpsMarketProxy: 0x0A2AF931eFFd34b81ebcc57E3d3c9B1E1dE1C9Ce * SpotMarketProxy: 0x18141523403e2595D31b22604AcB8Fc06a4CaA61 * CoreProxy: 0x32C222A9A159782aFD7529c87FA34b96CA72C696 * sUSDC: 0xC74eA762cF06c9151cE074E6a569a5945b6302E7 * USDC: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 * TrustedMulticallForwarder: 0xE2C5658cC5C448B48141168f3e475dF8f65A1e3e * PythERC7412Wrapper: 0x9Cb0B428632fc7dC56FDf453aEd890BA55B1953a */ import { ethers } from 'ethers'; export declare const SYNTHETIX_CONTRACTS: { readonly PERPS_MARKET_PROXY: "0x0A2AF931eFFd34b81ebcc57E3d3c9B1E1dE1C9Ce"; readonly SPOT_MARKET_PROXY: "0x18141523403e2595D31b22604AcB8Fc06a4CaA61"; readonly CORE_PROXY: "0x32C222A9A159782aFD7529c87FA34b96CA72C696"; readonly SUSDC: "0xC74eA762cF06c9151cE074E6a569a5945b6302E7"; readonly USDC: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"; readonly MULTICALL_FORWARDER: "0xE2C5658cC5C448B48141168f3e475dF8f65A1e3e"; readonly PYTH_ERC7412_WRAPPER: "0x9Cb0B428632fc7dC56FDf453aEd890BA55B1953a"; }; export declare const PERPS_MARKET_ABI: string[]; export declare const SPOT_MARKET_ABI: string[]; export declare const PERPS_MARKETS: Record; export type PerpSide = 'long' | 'short'; export interface PerpOrder { /** Market symbol (ETH, BTC, SOL, etc.) */ market: string; /** Long or short */ side: PerpSide; /** Size in base asset (e.g. '0.1' = 0.1 ETH) */ size: string; /** USDC margin to deposit */ margin: string; /** Max acceptable slippage in basis points (default: 100 = 1%) */ slippageBps?: number; } export interface PerpPosition { marketId: number; market: string; size: string; pnl: string; funding: string; margin: string; } export interface PerpAccountInfo { accountId: string; margin: string; availableMargin: string; positions: PerpPosition[]; } /** * Build calls to create a Synthetix perps account. * Returns the createAccount call for the PerpsMarketProxy. */ export declare function buildCreateAccountCall(): { to: string; data: string; value: string; }; /** * Build calls to wrap USDC → sUSDC and deposit as perps margin. * * Steps: * 1. Approve USDC to SpotMarketProxy * 2. Wrap USDC → sUSDC (1:1, zero fee) * 3. Approve sUSDC to PerpsMarketProxy * 4. modifyCollateral (deposit sUSDC as margin) */ export declare function buildDepositMarginCalls(usdcAmount: bigint, accountId: bigint): Array<{ to: string; data: string; value: string; }>; /** * Build the commitOrder call for opening/modifying a perp position. * * @param order - Order parameters * @param accountId - Synthetix perps account ID * @param indexPrice - Current index price (18 decimals) for slippage calc */ export declare function buildCommitOrderCall(order: PerpOrder, accountId: bigint, indexPrice: bigint): { to: string; data: string; value: string; }; /** * Build the withdraw margin calls: withdraw sUSDC → unwrap to USDC. */ export declare function buildWithdrawMarginCalls(susdcAmount: bigint, accountId: bigint): Array<{ to: string; data: string; value: string; }>; /** * Read perps account info from chain. */ export declare function getAccountInfo(accountId: bigint, provider: ethers.JsonRpcProvider): Promise; /** * Get the current index price for a market (18 decimals). */ export declare function getIndexPrice(market: string, provider: ethers.JsonRpcProvider): Promise; /** * Get order fees and fill price for a potential order. */ export declare function computeOrderFees(market: string, size: string, side: PerpSide, provider: ethers.JsonRpcProvider): Promise<{ fees: string; fillPrice: string; }>;