@drift-labs/sdk 0.1.18 → 0.1.20

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 (101) hide show
  1. package/lib/accounts/bulkAccountLoader.d.ts +32 -0
  2. package/lib/accounts/bulkAccountLoader.d.ts.map +1 -0
  3. package/lib/accounts/bulkAccountLoader.js +166 -0
  4. package/lib/accounts/bulkUserSubscription.d.ts +8 -0
  5. package/lib/accounts/bulkUserSubscription.d.ts.map +1 -0
  6. package/lib/accounts/bulkUserSubscription.js +28 -0
  7. package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +46 -0
  8. package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts.map +1 -0
  9. package/lib/accounts/pollingClearingHouseAccountSubscriber.js +206 -0
  10. package/lib/accounts/pollingTokenAccountSubscriber.d.ts +26 -0
  11. package/lib/accounts/pollingTokenAccountSubscriber.d.ts.map +1 -0
  12. package/lib/accounts/pollingTokenAccountSubscriber.js +79 -0
  13. package/lib/accounts/pollingUserAccountSubscriber.d.ts +31 -0
  14. package/lib/accounts/pollingUserAccountSubscriber.d.ts.map +1 -0
  15. package/lib/accounts/pollingUserAccountSubscriber.js +123 -0
  16. package/lib/accounts/types.d.ts +30 -0
  17. package/lib/accounts/types.d.ts.map +1 -1
  18. package/lib/accounts/utils.d.ts +2 -0
  19. package/lib/accounts/utils.d.ts.map +1 -0
  20. package/lib/accounts/utils.js +7 -0
  21. package/lib/accounts/webSocketAccountSubscriber.d.ts +6 -2
  22. package/lib/accounts/webSocketAccountSubscriber.d.ts.map +1 -1
  23. package/lib/accounts/webSocketAccountSubscriber.js +43 -12
  24. package/lib/accounts/{defaultClearingHouseAccountSubscriber.d.ts → webSocketClearingHouseAccountSubscriber.d.ts} +4 -2
  25. package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts.map +1 -0
  26. package/lib/accounts/{defaultClearingHouseAccountSubscriber.js → webSocketClearingHouseAccountSubscriber.js} +4 -3
  27. package/lib/accounts/{defaultUserAccountSubscriber.d.ts → webSocketUserAccountSubscriber.d.ts} +4 -2
  28. package/lib/accounts/webSocketUserAccountSubscriber.d.ts.map +1 -0
  29. package/lib/accounts/{defaultUserAccountSubscriber.js → webSocketUserAccountSubscriber.js} +4 -3
  30. package/lib/admin.d.ts +1 -0
  31. package/lib/admin.d.ts.map +1 -1
  32. package/lib/admin.js +20 -11
  33. package/lib/clearingHouse.d.ts +12 -2
  34. package/lib/clearingHouse.d.ts.map +1 -1
  35. package/lib/clearingHouse.js +19 -8
  36. package/lib/clearingHouseUser.d.ts +11 -3
  37. package/lib/clearingHouseUser.d.ts.map +1 -1
  38. package/lib/clearingHouseUser.js +33 -23
  39. package/lib/constants/markets.d.ts +2 -1
  40. package/lib/constants/markets.d.ts.map +1 -1
  41. package/lib/constants/markets.js +20 -15
  42. package/lib/constants/numericConstants.d.ts +3 -1
  43. package/lib/constants/numericConstants.d.ts.map +1 -1
  44. package/lib/constants/numericConstants.js +15 -17
  45. package/lib/examples/makeTradeExample.js +1 -1
  46. package/lib/factory/clearingHouse.d.ts +26 -0
  47. package/lib/factory/clearingHouse.d.ts.map +1 -0
  48. package/lib/factory/clearingHouse.js +64 -0
  49. package/lib/factory/clearingHouseUser.d.ts +20 -0
  50. package/lib/factory/clearingHouseUser.d.ts.map +1 -0
  51. package/lib/factory/clearingHouseUser.js +34 -0
  52. package/lib/index.d.ts +8 -2
  53. package/lib/index.d.ts.map +1 -1
  54. package/lib/index.js +9 -2
  55. package/lib/math/conversion.d.ts +1 -1
  56. package/lib/math/conversion.d.ts.map +1 -1
  57. package/lib/math/insuranceFund.d.ts +2 -1
  58. package/lib/math/insuranceFund.d.ts.map +1 -1
  59. package/lib/math/insuranceFund.js +3 -6
  60. package/lib/math/position.d.ts +2 -1
  61. package/lib/math/position.d.ts.map +1 -1
  62. package/lib/math/position.js +2 -5
  63. package/lib/math/utils.d.ts +2 -1
  64. package/lib/math/utils.d.ts.map +1 -1
  65. package/lib/math/utils.js +3 -3
  66. package/lib/mockUSDCFaucet.d.ts +2 -1
  67. package/lib/mockUSDCFaucet.d.ts.map +1 -1
  68. package/lib/token/index.d.ts +4 -0
  69. package/lib/token/index.d.ts.map +1 -0
  70. package/lib/token/index.js +38 -0
  71. package/lib/types.d.ts +3 -1
  72. package/lib/types.d.ts.map +1 -1
  73. package/package.json +11 -3
  74. package/src/accounts/bulkAccountLoader.ts +207 -0
  75. package/src/accounts/bulkUserSubscription.ts +28 -0
  76. package/src/accounts/pollingClearingHouseAccountSubscriber.ts +293 -0
  77. package/src/accounts/pollingTokenAccountSubscriber.ts +99 -0
  78. package/src/accounts/pollingUserAccountSubscriber.ts +166 -0
  79. package/src/accounts/types.ts +38 -0
  80. package/src/accounts/utils.ts +3 -0
  81. package/src/accounts/webSocketAccountSubscriber.ts +67 -17
  82. package/src/accounts/{defaultClearingHouseAccountSubscriber.ts → webSocketClearingHouseAccountSubscriber.ts} +4 -1
  83. package/src/accounts/{defaultUserAccountSubscriber.ts → webSocketUserAccountSubscriber.ts} +4 -1
  84. package/src/admin.ts +27 -18
  85. package/src/clearingHouse.ts +25 -17
  86. package/src/clearingHouseUser.ts +26 -6
  87. package/src/constants/markets.ts +9 -1
  88. package/src/constants/numericConstants.ts +2 -1
  89. package/src/examples/makeTradeExample.ts +4 -1
  90. package/src/factory/clearingHouse.ts +125 -0
  91. package/src/factory/clearingHouseUser.ts +73 -0
  92. package/src/index.ts +8 -2
  93. package/src/math/conversion.ts +1 -1
  94. package/src/math/insuranceFund.ts +1 -1
  95. package/src/math/position.ts +1 -1
  96. package/src/math/utils.ts +1 -1
  97. package/src/mockUSDCFaucet.ts +1 -1
  98. package/src/token/index.ts +37 -0
  99. package/src/types.ts +2 -1
  100. package/lib/accounts/defaultClearingHouseAccountSubscriber.d.ts.map +0 -1
  101. package/lib/accounts/defaultUserAccountSubscriber.d.ts.map +0 -1
