@depthhq/sdk 0.0.0-stage → 0.1.1

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.
Files changed (44) hide show
  1. package/dist/account/confirm.d.ts +5 -0
  2. package/dist/account/discovery.d.ts +49 -0
  3. package/dist/account/funding.d.ts +86 -0
  4. package/dist/account/funding.js +498 -0
  5. package/dist/account/release.d.ts +8 -0
  6. package/dist/account/token.d.ts +5 -0
  7. package/dist/app/app.d.ts +50 -0
  8. package/dist/catalog/catalog.d.ts +50 -0
  9. package/dist/catalog/data.d.ts +30 -0
  10. package/dist/catalog/data.js +169 -0
  11. package/dist/chain/arcium.d.ts +10 -0
  12. package/dist/chain/connection.d.ts +4 -0
  13. package/dist/chain/environment.d.ts +20 -0
  14. package/dist/chain/manifest.d.ts +36 -0
  15. package/dist/chain/network.d.ts +18 -0
  16. package/dist/chain/provider.d.ts +6 -0
  17. package/dist/chain/random.d.ts +1 -0
  18. package/dist/chain/settlement.d.ts +15 -0
  19. package/dist/chain/transaction.d.ts +12 -0
  20. package/dist/client/client.d.ts +137 -0
  21. package/dist/client/types.d.ts +105 -0
  22. package/dist/history/history.d.ts +26 -0
  23. package/dist/history/replay.d.ts +13 -0
  24. package/dist/index.d.ts +34 -0
  25. package/dist/index.js +47534 -0
  26. package/dist/operation/error.d.ts +10 -0
  27. package/dist/operation/operation.d.ts +49 -0
  28. package/dist/operator.d.ts +6 -0
  29. package/dist/operator.js +25383 -0
  30. package/dist/position/pnl.d.ts +14 -0
  31. package/dist/recovery/coordinator.d.ts +17 -0
  32. package/dist/recovery/recovery.d.ts +26 -0
  33. package/dist/recovery/recovery.js +1420 -0
  34. package/dist/recovery/shares.d.ts +26 -0
  35. package/dist/recovery/winddown.d.ts +38 -0
  36. package/dist/recovery/witness.d.ts +16 -0
  37. package/dist/trade/amount.d.ts +2 -0
  38. package/dist/trade/flow.d.ts +21 -0
  39. package/dist/trade/input.d.ts +3 -0
  40. package/dist/trade/terms.d.ts +3 -0
  41. package/dist/view/view.d.ts +59 -0
  42. package/dist/view/view.js +26681 -0
  43. package/package.json +52 -3
  44. package/README.md +0 -3
