/** * Aster V3 EIP-712 typed-data builders. * * Pure functions — no side effects, no fs/fetch/env reads. * All field ordering and serialization matches the HypurrQuant_FE mainnet * production reference: AsterPerpAdapter.ts:456-700. * * Key conventions: * - Domain A (chainId=56) — master-signed ops: approveAgent, delAgent, approveBuilder * - Domain B (chainId=1666) — agent-signed per-order ops * - uint256 fields serialized as decimal strings (never BigInt) to survive JSON.stringify * - EIP-712 message keys are PascalCase; HTTP query-string keys are camelCase */ /** Domain A: used for master-signed ops (ApproveAgent, DelAgent, ApproveBuilder). */ export declare const ASTER_DOMAIN_A: { readonly name: "AsterSignTransaction"; readonly version: "1"; readonly chainId: 56; readonly verifyingContract: "0x0000000000000000000000000000000000000000"; }; /** Domain B: used for agent-signed per-request ops (order, cancel, leverage). */ export declare const ASTER_DOMAIN_B: { readonly chainId: 1666; readonly name: "AsterSignTransaction"; readonly version: "1"; readonly verifyingContract: "0x0000000000000000000000000000000000000000"; }; /** Domain B (testnet): chainId=714 per Aster V3 testnet docs. */ export declare const ASTER_DOMAIN_B_TESTNET: { readonly chainId: 714; readonly name: "AsterSignTransaction"; readonly version: "1"; readonly verifyingContract: "0x0000000000000000000000000000000000000000"; }; /** Returns the Domain B object for the requested network (testnet branches chainId). */ export declare function getAsterDomainB(testnet: boolean): typeof ASTER_DOMAIN_B | typeof ASTER_DOMAIN_B_TESTNET; /** EIP-712 types for Domain B order signing — single msg string (URL-encoded query string). */ export declare const ORDER_TYPES: { readonly Message: readonly [{ readonly name: "msg"; readonly type: "string"; }]; }; type Eip712Field = { name: string; type: string; }; type AsterChain = "Mainnet" | "Testnet"; export interface ApproveAgentParams { user: `0x${string}`; agentAddress: `0x${string}`; agentName: string; /** Unix milliseconds timestamp when the agent expires. Serialized as decimal string. */ expiredMs: number | string; canPerpTrade: boolean; canSpotTrade: boolean; canWithdraw: boolean; /** * Optional IP whitelist. Include (even as "") when defined and non-null. * Undefined/null = field omitted from EIP-712 struct. */ ipWhitelist?: string; /** Optional builder address. When present, Builder + MaxFeeRate are included. */ builder?: string; /** Required when builder is set. */ maxFeeRate?: string; /** Optional builder name. Independently gated by its own undefined-check. */ builderName?: string; /** Microsecond-precision nonce (Date.now() * 1000 + counter). Serialized as decimal string. */ nonceMicros: number | string; asterChain?: AsterChain; } /** * Build the EIP-712 typed-data payload for `POST /fapi/v3/approveAgent`. * * Field order in types array and message object matches HypurrQuant_FE * AsterPerpAdapter.ts:481-533 exactly: * AgentName, AgentAddress, [IpWhitelist?,] Expired, CanSpotTrade, CanPerpTrade, * CanWithdraw, [Builder?, MaxFeeRate?, BuilderName?,] AsterChain, User, Nonce */ export declare function buildApproveAgentTypedData(params: ApproveAgentParams): { domain: typeof ASTER_DOMAIN_A; types: { ApproveAgent: Eip712Field[]; }; primaryType: "ApproveAgent"; message: Record; }; export interface DelAgentParams { user: `0x${string}`; agentAddress: `0x${string}`; nonceMicros: number | string; asterChain?: AsterChain; } /** * Build the EIP-712 typed-data payload for `DELETE /fapi/v3/agent`. * * TODO: confirm DelAgent struct vs Aster docs at Step 0b spike. * HypurrQuant_FE does not implement a revoke/delAgent method — this is a * best-effort field set mirroring the ApproveAgent terminal fields (AgentAddress, * AsterChain, User, Nonce) without the permission booleans. */ export declare function buildDelAgentTypedData(params: DelAgentParams): { domain: typeof ASTER_DOMAIN_A; types: { DelAgent: Eip712Field[]; }; primaryType: "DelAgent"; message: Record; }; /** * Encode order parameters as a URL-encoded query string. * * Deterministic key order = insertion order of `orderParams` (JS object property * iteration order). Caller must pre-populate `user` and `nonce` (microseconds) * in the dict; this function does NOT inject defaults. * * Uses `URLSearchParams` for encoding consistency with Python * `urllib.parse.urlencode`. */ export declare function buildOrderQueryStringMsg(orderParams: Record): string; /** * Build the EIP-712 typed-data payload for agent-signed order requests. * * Domain B (chainId=1666 mainnet / 714 testnet), primaryType="Message", * single `msg` field containing the URL-encoded query string produced by * buildOrderQueryStringMsg. * * @param testnet When true, returns Domain B with chainId=714 per Aster V3 * testnet docs. Defaults to false (mainnet). */ export declare function buildOrderTypedData(orderParams: Record, testnet?: boolean): { domain: typeof ASTER_DOMAIN_B | typeof ASTER_DOMAIN_B_TESTNET; types: typeof ORDER_TYPES; primaryType: "Message"; message: { msg: string; }; }; export interface ApproveBuilderParams { builder: string; maxFeeRate: string; builderName?: string; user: `0x${string}`; nonceMicros: number | string; asterChain?: AsterChain; } /** * Build the EIP-712 typed-data payload for `POST /fapi/v3/approveBuilder`. * * Domain A (chainId=56), primaryType="ApproveBuilder". * Default-path field order from HypurrQuant_FE AsterPerpAdapter.ts:630-651: * Builder, MaxFeeRate, AsterChain, User, Nonce * `BuilderName` is a forward-compatible extension (HQ_FE omits it); included * only when explicitly provided so the default path stays byte-equivalent to * the production reference. * * Must be called BEFORE approveAgent so Aster fee attribution is set up * before the first order. */ export declare function buildApproveBuilderTypedData(params: ApproveBuilderParams): { domain: typeof ASTER_DOMAIN_A; types: { ApproveBuilder: Eip712Field[]; }; primaryType: "ApproveBuilder"; message: Record; }; export {};