Skip to content

Commit debbe95

Browse files
authored
Remove barrel imports from SDK (#1777)
1 parent 9c0b2bf commit debbe95

35 files changed

+389
-119
lines changed

sdk/bun.lock

Lines changed: 232 additions & 1 deletion
Large diffs are not rendered by default.

sdk/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
"patch-and-pub": "npm version patch --force && npm publish",
2323
"prettify": "prettier --check './src/***/*.ts'",
2424
"prettify:fix": "prettier --write './{src,tests}/***/*.ts'",
25-
"version": "node ./scripts/updateVersion.js"
25+
"version": "node ./scripts/updateVersion.js",
26+
"circular-deps": "bunx madge --circular --circular --extensions ts src"
2627
},
2728
"keywords": [
2829
"drift-labs",
@@ -78,6 +79,7 @@
7879
"eslint-config-prettier": "8.3.0",
7980
"eslint-plugin-prettier": "3.4.0",
8081
"lodash": "4.17.21",
82+
"madge": "^8.0.0",
8183
"mocha": "10.7.3",
8284
"object-sizeof": "2.6.5",
8385
"prettier": "3.0.1",
@@ -94,4 +96,4 @@
9496
"@solana/errors": "2.0.0-preview.4",
9597
"@solana/codecs-data-structures": "2.0.0-preview.4"
9698
}
97-
}
99+
}

sdk/src/accounts/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import {
66
UserAccount,
77
UserStatsAccount,
88
InsuranceFundStake,
9+
HighLeverageModeConfig,
910
} from '../types';
1011
import StrictEventEmitter from 'strict-event-emitter-types';
1112
import { EventEmitter } from 'events';
1213
import { Context, PublicKey } from '@solana/web3.js';
1314
import { Account } from '@solana/spl-token';
14-
import { HighLeverageModeConfig, OracleInfo, OraclePriceData, User } from '..';
15+
import { OracleInfo, OraclePriceData } from '../oracles/types';
16+
import { User } from '../user';
1517
import { ChannelOptions, CommitmentLevel } from '../isomorphic/grpc';
1618

1719
export interface AccountSubscriber<T> {

sdk/src/addresses/pda.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PublicKey } from '@solana/web3.js';
22
import * as anchor from '@coral-xyz/anchor';
33
import { BN } from '@coral-xyz/anchor';
44
import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID } from '@solana/spl-token';
5-
import { SpotMarketAccount, TokenProgramFlag } from '..';
5+
import { SpotMarketAccount, TokenProgramFlag } from '../types';
66

77
export async function getDriftStateAccountPublicKeyAndNonce(
88
programId: PublicKey

sdk/src/clock/clockSubscriber.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Commitment, Connection, SYSVAR_CLOCK_PUBKEY } from '@solana/web3.js';
22
import { EventEmitter } from 'events';
33
import StrictEventEmitter from 'strict-event-emitter-types/types/src';
4-
import { BN } from '..';
4+
import { BN } from '@coral-xyz/anchor';
55

