@drift-labs/sdk 0.2.0-master.18 → 0.2.0-master.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.
- package/lib/clearingHouse.d.ts +11 -11
- package/lib/clearingHouse.js +78 -18
- package/lib/clearingHouseUser.js +7 -25
- package/lib/clearingHouseUserStats.d.ts +2 -1
- package/lib/clearingHouseUserStats.js +13 -0
- package/lib/config.js +1 -1
- package/lib/events/types.d.ts +2 -1
- package/lib/events/types.js +1 -0
- package/lib/idl/clearing_house.json +200 -129
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/math/amm.d.ts +1 -0
- package/lib/math/amm.js +13 -1
- package/lib/math/market.d.ts +1 -1
- package/lib/math/market.js +5 -5
- package/lib/math/orders.d.ts +3 -0
- package/lib/math/orders.js +35 -1
- package/lib/types.d.ts +25 -7
- package/package.json +1 -1
- package/src/clearingHouse.ts +113 -19
- package/src/clearingHouseUser.ts +11 -49
- package/src/clearingHouseUserStats.ts +23 -1
- package/src/config.ts +1 -1
- package/src/events/types.ts +3 -0
- package/src/idl/clearing_house.json +200 -129
- package/src/index.ts +0 -1
- package/src/math/amm.ts +27 -1
- package/src/math/market.ts +6 -6
- package/src/math/orders.ts +96 -1
- package/src/types.ts +27 -7
- package/lib/orders.d.ts +0 -7
- package/lib/orders.js +0 -59
- package/src/events/types.js +0 -20
- package/src/math/amm.js +0 -369
- package/src/orders.ts +0 -91
- package/src/types.js +0 -125
|
@@ -4,7 +4,11 @@ import { DataAndSlot, UserStatsAccountSubscriber } from './accounts/types';
|
|
|
4
4
|
import { ClearingHouseUserStatsConfig } from './clearingHouseUserStatsConfig';
|
|
5
5
|
import { PollingUserStatsAccountSubscriber } from './accounts/pollingUserStatsAccountSubscriber';
|
|
6
6
|
import { WebSocketUserStatsAccountSubscriber } from './accounts/webSocketUserStatsAccountSubsriber';
|
|
7
|
-
import { UserStatsAccount } from './types';
|
|
7
|
+
import { ReferrerInfo, UserStatsAccount } from './types';
|
|
8
|
+
import {
|
|
9
|
+
getUserAccountPublicKeySync,
|
|
10
|
+
getUserStatsAccountPublicKey,
|
|
11
|
+
} from './addresses/pda';
|
|
8
12
|
|
|
9
13
|
export class ClearingHouseUserStats {
|
|
10
14
|
clearingHouse: ClearingHouse;
|
|
@@ -50,4 +54,22 @@ export class ClearingHouseUserStats {
|
|
|
50
54
|
public getAccount(): UserStatsAccount {
|
|
51
55
|
return this.accountSubscriber.getUserStatsAccountAndSlot().data;
|
|
52
56
|
}
|
|
57
|
+
|
|
58
|
+
public getReferrerInfo(): ReferrerInfo | undefined {
|
|
59
|
+
if (this.getAccount().referrer.equals(PublicKey.default)) {
|
|
60
|
+
return undefined;
|
|
61
|
+
} else {
|
|
62
|
+
return {
|
|
63
|
+
referrer: getUserAccountPublicKeySync(
|
|
64
|
+
this.clearingHouse.program.programId,
|
|
65
|
+
this.getAccount().referrer,
|
|
66
|
+
0
|
|
67
|
+
),
|
|
68
|
+
referrerStats: getUserStatsAccountPublicKey(
|
|
69
|
+
this.clearingHouse.program.programId,
|
|
70
|
+
this.getAccount().referrer
|
|
71
|
+
),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
}
|
|
53
75
|
}
|
package/src/config.ts
CHANGED
|
@@ -28,7 +28,7 @@ export const configs: { [key in DriftEnv]: DriftConfig } = {
|
|
|
28
28
|
devnet: {
|
|
29
29
|
ENV: 'devnet',
|
|
30
30
|
PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
|
|
31
|
-
CLEARING_HOUSE_PROGRAM_ID: '
|
|
31
|
+
CLEARING_HOUSE_PROGRAM_ID: '65sz7dRiWDRPZjiRxcTxPM7AE6VK4Nag9HEK6oBJXhJn',
|
|
32
32
|
USDC_MINT_ADDRESS: '8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2',
|
|
33
33
|
MARKETS: DevnetMarkets,
|
|
34
34
|
BANKS: DevnetBanks,
|
package/src/events/types.ts
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
FundingPaymentRecord,
|
|
5
5
|
FundingRateRecord,
|
|
6
6
|
LiquidationRecord,
|
|
7
|
+
NewUserRecord,
|
|
7
8
|
OrderRecord,
|
|
8
9
|
SettlePnlRecord,
|
|
9
10
|
} from '../index';
|
|
@@ -28,6 +29,7 @@ export const DefaultEventSubscriptionOptions: EventSubscriptionOptions = {
|
|
|
28
29
|
'LiquidationRecord',
|
|
29
30
|
'OrderRecord',
|
|
30
31
|
'FundingRateRecord',
|
|
32
|
+
'NewUserRecord',
|
|
31
33
|
'SettlePnlRecord',
|
|
32
34
|
],
|
|
33
35
|
maxEventsPerType: 4096,
|
|
@@ -62,6 +64,7 @@ export type EventMap = {
|
|
|
62
64
|
FundingRateRecord: Event<FundingRateRecord>;
|
|
63
65
|
OrderRecord: Event<OrderRecord>;
|
|
64
66
|
SettlePnlRecord: Event<SettlePnlRecord>;
|
|
67
|
+
NewUserRecord: Event<NewUserRecord>;
|
|
65
68
|
};
|
|
66
69
|
|
|
67
70
|
export type EventType = keyof EventMap;
|