@drift-labs/sdk 0.1.20 → 0.1.21-master.5
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 +0 -1
- package/lib/accounts/bulkAccountLoader.js +17 -6
- package/lib/accounts/bulkUserSubscription.d.ts +0 -1
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +5 -2
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +23 -1
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts +0 -1
- package/lib/accounts/pollingUserAccountSubscriber.d.ts +3 -2
- package/lib/accounts/pollingUserAccountSubscriber.js +13 -0
- package/lib/accounts/types.d.ts +8 -3
- package/lib/accounts/utils.d.ts +0 -1
- package/lib/accounts/webSocketAccountSubscriber.d.ts +0 -1
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +5 -2
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +25 -0
- package/lib/accounts/webSocketUserAccountSubscriber.d.ts +3 -2
- package/lib/accounts/webSocketUserAccountSubscriber.js +11 -0
- package/lib/addresses.d.ts +4 -1
- package/lib/addresses.js +28 -1
- package/lib/admin.d.ts +10 -4
- package/lib/admin.js +48 -3
- package/lib/assert/assert.d.ts +0 -1
- package/lib/clearingHouse.d.ts +27 -2
- package/lib/clearingHouse.js +307 -7
- package/lib/clearingHouseUser.d.ts +16 -3
- package/lib/clearingHouseUser.js +79 -9
- package/lib/config.d.ts +0 -1
- package/lib/constants/markets.d.ts +0 -1
- package/lib/constants/markets.js +8 -0
- package/lib/constants/numericConstants.d.ts +1 -1
- package/lib/constants/numericConstants.js +2 -1
- package/lib/examples/makeTradeExample.d.ts +0 -1
- package/lib/factory/clearingHouse.d.ts +0 -1
- package/lib/factory/clearingHouseUser.d.ts +0 -1
- package/lib/idl/clearing_house.json +1077 -50
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -0
- package/lib/math/amm.d.ts +3 -1
- package/lib/math/amm.js +121 -8
- package/lib/math/conversion.d.ts +0 -1
- package/lib/math/funding.d.ts +0 -1
- package/lib/math/insuranceFund.d.ts +0 -1
- package/lib/math/market.d.ts +2 -2
- package/lib/math/market.js +11 -1
- package/lib/math/orders.d.ts +3 -0
- package/lib/math/orders.js +32 -0
- package/lib/math/position.d.ts +4 -2
- package/lib/math/position.js +18 -4
- package/lib/math/trade.d.ts +0 -1
- package/lib/math/utils.d.ts +0 -1
- package/lib/mockUSDCFaucet.d.ts +0 -1
- 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/token/index.d.ts +0 -1
- 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 +145 -2
- 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 +1 -1
- package/src/accounts/bulkAccountLoader.ts +21 -13
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +33 -0
- package/src/accounts/pollingUserAccountSubscriber.ts +30 -2
- package/src/accounts/types.ts +11 -2
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +47 -0
- package/src/accounts/webSocketUserAccountSubscriber.ts +29 -2
- package/src/addresses.ts +37 -0
- package/src/admin.ts +84 -6
- package/src/clearingHouse.ts +430 -5
- package/src/clearingHouseUser.ts +129 -12
- package/src/constants/markets.ts +8 -0
- package/src/constants/numericConstants.ts +1 -0
- package/src/idl/clearing_house.json +1077 -50
- package/src/index.ts +3 -0
- package/src/math/amm.ts +169 -14
- package/src/math/market.ts +28 -2
- package/src/math/orders.ts +44 -0
- package/src/math/position.ts +23 -3
- package/src/orderParams.ts +151 -0
- package/src/orders.ts +236 -0
- package/src/types.ts +129 -1
- package/tsconfig.json +0 -1
- package/lib/accounts/bulkAccountLoader.d.ts.map +0 -1
- package/lib/accounts/bulkUserSubscription.d.ts.map +0 -1
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/pollingTokenAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/pollingUserAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/types.d.ts.map +0 -1
- package/lib/accounts/utils.d.ts.map +0 -1
- package/lib/accounts/webSocketAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts.map +0 -1
- package/lib/accounts/webSocketUserAccountSubscriber.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/factory/clearingHouse.d.ts.map +0 -1
- package/lib/factory/clearingHouseUser.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/token/index.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
|
@@ -78,12 +78,23 @@ class BulkAccountLoader {
|
|
|
78
78
|
this.loadPromise = new Promise((resolver) => {
|
|
79
79
|
this.loadPromiseResolver = resolver;
|
|
80
80
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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
|
+
}
|
|
87
98
|
});
|
|
88
99
|
}
|
|
89
100
|
loadChunk(accountsToLoad) {
|
|
@@ -3,7 +3,7 @@ import { AccountToPoll, ClearingHouseAccountEvents, ClearingHouseAccountSubscrib
|
|
|
3
3
|
import { Program } from '@project-serum/anchor';
|
|
4
4
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
|
-
import { DepositHistoryAccount, ExtendedCurveHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, LiquidationHistoryAccount, MarketsAccount, StateAccount, TradeHistoryAccount } from '../types';
|
|
6
|
+
import { DepositHistoryAccount, ExtendedCurveHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, LiquidationHistoryAccount, MarketsAccount, OrderHistoryAccount, OrderStateAccount, StateAccount, TradeHistoryAccount } from '../types';
|
|
7
7
|
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
8
8
|
import { ClearingHouseConfigType } from '../factory/clearingHouse';
|
|
9
9
|
export declare class PollingClearingHouseAccountSubscriber implements ClearingHouseAccountSubscriber {
|
|
@@ -15,12 +15,14 @@ export declare class PollingClearingHouseAccountSubscriber implements ClearingHo
|
|
|
15
15
|
errorCallbackId?: string;
|
|
16
16
|
state?: StateAccount;
|
|
17
17
|
markets?: MarketsAccount;
|
|
18
|
+
orderState?: OrderStateAccount;
|
|
18
19
|
tradeHistory?: TradeHistoryAccount;
|
|
19
20
|
depositHistory?: DepositHistoryAccount;
|
|
20
21
|
fundingPaymentHistory?: FundingPaymentHistoryAccount;
|
|
21
22
|
fundingRateHistory?: FundingRateHistoryAccount;
|
|
22
23
|
liquidationHistory?: LiquidationHistoryAccount;
|
|
23
24
|
extendedCurveHistory: ExtendedCurveHistoryAccount;
|
|
25
|
+
orderHistory?: OrderHistoryAccount;
|
|
24
26
|
optionalExtraSubscriptions: ClearingHouseAccountTypes[];
|
|
25
27
|
type: ClearingHouseConfigType;
|
|
26
28
|
private isSubscribing;
|
|
@@ -36,11 +38,12 @@ export declare class PollingClearingHouseAccountSubscriber implements ClearingHo
|
|
|
36
38
|
assertOptionalIsSubscribed(optionalSubscription: ClearingHouseAccountTypes): void;
|
|
37
39
|
getStateAccount(): StateAccount;
|
|
38
40
|
getMarketsAccount(): MarketsAccount;
|
|
41
|
+
getOrderStateAccount(): OrderStateAccount;
|
|
39
42
|
getTradeHistoryAccount(): TradeHistoryAccount;
|
|
40
43
|
getDepositHistoryAccount(): DepositHistoryAccount;
|
|
41
44
|
getFundingPaymentHistoryAccount(): FundingPaymentHistoryAccount;
|
|
42
45
|
getFundingRateHistoryAccount(): FundingRateHistoryAccount;
|
|
43
46
|
getCurveHistoryAccount(): ExtendedCurveHistoryAccount;
|
|
44
47
|
getLiquidationHistoryAccount(): LiquidationHistoryAccount;
|
|
48
|
+
getOrderHistoryAccount(): OrderHistoryAccount;
|
|
45
49
|
}
|
|
46
|
-
//# sourceMappingURL=pollingClearingHouseAccountSubscriber.d.ts.map
|
|
@@ -49,7 +49,7 @@ class PollingClearingHouseAccountSubscriber {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
updateAccountsToPoll() {
|
|
52
|
-
var _a, _b, _c, _d, _e, _f;
|
|
52
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
53
53
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
54
|
if (this.accountsToPoll.size > 0) {
|
|
55
55
|
return;
|
|
@@ -66,6 +66,11 @@ class PollingClearingHouseAccountSubscriber {
|
|
|
66
66
|
publicKey: state.markets,
|
|
67
67
|
eventType: 'marketsAccountUpdate',
|
|
68
68
|
});
|
|
69
|
+
this.accountsToPoll.set(state.orderState.toString(), {
|
|
70
|
+
key: 'orderState',
|
|
71
|
+
publicKey: state.orderState,
|
|
72
|
+
eventType: 'orderStateAccountUpdate',
|
|
73
|
+
});
|
|
69
74
|
if ((_a = this.optionalExtraSubscriptions) === null || _a === void 0 ? void 0 : _a.includes('tradeHistoryAccount')) {
|
|
70
75
|
this.accountsToPoll.set(state.tradeHistory.toString(), {
|
|
71
76
|
key: 'tradeHistory',
|
|
@@ -108,6 +113,14 @@ class PollingClearingHouseAccountSubscriber {
|
|
|
108
113
|
eventType: 'liquidationHistoryAccountUpdate',
|
|
109
114
|
});
|
|
110
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
|
+
}
|
|
111
124
|
});
|
|
112
125
|
}
|
|
113
126
|
addToAccountLoader() {
|
|
@@ -172,6 +185,10 @@ class PollingClearingHouseAccountSubscriber {
|
|
|
172
185
|
this.assertIsSubscribed();
|
|
173
186
|
return this.markets;
|
|
174
187
|
}
|
|
188
|
+
getOrderStateAccount() {
|
|
189
|
+
this.assertIsSubscribed();
|
|
190
|
+
return this.orderState;
|
|
191
|
+
}
|
|
175
192
|
getTradeHistoryAccount() {
|
|
176
193
|
this.assertIsSubscribed();
|
|
177
194
|
this.assertOptionalIsSubscribed('tradeHistoryAccount');
|
|
@@ -202,5 +219,10 @@ class PollingClearingHouseAccountSubscriber {
|
|
|
202
219
|
this.assertOptionalIsSubscribed('liquidationHistoryAccount');
|
|
203
220
|
return this.liquidationHistory;
|
|
204
221
|
}
|
|
222
|
+
getOrderHistoryAccount() {
|
|
223
|
+
this.assertIsSubscribed();
|
|
224
|
+
this.assertOptionalIsSubscribed('orderHistoryAccount');
|
|
225
|
+
return this.orderHistory;
|
|
226
|
+
}
|
|
205
227
|
}
|
|
206
228
|
exports.PollingClearingHouseAccountSubscriber = PollingClearingHouseAccountSubscriber;
|
|
@@ -4,7 +4,7 @@ import { Program } from '@project-serum/anchor';
|
|
|
4
4
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
6
|
import { PublicKey } from '@solana/web3.js';
|
|
7
|
-
import { UserAccount, UserPositionsAccount } from '../types';
|
|
7
|
+
import { UserAccount, UserOrdersAccount, UserPositionsAccount } from '../types';
|
|
8
8
|
import { BulkAccountLoader } from './bulkAccountLoader';
|
|
9
9
|
import { ClearingHouseConfigType } from '../factory/clearingHouse';
|
|
10
10
|
export declare class PollingUserAccountSubscriber implements UserAccountSubscriber {
|
|
@@ -17,6 +17,7 @@ export declare class PollingUserAccountSubscriber implements UserAccountSubscrib
|
|
|
17
17
|
errorCallbackId?: string;
|
|
18
18
|
user?: UserAccount;
|
|
19
19
|
userPositions?: UserPositionsAccount;
|
|
20
|
+
userOrders?: UserOrdersAccount;
|
|
20
21
|
type: ClearingHouseConfigType;
|
|
21
22
|
constructor(program: Program, authority: PublicKey, accountLoader: BulkAccountLoader);
|
|
22
23
|
subscribe(): Promise<boolean>;
|
|
@@ -27,5 +28,5 @@ export declare class PollingUserAccountSubscriber implements UserAccountSubscrib
|
|
|
27
28
|
assertIsSubscribed(): void;
|
|
28
29
|
getUserAccount(): UserAccount;
|
|
29
30
|
getUserPositionsAccount(): UserPositionsAccount;
|
|
31
|
+
getUserOrdersAccount(): UserOrdersAccount;
|
|
30
32
|
}
|
|
31
|
-
//# sourceMappingURL=pollingUserAccountSubscriber.d.ts.map
|
|
@@ -53,6 +53,15 @@ class PollingUserAccountSubscriber {
|
|
|
53
53
|
publicKey: userAccount.positions,
|
|
54
54
|
eventType: 'userPositionsData',
|
|
55
55
|
});
|
|
56
|
+
const userOrdersPublicKey = yield addresses_1.getUserOrdersAccountPublicKey(this.program.programId, userPublicKey);
|
|
57
|
+
const userOrdersExist = (yield this.program.provider.connection.getParsedAccountInfo(userOrdersPublicKey)).value !== null;
|
|
58
|
+
if (userOrdersExist) {
|
|
59
|
+
this.accountsToPoll.set(userOrdersPublicKey.toString(), {
|
|
60
|
+
key: 'userOrders',
|
|
61
|
+
publicKey: userOrdersPublicKey,
|
|
62
|
+
eventType: 'userOrdersData',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
56
65
|
for (const [_, accountToPoll] of this.accountsToPoll) {
|
|
57
66
|
accountToPoll.callbackId = this.accountLoader.addAccount(accountToPoll.publicKey, (buffer) => {
|
|
58
67
|
const account = this.program.account[accountToPoll.key].coder.accounts.decode(utils_1.capitalize(accountToPoll.key), buffer);
|
|
@@ -119,5 +128,9 @@ class PollingUserAccountSubscriber {
|
|
|
119
128
|
this.assertIsSubscribed();
|
|
120
129
|
return this.userPositions;
|
|
121
130
|
}
|
|
131
|
+
getUserOrdersAccount() {
|
|
132
|
+
this.assertIsSubscribed();
|
|
133
|
+
return this.userOrders;
|
|
134
|
+
}
|
|
122
135
|
}
|
|
123
136
|
exports.PollingUserAccountSubscriber = PollingUserAccountSubscriber;
|
package/lib/accounts/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { DepositHistoryAccount, ExtendedCurveHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, LiquidationHistoryAccount, MarketsAccount, StateAccount, TradeHistoryAccount, UserAccount, UserPositionsAccount } from '../types';
|
|
2
|
+
import { DepositHistoryAccount, ExtendedCurveHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, LiquidationHistoryAccount, MarketsAccount, OrderHistoryAccount, OrderStateAccount, StateAccount, TradeHistoryAccount, UserAccount, UserOrdersAccount, UserPositionsAccount } from '../types';
|
|
3
3
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
4
4
|
import { EventEmitter } from 'events';
|
|
5
5
|
import { PublicKey } from '@solana/web3.js';
|
|
@@ -23,10 +23,12 @@ export interface ClearingHouseAccountEvents {
|
|
|
23
23
|
liquidationHistoryAccountUpdate: (payload: LiquidationHistoryAccount) => void;
|
|
24
24
|
depositHistoryAccountUpdate: (payload: DepositHistoryAccount) => void;
|
|
25
25
|
curveHistoryAccountUpdate: (payload: ExtendedCurveHistoryAccount) => void;
|
|
26
|
+
orderHistoryAccountUpdate: (payload: OrderHistoryAccount) => void;
|
|
27
|
+
orderStateAccountUpdate: (payload: OrderStateAccount) => void;
|
|
26
28
|
update: void;
|
|
27
29
|
error: (e: Error) => void;
|
|
28
30
|
}
|
|
29
|
-
export declare type ClearingHouseAccountTypes = 'tradeHistoryAccount' | 'depositHistoryAccount' | 'fundingPaymentHistoryAccount' | 'fundingRateHistoryAccount' | 'curveHistoryAccount' | 'liquidationHistoryAccount';
|
|
31
|
+
export declare type ClearingHouseAccountTypes = 'tradeHistoryAccount' | 'depositHistoryAccount' | 'fundingPaymentHistoryAccount' | 'fundingRateHistoryAccount' | 'curveHistoryAccount' | 'liquidationHistoryAccount' | 'orderHistoryAccount';
|
|
30
32
|
export interface ClearingHouseAccountSubscriber {
|
|
31
33
|
eventEmitter: StrictEventEmitter<EventEmitter, ClearingHouseAccountEvents>;
|
|
32
34
|
isSubscribed: boolean;
|
|
@@ -42,11 +44,14 @@ export interface ClearingHouseAccountSubscriber {
|
|
|
42
44
|
getFundingRateHistoryAccount(): FundingRateHistoryAccount;
|
|
43
45
|
getCurveHistoryAccount(): ExtendedCurveHistoryAccount;
|
|
44
46
|
getLiquidationHistoryAccount(): LiquidationHistoryAccount;
|
|
47
|
+
getOrderStateAccount(): OrderStateAccount;
|
|
48
|
+
getOrderHistoryAccount(): OrderHistoryAccount;
|
|
45
49
|
type: ClearingHouseConfigType;
|
|
46
50
|
}
|
|
47
51
|
export interface UserAccountEvents {
|
|
48
52
|
userAccountData: (payload: UserAccount) => void;
|
|
49
53
|
userPositionsData: (payload: UserPositionsAccount) => void;
|
|
54
|
+
userOrdersData: (payload: UserOrdersAccount) => void;
|
|
50
55
|
update: void;
|
|
51
56
|
error: (e: Error) => void;
|
|
52
57
|
}
|
|
@@ -58,6 +63,7 @@ export interface UserAccountSubscriber {
|
|
|
58
63
|
unsubscribe(): Promise<void>;
|
|
59
64
|
getUserAccount(): UserAccount;
|
|
60
65
|
getUserPositionsAccount(): UserPositionsAccount;
|
|
66
|
+
getUserOrdersAccount(): UserOrdersAccount;
|
|
61
67
|
type: ClearingHouseUserConfigType;
|
|
62
68
|
}
|
|
63
69
|
export interface TokenAccountEvents {
|
|
@@ -83,4 +89,3 @@ export declare type AccountData = {
|
|
|
83
89
|
slot: number;
|
|
84
90
|
buffer: Buffer | undefined;
|
|
85
91
|
};
|
|
86
|
-
//# sourceMappingURL=types.d.ts.map
|
package/lib/accounts/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { ClearingHouseAccountSubscriber, ClearingHouseAccountEvents, ClearingHouseAccountTypes } from './types';
|
|
3
3
|
import { AccountSubscriber } from './types';
|
|
4
|
-
import { DepositHistoryAccount, ExtendedCurveHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, LiquidationHistoryAccount, MarketsAccount, StateAccount, TradeHistoryAccount } from '../types';
|
|
4
|
+
import { DepositHistoryAccount, ExtendedCurveHistoryAccount, FundingPaymentHistoryAccount, FundingRateHistoryAccount, LiquidationHistoryAccount, MarketsAccount, OrderHistoryAccount, OrderStateAccount, StateAccount, TradeHistoryAccount } from '../types';
|
|
5
5
|
import { Program } from '@project-serum/anchor';
|
|
6
6
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
7
7
|
import { EventEmitter } from 'events';
|
|
@@ -18,6 +18,8 @@ export declare class WebSocketClearingHouseAccountSubscriber implements Clearing
|
|
|
18
18
|
fundingRateHistoryAccountSubscriber?: AccountSubscriber<FundingRateHistoryAccount>;
|
|
19
19
|
curveHistoryAccountSubscriber?: AccountSubscriber<ExtendedCurveHistoryAccount>;
|
|
20
20
|
liquidationHistoryAccountSubscriber?: AccountSubscriber<LiquidationHistoryAccount>;
|
|
21
|
+
orderStateAccountSubscriber?: AccountSubscriber<OrderStateAccount>;
|
|
22
|
+
orderHistoryAccountSubscriber?: AccountSubscriber<OrderHistoryAccount>;
|
|
21
23
|
optionalExtraSubscriptions: ClearingHouseAccountTypes[];
|
|
22
24
|
type: ClearingHouseConfigType;
|
|
23
25
|
private isSubscribing;
|
|
@@ -37,5 +39,6 @@ export declare class WebSocketClearingHouseAccountSubscriber implements Clearing
|
|
|
37
39
|
getFundingRateHistoryAccount(): FundingRateHistoryAccount;
|
|
38
40
|
getCurveHistoryAccount(): ExtendedCurveHistoryAccount;
|
|
39
41
|
getLiquidationHistoryAccount(): LiquidationHistoryAccount;
|
|
42
|
+
getOrderHistoryAccount(): OrderHistoryAccount;
|
|
43
|
+
getOrderStateAccount(): OrderStateAccount;
|
|
40
44
|
}
|
|
41
|
-
//# sourceMappingURL=webSocketClearingHouseAccountSubscriber.d.ts.map
|
|
@@ -48,6 +48,12 @@ class WebSocketClearingHouseAccountSubscriber {
|
|
|
48
48
|
this.eventEmitter.emit('marketsAccountUpdate', data);
|
|
49
49
|
this.eventEmitter.emit('update');
|
|
50
50
|
});
|
|
51
|
+
this.orderStateAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('orderState', this.program, state.orderState);
|
|
52
|
+
yield this.orderStateAccountSubscriber.subscribe((data) => {
|
|
53
|
+
this.eventEmitter.emit('orderStateAccountUpdate', data);
|
|
54
|
+
this.eventEmitter.emit('update');
|
|
55
|
+
});
|
|
56
|
+
const orderState = this.orderStateAccountSubscriber.data;
|
|
51
57
|
// create subscribers for other state accounts
|
|
52
58
|
this.tradeHistoryAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('tradeHistory', this.program, state.tradeHistory);
|
|
53
59
|
this.depositHistoryAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('depositHistory', this.program, state.depositHistory);
|
|
@@ -56,6 +62,7 @@ class WebSocketClearingHouseAccountSubscriber {
|
|
|
56
62
|
this.fundingRateHistoryAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('fundingRateHistory', this.program, state.fundingRateHistory);
|
|
57
63
|
this.liquidationHistoryAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('liquidationHistory', this.program, state.liquidationHistory);
|
|
58
64
|
this.curveHistoryAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('extendedCurveHistory', this.program, state.extendedCurveHistory);
|
|
65
|
+
this.orderHistoryAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('orderHistory', this.program, orderState.orderHistory);
|
|
59
66
|
const extraSusbcribersToUse = [];
|
|
60
67
|
if (optionalSubscriptions === null || optionalSubscriptions === void 0 ? void 0 : optionalSubscriptions.includes('tradeHistoryAccount'))
|
|
61
68
|
extraSusbcribersToUse.push({
|
|
@@ -87,6 +94,11 @@ class WebSocketClearingHouseAccountSubscriber {
|
|
|
87
94
|
subscriber: this.curveHistoryAccountSubscriber,
|
|
88
95
|
eventType: 'curveHistoryAccountUpdate',
|
|
89
96
|
});
|
|
97
|
+
if (optionalSubscriptions === null || optionalSubscriptions === void 0 ? void 0 : optionalSubscriptions.includes('orderHistoryAccount'))
|
|
98
|
+
extraSusbcribersToUse.push({
|
|
99
|
+
subscriber: this.orderHistoryAccountSubscriber,
|
|
100
|
+
eventType: 'orderHistoryAccountUpdate',
|
|
101
|
+
});
|
|
90
102
|
this.optionalExtraSubscriptions = optionalSubscriptions !== null && optionalSubscriptions !== void 0 ? optionalSubscriptions : [];
|
|
91
103
|
// await all subcriptions in parallel to boost performance
|
|
92
104
|
//// the state account subscription above can't happen in here, because some of these susbcriptions are dependent on clearing house state being available
|
|
@@ -125,6 +137,7 @@ class WebSocketClearingHouseAccountSubscriber {
|
|
|
125
137
|
}
|
|
126
138
|
yield this.stateAccountSubscriber.unsubscribe();
|
|
127
139
|
yield this.marketsAccountSubscriber.unsubscribe();
|
|
140
|
+
yield this.orderStateAccountSubscriber.unsubscribe();
|
|
128
141
|
if (this.optionalExtraSubscriptions.includes('tradeHistoryAccount')) {
|
|
129
142
|
yield this.tradeHistoryAccountSubscriber.unsubscribe();
|
|
130
143
|
}
|
|
@@ -143,6 +156,9 @@ class WebSocketClearingHouseAccountSubscriber {
|
|
|
143
156
|
if (this.optionalExtraSubscriptions.includes('liquidationHistoryAccount')) {
|
|
144
157
|
yield this.liquidationHistoryAccountSubscriber.unsubscribe();
|
|
145
158
|
}
|
|
159
|
+
if (this.optionalExtraSubscriptions.includes('orderHistoryAccount')) {
|
|
160
|
+
yield this.orderHistoryAccountSubscriber.unsubscribe();
|
|
161
|
+
}
|
|
146
162
|
this.isSubscribed = false;
|
|
147
163
|
});
|
|
148
164
|
}
|
|
@@ -197,5 +213,14 @@ class WebSocketClearingHouseAccountSubscriber {
|
|
|
197
213
|
this.assertOptionalIsSubscribed('liquidationHistoryAccount');
|
|
198
214
|
return this.liquidationHistoryAccountSubscriber.data;
|
|
199
215
|
}
|
|
216
|
+
getOrderHistoryAccount() {
|
|
217
|
+
this.assertIsSubscribed();
|
|
218
|
+
this.assertOptionalIsSubscribed('orderHistoryAccount');
|
|
219
|
+
return this.orderHistoryAccountSubscriber.data;
|
|
220
|
+
}
|
|
221
|
+
getOrderStateAccount() {
|
|
222
|
+
this.assertIsSubscribed();
|
|
223
|
+
return this.orderStateAccountSubscriber.data;
|
|
224
|
+
}
|
|
200
225
|
}
|
|
201
226
|
exports.WebSocketClearingHouseAccountSubscriber = WebSocketClearingHouseAccountSubscriber;
|
|
@@ -4,7 +4,7 @@ import { Program } from '@project-serum/anchor';
|
|
|
4
4
|
import StrictEventEmitter from 'strict-event-emitter-types';
|
|
5
5
|
import { EventEmitter } from 'events';
|
|
6
6
|
import { PublicKey } from '@solana/web3.js';
|
|
7
|
-
import { UserAccount, UserPositionsAccount } from '../types';
|
|
7
|
+
import { UserAccount, UserOrdersAccount, UserPositionsAccount } from '../types';
|
|
8
8
|
import { ClearingHouseConfigType } from '../factory/clearingHouse';
|
|
9
9
|
export declare class WebSocketUserAccountSubscriber implements UserAccountSubscriber {
|
|
10
10
|
isSubscribed: boolean;
|
|
@@ -13,6 +13,7 @@ export declare class WebSocketUserAccountSubscriber implements UserAccountSubscr
|
|
|
13
13
|
authority: PublicKey;
|
|
14
14
|
userDataAccountSubscriber: AccountSubscriber<UserAccount>;
|
|
15
15
|
userPositionsAccountSubscriber: AccountSubscriber<UserPositionsAccount>;
|
|
16
|
+
userOrdersAccountSubscriber: AccountSubscriber<UserOrdersAccount>;
|
|
16
17
|
type: ClearingHouseConfigType;
|
|
17
18
|
constructor(program: Program, authority: PublicKey);
|
|
18
19
|
subscribe(): Promise<boolean>;
|
|
@@ -21,5 +22,5 @@ export declare class WebSocketUserAccountSubscriber implements UserAccountSubscr
|
|
|
21
22
|
assertIsSubscribed(): void;
|
|
22
23
|
getUserAccount(): UserAccount;
|
|
23
24
|
getUserPositionsAccount(): UserPositionsAccount;
|
|
25
|
+
getUserOrdersAccount(): UserOrdersAccount;
|
|
24
26
|
}
|
|
25
|
-
//# sourceMappingURL=webSocketUserAccountSubscriber.d.ts.map
|
|
@@ -39,6 +39,12 @@ class WebSocketUserAccountSubscriber {
|
|
|
39
39
|
this.eventEmitter.emit('userPositionsData', data);
|
|
40
40
|
this.eventEmitter.emit('update');
|
|
41
41
|
});
|
|
42
|
+
const userOrdersPublicKey = yield addresses_1.getUserOrdersAccountPublicKey(this.program.programId, userPublicKey);
|
|
43
|
+
this.userOrdersAccountSubscriber = new webSocketAccountSubscriber_1.WebSocketAccountSubscriber('userOrders', this.program, userOrdersPublicKey);
|
|
44
|
+
yield this.userOrdersAccountSubscriber.subscribe((data) => {
|
|
45
|
+
this.eventEmitter.emit('userOrdersData', data);
|
|
46
|
+
this.eventEmitter.emit('update');
|
|
47
|
+
});
|
|
42
48
|
this.eventEmitter.emit('update');
|
|
43
49
|
this.isSubscribed = true;
|
|
44
50
|
return true;
|
|
@@ -49,6 +55,7 @@ class WebSocketUserAccountSubscriber {
|
|
|
49
55
|
yield Promise.all([
|
|
50
56
|
this.userDataAccountSubscriber.fetch(),
|
|
51
57
|
this.userPositionsAccountSubscriber.fetch(),
|
|
58
|
+
this.userOrdersAccountSubscriber.fetch(),
|
|
52
59
|
]);
|
|
53
60
|
});
|
|
54
61
|
}
|
|
@@ -60,6 +67,7 @@ class WebSocketUserAccountSubscriber {
|
|
|
60
67
|
yield Promise.all([
|
|
61
68
|
this.userDataAccountSubscriber.unsubscribe(),
|
|
62
69
|
this.userPositionsAccountSubscriber.unsubscribe(),
|
|
70
|
+
yield this.userOrdersAccountSubscriber.unsubscribe(),
|
|
63
71
|
]);
|
|
64
72
|
this.isSubscribed = false;
|
|
65
73
|
});
|
|
@@ -77,5 +85,8 @@ class WebSocketUserAccountSubscriber {
|
|
|
77
85
|
this.assertIsSubscribed();
|
|
78
86
|
return this.userPositionsAccountSubscriber.data;
|
|
79
87
|
}
|
|
88
|
+
getUserOrdersAccount() {
|
|
89
|
+
return this.userOrdersAccountSubscriber.data;
|
|
90
|
+
}
|
|
80
91
|
}
|
|
81
92
|
exports.WebSocketUserAccountSubscriber = WebSocketUserAccountSubscriber;
|
package/lib/addresses.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
export declare function getClearingHouseStateAccountPublicKeyAndNonce(programId: PublicKey): Promise<[PublicKey, number]>;
|
|
3
|
+
export declare function getOrderStateAccountPublicKey(programId: PublicKey): Promise<PublicKey>;
|
|
4
|
+
export declare function getOrderStateAccountPublicKeyAndNonce(programId: PublicKey): Promise<[PublicKey, number]>;
|
|
3
5
|
export declare function getClearingHouseStateAccountPublicKey(programId: PublicKey): Promise<PublicKey>;
|
|
4
6
|
export declare function getUserAccountPublicKeyAndNonce(programId: PublicKey, authority: PublicKey): Promise<[PublicKey, number]>;
|
|
5
7
|
export declare function getUserAccountPublicKey(programId: PublicKey, authority: PublicKey): Promise<PublicKey>;
|
|
6
|
-
|
|
8
|
+
export declare function getUserOrdersAccountPublicKeyAndNonce(programId: PublicKey, userAccount: PublicKey): Promise<[PublicKey, number]>;
|
|
9
|
+
export declare function getUserOrdersAccountPublicKey(programId: PublicKey, userAccount: PublicKey): Promise<PublicKey>;
|
package/lib/addresses.js
CHANGED
|
@@ -28,7 +28,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getClearingHouseStateAccountPublicKey = exports.getClearingHouseStateAccountPublicKeyAndNonce = void 0;
|
|
31
|
+
exports.getUserOrdersAccountPublicKey = exports.getUserOrdersAccountPublicKeyAndNonce = exports.getUserAccountPublicKey = exports.getUserAccountPublicKeyAndNonce = exports.getClearingHouseStateAccountPublicKey = exports.getOrderStateAccountPublicKeyAndNonce = exports.getOrderStateAccountPublicKey = exports.getClearingHouseStateAccountPublicKeyAndNonce = void 0;
|
|
32
32
|
const anchor = __importStar(require("@project-serum/anchor"));
|
|
33
33
|
function getClearingHouseStateAccountPublicKeyAndNonce(programId) {
|
|
34
34
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -36,6 +36,18 @@ function getClearingHouseStateAccountPublicKeyAndNonce(programId) {
|
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
exports.getClearingHouseStateAccountPublicKeyAndNonce = getClearingHouseStateAccountPublicKeyAndNonce;
|
|
39
|
+
function getOrderStateAccountPublicKey(programId) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
return (yield getOrderStateAccountPublicKeyAndNonce(programId))[0];
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
exports.getOrderStateAccountPublicKey = getOrderStateAccountPublicKey;
|
|
45
|
+
function getOrderStateAccountPublicKeyAndNonce(programId) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
+
return anchor.web3.PublicKey.findProgramAddress([Buffer.from(anchor.utils.bytes.utf8.encode('order_state'))], programId);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
exports.getOrderStateAccountPublicKeyAndNonce = getOrderStateAccountPublicKeyAndNonce;
|
|
39
51
|
function getClearingHouseStateAccountPublicKey(programId) {
|
|
40
52
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
53
|
return (yield getClearingHouseStateAccountPublicKeyAndNonce(programId))[0];
|
|
@@ -54,3 +66,18 @@ function getUserAccountPublicKey(programId, authority) {
|
|
|
54
66
|
});
|
|
55
67
|
}
|
|
56
68
|
exports.getUserAccountPublicKey = getUserAccountPublicKey;
|
|
69
|
+
function getUserOrdersAccountPublicKeyAndNonce(programId, userAccount) {
|
|
70
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
71
|
+
return anchor.web3.PublicKey.findProgramAddress([
|
|
72
|
+
Buffer.from(anchor.utils.bytes.utf8.encode('user_orders')),
|
|
73
|
+
userAccount.toBuffer(),
|
|
74
|
+
], programId);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
exports.getUserOrdersAccountPublicKeyAndNonce = getUserOrdersAccountPublicKeyAndNonce;
|
|
78
|
+
function getUserOrdersAccountPublicKey(programId, userAccount) {
|
|
79
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
+
return (yield getUserOrdersAccountPublicKeyAndNonce(programId, userAccount))[0];
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
exports.getUserOrdersAccountPublicKey = getUserOrdersAccountPublicKey;
|
package/lib/admin.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
/// <reference types="bn.js" />
|
|
2
2
|
import { ConfirmOptions, Connection, PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
3
|
-
import { FeeStructure, IWallet, OracleGuardRails, OracleSource } from './types';
|
|
3
|
+
import { FeeStructure, IWallet, OracleGuardRails, OracleSource, OrderFillerRewardStructure } from './types';
|
|
4
4
|
import { BN } from '@project-serum/anchor';
|
|
5
5
|
import { ClearingHouse } from './clearingHouse';
|
|
6
6
|
export declare class Admin extends ClearingHouse {
|
|
7
7
|
static from(connection: Connection, wallet: IWallet, clearingHouseProgramId: PublicKey, opts?: ConfirmOptions): Admin;
|
|
8
|
-
initialize(usdcMint: PublicKey, adminControlsPrices: boolean): Promise<[
|
|
8
|
+
initialize(usdcMint: PublicKey, adminControlsPrices: boolean): Promise<[
|
|
9
|
+
TransactionSignature,
|
|
10
|
+
TransactionSignature,
|
|
11
|
+
TransactionSignature
|
|
12
|
+
]>;
|
|
13
|
+
initializeOrderState(): Promise<TransactionSignature>;
|
|
9
14
|
initializeMarket(marketIndex: BN, priceOracle: PublicKey, baseAssetReserve: BN, quoteAssetReserve: BN, periodicity: BN, pegMultiplier?: BN): Promise<TransactionSignature>;
|
|
10
15
|
moveAmmPrice(baseAssetReserve: BN, quoteAssetReserve: BN, marketIndex: BN): Promise<TransactionSignature>;
|
|
11
16
|
updateK(sqrtK: BN, marketIndex: BN): Promise<TransactionSignature>;
|
|
@@ -24,10 +29,12 @@ export declare class Admin extends ClearingHouse {
|
|
|
24
29
|
updateFullLiquidationPenaltyPercentage(numerator: BN, denominator: BN): Promise<TransactionSignature>;
|
|
25
30
|
updatePartialLiquidationShareDenominator(denominator: BN): Promise<TransactionSignature>;
|
|
26
31
|
updateFullLiquidationShareDenominator(denominator: BN): Promise<TransactionSignature>;
|
|
32
|
+
updateOrderFillerRewardStructure(orderFillerRewardStructure: OrderFillerRewardStructure): Promise<TransactionSignature>;
|
|
27
33
|
updateFee(fees: FeeStructure): Promise<TransactionSignature>;
|
|
28
34
|
updateOracleGuardRails(oracleGuardRails: OracleGuardRails): Promise<TransactionSignature>;
|
|
29
35
|
updateMarketOracle(marketIndex: BN, oracle: PublicKey, oracleSource: OracleSource): Promise<TransactionSignature>;
|
|
30
|
-
|
|
36
|
+
updateMarketMinimumQuoteAssetTradeSize(marketIndex: BN, minimumTradeSize: BN): Promise<TransactionSignature>;
|
|
37
|
+
updateMarketMinimumBaseAssetTradeSize(marketIndex: BN, minimumTradeSize: BN): Promise<TransactionSignature>;
|
|
31
38
|
updateWhitelistMint(whitelistMint?: PublicKey): Promise<TransactionSignature>;
|
|
32
39
|
updateDiscountMint(discountMint: PublicKey): Promise<TransactionSignature>;
|
|
33
40
|
updateMaxDeposit(maxDeposit: BN): Promise<TransactionSignature>;
|
|
@@ -35,4 +42,3 @@ export declare class Admin extends ClearingHouse {
|
|
|
35
42
|
updateExchangePaused(exchangePaused: boolean): Promise<TransactionSignature>;
|
|
36
43
|
disableAdminControlsPrices(): Promise<TransactionSignature>;
|
|
37
44
|
}
|
|
38
|
-
//# sourceMappingURL=admin.d.ts.map
|
package/lib/admin.js
CHANGED
|
@@ -111,7 +111,29 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
111
111
|
fundingRateHistory,
|
|
112
112
|
curveHistory,
|
|
113
113
|
], this.opts);
|
|
114
|
-
|
|
114
|
+
const initializeOrderStateTxSig = yield this.initializeOrderState();
|
|
115
|
+
return [initializeTxSig, initializeHistoryTxSig, initializeOrderStateTxSig];
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
initializeOrderState() {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
const orderHistory = anchor.web3.Keypair.generate();
|
|
121
|
+
const [orderStatePublicKey, orderStateNonce] = yield addresses_1.getOrderStateAccountPublicKeyAndNonce(this.program.programId);
|
|
122
|
+
const clearingHouseStatePublicKey = yield addresses_1.getClearingHouseStateAccountPublicKey(this.program.programId);
|
|
123
|
+
const initializeOrderStateTx = yield this.program.transaction.initializeOrderState(orderStateNonce, {
|
|
124
|
+
accounts: {
|
|
125
|
+
admin: this.wallet.publicKey,
|
|
126
|
+
state: clearingHouseStatePublicKey,
|
|
127
|
+
orderHistory: orderHistory.publicKey,
|
|
128
|
+
orderState: orderStatePublicKey,
|
|
129
|
+
rent: web3_js_1.SYSVAR_RENT_PUBKEY,
|
|
130
|
+
systemProgram: anchor.web3.SystemProgram.programId,
|
|
131
|
+
},
|
|
132
|
+
instructions: [
|
|
133
|
+
yield this.program.account.orderHistory.createInstruction(orderHistory),
|
|
134
|
+
],
|
|
135
|
+
});
|
|
136
|
+
return yield this.txSender.send(initializeOrderStateTx, [orderHistory], this.opts);
|
|
115
137
|
});
|
|
116
138
|
}
|
|
117
139
|
initializeMarket(marketIndex, priceOracle, baseAssetReserve, quoteAssetReserve, periodicity, pegMultiplier = numericConstants_1.PEG_PRECISION) {
|
|
@@ -360,6 +382,17 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
360
382
|
});
|
|
361
383
|
});
|
|
362
384
|
}
|
|
385
|
+
updateOrderFillerRewardStructure(orderFillerRewardStructure) {
|
|
386
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
387
|
+
return yield this.program.rpc.updateOrderFillerRewardStructure(orderFillerRewardStructure, {
|
|
388
|
+
accounts: {
|
|
389
|
+
admin: this.wallet.publicKey,
|
|
390
|
+
state: yield this.getStatePublicKey(),
|
|
391
|
+
orderState: yield this.getOrderStatePublicKey(),
|
|
392
|
+
},
|
|
393
|
+
});
|
|
394
|
+
});
|
|
395
|
+
}
|
|
363
396
|
updateFee(fees) {
|
|
364
397
|
return __awaiter(this, void 0, void 0, function* () {
|
|
365
398
|
return yield this.program.rpc.updateFee(fees, {
|
|
@@ -392,10 +425,22 @@ class Admin extends clearingHouse_1.ClearingHouse {
|
|
|
392
425
|
});
|
|
393
426
|
});
|
|
394
427
|
}
|
|
395
|
-
|
|
428
|
+
updateMarketMinimumQuoteAssetTradeSize(marketIndex, minimumTradeSize) {
|
|
429
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
430
|
+
const state = this.getStateAccount();
|
|
431
|
+
return yield this.program.rpc.updateMarketMinimumQuoteAssetTradeSize(marketIndex, minimumTradeSize, {
|
|
432
|
+
accounts: {
|
|
433
|
+
admin: this.wallet.publicKey,
|
|
434
|
+
state: yield this.getStatePublicKey(),
|
|
435
|
+
markets: state.markets,
|
|
436
|
+
},
|
|
437
|
+
});
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
updateMarketMinimumBaseAssetTradeSize(marketIndex, minimumTradeSize) {
|
|
396
441
|
return __awaiter(this, void 0, void 0, function* () {
|
|
397
442
|
const state = this.getStateAccount();
|
|
398
|
-
return yield this.program.rpc.
|
|
443
|
+
return yield this.program.rpc.updateMarketMinimumBaseAssetTradeSize(marketIndex, minimumTradeSize, {
|
|
399
444
|
accounts: {
|
|
400
445
|
admin: this.wallet.publicKey,
|
|
401
446
|
state: yield this.getStatePublicKey(),
|
package/lib/assert/assert.d.ts
CHANGED