@@ -0,0 +1,32 @@
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 {};
32
+ //# sourceMappingURL=bulkAccountLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkAccountLoader.d.ts","sourceRoot":"","sources":["../../src/accounts/bulkAccountLoader.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEpE,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,aAAK,aAAa,GAAG;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,CAAC;CACjD,CAAC;AAIF,qBAAa,iBAAiB;IAC7B,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,6BAAoC;IAClD,WAAW,2BAAkC;IAC7C,cAAc,0BAA0B,IAAI,EAAI;IAChD,UAAU,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;IAE1B,WAAW,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,mBAAmB,EAAE,MAAM,IAAI,CAAC;gBAG/B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,MAAM;IAOlB,UAAU,CAChB,SAAS,EAAE,SAAS,EACpB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAChC,MAAM;IA2BF,aAAa,CAAC,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI;IAc7D,iBAAiB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,MAAM;IAM3D,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI;IAIrD,MAAM,CAAC,CAAC,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE;IAOtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAuB5B,SAAS,CAAC,cAAc,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;IAgE/D,sBAAsB,CAAC,aAAa,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAMnE,cAAc,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS;IAKxD,YAAY,IAAI,IAAI;IAQpB,WAAW,IAAI,IAAI;CAM1B"}
@@ -0,0 +1,166 @@
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
+ const chunks = this.chunks(Array.from(this.accountsToLoad.values()), GET_MULTIPLE_ACCOUNTS_CHUNK_SIZE);
82
+ yield Promise.all(chunks.map((chunk) => {
83
+ return this.loadChunk(chunk);
84
+ }));
85
+ this.loadPromiseResolver();
86
+ this.loadPromise = undefined;
87
+ });
88
+ }
89
+ loadChunk(accountsToLoad) {
90
+ return __awaiter(this, void 0, void 0, function* () {
91
+ if (accountsToLoad.length === 0) {
92
+ return;
93
+ }
94
+ const args = [
95
+ accountsToLoad.map((accountToLoad) => {
96
+ return accountToLoad.publicKey.toBase58();
97
+ }),
98
+ { commitment: this.commitment },
99
+ ];
100
+ let rpcResponse;
101
+ try {
102
+ // @ts-ignore
103
+ rpcResponse = yield this.connection._rpcRequest('getMultipleAccounts', args);
104
+ }
105
+ catch (e) {
106
+ for (const [_, callback] of this.errorCallbacks) {
107
+ callback(e);
108
+ }
109
+ return;
110
+ }
111
+ const newSlot = rpcResponse.result.context.slot;
112
+ for (const i in accountsToLoad) {
113
+ const accountToLoad = accountsToLoad[i];
114
+ const key = accountToLoad.publicKey.toString();
115
+ const oldRPCResponse = this.accountData.get(key);
116
+ let newBuffer = undefined;
117
+ if (rpcResponse.result.value[i]) {
118
+ const raw = rpcResponse.result.value[i].data[0];
119
+ const dataType = rpcResponse.result.value[i].data[1];
120
+ newBuffer = Buffer.from(raw, dataType);
121
+ }
122
+ if (!oldRPCResponse) {
123
+ this.accountData.set(key, {
124
+ slot: newSlot,
125
+ buffer: newBuffer,
126
+ });
127
+ this.handleAccountCallbacks(accountToLoad, newBuffer);
128
+ continue;
129
+ }
130
+ if (newSlot <= oldRPCResponse.slot) {
131
+ continue;
132
+ }
133
+ const oldBuffer = oldRPCResponse.buffer;
134
+ if (newBuffer && (!oldBuffer || !newBuffer.equals(oldBuffer))) {
135
+ this.accountData.set(key, {
136
+ slot: newSlot,
137
+ buffer: newBuffer,
138
+ });
139
+ this.handleAccountCallbacks(accountToLoad, newBuffer);
140
+ }
141
+ }
142
+ });
143
+ }
144
+ handleAccountCallbacks(accountToLoad, buffer) {
145
+ for (const [_, callback] of accountToLoad.callbacks) {
146
+ callback(buffer);
147
+ }
148
+ }
149
+ getAccountData(publicKey) {
150
+ const accountData = this.accountData.get(publicKey.toString());
151
+ return accountData === null || accountData === void 0 ? void 0 : accountData.buffer;
152
+ }
153
+ startPolling() {
154
+ if (this.intervalId) {
155
+ return;
156
+ }
157
+ this.intervalId = setInterval(this.load.bind(this), this.pollingFrequency);
158
+ }
159
+ stopPolling() {
160
+ if (this.intervalId) {
161
+ clearInterval(this.intervalId);
162
+ this.intervalId = undefined;
163
+ }
164
+ }
165
+ }
166
+ exports.BulkAccountLoader = BulkAccountLoader;
@@ -0,0 +1,8 @@
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>;
8
+ //# sourceMappingURL=bulkUserSubscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulkUserSubscription.d.ts","sourceRoot":"","sources":["../../src/accounts/bulkUserSubscription.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGxD;;;GAGG;AACH,wBAAsB,wBAAwB,CAC7C,KAAK,EAAE,iBAAiB,EAAE,EAC1B,aAAa,EAAE,iBAAiB,GAC9B,OAAO,CAAC,IAAI,CAAC,CAgBf"}
@@ -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,46 @@
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, 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
+ tradeHistory?: TradeHistoryAccount;
19
+ depositHistory?: DepositHistoryAccount;
20
+ fundingPaymentHistory?: FundingPaymentHistoryAccount;
21
+ fundingRateHistory?: FundingRateHistoryAccount;
22
+ liquidationHistory?: LiquidationHistoryAccount;
23
+ extendedCurveHistory: ExtendedCurveHistoryAccount;
24
+ optionalExtraSubscriptions: ClearingHouseAccountTypes[];
25
+ type: ClearingHouseConfigType;
26
+ private isSubscribing;
27
+ private subscriptionPromise;
28
+ private subscriptionPromiseResolver;
29
+ constructor(program: Program, accountLoader: BulkAccountLoader);
30
+ subscribe(optionalSubscriptions?: ClearingHouseAccountTypes[]): Promise<boolean>;
31
+ updateAccountsToPoll(): Promise<void>;
32
+ addToAccountLoader(): Promise<void>;
33
+ fetch(): Promise<void>;
34
+ unsubscribe(): Promise<void>;
35
+ assertIsSubscribed(): void;
36
+ assertOptionalIsSubscribed(optionalSubscription: ClearingHouseAccountTypes): void;
37
+ getStateAccount(): StateAccount;
38
+ getMarketsAccount(): MarketsAccount;
39
+ getTradeHistoryAccount(): TradeHistoryAccount;
40
+ getDepositHistoryAccount(): DepositHistoryAccount;
41
+ getFundingPaymentHistoryAccount(): FundingPaymentHistoryAccount;
42
+ getFundingRateHistoryAccount(): FundingRateHistoryAccount;
43
+ getCurveHistoryAccount(): ExtendedCurveHistoryAccount;
44
+ getLiquidationHistoryAccount(): LiquidationHistoryAccount;
45
+ }
46
+ //# sourceMappingURL=pollingClearingHouseAccountSubscriber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pollingClearingHouseAccountSubscriber.d.ts","sourceRoot":"","sources":["../../src/accounts/pollingClearingHouseAccountSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,aAAa,EACb,0BAA0B,EAC1B,8BAA8B,EAC9B,yBAAyB,EAEzB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EACN,qBAAqB,EACrB,2BAA2B,EAC3B,4BAA4B,EAC5B,yBAAyB,EACzB,yBAAyB,EACzB,cAAc,EACd,YAAY,EACZ,mBAAmB,EACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,qBAAa,qCACZ,YAAW,8BAA8B;IAEzC,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,0BAA0B,CAAC,CAAC;IAE3E,aAAa,EAAE,iBAAiB,CAAC;IACjC,cAAc,6BAAoC;IAClD,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,cAAc,CAAC,EAAE,qBAAqB,CAAC;IACvC,qBAAqB,CAAC,EAAE,4BAA4B,CAAC;IACrD,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,kBAAkB,CAAC,EAAE,yBAAyB,CAAC;IAC/C,oBAAoB,EAAE,2BAA2B,CAAC;IAElD,0BAA0B,EAAE,yBAAyB,EAAE,CAAM;IAE7D,IAAI,EAAE,uBAAuB,CAAa;IAE1C,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,mBAAmB,CAAmB;IAC9C,OAAO,CAAC,2BAA2B,CAAyB;gBAEzC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,iBAAiB;IAOxD,SAAS,CACrB,qBAAqB,CAAC,EAAE,yBAAyB,EAAE,GACjD,OAAO,CAAC,OAAO,CAAC;IA6Bb,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC;IAgFrC,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAqB5B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAmBzC,kBAAkB,IAAI,IAAI;IAQ1B,0BAA0B,CACzB,oBAAoB,EAAE,yBAAyB,GAC7C,IAAI;IAcA,eAAe,IAAI,YAAY;IAK/B,iBAAiB,IAAI,cAAc;IAKnC,sBAAsB,IAAI,mBAAmB;IAM7C,wBAAwB,IAAI,qBAAqB;IAMjD,+BAA+B,IAAI,4BAA4B;IAM/D,4BAA4B,IAAI,yBAAyB;IAMzD,sBAAsB,IAAI,2BAA2B;IAMrD,4BAA4B,IAAI,yBAAyB;CAKhE"}
@@ -0,0 +1,206 @@
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;
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
+ if ((_a = this.optionalExtraSubscriptions) === null || _a === void 0 ? void 0 : _a.includes('tradeHistoryAccount')) {
70
+ this.accountsToPoll.set(state.tradeHistory.toString(), {
71
+ key: 'tradeHistory',
72
+ publicKey: state.tradeHistory,
73
+ eventType: 'tradeHistoryAccountUpdate',
74
+ });
75
+ }
76
+ if ((_b = this.optionalExtraSubscriptions) === null || _b === void 0 ? void 0 : _b.includes('depositHistoryAccount')) {
77
+ this.accountsToPoll.set(state.depositHistory.toString(), {
78
+ key: 'depositHistory',
79
+ publicKey: state.depositHistory,
80
+ eventType: 'depositHistoryAccountUpdate',
81
+ });
82
+ }
83
+ if ((_c = this.optionalExtraSubscriptions) === null || _c === void 0 ? void 0 : _c.includes('fundingPaymentHistoryAccount')) {
84
+ this.accountsToPoll.set(state.fundingPaymentHistory.toString(), {
85
+ key: 'fundingPaymentHistory',
86
+ publicKey: state.fundingPaymentHistory,
87
+ eventType: 'fundingPaymentHistoryAccountUpdate',
88
+ });
89
+ }
90
+ if ((_d = this.optionalExtraSubscriptions) === null || _d === void 0 ? void 0 : _d.includes('fundingRateHistoryAccount')) {
91
+ this.accountsToPoll.set(state.fundingRateHistory.toString(), {
92
+ key: 'fundingRateHistory',
93
+ publicKey: state.fundingRateHistory,
94
+ eventType: 'fundingRateHistoryAccountUpdate',
95
+ });
96
+ }
97
+ if ((_e = this.optionalExtraSubscriptions) === null || _e === void 0 ? void 0 : _e.includes('curveHistoryAccount')) {
98
+ this.accountsToPoll.set(state.extendedCurveHistory.toString(), {
99
+ key: 'extendedCurveHistory',
100
+ publicKey: state.extendedCurveHistory,
101
+ eventType: 'curveHistoryAccountUpdate',
102
+ });
103
+ }
104
+ if ((_f = this.optionalExtraSubscriptions) === null || _f === void 0 ? void 0 : _f.includes('liquidationHistoryAccount')) {
105
+ this.accountsToPoll.set(state.liquidationHistory.toString(), {
106
+ key: 'liquidationHistory',
107
+ publicKey: state.liquidationHistory,
108
+ eventType: 'liquidationHistoryAccountUpdate',
109
+ });
110
+ }
111
+ });
112
+ }
113
+ addToAccountLoader() {
114
+ return __awaiter(this, void 0, void 0, function* () {
115
+ for (const [_, accountToPoll] of this.accountsToPoll) {
116
+ accountToPoll.callbackId = this.accountLoader.addAccount(accountToPoll.publicKey, (buffer) => {
117
+ const account = this.program.account[accountToPoll.key].coder.accounts.decode(utils_1.capitalize(accountToPoll.key), buffer);
118
+ this[accountToPoll.key] = account;
119
+ // @ts-ignore
120
+ this.eventEmitter.emit(accountToPoll.eventType, account);
121
+ this.eventEmitter.emit('update');
122
+ });
123
+ }
124
+ this.errorCallbackId = this.accountLoader.addErrorCallbacks((error) => {
125
+ this.eventEmitter.emit('error', error);
126
+ });
127
+ });
128
+ }
129
+ fetch() {
130
+ return __awaiter(this, void 0, void 0, function* () {
131
+ yield this.accountLoader.load();
132
+ for (const [_, accountToPoll] of this.accountsToPoll) {
133
+ const buffer = this.accountLoader.getAccountData(accountToPoll.publicKey);
134
+ if (buffer) {
135
+ this[accountToPoll.key] = this.program.account[accountToPoll.key].coder.accounts.decode(utils_1.capitalize(accountToPoll.key), buffer);
136
+ }
137
+ }
138
+ });
139
+ }
140
+ unsubscribe() {
141
+ return __awaiter(this, void 0, void 0, function* () {
142
+ if (!this.isSubscribed) {
143
+ return;
144
+ }
145
+ for (const [_, accountToPoll] of this.accountsToPoll) {
146
+ this.accountLoader.removeAccount(accountToPoll.publicKey, accountToPoll.callbackId);
147
+ }
148
+ this.accountLoader.removeErrorCallbacks(this.errorCallbackId);
149
+ this.errorCallbackId = undefined;
150
+ this.accountsToPoll.clear();
151
+ this.isSubscribed = false;
152
+ });
153
+ }
154
+ assertIsSubscribed() {
155
+ if (!this.isSubscribed) {
156
+ throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
157
+ }
158
+ }
159
+ assertOptionalIsSubscribed(optionalSubscription) {
160
+ if (!this.isSubscribed) {
161
+ throw new types_1.NotSubscribedError('You must call `subscribe` before using this function');
162
+ }
163
+ if (!this.optionalExtraSubscriptions.includes(optionalSubscription)) {
164
+ throw new types_1.NotSubscribedError(`You need to subscribe to the optional Clearing House account "${optionalSubscription}" to use this method`);
165
+ }
166
+ }
167
+ getStateAccount() {
168
+ this.assertIsSubscribed();
169
+ return this.state;
170
+ }
171
+ getMarketsAccount() {
172
+ this.assertIsSubscribed();
173
+ return this.markets;
174
+ }
175
+ getTradeHistoryAccount() {
176
+ this.assertIsSubscribed();
177
+ this.assertOptionalIsSubscribed('tradeHistoryAccount');
178
+ return this.tradeHistory;
179
+ }
180
+ getDepositHistoryAccount() {
181
+ this.assertIsSubscribed();
182
+ this.assertOptionalIsSubscribed('depositHistoryAccount');
183
+ return this.depositHistory;
184
+ }
185
+ getFundingPaymentHistoryAccount() {
186
+ this.assertIsSubscribed();
187
+ this.assertOptionalIsSubscribed('fundingPaymentHistoryAccount');
188
+ return this.fundingPaymentHistory;
189
+ }
190
+ getFundingRateHistoryAccount() {
191
+ this.assertIsSubscribed();
192
+ this.assertOptionalIsSubscribed('fundingRateHistoryAccount');
193
+ return this.fundingRateHistory;
194
+ }
195
+ getCurveHistoryAccount() {
196
+ this.assertIsSubscribed();
197
+ this.assertOptionalIsSubscribed('curveHistoryAccount');
198
+ return this.extendedCurveHistory;
199
+ }
200
+ getLiquidationHistoryAccount() {
201
+ this.assertIsSubscribed();
202
+ this.assertOptionalIsSubscribed('liquidationHistoryAccount');
203
+ return this.liquidationHistory;
204
+ }
205
+ }
206
+ exports.PollingClearingHouseAccountSubscriber = PollingClearingHouseAccountSubscriber;
@@ -0,0 +1,26 @@
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
+ }
26
+ //# sourceMappingURL=pollingTokenAccountSubscriber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pollingTokenAccountSubscriber.d.ts","sourceRoot":"","sources":["../../src/accounts/pollingTokenAccountSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EAEN,kBAAkB,EAClB,sBAAsB,EACtB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,qBAAa,6BAA8B,YAAW,sBAAsB;IAC3E,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;IACnE,SAAS,EAAE,SAAS,CAAC;IAErB,aAAa,EAAE,iBAAiB,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,YAAY,CAAC,EAAE,WAAW,CAAC;gBAER,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB;IAOnE,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAanC,kBAAkB,IAAI,IAAI;IAqBpB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAMtB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAclC,kBAAkB,IAAI,IAAI;IAQnB,eAAe,IAAI,WAAW;CAIrC"}
@@ -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,31 @@
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, 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
+ type: ClearingHouseConfigType;
21
+ constructor(program: Program, authority: PublicKey, accountLoader: BulkAccountLoader);
22
+ subscribe(): Promise<boolean>;
23
+ addToAccountLoader(): Promise<void>;
24
+ fetchIfUnloaded(): Promise<void>;
25
+ fetch(): Promise<void>;
26
+ unsubscribe(): Promise<void>;
27
+ assertIsSubscribed(): void;
28
+ getUserAccount(): UserAccount;
29
+ getUserPositionsAccount(): UserPositionsAccount;
30
+ }
31
+ //# sourceMappingURL=pollingUserAccountSubscriber.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pollingUserAccountSubscriber.d.ts","sourceRoot":"","sources":["../../src/accounts/pollingUserAccountSubscriber.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,aAAa,EAEb,iBAAiB,EACjB,qBAAqB,EACrB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,kBAAkB,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,qBAAa,4BAA6B,YAAW,qBAAqB;IACzE,YAAY,EAAE,OAAO,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,EAAE,kBAAkB,CAAC,YAAY,EAAE,iBAAiB,CAAC,CAAC;IAClE,SAAS,EAAE,SAAS,CAAC;IAErB,aAAa,EAAE,iBAAiB,CAAC;IACjC,cAAc,6BAAoC;IAClD,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,aAAa,CAAC,EAAE,oBAAoB,CAAC;IAErC,IAAI,EAAE,uBAAuB,CAAa;gBAGzC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,SAAS,EACpB,aAAa,EAAE,iBAAiB;IAS3B,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC;IAa7B,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IA8CnC,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAchC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAYtB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAoBlC,kBAAkB,IAAI,IAAI;IAQnB,cAAc,IAAI,WAAW;IAK7B,uBAAuB,IAAI,oBAAoB;CAItD"}