@drift-labs/sdk 0.1.19-master.1 → 0.1.21-master.3
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.
- package/lib/accounts/bulkAccountLoader.d.ts +31 -0
- package/lib/accounts/bulkAccountLoader.js +177 -0
- package/lib/accounts/bulkUserSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserSubscription.js +28 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +49 -0
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +228 -0
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts +25 -0
- package/lib/accounts/pollingTokenAccountSubscriber.js +79 -0
- package/lib/accounts/pollingUserAccountSubscriber.d.ts +32 -0
- package/lib/accounts/pollingUserAccountSubscriber.js +136 -0
- package/lib/accounts/types.d.ts +38 -3
- package/lib/accounts/utils.d.ts +1 -0
- package/lib/accounts/utils.js +7 -0
- package/lib/accounts/webSocketAccountSubscriber.d.ts +6 -3
- package/lib/accounts/webSocketAccountSubscriber.js +43 -12
- package/lib/accounts/{defaultClearingHouseAccountSubscriber.d.ts → webSocketClearingHouseAccountSubscriber.d.ts} +8 -3
- package/lib/accounts/{defaultClearingHouseAccountSubscriber.js → webSocketClearingHouseAccountSubscriber.js} +30 -4
- package/lib/accounts/{defaultUserAccountSubscriber.d.ts → webSocketUserAccountSubscriber.d.ts} +6 -3
- package/lib/accounts/{defaultUserAccountSubscriber.js → webSocketUserAccountSubscriber.js} +16 -4
- package/lib/addresses.d.ts +4 -1
- package/lib/addresses.js +28 -1
- package/lib/admin.d.ts +10 -4
- package/lib/admin.js +54 -17
- package/lib/assert/assert.d.ts +0 -1
- package/lib/clearingHouse.d.ts +39 -4
- package/lib/clearingHouse.js +334 -23
- package/lib/clearingHouseUser.d.ts +26 -20
- package/lib/clearingHouseUser.js +149 -118
- package/lib/config.d.ts +0 -1
- package/lib/constants/markets.d.ts +2 -2
- package/lib/constants/markets.js +28 -15
- package/lib/constants/numericConstants.d.ts +4 -2
- package/lib/constants/numericConstants.js +16 -17
- package/lib/examples/makeTradeExample.d.ts +0 -1
- package/lib/examples/makeTradeExample.js +6 -6
- package/lib/factory/clearingHouse.d.ts +25 -0
- package/lib/factory/clearingHouse.js +64 -0
- package/lib/factory/clearingHouseUser.d.ts +19 -0
- package/lib/factory/clearingHouseUser.js +34 -0
- package/lib/idl/clearing_house.json +1066 -39
- package/lib/index.d.ts +11 -3
- package/lib/index.js +12 -2
- package/lib/math/amm.d.ts +1 -1
- package/lib/math/amm.js +38 -15
- package/lib/math/conversion.d.ts +1 -2
- package/lib/math/conversion.js +1 -1
- package/lib/math/funding.d.ts +0 -1
- package/lib/math/funding.js +1 -1
- package/lib/math/insuranceFund.d.ts +2 -2
- package/lib/math/insuranceFund.js +3 -6
- package/lib/math/market.d.ts +2 -2
- package/lib/math/market.js +12 -2
- package/lib/math/orders.d.ts +3 -0
- package/lib/math/orders.js +32 -0
- package/lib/math/position.d.ts +6 -3
- package/lib/math/position.js +21 -10
- package/lib/math/trade.d.ts +0 -1
- package/lib/math/trade.js +16 -16
- package/lib/math/utils.d.ts +2 -2
- package/lib/math/utils.js +3 -3
- package/lib/mockUSDCFaucet.d.ts +2 -2
- package/lib/orderParams.d.ts +7 -0
- package/lib/orderParams.js +108 -0
- package/lib/orders.d.ts +6 -0
- package/lib/orders.js +136 -0
- package/lib/pythClient.d.ts +0 -1
- package/lib/pythClient.js +1 -1
- package/lib/token/index.d.ts +3 -0
- package/lib/token/index.js +38 -0
- package/lib/tx/defaultTxSender.d.ts +0 -1
- package/lib/tx/types.d.ts +0 -1
- package/lib/tx/utils.d.ts +0 -1
- package/lib/types.d.ts +147 -3
- package/lib/types.js +36 -1
- package/lib/util/computeUnits.d.ts +0 -1
- package/lib/util/tps.d.ts +0 -1
- package/lib/wallet.d.ts +0 -1
- package/package.json +11 -3
- package/src/accounts/bulkAccountLoader.ts +215 -0
- package/src/accounts/bulkUserSubscription.ts +28 -0
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +326 -0
- package/src/accounts/pollingTokenAccountSubscriber.ts +99 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +194 -0
- package/src/accounts/types.ts +48 -1
- package/src/accounts/utils.ts +3 -0
- package/src/accounts/webSocketAccountSubscriber.ts +67 -17
- package/src/accounts/{defaultClearingHouseAccountSubscriber.ts → webSocketClearingHouseAccountSubscriber.ts} +51 -1
- package/src/accounts/{defaultUserAccountSubscriber.ts → webSocketUserAccountSubscriber.ts} +33 -3
- package/src/addresses.ts +37 -0
- package/src/admin.ts +92 -24
- package/src/clearingHouse.ts +455 -22
- package/src/clearingHouseUser.ts +190 -108
- package/src/constants/markets.ts +17 -1
- package/src/constants/numericConstants.ts +3 -1
- package/src/examples/makeTradeExample.ts +4 -1
- package/src/factory/clearingHouse.ts +125 -0
- package/src/factory/clearingHouseUser.ts +73 -0
- package/src/idl/clearing_house.json +1066 -39
- package/src/index.ts +11 -2
- package/src/math/amm.ts +47 -14
- package/src/math/conversion.ts +1 -1
- package/src/math/insuranceFund.ts +1 -1
- package/src/math/market.ts +28 -2
- package/src/math/orders.ts +44 -0
- package/src/math/position.ts +24 -4
- package/src/math/utils.ts +1 -1
- package/src/mockUSDCFaucet.ts +1 -1
- package/src/orderParams.ts +151 -0
- package/src/orders.ts +236 -0
- package/src/token/index.ts +37 -0
- package/src/types.ts +130 -2
- package/tsconfig.json +0 -1
- package/lib/accounts/defaultClearingHouseAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/defaultUserAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/types.d.ts.map +0 -1
- package/lib/accounts/webSocketAccountSubscriber.d.ts.map +0 -1
- package/lib/addresses.d.ts.map +0 -1
- package/lib/admin.d.ts.map +0 -1
- package/lib/assert/assert.d.ts.map +0 -1
- package/lib/clearingHouse.d.ts.map +0 -1
- package/lib/clearingHouseUser.d.ts.map +0 -1
- package/lib/config.d.ts.map +0 -1
- package/lib/constants/markets.d.ts.map +0 -1
- package/lib/constants/numericConstants.d.ts.map +0 -1
- package/lib/examples/makeTradeExample.d.ts.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/math/amm.d.ts.map +0 -1
- package/lib/math/conversion.d.ts.map +0 -1
- package/lib/math/funding.d.ts.map +0 -1
- package/lib/math/insuranceFund.d.ts.map +0 -1
- package/lib/math/market.d.ts.map +0 -1
- package/lib/math/position.d.ts.map +0 -1
- package/lib/math/trade.d.ts.map +0 -1
- package/lib/math/utils.d.ts.map +0 -1
- package/lib/mockUSDCFaucet.d.ts.map +0 -1
- package/lib/pythClient.d.ts.map +0 -1
- package/lib/tx/defaultTxSender.d.ts.map +0 -1
- package/lib/tx/types.d.ts.map +0 -1
- package/lib/tx/utils.d.ts.map +0 -1
- package/lib/types.d.ts.map +0 -1
- package/lib/util/computeUnits.d.ts.map +0 -1
- package/lib/util/tps.d.ts.map +0 -1
- package/lib/wallet.d.ts.map +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Commitment, Connection, PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { AccountData } from './types';
|
|
4
|
+
declare type AccountToLoad = {
|
|
5
|
+
publicKey: PublicKey;
|
|
6
|
+
callbacks: Map<string, (buffer: Buffer) => void>;
|
|
7
|
+
};
|
|
8
|
+
export declare class BulkAccountLoader {
|
|
9
|
+
connection: Connection;
|
|
10
|
+
commitment: Commitment;
|
|
11
|
+
pollingFrequency: number;
|
|
12
|
+
accountsToLoad: Map<string, AccountToLoad>;
|
|
13
|
+
accountData: Map<string, AccountData>;
|
|
14
|
+
errorCallbacks: Map<string, (e: any) => void>;
|
|
15
|
+
intervalId?: NodeJS.Timer;
|
|
16
|
+
loadPromise?: Promise<void>;
|
|
17
|
+
loadPromiseResolver: () => void;
|
|
18
|
+
constructor(connection: Connection, commitment: Commitment, pollingFrequency: number);
|
|
19
|
+
addAccount(publicKey: PublicKey, callback: (buffer: Buffer) => void): string;
|
|
20
|
+
removeAccount(publicKey: PublicKey, callbackId: string): void;
|
|
21
|
+
addErrorCallbacks(callback: (error: Error) => void): string;
|
|
22
|
+
removeErrorCallbacks(callbackId: string): void;
|
|
23
|
+
chunks<T>(array: readonly T[], size: number): T[][];
|
|
24
|
+
load(): Promise<void>;
|
|
25
|
+
loadChunk(accountsToLoad: AccountToLoad[]): Promise<void>;
|
|
26
|
+
handleAccountCallbacks(accountToLoad: AccountToLoad, buffer: Buffer): void;
|
|
27
|
+
getAccountData(publicKey: PublicKey): Buffer | undefined;
|
|
28
|
+
startPolling(): void;
|
|
29
|
+
stopPolling(): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BulkAccountLoader = void 0;
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
const GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE = 99;
|
|
15
|
+
class BulkAccountLoader {
|
|
16
|
+
constructor(connection, commitment, pollingFrequency) {
|
|
17
|
+
this.accountsToLoad = new Map();
|
|
18
|
+
this.accountData = new Map();
|
|
19
|
+
this.errorCallbacks = new Map();
|
|
20
|
+
this.connection = connection;
|
|
21
|
+
this.commitment = commitment;
|
|
22
|
+
this.pollingFrequency = pollingFrequency;
|
|
23
|
+
}
|
|
24
|
+
addAccount(publicKey, callback) {
|
|
25
|
+
const existingSize = this.accountsToLoad.size;
|
|
26
|
+
const callbackId = uuid_1.v4();
|
|
27
|
+
const existingAccountToLoad = this.accountsToLoad.get(publicKey.toString());
|
|
28
|
+
if (existingAccountToLoad) {
|
|
29
|
+
existingAccountToLoad.callbacks.set(callbackId, callback);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const callbacks = new Map();
|
|
33
|
+
callbacks.set(callbackId, callback);
|
|
34
|
+
const newAccountToLoad = {
|
|
35
|
+
publicKey,
|
|
36
|
+
callbacks,
|
|
37
|
+
};
|
|
38
|
+
this.accountsToLoad.set(publicKey.toString(), newAccountToLoad);
|
|
39
|
+
}
|
|
40
|
+
if (existingSize === 0) {
|
|
41
|
+
this.startPolling();
|
|
42
|
+
}
|
|
43
|
+
// if a new account needs to be polled, remove the cached loadPromise in case client calls load immediately after
|
|
44
|
+
this.loadPromise = undefined;
|
|
45
|
+
return callbackId;
|
|
46
|
+
}
|
|
47
|
+
removeAccount(publicKey, callbackId) {
|
|
48
|
+
const existingAccountToLoad = this.accountsToLoad.get(publicKey.toString());
|
|
49
|
+
if (existingAccountToLoad) {
|
|
50
|
+
existingAccountToLoad.callbacks.delete(callbackId);
|
|
51
|
+
if (existingAccountToLoad.callbacks.size === 0) {
|
|
52
|
+
this.accountsToLoad.delete(existingAccountToLoad.publicKey.toString());
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (this.accountsToLoad.size === 0) {
|
|
56
|
+
this.stopPolling();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
addErrorCallbacks(callback) {
|
|
60
|
+
const callbackId = uuid_1.v4();
|
|
61
|
+
this.errorCallbacks.set(callbackId, callback);
|
|
62
|
+
return callbackId;
|
|
63
|
+
}
|
|
64
|
+
removeErrorCallbacks(callbackId) {
|
|
65
|
+
this.errorCallbacks.delete(callbackId);
|
|
66
|
+
}
|
|
67
|
+
chunks(array, size) {
|
|
68
|
+
return new Array(Math.ceil(array.length / size))
|
|
69
|
+
.fill(null)
|
|
70
|
+
.map((_, index) => index * size)
|
|
71
|
+
.map((begin) => array.slice(begin, begin + size));
|
|
72
|
+
}
|
|
73
|
+
load() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
if (this.loadPromise) {
|
|
76
|
+
return this.loadPromise;
|
|
77
|
+
}
|
|
78
|
+
this.loadPromise = new Promise((resolver) => {
|
|
79
|
+
this.loadPromiseResolver = resolver;
|
|
80
|
+
});
|
|
81
|
+
try {
|
|
82
|
+
const chunks = this.chunks(Array.from(this.accountsToLoad.values()), GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE);
|
|
83
|
+
yield Promise.all(chunks.map((chunk) => {
|
|
84
|
+
return this.loadChunk(chunk);
|
|
85
|
+
}));
|
|
86
|
+
}
|
|
87
|
+
catch (e) {
|
|
88
|
+
console.error(`Error in bulkAccountLoader.load()`);
|
|
89
|
+
console.error(e);
|
|
90
|
+
for (const [_, callback] of this.errorCallbacks) {
|
|
91
|
+
callback(e);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
finally {
|
|
95
|
+
this.loadPromiseResolver();
|
|
96
|
+
this.loadPromise = undefined;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
loadChunk(accountsToLoad) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
if (accountsToLoad.length === 0) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const args = [
|
|
106
|
+
accountsToLoad.map((accountToLoad) => {
|
|
107
|
+
return accountToLoad.publicKey.toBase58();
|
|
108
|
+
}),
|
|
109
|
+
{ commitment: this.commitment },
|
|
110
|
+
];
|
|
111
|
+
let rpcResponse;
|
|
112
|
+
try {
|
|
113
|
+
// @ts-ignore
|
|
114
|
+
rpcResponse = yield this.connection._rpcRequest('getMultipleAccounts', args);
|
|
115
|
+
}
|
|
116
|
+
catch (e) {
|
|
117
|
+
for (const [_, callback] of this.errorCallbacks) {
|
|
118
|
+
callback(e);
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
const newSlot = rpcResponse.result.context.slot;
|
|
123
|
+
for (const i in accountsToLoad) {
|
|
124
|
+
const accountToLoad = accountsToLoad[i];
|
|
125
|
+
const key = accountToLoad.publicKey.toString();
|
|
126
|
+
const oldRPCResponse = this.accountData.get(key);
|
|
127
|
+
let newBuffer = undefined;
|
|
128
|
+
if (rpcResponse.result.value[i]) {
|
|
129
|
+
const raw = rpcResponse.result.value[i].data[0];
|
|
130
|
+
const dataType = rpcResponse.result.value[i].data[1];
|
|
131
|
+
newBuffer = Buffer.from(raw, dataType);
|
|
132
|
+
}
|
|
133
|
+
if (!oldRPCResponse) {
|
|
134
|
+
this.accountData.set(key, {
|
|
135
|
+
slot: newSlot,
|
|
136
|
+
buffer: newBuffer,
|
|
137
|
+
});
|
|
138
|
+
this.handleAccountCallbacks(accountToLoad, newBuffer);
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (newSlot <= oldRPCResponse.slot) {
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const oldBuffer = oldRPCResponse.buffer;
|
|
145
|
+
if (newBuffer && (!oldBuffer || !newBuffer.equals(oldBuffer))) {
|
|
146
|
+
this.accountData.set(key, {
|
|
147
|
+
slot: newSlot,
|
|
148
|
+
buffer: newBuffer,
|
|
149
|
+
});
|
|
150
|
+
this.handleAccountCallbacks(accountToLoad, newBuffer);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
handleAccountCallbacks(accountToLoad, buffer) {
|
|
156
|
+
for (const [_, callback] of accountToLoad.callbacks) {
|
|
157
|
+
callback(buffer);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
getAccountData(publicKey) {
|
|
161
|
+
const accountData = this.accountData.get(publicKey.toString());
|
|
162
|
+
return accountData === null || accountData === void 0 ? void 0 : accountData.buffer;
|
|
163
|
+
}
|
|
164
|
+
startPolling() {
|
|
165
|
+
if (this.intervalId) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.intervalId = setInterval(this.load.bind(this), this.pollingFrequency);
|
|
169
|
+
}
|
|
170
|
+
stopPolling() {
|
|
171
|
+
if (this.intervalId) {
|
|
172
|
+
clearInterval(this.intervalId);
|
|
173
|
+
this.intervalId = undefined;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
exports.BulkAccountLoader = BulkAccountLoader;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ClearingHouseUser } from '../clearingHouseUser';
|
|
2
|
+
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
3
|
+
/**
|
|
4
|
+
* @param users
|
|
5
|
+
* @param accountLoader
|
|
6
|
+
*/
|
|
7
|
+
export declare function bulkPollingUserSubscribe(users: ClearingHouseUser[], accountLoader: BulkAccountLoader): Promise<void>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.bulkPollingUserSubscribe = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* @param users
|
|
15
|
+
* @param accountLoader
|
|
16
|
+
*/
|
|
17
|
+
function bulkPollingUserSubscribe(users, accountLoader) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
yield Promise.all(users.map((user) => {
|
|
20
|
+
return user.accountSubscriber.addToAccountLoader();
|
|
21
|
+
}));
|
|
22
|
+
yield accountLoader.load();
|
|
23
|
+
yield Promise.all(users.map((user) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
return user.subscribe();
|
|
25
|
+
})));
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
exports.bulkPollingUserSubscribe = bulkPollingUserSubscribe;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AccountToPoll, ClearingHouseAccountEvents, ClearingHouseAccountSubscriber, ClearingHouseAccountTypes } from './types';
|
|
3
|
+
import { Program } from '@project-serum/anchor';
|
|
4
|
+
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { DepositHistoryAccount, ExtendedCurveHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, LiquidationHistoryAccount, MarketsAccount, OrderHistoryAccount, OrderStateAccount, StateAccount, TradeHistoryAccount } from '../types';
|
|
7
|
+
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
8
|
+
import { ClearingHouseConfigType } from '../factory/clearingHouse';
|
|
9
|
+
export declare class PollingClearingHouseAccountSubscriber implements ClearingHouseAccountSubscriber {
|
|
10
|
+
isSubscribed: boolean;
|
|
11
|
+
program: Program;
|
|
12
|
+
eventEmitter: StrictEventEmitter<EventEmitter, ClearingHouseAccountEvents>;
|
|
13
|
+
accountLoader: BulkAccountLoader;
|
|
14
|
+
accountsToPoll: Map<string, AccountToPoll>;
|
|
15
|
+
errorCallbackId?: string;
|
|
16
|
+
state?: StateAccount;
|
|
17
|
+
markets?: MarketsAccount;
|
|
18
|
+
orderState?: OrderStateAccount;
|
|
19
|
+
tradeHistory?: TradeHistoryAccount;
|
|
20
|
+
depositHistory?: DepositHistoryAccount;
|
|
21
|
+
fundingPaymentHistory?: FundingPaymentHistoryAccount;
|
|
22
|
+
fundingRateHistory?: FundingRateHistoryAccount;
|
|
23
|
+
liquidationHistory?: LiquidationHistoryAccount;
|
|
24
|
+
extendedCurveHistory: ExtendedCurveHistoryAccount;
|
|
25
|
+
orderHistory?: OrderHistoryAccount;
|
|
26
|
+
optionalExtraSubscriptions: ClearingHouseAccountTypes[];
|
|
27
|
+
type: ClearingHouseConfigType;
|
|
28
|
+
private isSubscribing;
|
|
29
|
+
private subscriptionPromise;
|
|
30
|
+
private subscriptionPromiseResolver;
|
|
31
|
+
constructor(program: Program, accountLoader: BulkAccountLoader);
|
|
32
|
+
subscribe(optionalSubscriptions?: ClearingHouseAccountTypes[]): Promise<boolean>;
|
|
33
|
+
updateAccountsToPoll(): Promise<void>;
|
|
34
|
+
addToAccountLoader(): Promise<void>;
|
|
35
|
+
fetch(): Promise<void>;
|
|
36
|
+
unsubscribe(): Promise<void>;
|
|
37
|
+
assertIsSubscribed(): void;
|
|
38
|
+
assertOptionalIsSubscribed(optionalSubscription: ClearingHouseAccountTypes): void;
|
|
39
|
+
getStateAccount(): StateAccount;
|
|
40
|
+
getMarketsAccount(): MarketsAccount;
|
|
41
|
+
getOrderStateAccount(): OrderStateAccount;
|
|
42
|
+
getTradeHistoryAccount(): TradeHistoryAccount;
|
|
43
|
+
getDepositHistoryAccount(): DepositHistoryAccount;
|
|
44
|
+
getFundingPaymentHistoryAccount(): FundingPaymentHistoryAccount;
|
|
45
|
+
getFundingRateHistoryAccount(): FundingRateHistoryAccount;
|
|
46
|
+
getCurveHistoryAccount(): ExtendedCurveHistoryAccount;
|
|
47
|
+
getLiquidationHistoryAccount(): LiquidationHistoryAccount;
|
|
48
|
+
getOrderHistoryAccount(): OrderHistoryAccount;
|
|
49
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PollingClearingHouseAccountSubscriber = void 0;
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
const events_1 = require("events");
|
|
15
|
+
const addresses_1 = require("../addresses");
|
|
16
|
+
const utils_1 = require("./utils");
|
|
17
|
+
class PollingClearingHouseAccountSubscriber {
|
|
18
|
+
constructor(program, accountLoader) {
|
|
19
|
+
this.accountsToPoll = new Map();
|
|
20
|
+
this.optionalExtraSubscriptions = [];
|
|
21
|
+
this.type = 'polling';
|
|
22
|
+
this.isSubscribing = false;
|
|
23
|
+
this.isSubscribed = false;
|
|
24
|
+
this.program = program;
|
|
25
|
+
this.eventEmitter = new events_1.EventEmitter();
|
|
26
|
+
this.accountLoader = accountLoader;
|
|
27
|
+
}
|
|
28
|
+
subscribe(optionalSubscriptions) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
if (this.isSubscribed) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
33
|
+
if (this.isSubscribing) {
|
|
34
|
+
return yield this.subscriptionPromise;
|
|
35
|
+
}
|
|
36
|
+
this.optionalExtraSubscriptions = optionalSubscriptions;
|
|
37
|
+
this.isSubscribing = true;
|
|
38
|
+
this.subscriptionPromise = new Promise((res) => {
|
|
39
|
+
this.subscriptionPromiseResolver = res;
|
|
40
|
+
});
|
|
41
|
+
yield this.updateAccountsToPoll();
|
|
42
|
+
yield this.addToAccountLoader();
|
|
43
|
+
yield this.fetch();
|
|
44
|
+
this.eventEmitter.emit('update');
|
|
45
|
+
this.isSubscribing = false;
|
|
46
|
+
this.isSubscribed = true;
|
|
47
|
+
this.subscriptionPromiseResolver(true);
|
|
48
|
+
return true;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
updateAccountsToPoll() {
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
53
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
+
if (this.accountsToPoll.size > 0) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const statePublicKey = yield addresses_1.getClearingHouseStateAccountPublicKey(this.program.programId);
|
|
58
|
+
const state = (yield this.program.account.state.fetch(statePublicKey));
|
|
59
|
+
this.accountsToPoll.set(statePublicKey.toString(), {
|
|
60
|
+
key: 'state',
|
|
61
|
+
publicKey: statePublicKey,
|
|
62
|
+
eventType: 'stateAccountUpdate',
|
|
63
|
+
});
|
|
64
|
+
this.accountsToPoll.set(state.markets.toString(), {
|
|
65
|
+
key: 'markets',
|
|
66
|
+
publicKey: state.markets,
|
|
67
|
+
eventType: 'marketsAccountUpdate',
|
|
68
|
+
});
|
|
69
|
+
this.accountsToPoll.set(state.orderState.toString(), {
|
|
70
|
+
key: 'orderState',
|
|
71
|
+
publicKey: state.orderState,
|
|
72
|
+
eventType: 'orderStateAccountUpdate',
|
|
73
|
+
});
|
|
74
|
+
if ((_a = this.optionalExtraSubscriptions) === null || _a === void 0 ? void 0 : _a.includes('tradeHistoryAccount')) {
|
|
75
|
+
this.accountsToPoll.set(state.tradeHistory.toString(), {
|
|
76
|
+
key: 'tradeHistory',
|
|
77
|
+
publicKey: state.tradeHistory,
|
|
78
|
+
eventType: 'tradeHistoryAccountUpdate',
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if ((_b = this.optionalExtraSubscriptions) === null || _b === void 0 ? void 0 : _b.includes('depositHistoryAccount')) {
|
|
82
|
+
this.accountsToPoll.set(state.depositHistory.toString(), {
|
|
83
|
+
key: 'depositHistory',
|
|
84
|
+
publicKey: state.depositHistory,
|
|
85
|
+
eventType: 'depositHistoryAccountUpdate',
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if ((_c = this.optionalExtraSubscriptions) === null || _c === void 0 ? void 0 : _c.includes('fundingPaymentHistoryAccount')) {
|
|
89
|
+
this.accountsToPoll.set(state.fundingPaymentHistory.toString(), {
|
|
90
|
+
key: 'fundingPaymentHistory',
|
|
91
|
+
publicKey: state.fundingPaymentHistory,
|
|
92
|
+
eventType: 'fundingPaymentHistoryAccountUpdate',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
if ((_d = this.optionalExtraSubscriptions) === null || _d === void 0 ? void 0 : _d.includes('fundingRateHistoryAccount')) {
|
|
96
|
+
this.accountsToPoll.set(state.fundingRateHistory.toString(), {
|
|
97
|
+
key: 'fundingRateHistory',
|
|
98
|
+
publicKey: state.fundingRateHistory,
|
|
99
|
+
eventType: 'fundingRateHistoryAccountUpdate',
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if ((_e = this.optionalExtraSubscriptions) === null || _e === void 0 ? void 0 : _e.includes('curveHistoryAccount')) {
|
|
103
|
+
this.accountsToPoll.set(state.extendedCurveHistory.toString(), {
|
|
104
|
+
key: 'extendedCurveHistory',
|
|
105
|
+
publicKey: state.extendedCurveHistory,
|
|
106
|
+
eventType: 'curveHistoryAccountUpdate',
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
if ((_f = this.optionalExtraSubscriptions) === null || _f === void 0 ? void 0 : _f.includes('liquidationHistoryAccount')) {
|
|
110
|
+
this.accountsToPoll.set(state.liquidationHistory.toString(), {
|
|
111
|
+
key: 'liquidationHistory',
|
|
112
|
+
publicKey: state.liquidationHistory,
|
|
113
|
+
eventType: 'liquidationHistoryAccountUpdate',
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
if ((_g = this.optionalExtraSubscriptions) === null || _g === void 0 ? void 0 : _g.includes('orderHistoryAccount')) {
|
|
117
|
+
const orderState = (yield this.program.account.orderState.fetch(state.orderState));
|
|
118
|
+
this.accountsToPoll.set(orderState.orderHistory.toString(), {
|
|
119
|
+
key: 'orderHistory',
|
|
120
|
+
publicKey: orderState.orderHistory,
|
|
121
|
+
eventType: 'orderHistoryAccountUpdate',
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
addToAccountLoader() {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
for (const [_, accountToPoll] of this.accountsToPoll) {
|
|
129
|
+
accountToPoll.callbackId = this.accountLoader.addAccount(accountToPoll.publicKey, (buffer) => {
|
|
130
|
+
const account = this.program.account[accountToPoll.key].coder.accounts.decode(utils_1.capitalize(accountToPoll.key), buffer);
|
|
131
|
+
this[accountToPoll.key] = account;
|
|
132
|
+
// @ts-ignore
|
|
133
|
+
this.eventEmitter.emit(accountToPoll.eventType, account);
|
|
134
|
+
this.eventEmitter.emit('update');
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
this.errorCallbackId = this.accountLoader.addErrorCallbacks((error) => {
|
|
138
|
+
this.eventEmitter.emit('error', error);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
fetch() {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
144
|
+
yield this.accountLoader.load();
|
|
145
|
+
for (const [_, accountToPoll] of this.accountsToPoll) {
|
|
146
|
+
const buffer = this.accountLoader.getAccountData(accountToPoll.publicKey);
|
|
147
|
+
if (buffer) {
|
|
148
|
+
this[accountToPoll.key] = this.program.account[accountToPoll.key].coder.accounts.decode(utils_1.capitalize(accountToPoll.key), buffer);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
unsubscribe() {
|
|
154
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
155
|
+
if (!this.isSubscribed) {
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
for (const [_, accountToPoll] of this.accountsToPoll) {
|
|
159
|
+
this.accountLoader.removeAccount(accountToPoll.publicKey, accountToPoll.callbackId);
|
|
160
|
+
}
|
|
161
|
+
this.accountLoader.removeErrorCallbacks(this.errorCallbackId);
|
|
162
|
+
this.errorCallbackId = undefined;
|
|
163
|
+
this.accountsToPoll.clear();
|
|
164
|
+
this.isSubscribed = false;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
assertIsSubscribed() {
|
|
168
|
+
if (!this.isSubscribed) {
|
|
169
|
+
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
assertOptionalIsSubscribed(optionalSubscription) {
|
|
173
|
+
if (!this.isSubscribed) {
|
|
174
|
+
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
175
|
+
}
|
|
176
|
+
if (!this.optionalExtraSubscriptions.includes(optionalSubscription)) {
|
|
177
|
+
throw new types_1.NotSubscribedError(`You need to subscribe to the optional Clearing House account "${optionalSubscription}" to use this method`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
getStateAccount() {
|
|
181
|
+
this.assertIsSubscribed();
|
|
182
|
+
return this.state;
|
|
183
|
+
}
|
|
184
|
+
getMarketsAccount() {
|
|
185
|
+
this.assertIsSubscribed();
|
|
186
|
+
return this.markets;
|
|
187
|
+
}
|
|
188
|
+
getOrderStateAccount() {
|
|
189
|
+
this.assertIsSubscribed();
|
|
190
|
+
return this.orderState;
|
|
191
|
+
}
|
|
192
|
+
getTradeHistoryAccount() {
|
|
193
|
+
this.assertIsSubscribed();
|
|
194
|
+
this.assertOptionalIsSubscribed('tradeHistoryAccount');
|
|
195
|
+
return this.tradeHistory;
|
|
196
|
+
}
|
|
197
|
+
getDepositHistoryAccount() {
|
|
198
|
+
this.assertIsSubscribed();
|
|
199
|
+
this.assertOptionalIsSubscribed('depositHistoryAccount');
|
|
200
|
+
return this.depositHistory;
|
|
201
|
+
}
|
|
202
|
+
getFundingPaymentHistoryAccount() {
|
|
203
|
+
this.assertIsSubscribed();
|
|
204
|
+
this.assertOptionalIsSubscribed('fundingPaymentHistoryAccount');
|
|
205
|
+
return this.fundingPaymentHistory;
|
|
206
|
+
}
|
|
207
|
+
getFundingRateHistoryAccount() {
|
|
208
|
+
this.assertIsSubscribed();
|
|
209
|
+
this.assertOptionalIsSubscribed('fundingRateHistoryAccount');
|
|
210
|
+
return this.fundingRateHistory;
|
|
211
|
+
}
|
|
212
|
+
getCurveHistoryAccount() {
|
|
213
|
+
this.assertIsSubscribed();
|
|
214
|
+
this.assertOptionalIsSubscribed('curveHistoryAccount');
|
|
215
|
+
return this.extendedCurveHistory;
|
|
216
|
+
}
|
|
217
|
+
getLiquidationHistoryAccount() {
|
|
218
|
+
this.assertIsSubscribed();
|
|
219
|
+
this.assertOptionalIsSubscribed('liquidationHistoryAccount');
|
|
220
|
+
return this.liquidationHistory;
|
|
221
|
+
}
|
|
222
|
+
getOrderHistoryAccount() {
|
|
223
|
+
this.assertIsSubscribed();
|
|
224
|
+
this.assertOptionalIsSubscribed('orderHistoryAccount');
|
|
225
|
+
return this.orderHistory;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
exports.PollingClearingHouseAccountSubscriber = PollingClearingHouseAccountSubscriber;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { TokenAccountEvents, TokenAccountSubscriber } from './types';
|
|
3
|
+
import { Program } from '@project-serum/anchor';
|
|
4
|
+
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { PublicKey } from '@solana/web3.js';
|
|
7
|
+
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
8
|
+
import { AccountInfo } from '@solana/spl-token';
|
|
9
|
+
export declare class PollingTokenAccountSubscriber implements TokenAccountSubscriber {
|
|
10
|
+
isSubscribed: boolean;
|
|
11
|
+
program: Program;
|
|
12
|
+
eventEmitter: StrictEventEmitter<EventEmitter, TokenAccountEvents>;
|
|
13
|
+
publicKey: PublicKey;
|
|
14
|
+
accountLoader: BulkAccountLoader;
|
|
15
|
+
callbackId?: string;
|
|
16
|
+
errorCallbackId?: string;
|
|
17
|
+
tokenAccount?: AccountInfo;
|
|
18
|
+
constructor(publicKey: PublicKey, accountLoader: BulkAccountLoader);
|
|
19
|
+
subscribe(): Promise<boolean>;
|
|
20
|
+
addToAccountLoader(): void;
|
|
21
|
+
fetch(): Promise<void>;
|
|
22
|
+
unsubscribe(): Promise<void>;
|
|
23
|
+
assertIsSubscribed(): void;
|
|
24
|
+
getTokenAccount(): AccountInfo;
|
|
25
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PollingTokenAccountSubscriber = void 0;
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
const events_1 = require("events");
|
|
15
|
+
const token_1 = require("../token");
|
|
16
|
+
class PollingTokenAccountSubscriber {
|
|
17
|
+
constructor(publicKey, accountLoader) {
|
|
18
|
+
this.isSubscribed = false;
|
|
19
|
+
this.publicKey = publicKey;
|
|
20
|
+
this.accountLoader = accountLoader;
|
|
21
|
+
this.eventEmitter = new events_1.EventEmitter();
|
|
22
|
+
}
|
|
23
|
+
subscribe() {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
if (this.isSubscribed) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
this.addToAccountLoader();
|
|
29
|
+
yield this.fetch();
|
|
30
|
+
this.eventEmitter.emit('update');
|
|
31
|
+
this.isSubscribed = true;
|
|
32
|
+
return true;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
addToAccountLoader() {
|
|
36
|
+
if (this.callbackId) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
this.callbackId = this.accountLoader.addAccount(this.publicKey, (buffer) => {
|
|
40
|
+
const tokenAccount = token_1.parseTokenAccount(buffer);
|
|
41
|
+
this.tokenAccount = tokenAccount;
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
this.eventEmitter.emit('tokenAccountUpdate', tokenAccount);
|
|
44
|
+
this.eventEmitter.emit('update');
|
|
45
|
+
});
|
|
46
|
+
this.errorCallbackId = this.accountLoader.addErrorCallbacks((error) => {
|
|
47
|
+
this.eventEmitter.emit('error', error);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
fetch() {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
yield this.accountLoader.load();
|
|
53
|
+
const buffer = this.accountLoader.getAccountData(this.publicKey);
|
|
54
|
+
this.tokenAccount = token_1.parseTokenAccount(buffer);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
unsubscribe() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
if (!this.isSubscribed) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
this.accountLoader.removeAccount(this.publicKey, this.callbackId);
|
|
63
|
+
this.callbackId = undefined;
|
|
64
|
+
this.accountLoader.removeErrorCallbacks(this.errorCallbackId);
|
|
65
|
+
this.errorCallbackId = undefined;
|
|
66
|
+
this.isSubscribed = false;
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
assertIsSubscribed() {
|
|
70
|
+
if (!this.isSubscribed) {
|
|
71
|
+
throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
getTokenAccount() {
|
|
75
|
+
this.assertIsSubscribed();
|
|
76
|
+
return this.tokenAccount;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.PollingTokenAccountSubscriber = PollingTokenAccountSubscriber;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { AccountToPoll, UserAccountEvents, UserAccountSubscriber } from './types';
|
|
3
|
+
import { Program } from '@project-serum/anchor';
|
|
4
|
+
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
|
+
import { EventEmitter } from 'events';
|
|
6
|
+
import { PublicKey } from '@solana/web3.js';
|
|
7
|
+
import { UserAccount, UserOrdersAccount, UserPositionsAccount } from '../types';
|
|
8
|
+
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
9
|
+
import { ClearingHouseConfigType } from '../factory/clearingHouse';
|
|
10
|
+
export declare class PollingUserAccountSubscriber implements UserAccountSubscriber {
|
|
11
|
+
isSubscribed: boolean;
|
|
12
|
+
program: Program;
|
|
13
|
+
eventEmitter: StrictEventEmitter<EventEmitter, UserAccountEvents>;
|
|
14
|
+
authority: PublicKey;
|
|
15
|
+
accountLoader: BulkAccountLoader;
|
|
16
|
+
accountsToPoll: Map<string, AccountToPoll>;
|
|
17
|
+
errorCallbackId?: string;
|
|
18
|
+
user?: UserAccount;
|
|
19
|
+
userPositions?: UserPositionsAccount;
|
|
20
|
+
userOrders?: UserOrdersAccount;
|
|
21
|
+
type: ClearingHouseConfigType;
|
|
22
|
+
constructor(program: Program, authority: PublicKey, accountLoader: BulkAccountLoader);
|
|
23
|
+
subscribe(): Promise<boolean>;
|
|
24
|
+
addToAccountLoader(): Promise<void>;
|
|
25
|
+
fetchIfUnloaded(): Promise<void>;
|
|
26
|
+
fetch(): Promise<void>;
|
|
27
|
+
unsubscribe(): Promise<void>;
|
|
28
|
+
assertIsSubscribed(): void;
|
|
29
|
+
getUserAccount(): UserAccount;
|
|
30
|
+
getUserPositionsAccount(): UserPositionsAccount;
|
|
31
|
+
getUserOrdersAccount(): UserOrdersAccount;
|
|
32
|
+
}
|