@@ -0,0 +1,105 @@
1
+ import * as anchor from "@anchor-lang/core";
2
+ import { SOL_USD_MARKET_ID } from "@depthhq/bindings";
3
+ import { PublicKey, type Transaction, type VersionedTransaction } from "@solana/web3.js";
4
+ import type { AmountSelector } from "../trade/amount.js";
5
+ import type { ConnectionOptions, ResolvedConnection } from "../chain/environment.js";
6
+ export type DepthWallet = {
7
+ publicKey: PublicKey;
8
+ signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<T>;
9
+ signAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<T[]>;
10
+ };
11
+ export type DepthOptions = ConnectionOptions & {
12
+ appId?: PublicKey | string;
13
+ wallet: DepthWallet;
14
+ };
15
+ export type ResolvedDepthOptions = ResolvedConnection & {
16
+ appId?: PublicKey;
17
+ wallet: DepthWallet;
18
+ };
19
+ export type TradeTerms = {
20
+ marketId: typeof SOL_USD_MARKET_ID;
21
+ worstPriceE8?: bigint;
22
+ slippageBps?: number;
23
+ maxFee: bigint;
24
+ expiresAt?: number;
25
+ validForSeconds?: number;
26
+ clientNonce?: bigint;
27
+ };
28
+ export type TradeInput = TradeTerms & {
29
+ direction: "long" | "short";
30
+ notional: bigint;
31
+ margin: bigint;
32
+ };
33
+ export type ReductionInput = TradeTerms & {
34
+ amount: AmountSelector;
35
+ positionId?: PublicKey;
36
+ };
37
+ export type CloseInput = TradeTerms & {
38
+ positionId?: PublicKey;
39
+ };
40
+ export type ReverseInput = TradeInput & {
41
+ positionId?: PublicKey;
42
+ };
43
+ export type MarketState = {
44
+ revision: anchor.BN;
45
+ settlementMint: PublicKey;
46
+ vault: PublicKey;
47
+ status: Record<string, unknown>;
48
+ incident: Record<string, unknown>;
49
+ fundingIndex: anchor.BN;
50
+ lastFundingTimestamp: anchor.BN;
51
+ pendingOrders: number;
52
+ activeQuoteCount: number;
53
+ activeQuotes: PublicKey[];
54
+ backstopOffer: PublicKey;
55
+ oracleTimestamp: anchor.BN;
56
+ oraclePriceE8: anchor.BN;
57
+ oracleEmaE8: anchor.BN;
58
+ oracleConfidenceE8: anchor.BN;
59
+ oracleSlot: anchor.BN;
60
+ config: {
61
+ maxOracleAgeSeconds: number;
62
+ maxOrderQueueSeconds: number;
63
+ initialMarginBps: number;
64
+ maintenanceMarginBps: number;
65
+ liquidationFeeBps: number;
66
+ tradeFeeBps: number;
67
+ insuranceFeeBps: number;
68
+ maxAccountNotional: anchor.BN;
69
+ maxMarketNotional: anchor.BN;
70
+ maxConfidenceBps: number;
71
+ maxQuoteDeviationBps: number;
72
+ maxQuoteLifetimeSeconds: number;
73
+ fundingIntervalSeconds: number;
74
+ fundingRateCapBps: number;
75
+ quoteTiers: anchor.BN[];
76
+ backstopMinCollateral: anchor.BN;
77
+ };
78
+ };
79
+ export type TradeIntent = "increase" | "reduce" | "close" | "reverse";
80
+ export type AccountState = {
81
+ version: anchor.BN;
82
+ status: Record<string, unknown>;
83
+ market: PublicKey;
84
+ owner: PublicKey;
85
+ };
86
+ export type AppState = {
87
+ app: PublicKey;
88
+ active: boolean;
89
+ feeBps: number;
90
+ version: anchor.BN;
91
+ };
92
+ export type ProtocolState = {
93
+ tradingEnabled: boolean;
94
+ settlementMint: PublicKey;
95
+ vault: PublicKey;
96
+ };
97
+ export type OrderState = {
98
+ status: Record<string, unknown>;
99
+ kind: Record<string, unknown>;
100
+ trader: PublicKey;
101
+ maker?: PublicKey;
102
+ market: PublicKey;
103
+ traderVersion: anchor.BN;
104
+ fundingIndex: anchor.BN;
105
+ };
@@ -0,0 +1,26 @@
1
+ import * as anchor from "@anchor-lang/core";
2
+ import { Connection, PublicKey } from "@solana/web3.js";
3
+ import type { DepthView, FillSnapshot } from "../view/view.js";
4
+ import { type SettlementTransaction } from "../chain/settlement.js";
5
+ import type { PositionPnl } from "../position/pnl.js";
6
+ export type ExecutionDetail = {
7
+ id: PublicKey;
8
+ fill: FillSnapshot;
9
+ pnl?: PositionPnl;
10
+ transaction: SettlementTransaction;
11
+ };
12
+ export declare class ExecutionHistory {
13
+ private readonly program;
14
+ private readonly connection;
15
+ private readonly owner;
16
+ private readonly requestView;
17
+ private readonly views;
18
+ private readonly fills;
19
+ private readonly transactions;
20
+ constructor(program: anchor.Program, connection: Connection, owner: PublicKey, requestView: (id: PublicKey) => Promise<DepthView>);
21
+ private orderAddress;
22
+ fill(id: PublicKey): Promise<FillSnapshot>;
23
+ execution(nonce: bigint): Promise<ExecutionDetail>;
24
+ private settlement;
25
+ private scan;
26
+ }
@@ -0,0 +1,13 @@
1
+ import type { FillSnapshot } from "../view/view.js";
2
+ import { type PositionPnl } from "../position/pnl.js";
3
+ export type ReplayState = {
4
+ position: bigint;
5
+ entryPriceE8: bigint;
6
+ fundingCheckpoint: bigint;
7
+ collateral?: bigint;
8
+ };
9
+ export declare function replayFill(state: ReplayState, fill: FillSnapshot, fundingIndex: bigint, maker?: boolean): {
10
+ state: ReplayState;
11
+ pnl?: PositionPnl;
12
+ };
13
+ export declare function replayMargin(state: ReplayState, amount: bigint, toMarket: boolean): ReplayState;
@@ -0,0 +1,34 @@
1
+ export { DepthClient, createDepth, createDepth as create_depth, } from "./client/client.js";
2
+ export { DepthOperation } from "./operation/operation.js";
3
+ export { ExecutionHistory } from "./history/history.js";
4
+ export type { ExecutionDetail } from "./history/history.js";
5
+ export type { PositionPnl } from "./position/pnl.js";
6
+ export { positionPnl } from "./position/pnl.js";
7
+ export type { SettlementTransaction } from "./chain/settlement.js";
8
+ export type { ReceiptTransaction } from "./chain/transaction.js";
9
+ export { TradeFlow } from "./trade/flow.js";
10
+ export type { TradeFlowSnapshot } from "./trade/flow.js";
11
+ export { MarketCatalog } from "./catalog/catalog.js";
12
+ export type { MarketPolicy, MarketSummary } from "./catalog/catalog.js";
13
+ export { MarketData, create_depth_data } from "./catalog/data.js";
14
+ export type { DataOptions, CandleQuery } from "./catalog/data.js";
15
+ export type { Candle, CandleInterval, CandlePage, PublicMarket, PublicApp, } from "@depthhq/schema";
16
+ export { AppAdmin, AppRegistration, AppUpdate } from "./app/app.js";
17
+ export { FundingDiscovery } from "./account/discovery.js";
18
+ export type { ReceiptDetail } from "./account/discovery.js";
19
+ export type { PendingItem, PendingKind, PendingPage, UnpairedAllocation, } from "./account/discovery.js";
20
+ export type { AppSummary } from "./app/app.js";
21
+ export { DepthRecovery } from "./recovery/recovery.js";
22
+ export type { RecoverySnapshot } from "./recovery/recovery.js";
23
+ export { DepositHandle, FundingClient, TransferHandle, WithdrawalHandle, } from "./account/funding.js";
24
+ export { DepthView } from "./view/view.js";
25
+ export { resolveAmount } from "./trade/amount.js";
26
+ export type { AmountSelector } from "./trade/amount.js";
27
+ export type { BalanceSnapshot, FillSnapshot, PositionSnapshot, QuoteBalanceSnapshot, } from "./view/view.js";
28
+ export type { DepthOptions, DepthWallet, TradeInput, ReductionInput, CloseInput, ReverseInput, TradeIntent, } from "./client/types.js";
29
+ export { resolveConnection } from "./chain/environment.js";
30
+ export type { ConnectionOptions, ResolvedConnection, DepthEnvironment, } from "./chain/environment.js";
31
+ export { DepthError } from "./operation/error.js";
32
+ export { DepthProvider } from "./chain/provider.js";
33
+ export { authenticateManifest, captureDeployment, manifestBytes, verifyDeployment, } from "./chain/manifest.js";
34
+ export type { DeploymentManifest, SignedManifest, DeploymentPolicy, } from "./chain/manifest.js";