@depthhq/sdk 0.1.2 → 0.1.4

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.
@@ -7,11 +7,12 @@ export declare class FundingClient {
7
7
  readonly connection: Connection;
8
8
  readonly owner: PublicKey;
9
9
  private readonly queue;
10
+ readonly settlement: "keeper" | "wallet";
10
11
  readonly market: PublicKey;
11
12
  readonly protocol: PublicKey;
12
13
  readonly balance: PublicKey;
13
14
  readonly marketAccount: PublicKey;
14
- constructor(program: anchor.Program, connection: Connection, owner: PublicKey, queue: Queue);
15
+ constructor(program: anchor.Program, connection: Connection, owner: PublicKey, queue: Queue, settlement?: "keeper" | "wallet");
15
16
  private assertOwner;
16
17
  read<T>(name: string, address: PublicKey): Promise<T | undefined>;
17
18
  private recoveryKey;
@@ -76,15 +76,17 @@ class FundingClient {
76
76
  connection;
77
77
  owner;
78
78
  queue;
79
+ settlement;
79
80
  market;
80
81
  protocol;
81
82
  balance;
82
83
  marketAccount;
83
- constructor(program, connection, owner, queue) {
84
+ constructor(program, connection, owner, queue, settlement = "wallet") {
84
85
  this.program = program;
85
86
  this.connection = connection;
86
87
  this.owner = owner;
87
88
  this.queue = queue;
89
+ this.settlement = settlement;
88
90
  this.market = marketAddress(program.programId);
89
91
  this.protocol = protocolAddress(program.programId);
90
92
  this.balance = balanceAddress(owner, program.programId);
@@ -418,7 +420,7 @@ class TransferHandle {
418
420
  return true;
419
421
  if (transfer.state === "rejected" || transfer.state === "refunded" || transfer.state === "cancelled")
420
422
  throw new DepthError("MARGIN_REJECTED", "confirmation", `Margin transfer ${transfer.state}`, false, "Read the receipt and private account before retrying", this.id.toBase58());
421
- if (transfer.state === "escrow") {
423
+ if (transfer.state === "escrow" && this.client.settlement === "wallet") {
422
424
  try {
423
425
  await this.settle();
424
426
  } catch (error) {
@@ -1,6 +1,9 @@
1
1
  import * as anchor from "@anchor-lang/core";
2
- import { Transaction } from "@solana/web3.js";
2
+ import { PublicKey, Transaction, TransactionInstruction } from "@solana/web3.js";
3
3
  export declare function applyDepthComputeBudget(transaction: Transaction): void;
4
4
  export declare class DepthProvider extends anchor.AnchorProvider {
5
+ private readonly cleanup;
6
+ deferClose(id: PublicKey, instruction: TransactionInstruction): void;
7
+ appendCleanup(transaction: Transaction): Promise<string[]>;
5
8
  sendAndConfirm(transaction: Parameters<anchor.AnchorProvider["sendAndConfirm"]>[0], signers?: Parameters<anchor.AnchorProvider["sendAndConfirm"]>[1], options?: Parameters<anchor.AnchorProvider["sendAndConfirm"]>[2]): Promise<string>;
6
9
  }
@@ -1,6 +1,7 @@
1
1
  import * as anchor from "@anchor-lang/core";
2
2
  import { SOL_USD_MARKET_ID } from "@depthhq/bindings";
3
3
  import { PublicKey } from "@solana/web3.js";
4
+ import { DepthProvider } from "../chain/provider.js";
4
5
  import { AppAdmin } from "../app/app.js";
5
6
  import { MarketCatalog } from "../catalog/catalog.js";
6
7
  import { FundingDiscovery } from "../account/discovery.js";
@@ -11,12 +12,16 @@ import { ExecutionHistory } from "../history/history.js";
11
12
  import type { AmountSelector } from "../trade/amount.js";
12
13
  import { TradeFlow } from "../trade/flow.js";
13
14
  import { DepthView } from "../view/view.js";
15
+ import { ViewSession } from "../view/session.js";
14
16
  import type { BalanceSnapshot } from "../view/view.js";
15
17
  import type { CloseInput, DepthOptions, ResolvedDepthOptions, MarketState, ReductionInput, ReverseInput, TradeInput } from "./types.js";
16
18
  export declare class DepthClient {
17
19
  readonly options: ResolvedDepthOptions;
18
20
  readonly program: anchor.Program;
19
- readonly provider: anchor.AnchorProvider;
21
+ readonly provider: DepthProvider;
22
+ private readonly viewCache;
23
+ readonly views: ViewSession;
24
+ private readonly viewReads;
20
25
  readonly position: ReturnType<DepthClient["positionActions"]>;
21
26
  readonly marketAddress: anchor.web3.PublicKey;
22
27
  readonly protocolAddress: anchor.web3.PublicKey;
@@ -39,6 +44,7 @@ export declare class DepthClient {
39
44
  slot: number;
40
45
  }>;
41
46
  operation(id: PublicKey): DepthOperation;
47
+ requestQuoteView(quote: PublicKey): Promise<DepthView>;
42
48
  requestBalanceView(): Promise<DepthView>;
43
49
  requestMarketView(): Promise<DepthView>;
44
50
  requestFillView(order: PublicKey): Promise<DepthView>;
@@ -133,7 +139,12 @@ export declare class DepthClient {
133
139
  }>;
134
140
  };
135
141
  private orderAddress;
142
+ private deferViewClose;
143
+ private viewState;
144
+ private summaryView;
145
+ private readSummaryView;
136
146
  private submitTrade;
147
+ private waitForMarket;
137
148
  private validateTrade;
138
149
  }
139
150
  export declare function createDepth(options: DepthOptions): Promise<DepthClient>;
@@ -11,10 +11,16 @@ export type DepthWallet = {
11
11
  export type DepthOptions = ConnectionOptions & {
12
12
  appId?: PublicKey | string;
13
13
  wallet: DepthWallet;
14
+ privateViews?: "memory" | "device";
15
+ viewAuthorization?: "session" | "wallet";
16
+ settlement?: "keeper" | "wallet";
14
17
  };
15
18
  export type ResolvedDepthOptions = ResolvedConnection & {
16
19
  appId?: PublicKey;
17
20
  wallet: DepthWallet;
21
+ privateViews?: "memory" | "device";
22
+ viewAuthorization?: "session" | "wallet";
23
+ settlement?: "keeper" | "wallet";
18
24
  };
19
25
  export type TradeTerms = {
20
26
  marketId: typeof SOL_USD_MARKET_ID;
package/dist/index.d.ts CHANGED
@@ -33,3 +33,4 @@ export { DepthError } from "./operation/error.js";
33
33
  export { DepthProvider } from "./chain/provider.js";
34
34
  export { authenticateManifest, captureDeployment, manifestBytes, verifyDeployment, } from "./chain/manifest.js";
35
35
  export type { DeploymentManifest, SignedManifest, DeploymentPolicy, } from "./chain/manifest.js";
36
+ export { ViewSession } from "./view/session.js";