66
// eslint-disable-next-line @typescript-eslint/ban-types
77
type ClockSubscriberConfig = {

sdk/src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ConfirmOptions } from '@solana/web3.js';
2-
import { PerpMarketAccount, PublicKey, SpotMarketAccount } from '.';
1+
import { ConfirmOptions, PublicKey } from '@solana/web3.js';
2+
import { PerpMarketAccount, SpotMarketAccount } from './types';
33
import {
44
DevnetPerpMarkets,
55
MainnetPerpMarkets,

sdk/src/constants/perpMarkets.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { OracleSource } from '../';
2-
import { DriftEnv } from '../';
31
import { PublicKey } from '@solana/web3.js';
2+
import { OracleSource } from '../types';
3+
import { DriftEnv } from '../config';
44

55
export type PerpMarketConfig = {
66
fullName?: string;

sdk/src/constants/spotMarkets.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { PublicKey } from '@solana/web3.js';
2-
import { BN, DriftEnv, OracleSource } from '../';
32
import {
43
QUOTE_PRECISION,
54
QUOTE_PRECISION_EXP,
@@ -10,6 +9,9 @@ import {
109
NINE,
1110
FIVE,
1211
} from './numericConstants';
12+
import { OracleSource } from '../types';
13+
import { BN } from '@coral-xyz/anchor';
14+
import { DriftEnv } from '../config';
1315

1416
export type SpotMarketConfig = {
1517
symbol: string;

sdk/src/decode/user.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import { BN } from '@coral-xyz/anchor';
12
import {
3+
MarginMode,
24
MarketType,
35
Order,
46
OrderStatus,
@@ -11,8 +13,7 @@ import {
1113
UserAccount,
1214
} from '../types';
1315
import { PublicKey } from '@solana/web3.js';
14-
import { BN, MarginMode } from '../';
15-
import { ZERO } from '../';
16+
import { ZERO } from '../constants/numericConstants';
1617

1718
function readUnsignedBigInt64LE(buffer: Buffer, offset: number): BN {
1819
return new BN(buffer.subarray(offset, offset + 8), 10, 'le');

sdk/src/dlob/DLOB.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
import { getOrderSignature, NodeList } from './NodeList';
2+
import { BN } from '@coral-xyz/anchor';
23
import {
34
BASE_PRECISION,
4-
BN,
55
BN_MAX,
6-
convertToNumber,
7-
decodeName,
8-
DLOBNode,
9-
DLOBNodeType,
10-
DriftClient,
6+
PRICE_PRECISION,
7+
QUOTE_PRECISION,
8+
ZERO,
9+
} from '../constants/numericConstants';
10+
import { decodeName } from '../userName';
11+
import { DLOBNode, DLOBNodeType, TriggerOrderNode } from './DLOBNode';
12+
import { DriftClient } from '../driftClient';
13+
import {
1114
getLimitPrice,
12-
getVariant,
13-
isFallbackAvailableLiquiditySource,
14-
isOneOfVariant,
1515
isOrderExpired,
1616
isRestingLimitOrder,
1717
isTriggered,
18-
isUserProtectedMaker,
18+
mustBeTriggered,
19+
} from '../math/orders';
20+
import {
21+
getVariant,
22+
isOneOfVariant,
1923
isVariant,
2024
MarketType,
2125
MarketTypeStr,
22-
mustBeTriggered,
23-
OraclePriceData,
2426
Order,
2527
PerpMarketAccount,
2628
PositionDirection,
27-
PRICE_PRECISION,
2829
ProtectedMakerParams,
29-
ProtectMakerParamsMap,
30-
QUOTE_PRECISION,
31-
SlotSubscriber,
3230
SpotMarketAccount,
3331
StateAccount,
34-
TriggerOrderNode,
35-
UserMap,
36-
ZERO,
37-
} from '..';
32+
} from '../types';
33+
import { isUserProtectedMaker } from '../math/userStatus';
34+
import { OraclePriceData } from '../oracles/types';
35+
import { ProtectMakerParamsMap } from './types';
36+
import { SlotSubscriber } from '../slot/SlotSubscriber';
37+
import { UserMap } from '../userMap/userMap';
3838
import { PublicKey } from '@solana/web3.js';
3939
import { ammPaused, exchangePaused, fillPaused } from '../math/exchangeStatus';
4040
import {
@@ -46,6 +46,8 @@ import {
4646
L3OrderBook,
4747
mergeL2LevelGenerators,
4848
} from './orderBookLevels';
49+
import { isFallbackAvailableLiquiditySource } from '../math/auction';
50+
import { convertToNumber } from '../math/conversion';
4951

5052
export type DLOBOrder = { user: PublicKey; order: Order };
5153
export type DLOBOrders = DLOBOrder[];

0 commit comments

Comments
 (0)