@depthhq/maker-sdk 0.0.0-stage → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,24 @@
1
+ import type { AbstractWallet } from "@nktkas/hyperliquid/signing";
2
+ import type { MakerClient } from "../client/client.js";
3
+ import { WalletSession } from "../hedge/access.js";
4
+ import { type AutomationConfig, type AutomationView } from "./types.js";
5
+ export declare class MakerAutomation extends WalletSession {
6
+ private readonly maker;
7
+ constructor(maker: MakerClient);
8
+ private view;
9
+ summary(): Promise<AutomationView | null>;
10
+ configure(config: AutomationConfig, revision?: number): Promise<AutomationView>;
11
+ approve(profile: AutomationView, options?: {
12
+ grantSeconds?: number;
13
+ operatorFundingLamports?: bigint;
14
+ hedgeWallet?: AbstractWallet;
15
+ }): Promise<{
16
+ profile: AutomationView;
17
+ signatures: string[];
18
+ }>;
19
+ private waitFunding;
20
+ private command;
21
+ start(revision?: number): Promise<AutomationView>;
22
+ pause(revision?: number): Promise<AutomationView>;
23
+ resume(revision?: number): Promise<AutomationView>;
24
+ }
@@ -0,0 +1,40 @@
1
+ import { type BotPolicy } from "../bot/policy.js";
2
+ import type { HedgePolicy } from "../hedge/types.js";
3
+ import type { MakerHedgeView } from "../hedge/access.js";
4
+ export type AutomationConfig = {
5
+ quote: BotPolicy;
6
+ hedge?: {
7
+ account: `0x${string}`;
8
+ policy: HedgePolicy;
9
+ };
10
+ };
11
+ export type Wire<T> = T extends bigint ? string : T extends object ? {
12
+ [K in keyof T]: Wire<T[K]>;
13
+ } : T;
14
+ export type AutomationView = {
15
+ owner: string;
16
+ environment: "devnet" | "mainnet-beta";
17
+ revision: number;
18
+ operator: string;
19
+ agent: `0x${string}`;
20
+ config: Wire<AutomationConfig>;
21
+ desired: "running" | "paused";
22
+ phase: "configured" | "starting" | "running" | "pausing" | "paused" | "blocked";
23
+ updatedAt: number;
24
+ reason?: string;
25
+ bot?: {
26
+ phase: "active" | "pending" | "idle" | "stopped";
27
+ reason?: string;
28
+ quoteId?: string;
29
+ fillCount: number;
30
+ };
31
+ hedge: MakerHedgeView;
32
+ funding?: {
33
+ signature: string;
34
+ lamports: string;
35
+ status: "pending" | "confirmed" | "expired" | "failed";
36
+ };
37
+ };
38
+ export declare function automationConfig(value: unknown): AutomationConfig;
39
+ export declare const automationWire: (config: AutomationConfig) => Wire<AutomationConfig>;
40
+ export declare function automationView(value: unknown, owner: string, environment: string): AutomationView | null;
@@ -0,0 +1,35 @@
1
+ import { PublicKey } from "@solana/web3.js";
2
+ import type { MakerClient } from "../client/client.js";
3
+ import type { BackstopInput } from "../client/types.js";
4
+ export type BackstopSnapshot = {
5
+ offerId: PublicKey;
6
+ status: string;
7
+ capacity: bigint;
8
+ margin: bigint;
9
+ expiresAt: number;
10
+ };
11
+ type ConfirmOptions = {
12
+ timeoutMs?: number;
13
+ pollMs?: number;
14
+ };
15
+ export declare class BackstopHandle {
16
+ readonly id: PublicKey;
17
+ private readonly client;
18
+ readonly signature?: string | undefined;
19
+ constructor(id: PublicKey, client: MakerClient, signature?: string | undefined);
20
+ static offer(client: MakerClient, input: BackstopInput): Promise<BackstopHandle>;
21
+ status(): Promise<BackstopSnapshot>;
22
+ confirm(options?: ConfirmOptions): Promise<{
23
+ offerId: PublicKey;
24
+ snapshot: BackstopSnapshot;
25
+ }>;
26
+ release(): Promise<BackstopRelease>;
27
+ close(): Promise<string>;
28
+ }
29
+ export declare class BackstopRelease {
30
+ private readonly offer;
31
+ readonly signature?: string | undefined;
32
+ constructor(offer: BackstopHandle, signature?: string | undefined);
33
+ confirm(options?: ConfirmOptions): Promise<BackstopSnapshot>;
34
+ }
35
+ export {};
@@ -0,0 +1,42 @@
1
+ import type { MakerClient } from "../client/client.js";
2
+ import { BotStore } from "./store.js";
3
+ import { type BotPolicy } from "./policy.js";
4
+ import { HedgeEngine } from "../hedge/engine.js";
5
+ export type BotSnapshot = {
6
+ phase: "active" | "pending" | "idle" | "stopped";
7
+ reason?: string;
8
+ quoteId?: string;
9
+ fillCount: number;
10
+ };
11
+ export declare class MakerBot {
12
+ readonly maker: MakerClient;
13
+ readonly policy: BotPolicy;
14
+ readonly store: BotStore;
15
+ readonly hedge?: HedgeEngine | undefined;
16
+ private state?;
17
+ private position?;
18
+ private dirty;
19
+ private busy;
20
+ private stopping;
21
+ private pricing?;
22
+ private hedgeLease?;
23
+ private pricingDirty;
24
+ private constructor();
25
+ static create(options: {
26
+ maker: MakerClient;
27
+ policy: BotPolicy;
28
+ stateDirectory: string;
29
+ hedge?: HedgeEngine;
30
+ }): Promise<MakerBot>;
31
+ private saveHedge;
32
+ private hedgeTick;
33
+ private snapshot;
34
+ private requestId;
35
+ private reconcile;
36
+ private fills;
37
+ private cancel;
38
+ tick(): Promise<BotSnapshot>;
39
+ stop(): void;
40
+ close(): Promise<void>;
41
+ }
42
+ export declare const create_maker_bot: typeof MakerBot.create;
@@ -0,0 +1,41 @@
1
+ import type { QuoteInput, MarketState } from "../client/types.js";
2
+ import type { PositionSnapshot } from "@depthhq/sdk";
3
+ import { type HedgeBook } from "../hedge/types.js";
4
+ export type BotPolicy = {
5
+ maxCapacity: bigint;
6
+ maxInventoryNotional: bigint;
7
+ spreadBps: number;
8
+ repriceBps: number;
9
+ lifetimeSeconds: number;
10
+ refreshSeconds: number;
11
+ gasReserveLamports?: bigint;
12
+ inventorySkewBps?: number;
13
+ executionCostBps?: number;
14
+ fundingHours?: number;
15
+ };
16
+ export type BotPricing = {
17
+ book: HedgeBook;
18
+ externalPosition: bigint;
19
+ maxPriceAgeMs: number;
20
+ takerFeeBps: number;
21
+ hourlyFundingBps: number;
22
+ };
23
+ export type BotMarket = MarketState & {
24
+ oraclePriceE8: {
25
+ toString(): string;
26
+ };
27
+ fundingIndex: {
28
+ toString(): string;
29
+ };
30
+ incident: Record<string, unknown>;
31
+ lastFundingTimestamp: {
32
+ toNumber(): number;
33
+ };
34
+ config: MarketState["config"] & {
35
+ maxQuoteDeviationBps: number;
36
+ fundingIntervalSeconds: number;
37
+ };
38
+ };
39
+ export declare function validateBotPolicy(policy: BotPolicy): void;
40
+ export declare function quoteHealth(market: BotMarket, now: number): string | undefined;
41
+ export declare function botQuote(policy: BotPolicy, market: BotMarket, position: PositionSnapshot, nonce: bigint, now: number, pricing?: BotPricing): QuoteInput | undefined;
@@ -0,0 +1,32 @@
1
+ import type { QuoteInput } from "../client/types.js";
2
+ import type { HedgeState } from "../hedge/types.js";
3
+ export type BotState = {
4
+ genesis: string;
5
+ maker: string;
6
+ operator: string;
7
+ cursor?: string;
8
+ quote?: string;
9
+ request?: QuoteInput;
10
+ referencePrice?: bigint;
11
+ replacement?: {
12
+ prior: string;
13
+ nonce: bigint;
14
+ };
15
+ fills: Record<string, {
16
+ signature: string;
17
+ slot: number;
18
+ }>;
19
+ hedge?: HedgeState;
20
+ };
21
+ export declare class BotStore {
22
+ readonly genesis: string;
23
+ readonly maker: string;
24
+ readonly operator: string;
25
+ readonly path: string;
26
+ private lock?;
27
+ constructor(genesis: string, maker: string, operator: string, directory: string);
28
+ acquire(): Promise<void>;
29
+ release(): Promise<void>;
30
+ load(): Promise<BotState>;
31
+ save(state: BotState): Promise<void>;
32
+ }
@@ -0,0 +1,18 @@
1
+ import * as anchor from "@anchor-lang/core";
2
+ import type { Connection, PublicKey } from "@solana/web3.js";
3
+ type MxeState = {
4
+ cluster: number;
5
+ mxeProgramId: PublicKey;
6
+ };
7
+ export declare function mxeAccount(provider: anchor.AnchorProvider): {
8
+ fetch(address: PublicKey): Promise<MxeState>;
9
+ };
10
+ export declare function queueAccounts(provider: anchor.AnchorProvider, connection: Connection, name: string, offset: anchor.BN): Promise<{
11
+ computationAccount: anchor.web3.PublicKey;
12
+ clusterAccount: anchor.web3.PublicKey;
13
+ mxeAccount: anchor.web3.PublicKey;
14
+ mempoolAccount: anchor.web3.PublicKey;
15
+ executingPool: anchor.web3.PublicKey;
16
+ compDefAccount: anchor.web3.PublicKey;
17
+ }>;
18
+ export {};
@@ -0,0 +1 @@
1
+ export declare function randomBytes(length: number): Uint8Array;
@@ -0,0 +1,181 @@
1
+ import * as anchor from "@anchor-lang/core";
2
+ import { SOL_USD_MARKET_ID } from "@depthhq/bindings";
3
+ import { DepthView } from "@depthhq/sdk/views";
4
+ import { DepthRecovery } from "@depthhq/sdk/recovery";
5
+ import type { FillSnapshot } from "@depthhq/sdk/views";
6
+ import { PublicKey } from "@solana/web3.js";
7
+ import { MakerAccess } from "../hedge/access.js";
8
+ import { MakerAutomation } from "../automation/automation.js";
9
+ import { DepthClient, FundingClient } from "@depthhq/sdk";
10
+ import type { AmountSelector, CloseInput, ReductionInput, ReverseInput, TradeInput } from "@depthhq/sdk";
11
+ import { BackstopHandle } from "../backstop/backstop.js";
12
+ import { FillHistory } from "../fill/history.js";
13
+ import { QuoteHandle } from "../quote/quote.js";
14
+ import { QuoteReplacement } from "../quote/replacement.js";
15
+ import type { GrantState, BackstopInput, MakerOptions, ResolvedMakerOptions, QuoteRequest, QuoteState } from "./types.js";
16
+ export declare function retryQuote<T>(action: () => Promise<T>, deadline: number): Promise<T>;
17
+ export declare class MakerClient {
18
+ readonly options: ResolvedMakerOptions;
19
+ readonly hedges: MakerAccess;
20
+ readonly automation: MakerAutomation;
21
+ readonly provider: anchor.AnchorProvider;
22
+ readonly program: anchor.Program;
23
+ readonly position: ReturnType<MakerClient["positionActions"]>;
24
+ readonly marketAddress: anchor.web3.PublicKey;
25
+ readonly quoteQueueAddress: anchor.web3.PublicKey;
26
+ readonly protocolAddress: anchor.web3.PublicKey;
27
+ readonly backstop: ((id: PublicKey) => BackstopHandle) & {
28
+ offer: (input: BackstopInput) => Promise<BackstopHandle>;
29
+ };
30
+ private ownerClient?;
31
+ private owned;
32
+ get funding(): FundingClient;
33
+ get recovery(): DepthRecovery;
34
+ private constructor();
35
+ static create(options: MakerOptions): Promise<MakerClient>;
36
+ private accountActions;
37
+ readonly account: (() => {
38
+ history: (options?: Parameters<DepthClient["account"]["history"]>[0]) => Promise<import("@depthhq/sdk").PendingPage>;
39
+ cancelOpen: () => Promise<string>;
40
+ open: () => Promise<{
41
+ address: PublicKey;
42
+ signature: string;
43
+ }>;
44
+ openMarket: () => Promise<{
45
+ address: PublicKey;
46
+ signature: string;
47
+ }>;
48
+ summary: () => Promise<import("@depthhq/sdk").BalanceSnapshot>;
49
+ pending: () => Promise<import("@depthhq/sdk").PendingPage>;
50
+ deposit: (sourceOrAmount: PublicKey | bigint, amount?: bigint, clientNonce?: bigint) => Promise<import("@depthhq/sdk").DepositHandle>;
51
+ withdrawalHandle: (clientNonce: bigint) => import("@depthhq/sdk").WithdrawalHandle;
52
+ depositHandle: (nonce: bigint) => import("@depthhq/sdk").DepositHandle;
53
+ withdraw: (destinationOrAmount: PublicKey | AmountSelector, amount?: bigint, clientNonce?: bigint) => Promise<import("@depthhq/sdk").WithdrawalHandle>;
54
+ allocate: (input: bigint | {
55
+ marketId: typeof SOL_USD_MARKET_ID;
56
+ amount: AmountSelector;
57
+ }, clientNonce?: bigint) => Promise<import("@depthhq/sdk").TransferHandle>;
58
+ release: (input: bigint | {
59
+ marketId: typeof SOL_USD_MARKET_ID;
60
+ amount: AmountSelector;
61
+ }, clientNonce?: bigint) => Promise<import("@depthhq/sdk").TransferHandle>;
62
+ transferHandle: (nonce: bigint) => import("@depthhq/sdk").TransferHandle;
63
+ }) & {
64
+ history: (options?: Parameters<DepthClient["account"]["history"]>[0]) => Promise<import("@depthhq/sdk").PendingPage>;
65
+ cancelOpen: () => Promise<string>;
66
+ open: () => Promise<{
67
+ address: PublicKey;
68
+ signature: string;
69
+ }>;
70
+ openMarket: () => Promise<{
71
+ address: PublicKey;
72
+ signature: string;
73
+ }>;
74
+ summary: () => Promise<import("@depthhq/sdk").BalanceSnapshot>;
75
+ pending: () => Promise<import("@depthhq/sdk").PendingPage>;
76
+ deposit: (sourceOrAmount: PublicKey | bigint, amount?: bigint, clientNonce?: bigint) => Promise<import("@depthhq/sdk").DepositHandle>;
77
+ withdrawalHandle: (clientNonce: bigint) => import("@depthhq/sdk").WithdrawalHandle;
78
+ depositHandle: (nonce: bigint) => import("@depthhq/sdk").DepositHandle;
79
+ withdraw: (destinationOrAmount: PublicKey | AmountSelector, amount?: bigint, clientNonce?: bigint) => Promise<import("@depthhq/sdk").WithdrawalHandle>;
80
+ allocate: (input: bigint | {
81
+ marketId: typeof SOL_USD_MARKET_ID;
82
+ amount: AmountSelector;
83
+ }, clientNonce?: bigint) => Promise<import("@depthhq/sdk").TransferHandle>;
84
+ release: (input: bigint | {
85
+ marketId: typeof SOL_USD_MARKET_ID;
86
+ amount: AmountSelector;
87
+ }, clientNonce?: bigint) => Promise<import("@depthhq/sdk").TransferHandle>;
88
+ transferHandle: (nonce: bigint) => import("@depthhq/sdk").TransferHandle;
89
+ };
90
+ readonly positions: {
91
+ list: () => Promise<{
92
+ items: {
93
+ id: anchor.web3.PublicKey;
94
+ marketId: string;
95
+ }[];
96
+ nextCursor: null;
97
+ }>;
98
+ };
99
+ readonly trade: {
100
+ submit: (input: TradeInput) => Promise<import("@depthhq/sdk").DepthOperation>;
101
+ reduce: (input: ReductionInput) => Promise<import("@depthhq/sdk").DepthOperation>;
102
+ close: (input: CloseInput) => Promise<import("@depthhq/sdk").DepthOperation>;
103
+ reverse: (input: ReverseInput) => Promise<import("@depthhq/sdk").DepthOperation>;
104
+ };
105
+ marketAccount(): PublicKey;
106
+ grantAddress(operator?: anchor.web3.PublicKey): PublicKey;
107
+ read<T>(name: string, address: PublicKey, commitment?: "confirmed" | "finalized"): Promise<T>;
108
+ quoteState(id: PublicKey): Promise<QuoteState>;
109
+ queue(name: string, computationOffset: anchor.BN): Promise<{
110
+ computationAccount: anchor.web3.PublicKey;
111
+ clusterAccount: anchor.web3.PublicKey;
112
+ mxeAccount: anchor.web3.PublicKey;
113
+ mempoolAccount: anchor.web3.PublicKey;
114
+ executingPool: anchor.web3.PublicKey;
115
+ compDefAccount: anchor.web3.PublicKey;
116
+ }>;
117
+ private grantFor;
118
+ readonly operator: {
119
+ list: () => Promise<{
120
+ id: anchor.web3.PublicKey;
121
+ state: GrantState;
122
+ }[]>;
123
+ authorize: (input: {
124
+ operator: PublicKey;
125
+ maxCapacity: bigint;
126
+ expiresAt: number;
127
+ canView: boolean;
128
+ }) => Promise<string>;
129
+ revoke: (operator: PublicKey) => Promise<string>;
130
+ };
131
+ readonly quote: {
132
+ replacement: (prior: PublicKey, clientNonce: bigint) => QuoteReplacement;
133
+ publish: (request: QuoteRequest) => Promise<QuoteHandle>;
134
+ get: (id: PublicKey) => QuoteHandle;
135
+ list: (options?: {
136
+ cursor?: string;
137
+ limit?: number;
138
+ }) => Promise<{
139
+ items: {
140
+ id: anchor.web3.PublicKey;
141
+ nonce: bigint;
142
+ status: string;
143
+ replacementNonce: bigint | undefined;
144
+ handle: QuoteHandle;
145
+ }[];
146
+ nextCursor: string | null;
147
+ }>;
148
+ active: () => Promise<QuoteHandle[]>;
149
+ replace: (prior: PublicKey, input: QuoteRequest, options?: {
150
+ timeoutMs?: number;
151
+ pollMs?: number;
152
+ }) => Promise<QuoteHandle>;
153
+ };
154
+ private flatQuote;
155
+ private viewGrant;
156
+ requestMarketView(): Promise<DepthView>;
157
+ requestFillView(order: PublicKey): Promise<DepthView>;
158
+ requestQuoteView(quote: PublicKey): Promise<DepthView>;
159
+ private requestView;
160
+ private positionActions;
161
+ readonly fills: {
162
+ list: (options?: Parameters<FillHistory["list"]>[0]) => Promise<import("../fill/history.js").FillPage>;
163
+ subscribe: (options: {
164
+ marketId: typeof SOL_USD_MARKET_ID;
165
+ onFill: (fill: {
166
+ id: string;
167
+ signature: string;
168
+ slot: number;
169
+ execution: FillSnapshot;
170
+ }) => Promise<void>;
171
+ onError: (error: unknown) => void;
172
+ pollMs?: number;
173
+ }) => Promise<() => void>;
174
+ get: (order: PublicKey, options?: {
175
+ timeoutMs: number;
176
+ pollMs?: number;
177
+ }) => Promise<FillSnapshot>;
178
+ };
179
+ private validateQuote;
180
+ }
181
+ export declare function createDepthMaker(options: MakerOptions): Promise<MakerClient>;
@@ -0,0 +1,100 @@
1
+ import type { ConnectionOptions, ResolvedConnection, DepthWallet } from "@depthhq/sdk";
2
+ import type * as anchor from "@anchor-lang/core";
3
+ import type { PublicKey } from "@solana/web3.js";
4
+ import { SOL_USD_MARKET_ID } from "@depthhq/bindings";
5
+ export type MakerOptions = ConnectionOptions & {
6
+ wallet: DepthWallet & {
7
+ signMessage?: (message: Uint8Array) => Promise<Uint8Array>;
8
+ };
9
+ maker?: PublicKey;
10
+ makerOwner?: PublicKey;
11
+ appId?: PublicKey | string;
12
+ cursorDirectory?: string;
13
+ };
14
+ export type ResolvedMakerOptions = ResolvedConnection & Omit<MakerOptions, keyof ConnectionOptions | "maker" | "appId"> & {
15
+ maker: PublicKey;
16
+ appId?: PublicKey;
17
+ };
18
+ export type QuoteTier = {
19
+ size: bigint;
20
+ bidE8: bigint;
21
+ askE8: bigint;
22
+ };
23
+ export type QuoteInput = {
24
+ tiers: QuoteTier[];
25
+ maxCapacity: bigint;
26
+ expiresAt: number;
27
+ clientNonce: bigint;
28
+ };
29
+ export type FlatQuoteInput = {
30
+ marketId: typeof SOL_USD_MARKET_ID;
31
+ bidE8: bigint;
32
+ askE8: bigint;
33
+ maxCapacity: bigint;
34
+ validForSeconds: number;
35
+ clientNonce?: bigint;
36
+ };
37
+ export type QuoteRequest = QuoteInput | FlatQuoteInput;
38
+ export type QuoteState = {
39
+ status: Record<string, unknown>;
40
+ maker: PublicKey;
41
+ operator: PublicKey;
42
+ operatorVersion: anchor.BN;
43
+ market: PublicKey;
44
+ nonce: anchor.BN;
45
+ capacity: anchor.BN;
46
+ expiry: anchor.BN;
47
+ attachedOrders: number;
48
+ replacementNonce: anchor.BN | null;
49
+ };
50
+ export type MarketState = {
51
+ revision: anchor.BN;
52
+ status: Record<string, unknown>;
53
+ settlementMint: PublicKey;
54
+ vault: PublicKey;
55
+ oracleTimestamp: anchor.BN;
56
+ pendingOrders: number;
57
+ backstopOffer: PublicKey;
58
+ activeQuoteCount: number;
59
+ activeQuotes: PublicKey[];
60
+ quotedNotional: anchor.BN;
61
+ config: {
62
+ quoteTiers: anchor.BN[];
63
+ initialMarginBps: number;
64
+ maxAccountNotional: anchor.BN;
65
+ maxMarketNotional: anchor.BN;
66
+ maxQuoteLifetimeSeconds: number;
67
+ maxOracleAgeSeconds: number;
68
+ backstopMinCollateral: anchor.BN;
69
+ };
70
+ };
71
+ export type QuoteQueueState = {
72
+ market: PublicKey;
73
+ count: number;
74
+ entries: PublicKey[];
75
+ };
76
+ export type BackstopInput = {
77
+ marketId: typeof SOL_USD_MARKET_ID;
78
+ maxCapacity: bigint;
79
+ validForSeconds: number;
80
+ clientNonce?: bigint;
81
+ };
82
+ export type BackstopState = {
83
+ maker: PublicKey;
84
+ market: PublicKey;
85
+ nonce: anchor.BN;
86
+ capacity: anchor.BN;
87
+ margin: anchor.BN;
88
+ expiry: anchor.BN;
89
+ status: Record<string, unknown>;
90
+ };
91
+ export type GrantState = {
92
+ active: boolean;
93
+ canView: boolean;
94
+ maker: PublicKey;
95
+ operator: PublicKey;
96
+ market: PublicKey;
97
+ maxCapacity: anchor.BN;
98
+ expiresAt: anchor.BN;
99
+ version: anchor.BN;
100
+ };
@@ -0,0 +1,8 @@
1
+ export declare class BrowserCursorStore {
2
+ readonly key: string;
3
+ constructor(genesis: string, maker: string);
4
+ private database;
5
+ load(): Promise<string | undefined>;
6
+ save(cursor: string): Promise<void>;
7
+ }
8
+ export declare function createCursorStore(genesis: string, maker: string, _directory?: string): BrowserCursorStore;
@@ -0,0 +1,8 @@
1
+ export declare class FillCursorStore {
2
+ readonly genesis: string;
3
+ readonly maker: string;
4
+ readonly path: string;
5
+ constructor(genesis: string, maker: string, directory?: string);
6
+ load(): Promise<string | undefined>;
7
+ save(cursor: string): Promise<void>;
8
+ }
@@ -0,0 +1,25 @@
1
+ import type { MakerClient } from "../client/client.js";
2
+ export type FillPage = {
3
+ fills: {
4
+ id: string;
5
+ signature: string;
6
+ slot: number;
7
+ }[];
8
+ cursor?: string;
9
+ head?: string;
10
+ };
11
+ export declare class FillHistory {
12
+ private readonly client;
13
+ constructor(client: MakerClient);
14
+ list(options?: {
15
+ before?: string;
16
+ until?: string;
17
+ limit?: number;
18
+ }): Promise<FillPage>;
19
+ subscribe(listener: (fill: FillPage["fills"][number]) => Promise<void>, options: {
20
+ cursor?: string;
21
+ pollMs?: number;
22
+ saveCursor: (cursor: string) => Promise<void>;
23
+ onError: (error: unknown) => void;
24
+ }): () => void;
25
+ }
@@ -0,0 +1,2 @@
1
+ import { FillCursorStore } from "./cursor.js";
2
+ export declare function createCursorStore(genesis: string, maker: string, directory?: string): FillCursorStore;
@@ -0,0 +1,40 @@
1
+ import type { PublicKey } from "@solana/web3.js";
2
+ type Wire<T> = T extends bigint ? string : T extends Array<infer U> ? Wire<U>[] : T extends object ? {
3
+ [K in keyof T]: Wire<T[K]>;
4
+ } : T;
5
+ export type MakerHedgeView = {
6
+ enabled: boolean;
7
+ maker: string;
8
+ snapshot: Wire<import("./types.js").HedgeSnapshot> | null;
9
+ };
10
+ export declare const accessMessage: (wallet: string, nonce: string, expiresAt: number, scope?: string) => string;
11
+ export declare class WalletSession {
12
+ protected readonly options: {
13
+ serviceUrl?: string;
14
+ wallet: {
15
+ publicKey: PublicKey;
16
+ signMessage?: (message: Uint8Array) => Promise<Uint8Array>;
17
+ };
18
+ };
19
+ private readonly scope;
20
+ private readonly prefix;
21
+ protected token?: {
22
+ value: string;
23
+ expiresAt: number;
24
+ };
25
+ constructor(options: {
26
+ serviceUrl?: string;
27
+ wallet: {
28
+ publicKey: PublicKey;
29
+ signMessage?: (message: Uint8Array) => Promise<Uint8Array>;
30
+ };
31
+ }, scope?: string, prefix?: string);
32
+ protected request(path: string, init?: RequestInit): Promise<any>;
33
+ authorize(): Promise<void>;
34
+ protected authorizedRequest(path: string, body?: unknown): Promise<any>;
35
+ disconnect(): void;
36
+ }
37
+ export declare class MakerAccess extends WalletSession {
38
+ summary(): Promise<MakerHedgeView>;
39
+ }
40
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function units(value: string, decimals: number, exact?: boolean): bigint;
2
+ export declare function decimal(value: bigint, decimals: number): string;
@@ -0,0 +1,9 @@
1
+ import { type HedgeAdapter, type HedgePolicy, type HedgeSnapshot, type HedgeState } from "./types.js";
2
+ export declare class HedgeEngine {
3
+ readonly adapter: HedgeAdapter;
4
+ readonly policy: HedgePolicy;
5
+ snapshot?: HedgeSnapshot;
6
+ private busy;
7
+ constructor(adapter: HedgeAdapter, policy: HedgePolicy);
8
+ tick(state: HedgeState, save: () => Promise<void>, depthPosition: bigint | undefined, timestamp?: number, reconcileOnly?: boolean): Promise<HedgeSnapshot>;
9
+ }
@@ -0,0 +1,35 @@
1
+ import { type AbstractWallet } from "@nktkas/hyperliquid/signing";
2
+ import type { HedgeAccount, HedgeAdapter, HedgeBook, HedgeOrder, HedgeReceipt } from "./types.js";
3
+ export { units, decimal } from "./amount.js";
4
+ export declare class HyperliquidAdapter implements HedgeAdapter {
5
+ readonly network: "testnet" | "mainnet";
6
+ readonly address: `0x${string}`;
7
+ private readonly wallet;
8
+ private readonly transport;
9
+ private readonly info;
10
+ private readonly asset;
11
+ private readonly sizeDecimals;
12
+ readonly minNotional = 10000000n;
13
+ readonly identity: string;
14
+ readonly sizeStep: bigint;
15
+ private readonly cache;
16
+ private cached;
17
+ private constructor();
18
+ static create(options: {
19
+ wallet?: AbstractWallet;
20
+ agentKey?: `0x${string}`;
21
+ account: `0x${string}`;
22
+ network?: "testnet" | "mainnet";
23
+ }): Promise<HyperliquidAdapter>;
24
+ book(): Promise<HedgeBook>;
25
+ account(): Promise<HedgeAccount>;
26
+ costs(): Promise<{
27
+ takerFeeBps: number;
28
+ hourlyFundingBps: number;
29
+ }>;
30
+ price(value: bigint, buy: boolean): bigint;
31
+ submit(order: HedgeOrder): Promise<HedgeReceipt>;
32
+ receipt(order: HedgeOrder): Promise<HedgeReceipt>;
33
+ cancel(order: HedgeOrder, nonce?: number): Promise<void>;
34
+ }
35
+ export declare const create_hyperliquid: typeof HyperliquidAdapter.create;
@@ -0,0 +1,4 @@
1
+ import type { HedgeBook, HedgePolicy } from "./types.js";
2
+ export declare function validateHedgePolicy(policy: HedgePolicy): void;
3
+ export declare function validateBook(book: HedgeBook, now: number, maxAge: number): void;
4
+ export declare function executionPrice(levels: HedgeBook["bids"], size: bigint): bigint;
@@ -0,0 +1,2 @@
1
+ import type { MakerHedgeView } from "./access.js";
2
+ export declare function hedgeView(value: unknown, owner: string): MakerHedgeView;