@drift-labs/sdk 0.2.0-master.3 → 0.2.0-master.31
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/README.md +13 -13
- package/lib/accounts/bulkUserStatsSubscription.d.ts +7 -0
- package/lib/accounts/bulkUserStatsSubscription.js +21 -0
- package/lib/accounts/bulkUserSubscription.js +0 -1
- package/lib/accounts/fetch.d.ts +2 -1
- package/lib/accounts/fetch.js +9 -1
- package/lib/accounts/pollingClearingHouseAccountSubscriber.d.ts +16 -16
- package/lib/accounts/pollingClearingHouseAccountSubscriber.js +31 -28
- package/lib/accounts/pollingUserStatsAccountSubscriber.d.ts +27 -0
- package/lib/accounts/pollingUserStatsAccountSubscriber.js +113 -0
- package/lib/accounts/types.d.ts +22 -11
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.d.ts +17 -17
- package/lib/accounts/webSocketClearingHouseAccountSubscriber.js +37 -35
- package/lib/accounts/webSocketUserStatsAccountSubsriber.d.ts +20 -0
- package/lib/accounts/webSocketUserStatsAccountSubsriber.js +47 -0
- package/lib/addresses/marketAddresses.d.ts +1 -3
- package/lib/addresses/pda.d.ts +10 -4
- package/lib/addresses/pda.js +51 -14
- package/lib/admin.d.ts +42 -26
- package/lib/admin.js +228 -81
- package/lib/clearingHouse.d.ts +130 -49
- package/lib/clearingHouse.js +1256 -367
- package/lib/clearingHouseConfig.d.ts +4 -4
- package/lib/clearingHouseUser.d.ts +51 -39
- package/lib/clearingHouseUser.js +408 -191
- package/lib/clearingHouseUserStats.d.ts +18 -0
- package/lib/clearingHouseUserStats.js +49 -0
- package/lib/clearingHouseUserStatsConfig.d.ts +14 -0
- package/lib/clearingHouseUserStatsConfig.js +2 -0
- package/lib/config.d.ts +7 -9
- package/lib/config.js +21 -21
- package/lib/constants/numericConstants.d.ts +25 -12
- package/lib/constants/numericConstants.js +35 -21
- package/lib/constants/perpMarkets.d.ts +18 -0
- package/lib/constants/{markets.js → perpMarkets.js} +7 -7
- package/lib/constants/spotMarkets.d.ts +19 -0
- package/lib/constants/spotMarkets.js +53 -0
- package/lib/dlob/DLOB.d.ts +74 -0
- package/lib/dlob/DLOB.js +595 -0
- package/lib/dlob/DLOBNode.d.ts +54 -0
- package/lib/dlob/DLOBNode.js +85 -0
- package/lib/dlob/NodeList.d.ts +26 -0
- package/lib/dlob/NodeList.js +139 -0
- package/lib/events/eventList.js +3 -0
- package/lib/events/eventSubscriber.d.ts +4 -2
- package/lib/events/eventSubscriber.js +16 -9
- package/lib/events/fetchLogs.d.ts +10 -1
- package/lib/events/fetchLogs.js +27 -7
- package/lib/events/pollingLogProvider.d.ts +2 -1
- package/lib/events/pollingLogProvider.js +6 -2
- package/lib/events/sort.js +8 -11
- package/lib/events/types.d.ts +8 -2
- package/lib/events/types.js +6 -0
- package/lib/examples/makeTradeExample.js +20 -8
- package/lib/factory/bigNum.d.ts +2 -0
- package/lib/factory/bigNum.js +48 -10
- package/lib/idl/clearing_house.json +4889 -1529
- package/lib/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/lib/index.d.ts +21 -6
- package/lib/index.js +25 -6
- package/lib/math/amm.d.ts +9 -6
- package/lib/math/amm.js +91 -66
- package/lib/math/auction.js +4 -1
- package/lib/math/conversion.js +1 -1
- package/lib/math/funding.d.ts +6 -6
- package/lib/math/funding.js +11 -10
- package/lib/math/insurance.d.ts +4 -0
- package/lib/math/insurance.js +27 -0
- package/lib/math/margin.d.ts +11 -0
- package/lib/math/margin.js +77 -0
- package/lib/math/market.d.ts +14 -9
- package/lib/math/market.js +72 -10
- package/lib/math/oracles.d.ts +4 -0
- package/lib/math/oracles.js +36 -8
- package/lib/math/orders.d.ts +6 -2
- package/lib/math/orders.js +78 -3
- package/lib/math/position.d.ts +21 -13
- package/lib/math/position.js +76 -36
- package/lib/math/repeg.js +14 -5
- package/lib/math/spotBalance.d.ts +22 -0
- package/lib/math/spotBalance.js +192 -0
- package/lib/math/spotMarket.d.ts +4 -0
- package/lib/math/spotMarket.js +8 -0
- package/lib/math/spotPosition.d.ts +6 -0
- package/lib/math/spotPosition.js +23 -0
- package/lib/math/trade.d.ts +10 -10
- package/lib/math/trade.js +32 -39
- package/lib/oracles/pythClient.js +1 -1
- package/lib/oracles/quoteAssetOracleClient.js +1 -1
- package/lib/oracles/switchboardClient.js +1 -1
- package/lib/orderParams.d.ts +14 -5
- package/lib/orderParams.js +12 -92
- package/lib/serum/serumSubscriber.d.ts +23 -0
- package/lib/serum/serumSubscriber.js +41 -0
- package/lib/serum/types.d.ts +11 -0
- package/lib/serum/types.js +2 -0
- package/lib/slot/SlotSubscriber.d.ts +7 -0
- package/lib/slot/SlotSubscriber.js +3 -0
- package/lib/{mockUSDCFaucet.d.ts → tokenFaucet.d.ts} +8 -5
- package/lib/{mockUSDCFaucet.js → tokenFaucet.js} +63 -51
- package/lib/tx/retryTxSender.d.ts +1 -1
- package/lib/tx/retryTxSender.js +13 -4
- package/lib/tx/types.d.ts +1 -1
- package/lib/tx/utils.js +1 -1
- package/lib/types.d.ts +566 -138
- package/lib/types.js +129 -5
- package/lib/userMap/userMap.d.ts +25 -0
- package/lib/userMap/userMap.js +73 -0
- package/lib/userMap/userStatsMap.d.ts +19 -0
- package/lib/userMap/userStatsMap.js +68 -0
- package/lib/util/computeUnits.js +1 -1
- package/lib/util/getTokenAddress.d.ts +2 -0
- package/lib/util/getTokenAddress.js +9 -0
- package/package.json +12 -6
- package/src/accounts/bulkUserStatsSubscription.ts +33 -0
- package/src/accounts/bulkUserSubscription.ts +0 -1
- package/src/accounts/fetch.ts +27 -2
- package/src/accounts/pollingClearingHouseAccountSubscriber.ts +46 -42
- package/src/accounts/pollingUserStatsAccountSubscriber.ts +172 -0
- package/src/accounts/types.ts +31 -11
- package/src/accounts/webSocketClearingHouseAccountSubscriber.ts +64 -59
- package/src/accounts/webSocketUserStatsAccountSubsriber.ts +80 -0
- package/src/addresses/marketAddresses.ts +1 -2
- package/src/addresses/pda.ts +88 -14
- package/src/admin.ts +452 -147
- package/src/assert/assert.js +9 -0
- package/src/clearingHouse.ts +2066 -467
- package/src/clearingHouseConfig.ts +4 -3
- package/src/clearingHouseUser.ts +747 -294
- package/src/clearingHouseUserStats.ts +75 -0
- package/src/clearingHouseUserStatsConfig.ts +18 -0
- package/src/config.ts +30 -31
- package/src/constants/numericConstants.ts +48 -25
- package/src/constants/{markets.ts → perpMarkets.ts} +10 -10
- package/src/constants/spotMarkets.ts +73 -0
- package/src/dlob/DLOB.ts +953 -0
- package/src/dlob/DLOBNode.ts +167 -0
- package/src/dlob/NodeList.ts +189 -0
- package/src/events/eventList.js +77 -0
- package/src/events/eventList.ts +3 -0
- package/src/events/eventSubscriber.ts +20 -12
- package/src/events/fetchLogs.ts +35 -8
- package/src/events/pollingLogProvider.ts +10 -2
- package/src/events/sort.ts +11 -15
- package/src/events/types.ts +19 -1
- package/src/examples/makeTradeExample.js +157 -0
- package/src/examples/makeTradeExample.ts +32 -14
- package/src/factory/bigNum.ts +65 -13
- package/src/idl/clearing_house.json +4889 -1529
- package/src/idl/{mock_usdc_faucet.json → token_faucet.json} +46 -23
- package/src/index.ts +21 -6
- package/src/math/amm.ts +171 -88
- package/src/math/auction.ts +5 -1
- package/src/math/conversion.ts +2 -2
- package/src/math/funding.ts +20 -18
- package/src/math/insurance.ts +35 -0
- package/src/math/margin.ts +127 -0
- package/src/math/market.ts +145 -14
- package/src/math/oracles.ts +63 -9
- package/src/math/orders.ts +138 -4
- package/src/math/position.ts +119 -58
- package/src/math/repeg.ts +16 -6
- package/src/math/spotBalance.ts +319 -0
- package/src/math/spotMarket.ts +9 -0
- package/src/math/spotPosition.ts +47 -0
- package/src/math/trade.ts +53 -59
- package/src/oracles/pythClient.ts +2 -2
- package/src/oracles/quoteAssetOracleClient.ts +2 -2
- package/src/oracles/switchboardClient.ts +2 -2
- package/src/orderParams.ts +24 -137
- package/src/serum/serumSubscriber.ts +80 -0
- package/src/serum/types.ts +13 -0
- package/src/slot/SlotSubscriber.ts +11 -1
- package/src/token/index.js +38 -0
- package/src/{mockUSDCFaucet.ts → tokenFaucet.ts} +82 -70
- package/src/tx/retryTxSender.ts +16 -5
- package/src/tx/types.js +2 -0
- package/src/tx/types.ts +2 -1
- package/src/tx/utils.js +17 -0
- package/src/tx/utils.ts +1 -1
- package/src/types.ts +533 -140
- package/src/userMap/userMap.ts +100 -0
- package/src/userMap/userStatsMap.ts +110 -0
- package/src/util/computeUnits.js +21 -11
- package/src/util/computeUnits.ts +1 -1
- package/src/util/getTokenAddress.js +9 -0
- package/src/util/getTokenAddress.ts +18 -0
- package/src/util/promiseTimeout.js +14 -0
- package/src/util/tps.js +27 -0
- package/tests/bn/test.ts +24 -10
- package/tests/dlob/helpers.ts +397 -0
- package/tests/dlob/test.ts +3688 -0
- package/lib/constants/banks.d.ts +0 -16
- package/lib/constants/banks.js +0 -34
- package/lib/constants/markets.d.ts +0 -19
- package/lib/math/bankBalance.d.ts +0 -9
- package/lib/math/bankBalance.js +0 -75
- package/lib/math/state.d.ts +0 -8
- package/lib/math/state.js +0 -15
- package/lib/orders.d.ts +0 -8
- package/lib/orders.js +0 -134
- package/src/constants/banks.ts +0 -43
- package/src/math/bankBalance.ts +0 -112
- package/src/math/state.ts +0 -14
- package/src/math/utils.js +0 -27
- package/src/math/utils.js.map +0 -1
- package/src/orders.ts +0 -244
- package/src/util/computeUnits.js.map +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ClearingHouse } from './clearingHouse';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { DataAndSlot, UserStatsAccountSubscriber } from './accounts/types';
|
|
4
|
+
import { ClearingHouseUserStatsConfig } from './clearingHouseUserStatsConfig';
|
|
5
|
+
import { ReferrerInfo, UserStatsAccount } from './types';
|
|
6
|
+
export declare class ClearingHouseUserStats {
|
|
7
|
+
clearingHouse: ClearingHouse;
|
|
8
|
+
userStatsAccountPublicKey: PublicKey;
|
|
9
|
+
accountSubscriber: UserStatsAccountSubscriber;
|
|
10
|
+
isSubscribed: boolean;
|
|
11
|
+
constructor(config: ClearingHouseUserStatsConfig);
|
|
12
|
+
subscribe(): Promise<boolean>;
|
|
13
|
+
fetchAccounts(): Promise<void>;
|
|
14
|
+
unsubscribe(): Promise<void>;
|
|
15
|
+
getAccountAndSlot(): DataAndSlot<UserStatsAccount>;
|
|
16
|
+
getAccount(): UserStatsAccount;
|
|
17
|
+
getReferrerInfo(): ReferrerInfo | undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClearingHouseUserStats = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const pollingUserStatsAccountSubscriber_1 = require("./accounts/pollingUserStatsAccountSubscriber");
|
|
6
|
+
const webSocketUserStatsAccountSubsriber_1 = require("./accounts/webSocketUserStatsAccountSubsriber");
|
|
7
|
+
const pda_1 = require("./addresses/pda");
|
|
8
|
+
class ClearingHouseUserStats {
|
|
9
|
+
constructor(config) {
|
|
10
|
+
var _a;
|
|
11
|
+
this.clearingHouse = config.clearingHouse;
|
|
12
|
+
this.userStatsAccountPublicKey = config.userStatsAccountPublicKey;
|
|
13
|
+
if (((_a = config.accountSubscription) === null || _a === void 0 ? void 0 : _a.type) === 'polling') {
|
|
14
|
+
this.accountSubscriber = new pollingUserStatsAccountSubscriber_1.PollingUserStatsAccountSubscriber(config.clearingHouse.program, config.userStatsAccountPublicKey, config.accountSubscription.accountLoader);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
this.accountSubscriber = new webSocketUserStatsAccountSubsriber_1.WebSocketUserStatsAccountSubscriber(config.clearingHouse.program, config.userStatsAccountPublicKey);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
async subscribe() {
|
|
21
|
+
this.isSubscribed = await this.accountSubscriber.subscribe();
|
|
22
|
+
return this.isSubscribed;
|
|
23
|
+
}
|
|
24
|
+
async fetchAccounts() {
|
|
25
|
+
await this.accountSubscriber.fetch();
|
|
26
|
+
}
|
|
27
|
+
async unsubscribe() {
|
|
28
|
+
await this.accountSubscriber.unsubscribe();
|
|
29
|
+
this.isSubscribed = false;
|
|
30
|
+
}
|
|
31
|
+
getAccountAndSlot() {
|
|
32
|
+
return this.accountSubscriber.getUserStatsAccountAndSlot();
|
|
33
|
+
}
|
|
34
|
+
getAccount() {
|
|
35
|
+
return this.accountSubscriber.getUserStatsAccountAndSlot().data;
|
|
36
|
+
}
|
|
37
|
+
getReferrerInfo() {
|
|
38
|
+
if (this.getAccount().referrer.equals(web3_js_1.PublicKey.default)) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
return {
|
|
43
|
+
referrer: (0, pda_1.getUserAccountPublicKeySync)(this.clearingHouse.program.programId, this.getAccount().referrer, 0),
|
|
44
|
+
referrerStats: (0, pda_1.getUserStatsAccountPublicKey)(this.clearingHouse.program.programId, this.getAccount().referrer),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
exports.ClearingHouseUserStats = ClearingHouseUserStats;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClearingHouse } from './clearingHouse';
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { BulkAccountLoader } from './accounts/bulkAccountLoader';
|
|
4
|
+
export declare type ClearingHouseUserStatsConfig = {
|
|
5
|
+
accountSubscription?: ClearingHouseUserStatsAccountSubscriptionConfig;
|
|
6
|
+
clearingHouse: ClearingHouse;
|
|
7
|
+
userStatsAccountPublicKey: PublicKey;
|
|
8
|
+
};
|
|
9
|
+
export declare type ClearingHouseUserStatsAccountSubscriptionConfig = {
|
|
10
|
+
type: 'websocket';
|
|
11
|
+
} | {
|
|
12
|
+
type: 'polling';
|
|
13
|
+
accountLoader: BulkAccountLoader;
|
|
14
|
+
};
|
package/lib/config.d.ts
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import { BankConfig } from './constants/banks';
|
|
4
|
-
import { BN } from '@project-serum/anchor';
|
|
1
|
+
import { PerpMarketConfig } from './constants/perpMarkets';
|
|
2
|
+
import { SpotMarketConfig } from './constants/spotMarkets';
|
|
5
3
|
import { OracleInfo } from './oracles/types';
|
|
6
4
|
declare type DriftConfig = {
|
|
7
5
|
ENV: DriftEnv;
|
|
8
6
|
PYTH_ORACLE_MAPPING_ADDRESS: string;
|
|
9
7
|
CLEARING_HOUSE_PROGRAM_ID: string;
|
|
10
8
|
USDC_MINT_ADDRESS: string;
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
PERP_MARKETS: PerpMarketConfig[];
|
|
10
|
+
SPOT_MARKETS: SpotMarketConfig[];
|
|
13
11
|
};
|
|
14
12
|
export declare type DriftEnv = 'devnet' | 'mainnet-beta';
|
|
15
13
|
export declare const configs: {
|
|
@@ -27,9 +25,9 @@ export declare const initialize: (props: {
|
|
|
27
25
|
env: DriftEnv;
|
|
28
26
|
overrideEnv?: Partial<DriftConfig>;
|
|
29
27
|
}) => DriftConfig;
|
|
30
|
-
export declare function
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
export declare function getMarketsAndOraclesForSubscription(env: DriftEnv): {
|
|
29
|
+
perpMarketIndexes: number[];
|
|
30
|
+
spotMarketIndexes: number[];
|
|
33
31
|
oracleInfos: OracleInfo[];
|
|
34
32
|
};
|
|
35
33
|
export {};
|
package/lib/config.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
const
|
|
3
|
+
exports.getMarketsAndOraclesForSubscription = exports.initialize = exports.getConfig = exports.configs = void 0;
|
|
4
|
+
const perpMarkets_1 = require("./constants/perpMarkets");
|
|
5
|
+
const spotMarkets_1 = require("./constants/spotMarkets");
|
|
6
6
|
exports.configs = {
|
|
7
7
|
devnet: {
|
|
8
8
|
ENV: 'devnet',
|
|
9
9
|
PYTH_ORACLE_MAPPING_ADDRESS: 'BmA9Z6FjioHJPpjT39QazZyhDRUdZy2ezwx4GiDdE2u2',
|
|
10
|
-
CLEARING_HOUSE_PROGRAM_ID: '
|
|
10
|
+
CLEARING_HOUSE_PROGRAM_ID: 'DUZwKJKAk2C9S88BYvQzck1M1i5hySQjxB4zW6tJ29Nw',
|
|
11
11
|
USDC_MINT_ADDRESS: '8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2',
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
PERP_MARKETS: perpMarkets_1.DevnetPerpMarkets,
|
|
13
|
+
SPOT_MARKETS: spotMarkets_1.DevnetSpotMarkets,
|
|
14
14
|
},
|
|
15
15
|
'mainnet-beta': {
|
|
16
16
|
ENV: 'mainnet-beta',
|
|
17
17
|
PYTH_ORACLE_MAPPING_ADDRESS: 'AHtgzX45WTKfkPG53L6WYhGEXwQkN1BVknET3sVsLL8J',
|
|
18
18
|
CLEARING_HOUSE_PROGRAM_ID: 'dammHkt7jmytvbS3nHTxQNEcP59aE57nxwV21YdqEDN',
|
|
19
19
|
USDC_MINT_ADDRESS: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
PERP_MARKETS: perpMarkets_1.MainnetMarkets,
|
|
21
|
+
SPOT_MARKETS: spotMarkets_1.MainnetSpotMarkets,
|
|
22
22
|
},
|
|
23
23
|
};
|
|
24
24
|
let currentConfig = exports.configs.devnet;
|
|
@@ -40,28 +40,28 @@ const initialize = (props) => {
|
|
|
40
40
|
return currentConfig;
|
|
41
41
|
};
|
|
42
42
|
exports.initialize = initialize;
|
|
43
|
-
function
|
|
44
|
-
const
|
|
45
|
-
const
|
|
43
|
+
function getMarketsAndOraclesForSubscription(env) {
|
|
44
|
+
const perpMarketIndexes = [];
|
|
45
|
+
const spotMarketIndexes = [];
|
|
46
46
|
const oracleInfos = new Map();
|
|
47
|
-
for (const market of
|
|
48
|
-
|
|
47
|
+
for (const market of perpMarkets_1.PerpMarkets[env]) {
|
|
48
|
+
perpMarketIndexes.push(market.marketIndex);
|
|
49
49
|
oracleInfos.set(market.oracle.toString(), {
|
|
50
50
|
publicKey: market.oracle,
|
|
51
51
|
source: market.oracleSource,
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
-
for (const
|
|
55
|
-
|
|
56
|
-
oracleInfos.set(
|
|
57
|
-
publicKey:
|
|
58
|
-
source:
|
|
54
|
+
for (const spotMarket of spotMarkets_1.SpotMarkets[env]) {
|
|
55
|
+
spotMarketIndexes.push(spotMarket.marketIndex);
|
|
56
|
+
oracleInfos.set(spotMarket.oracle.toString(), {
|
|
57
|
+
publicKey: spotMarket.oracle,
|
|
58
|
+
source: spotMarket.oracleSource,
|
|
59
59
|
});
|
|
60
60
|
}
|
|
61
61
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
perpMarketIndexes: perpMarketIndexes,
|
|
63
|
+
spotMarketIndexes: spotMarketIndexes,
|
|
64
64
|
oracleInfos: Array.from(oracleInfos.values()),
|
|
65
65
|
};
|
|
66
66
|
}
|
|
67
|
-
exports.
|
|
67
|
+
exports.getMarketsAndOraclesForSubscription = getMarketsAndOraclesForSubscription;
|
|
@@ -3,27 +3,38 @@ import { BN } from '../';
|
|
|
3
3
|
export declare const ZERO: BN;
|
|
4
4
|
export declare const ONE: BN;
|
|
5
5
|
export declare const TWO: BN;
|
|
6
|
+
export declare const THREE: BN;
|
|
7
|
+
export declare const FOUR: BN;
|
|
8
|
+
export declare const FIVE: BN;
|
|
9
|
+
export declare const SIX: BN;
|
|
10
|
+
export declare const SEVEN: BN;
|
|
11
|
+
export declare const EIGHT: BN;
|
|
12
|
+
export declare const NINE: BN;
|
|
6
13
|
export declare const TEN: BN;
|
|
7
14
|
export declare const TEN_THOUSAND: BN;
|
|
8
15
|
export declare const BN_MAX: BN;
|
|
9
16
|
export declare const TEN_MILLION: BN;
|
|
10
17
|
export declare const MAX_LEVERAGE: BN;
|
|
11
18
|
export declare const QUOTE_PRECISION_EXP: BN;
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
19
|
+
export declare const FUNDING_RATE_BUFFER_PRECISION_EXP: BN;
|
|
20
|
+
export declare const PRICE_PRECISION_EXP: BN;
|
|
14
21
|
export declare const FUNDING_RATE_PRECISION_EXP: BN;
|
|
15
22
|
export declare const PEG_PRECISION_EXP: BN;
|
|
16
23
|
export declare const AMM_RESERVE_PRECISION_EXP: BN;
|
|
17
|
-
export declare const
|
|
18
|
-
export declare const
|
|
19
|
-
export declare const
|
|
20
|
-
export declare const
|
|
21
|
-
export declare const
|
|
22
|
-
export declare const
|
|
23
|
-
export declare const
|
|
24
|
+
export declare const SPOT_MARKET_RATE_PRECISION_EXP: BN;
|
|
25
|
+
export declare const SPOT_MARKET_RATE_PRECISION: BN;
|
|
26
|
+
export declare const SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP: BN;
|
|
27
|
+
export declare const SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION: BN;
|
|
28
|
+
export declare const SPOT_MARKET_UTILIZATION_PRECISION: BN;
|
|
29
|
+
export declare const SPOT_MARKET_WEIGHT_PRECISION: BN;
|
|
30
|
+
export declare const SPOT_MARKET_BALANCE_PRECISION_EXP: BN;
|
|
31
|
+
export declare const SPOT_MARKET_BALANCE_PRECISION: BN;
|
|
32
|
+
export declare const SPOT_MARKET_IMF_PRECISION_EXP: BN;
|
|
33
|
+
export declare const SPOT_MARKET_IMF_PRECISION: BN;
|
|
34
|
+
export declare const LIQUIDATION_FEE_PRECISION: BN;
|
|
24
35
|
export declare const QUOTE_PRECISION: BN;
|
|
25
|
-
export declare const
|
|
26
|
-
export declare const
|
|
36
|
+
export declare const PRICE_PRECISION: BN;
|
|
37
|
+
export declare const FUNDING_RATE_BUFFER_PRECISION: BN;
|
|
27
38
|
export declare const PEG_PRECISION: BN;
|
|
28
39
|
export declare const AMM_RESERVE_PRECISION: BN;
|
|
29
40
|
export declare const BASE_PRECISION: BN;
|
|
@@ -35,4 +46,6 @@ export declare const AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO: BN;
|
|
|
35
46
|
export declare const MARGIN_PRECISION: BN;
|
|
36
47
|
export declare const BID_ASK_SPREAD_PRECISION: BN;
|
|
37
48
|
export declare const ONE_YEAR: BN;
|
|
38
|
-
export declare const
|
|
49
|
+
export declare const QUOTE_SPOT_MARKET_INDEX = 0;
|
|
50
|
+
export declare const LAMPORTS_PRECISION: BN;
|
|
51
|
+
export declare const LAMPORTS_EXP: BN;
|
|
@@ -1,40 +1,54 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.LAMPORTS_EXP = exports.LAMPORTS_PRECISION = exports.QUOTE_SPOT_MARKET_INDEX = exports.ONE_YEAR = exports.BID_ASK_SPREAD_PRECISION = exports.MARGIN_PRECISION = exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.PRICE_TO_QUOTE_PRECISION = exports.PRICE_DIV_PEG = exports.AMM_TO_QUOTE_PRECISION_RATIO = exports.BASE_PRECISION_EXP = exports.BASE_PRECISION = exports.AMM_RESERVE_PRECISION = exports.PEG_PRECISION = exports.FUNDING_RATE_BUFFER_PRECISION = exports.PRICE_PRECISION = exports.QUOTE_PRECISION = exports.LIQUIDATION_FEE_PRECISION = exports.SPOT_MARKET_IMF_PRECISION = exports.SPOT_MARKET_IMF_PRECISION_EXP = exports.SPOT_MARKET_BALANCE_PRECISION = exports.SPOT_MARKET_BALANCE_PRECISION_EXP = exports.SPOT_MARKET_WEIGHT_PRECISION = exports.SPOT_MARKET_UTILIZATION_PRECISION = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION = exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP = exports.SPOT_MARKET_RATE_PRECISION = exports.SPOT_MARKET_RATE_PRECISION_EXP = exports.AMM_RESERVE_PRECISION_EXP = exports.PEG_PRECISION_EXP = exports.FUNDING_RATE_PRECISION_EXP = exports.PRICE_PRECISION_EXP = exports.FUNDING_RATE_BUFFER_PRECISION_EXP = exports.QUOTE_PRECISION_EXP = exports.MAX_LEVERAGE = exports.TEN_MILLION = exports.BN_MAX = exports.TEN_THOUSAND = exports.TEN = exports.NINE = exports.EIGHT = exports.SEVEN = exports.SIX = exports.FIVE = exports.FOUR = exports.THREE = exports.TWO = exports.ONE = exports.ZERO = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
4
5
|
const __1 = require("../");
|
|
5
6
|
exports.ZERO = new __1.BN(0);
|
|
6
7
|
exports.ONE = new __1.BN(1);
|
|
7
8
|
exports.TWO = new __1.BN(2);
|
|
9
|
+
exports.THREE = new __1.BN(3);
|
|
10
|
+
exports.FOUR = new __1.BN(4);
|
|
11
|
+
exports.FIVE = new __1.BN(5);
|
|
12
|
+
exports.SIX = new __1.BN(6);
|
|
13
|
+
exports.SEVEN = new __1.BN(7);
|
|
14
|
+
exports.EIGHT = new __1.BN(8);
|
|
15
|
+
exports.NINE = new __1.BN(9);
|
|
8
16
|
exports.TEN = new __1.BN(10);
|
|
9
17
|
exports.TEN_THOUSAND = new __1.BN(10000);
|
|
10
18
|
exports.BN_MAX = new __1.BN(Number.MAX_SAFE_INTEGER);
|
|
11
19
|
exports.TEN_MILLION = exports.TEN_THOUSAND.mul(exports.TEN_THOUSAND);
|
|
12
20
|
exports.MAX_LEVERAGE = new __1.BN(5);
|
|
13
21
|
exports.QUOTE_PRECISION_EXP = new __1.BN(6);
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.FUNDING_RATE_PRECISION_EXP = exports.
|
|
17
|
-
exports.PEG_PRECISION_EXP = new __1.BN(
|
|
18
|
-
exports.AMM_RESERVE_PRECISION_EXP = new __1.BN(
|
|
19
|
-
exports.
|
|
20
|
-
exports.
|
|
21
|
-
exports.
|
|
22
|
-
exports.
|
|
23
|
-
exports.
|
|
24
|
-
exports.
|
|
25
|
-
exports.
|
|
22
|
+
exports.FUNDING_RATE_BUFFER_PRECISION_EXP = new __1.BN(3);
|
|
23
|
+
exports.PRICE_PRECISION_EXP = new __1.BN(6);
|
|
24
|
+
exports.FUNDING_RATE_PRECISION_EXP = exports.PRICE_PRECISION_EXP.mul(exports.FUNDING_RATE_BUFFER_PRECISION_EXP);
|
|
25
|
+
exports.PEG_PRECISION_EXP = new __1.BN(6);
|
|
26
|
+
exports.AMM_RESERVE_PRECISION_EXP = new __1.BN(9);
|
|
27
|
+
exports.SPOT_MARKET_RATE_PRECISION_EXP = new __1.BN(6);
|
|
28
|
+
exports.SPOT_MARKET_RATE_PRECISION = new __1.BN(10).pow(exports.SPOT_MARKET_RATE_PRECISION_EXP);
|
|
29
|
+
exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP = new __1.BN(10);
|
|
30
|
+
exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION = new __1.BN(10).pow(exports.SPOT_MARKET_CUMULATIVE_INTEREST_PRECISION_EXP);
|
|
31
|
+
exports.SPOT_MARKET_UTILIZATION_PRECISION = new __1.BN(1000000);
|
|
32
|
+
exports.SPOT_MARKET_WEIGHT_PRECISION = new __1.BN(10000);
|
|
33
|
+
exports.SPOT_MARKET_BALANCE_PRECISION_EXP = new __1.BN(9);
|
|
34
|
+
exports.SPOT_MARKET_BALANCE_PRECISION = new __1.BN(10).pow(exports.SPOT_MARKET_BALANCE_PRECISION_EXP);
|
|
35
|
+
exports.SPOT_MARKET_IMF_PRECISION_EXP = new __1.BN(6);
|
|
36
|
+
exports.SPOT_MARKET_IMF_PRECISION = new __1.BN(10).pow(exports.SPOT_MARKET_IMF_PRECISION_EXP);
|
|
37
|
+
exports.LIQUIDATION_FEE_PRECISION = new __1.BN(1000000);
|
|
26
38
|
exports.QUOTE_PRECISION = new __1.BN(10).pow(exports.QUOTE_PRECISION_EXP);
|
|
27
|
-
exports.
|
|
28
|
-
exports.
|
|
39
|
+
exports.PRICE_PRECISION = new __1.BN(10).pow(exports.PRICE_PRECISION_EXP);
|
|
40
|
+
exports.FUNDING_RATE_BUFFER_PRECISION = new __1.BN(10).pow(exports.FUNDING_RATE_BUFFER_PRECISION_EXP);
|
|
29
41
|
exports.PEG_PRECISION = new __1.BN(10).pow(exports.PEG_PRECISION_EXP);
|
|
30
42
|
exports.AMM_RESERVE_PRECISION = new __1.BN(10).pow(exports.AMM_RESERVE_PRECISION_EXP);
|
|
31
43
|
exports.BASE_PRECISION = exports.AMM_RESERVE_PRECISION;
|
|
32
44
|
exports.BASE_PRECISION_EXP = exports.AMM_RESERVE_PRECISION_EXP;
|
|
33
|
-
exports.AMM_TO_QUOTE_PRECISION_RATIO = exports.AMM_RESERVE_PRECISION.div(exports.QUOTE_PRECISION); // 10^
|
|
34
|
-
exports.PRICE_DIV_PEG = exports.
|
|
35
|
-
exports.PRICE_TO_QUOTE_PRECISION = exports.
|
|
36
|
-
exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.AMM_RESERVE_PRECISION.mul(exports.PEG_PRECISION).div(exports.QUOTE_PRECISION); // 10^
|
|
45
|
+
exports.AMM_TO_QUOTE_PRECISION_RATIO = exports.AMM_RESERVE_PRECISION.div(exports.QUOTE_PRECISION); // 10^3
|
|
46
|
+
exports.PRICE_DIV_PEG = exports.PRICE_PRECISION.div(exports.PEG_PRECISION); //10^1
|
|
47
|
+
exports.PRICE_TO_QUOTE_PRECISION = exports.PRICE_PRECISION.div(exports.QUOTE_PRECISION); // 10^1
|
|
48
|
+
exports.AMM_TIMES_PEG_TO_QUOTE_PRECISION_RATIO = exports.AMM_RESERVE_PRECISION.mul(exports.PEG_PRECISION).div(exports.QUOTE_PRECISION); // 10^9
|
|
37
49
|
exports.MARGIN_PRECISION = exports.TEN_THOUSAND;
|
|
38
|
-
exports.BID_ASK_SPREAD_PRECISION = new __1.BN(1000000);
|
|
50
|
+
exports.BID_ASK_SPREAD_PRECISION = new __1.BN(1000000); // 10^6
|
|
39
51
|
exports.ONE_YEAR = new __1.BN(31536000);
|
|
40
|
-
exports.
|
|
52
|
+
exports.QUOTE_SPOT_MARKET_INDEX = 0;
|
|
53
|
+
exports.LAMPORTS_PRECISION = new __1.BN(web3_js_1.LAMPORTS_PER_SOL);
|
|
54
|
+
exports.LAMPORTS_EXP = new __1.BN(Math.log10(web3_js_1.LAMPORTS_PER_SOL));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { OracleSource } from '../';
|
|
2
|
+
import { DriftEnv } from '../';
|
|
3
|
+
import { PublicKey } from '@solana/web3.js';
|
|
4
|
+
export declare type PerpMarketConfig = {
|
|
5
|
+
fullName?: string;
|
|
6
|
+
category?: string[];
|
|
7
|
+
symbol: string;
|
|
8
|
+
baseAssetSymbol: string;
|
|
9
|
+
marketIndex: number;
|
|
10
|
+
launchTs: number;
|
|
11
|
+
oracle: PublicKey;
|
|
12
|
+
oracleSource: OracleSource;
|
|
13
|
+
};
|
|
14
|
+
export declare const DevnetPerpMarkets: PerpMarketConfig[];
|
|
15
|
+
export declare const MainnetMarkets: PerpMarketConfig[];
|
|
16
|
+
export declare const PerpMarkets: {
|
|
17
|
+
[key in DriftEnv]: PerpMarketConfig[];
|
|
18
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.PerpMarkets = exports.MainnetMarkets = exports.DevnetPerpMarkets = void 0;
|
|
4
4
|
const __1 = require("../");
|
|
5
5
|
const web3_js_1 = require("@solana/web3.js");
|
|
6
|
-
exports.
|
|
6
|
+
exports.DevnetPerpMarkets = [
|
|
7
7
|
{
|
|
8
8
|
fullName: 'Solana',
|
|
9
9
|
category: ['L1', 'Infra'],
|
|
10
10
|
symbol: 'SOL-PERP',
|
|
11
11
|
baseAssetSymbol: 'SOL',
|
|
12
|
-
marketIndex:
|
|
12
|
+
marketIndex: 0,
|
|
13
13
|
oracle: new web3_js_1.PublicKey('J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix'),
|
|
14
14
|
launchTs: 1655751353000,
|
|
15
15
|
oracleSource: __1.OracleSource.PYTH,
|
|
@@ -19,7 +19,7 @@ exports.DevnetMarkets = [
|
|
|
19
19
|
category: ['L1', 'Payment'],
|
|
20
20
|
symbol: 'BTC-PERP',
|
|
21
21
|
baseAssetSymbol: 'BTC',
|
|
22
|
-
marketIndex:
|
|
22
|
+
marketIndex: 1,
|
|
23
23
|
oracle: new web3_js_1.PublicKey('HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J'),
|
|
24
24
|
launchTs: 1655751353000,
|
|
25
25
|
oracleSource: __1.OracleSource.PYTH,
|
|
@@ -29,14 +29,14 @@ exports.DevnetMarkets = [
|
|
|
29
29
|
category: ['L1', 'Infra'],
|
|
30
30
|
symbol: 'ETH-PERP',
|
|
31
31
|
baseAssetSymbol: 'ETH',
|
|
32
|
-
marketIndex:
|
|
32
|
+
marketIndex: 2,
|
|
33
33
|
oracle: new web3_js_1.PublicKey('EdVCmQ9FSPcVe5YySXDPCRmc8aDQLKJ9xvYBMZPie1Vw'),
|
|
34
34
|
launchTs: 1637691133472,
|
|
35
35
|
oracleSource: __1.OracleSource.PYTH,
|
|
36
36
|
},
|
|
37
37
|
];
|
|
38
38
|
exports.MainnetMarkets = [];
|
|
39
|
-
exports.
|
|
40
|
-
devnet: exports.
|
|
39
|
+
exports.PerpMarkets = {
|
|
40
|
+
devnet: exports.DevnetPerpMarkets,
|
|
41
41
|
'mainnet-beta': [],
|
|
42
42
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { PublicKey } from '@solana/web3.js';
|
|
3
|
+
import { BN, DriftEnv, OracleSource } from '../';
|
|
4
|
+
export declare type SpotMarketConfig = {
|
|
5
|
+
symbol: string;
|
|
6
|
+
marketIndex: number;
|
|
7
|
+
oracle: PublicKey;
|
|
8
|
+
mint: PublicKey;
|
|
9
|
+
oracleSource: OracleSource;
|
|
10
|
+
precision: BN;
|
|
11
|
+
precisionExp: BN;
|
|
12
|
+
serumMarket?: PublicKey;
|
|
13
|
+
};
|
|
14
|
+
export declare const WRAPPED_SOL_MINT: PublicKey;
|
|
15
|
+
export declare const DevnetSpotMarkets: SpotMarketConfig[];
|
|
16
|
+
export declare const MainnetSpotMarkets: SpotMarketConfig[];
|
|
17
|
+
export declare const SpotMarkets: {
|
|
18
|
+
[key in DriftEnv]: SpotMarketConfig[];
|
|
19
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SpotMarkets = exports.MainnetSpotMarkets = exports.DevnetSpotMarkets = exports.WRAPPED_SOL_MINT = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
5
|
+
const __1 = require("../");
|
|
6
|
+
const numericConstants_1 = require("./numericConstants");
|
|
7
|
+
exports.WRAPPED_SOL_MINT = new web3_js_1.PublicKey('So11111111111111111111111111111111111111112');
|
|
8
|
+
exports.DevnetSpotMarkets = [
|
|
9
|
+
{
|
|
10
|
+
symbol: 'USDC',
|
|
11
|
+
marketIndex: 0,
|
|
12
|
+
oracle: web3_js_1.PublicKey.default,
|
|
13
|
+
oracleSource: __1.OracleSource.QUOTE_ASSET,
|
|
14
|
+
mint: new web3_js_1.PublicKey('8zGuJQqwhZafTah7Uc7Z4tXRnguqkn5KLFAP8oV6PHe2'),
|
|
15
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
16
|
+
precisionExp: numericConstants_1.SIX,
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
symbol: 'SOL',
|
|
20
|
+
marketIndex: 1,
|
|
21
|
+
oracle: new web3_js_1.PublicKey('J83w4HKfqxwcq3BEMMkPFSppX3gqekLyLJBexebFVkix'),
|
|
22
|
+
oracleSource: __1.OracleSource.PYTH,
|
|
23
|
+
mint: new web3_js_1.PublicKey(exports.WRAPPED_SOL_MINT),
|
|
24
|
+
precision: numericConstants_1.LAMPORTS_PRECISION,
|
|
25
|
+
precisionExp: numericConstants_1.LAMPORTS_EXP,
|
|
26
|
+
serumMarket: new web3_js_1.PublicKey('8N37SsnTu8RYxtjrV9SStjkkwVhmU8aCWhLvwduAPEKW'),
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
symbol: 'BTC',
|
|
30
|
+
marketIndex: 2,
|
|
31
|
+
oracle: new web3_js_1.PublicKey('HovQMDrbAgAYPCmHVSrezcSmkMtXSSUsLDFANExrZh2J'),
|
|
32
|
+
oracleSource: __1.OracleSource.PYTH,
|
|
33
|
+
mint: new web3_js_1.PublicKey('3BZPwbcqB5kKScF3TEXxwNfx5ipV13kbRVDvfVp5c6fv'),
|
|
34
|
+
precision: new __1.BN(10).pow(numericConstants_1.SIX),
|
|
35
|
+
precisionExp: numericConstants_1.SIX,
|
|
36
|
+
serumMarket: new web3_js_1.PublicKey('AGsmbVu3MS9u68GEYABWosQQCZwmLcBHu4pWEuBYH7Za'),
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
exports.MainnetSpotMarkets = [
|
|
40
|
+
{
|
|
41
|
+
symbol: 'USDC',
|
|
42
|
+
marketIndex: 0,
|
|
43
|
+
oracle: web3_js_1.PublicKey.default,
|
|
44
|
+
oracleSource: __1.OracleSource.QUOTE_ASSET,
|
|
45
|
+
mint: new web3_js_1.PublicKey('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
|
|
46
|
+
precision: numericConstants_1.SPOT_MARKET_BALANCE_PRECISION,
|
|
47
|
+
precisionExp: numericConstants_1.SPOT_MARKET_BALANCE_PRECISION_EXP,
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
exports.SpotMarkets = {
|
|
51
|
+
devnet: exports.DevnetSpotMarkets,
|
|
52
|
+
'mainnet-beta': exports.MainnetSpotMarkets,
|
|
53
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/// <reference types="bn.js" />
|
|
2
|
+
import { NodeList } from './NodeList';
|
|
3
|
+
import { MarketType, BN, ClearingHouse, Order, SpotMarketAccount, PerpMarketAccount, OraclePriceData, SlotSubscriber, UserMap, MarketTypeStr } from '..';
|
|
4
|
+
import { PublicKey } from '@solana/web3.js';
|
|
5
|
+
import { DLOBNode, TriggerOrderNode } from '..';
|
|
6
|
+
export declare type MarketNodeLists = {
|
|
7
|
+
limit: {
|
|
8
|
+
ask: NodeList<'limit'>;
|
|
9
|
+
bid: NodeList<'limit'>;
|
|
10
|
+
};
|
|
11
|
+
floatingLimit: {
|
|
12
|
+
ask: NodeList<'floatingLimit'>;
|
|
13
|
+
bid: NodeList<'floatingLimit'>;
|
|
14
|
+
};
|
|
15
|
+
market: {
|
|
16
|
+
ask: NodeList<'market'>;
|
|
17
|
+
bid: NodeList<'market'>;
|
|
18
|
+
};
|
|
19
|
+
trigger: {
|
|
20
|
+
above: NodeList<'trigger'>;
|
|
21
|
+
below: NodeList<'trigger'>;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
declare type OrderBookCallback = () => void;
|
|
25
|
+
export declare type NodeToFill = {
|
|
26
|
+
node: DLOBNode;
|
|
27
|
+
makerNode?: DLOBNode;
|
|
28
|
+
};
|
|
29
|
+
export declare type NodeToTrigger = {
|
|
30
|
+
node: TriggerOrderNode;
|
|
31
|
+
};
|
|
32
|
+
declare type Side = 'ask' | 'bid' | 'both' | 'nocross';
|
|
33
|
+
export declare class DLOB {
|
|
34
|
+
openOrders: Map<MarketTypeStr, Set<string>>;
|
|
35
|
+
orderLists: Map<MarketTypeStr, Map<number, MarketNodeLists>>;
|
|
36
|
+
marketIndexToAccount: Map<MarketTypeStr, Map<number, PerpMarketAccount | SpotMarketAccount>>;
|
|
37
|
+
silent: boolean;
|
|
38
|
+
initialized: boolean;
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param perpMarkets The perp markets to maintain a DLOB for
|
|
42
|
+
* @param spotMarkets The spot markets to maintain a DLOB for
|
|
43
|
+
* @param silent set to true to prevent logging on inserts and removals
|
|
44
|
+
*/
|
|
45
|
+
constructor(perpMarkets: PerpMarketAccount[], spotMarkets: SpotMarketAccount[], silent?: boolean);
|
|
46
|
+
/**
|
|
47
|
+
* initializes a new DLOB instance
|
|
48
|
+
*
|
|
49
|
+
* @param clearingHouse The ClearingHouse instance to use for price data
|
|
50
|
+
* @returns a promise that resolves when the DLOB is initialized
|
|
51
|
+
*/
|
|
52
|
+
init(clearingHouse: ClearingHouse, userMap?: UserMap): Promise<boolean>;
|
|
53
|
+
insertOrder(order: Order, userAccount: PublicKey, onInsert?: OrderBookCallback): void;
|
|
54
|
+
trigger(order: Order, userAccount: PublicKey, onTrigger?: OrderBookCallback): void;
|
|
55
|
+
getListForOrder(order: Order): NodeList<any> | undefined;
|
|
56
|
+
findNodesToFill(marketIndex: number, vBid: BN | undefined, vAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): NodeToFill[];
|
|
57
|
+
findCrossingNodesToFill(marketIndex: number, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): NodeToFill[];
|
|
58
|
+
findvAMMCrossingNodesToFill(marketIndex: number, vBid: BN, vAsk: BN, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): NodeToFill[];
|
|
59
|
+
findExpiredMarketNodesToFill(marketIndex: number, slot: number, marketType: MarketType): NodeToFill[];
|
|
60
|
+
findJitAuctionNodesToFill(marketIndex: number, slot: number, marketType: MarketType): NodeToFill[];
|
|
61
|
+
getMarketBids(marketIndex: number, marketType: MarketType): Generator<DLOBNode>;
|
|
62
|
+
getMarketAsks(marketIndex: number, marketType: MarketType): Generator<DLOBNode>;
|
|
63
|
+
getAsks(marketIndex: number, vAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): Generator<DLOBNode>;
|
|
64
|
+
getBids(marketIndex: number, vBid: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): Generator<DLOBNode>;
|
|
65
|
+
findCrossingOrders(askNode: DLOBNode, bidNode: DLOBNode, oraclePriceData: OraclePriceData, slot: number): {
|
|
66
|
+
crossingNodes: NodeToFill[];
|
|
67
|
+
exhaustedSide: Side;
|
|
68
|
+
};
|
|
69
|
+
getBestAsk(marketIndex: number, vAsk: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN;
|
|
70
|
+
getBestBid(marketIndex: number, vBid: BN | undefined, slot: number, marketType: MarketType, oraclePriceData: OraclePriceData): BN;
|
|
71
|
+
findNodesToTrigger(marketIndex: number, slot: number, oraclePrice: BN, marketType: MarketType): NodeToTrigger[];
|
|
72
|
+
printTopOfOrderLists(sdkConfig: any, clearingHouse: ClearingHouse, slotSubscriber: SlotSubscriber, marketIndex: number, marketType: MarketType): void;
|
|
73
|
+
}
|
|
74
|
+
export {};
|