more comprehensive spot market inclusion
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
|||||||
DriftEnv,
|
DriftEnv,
|
||||||
Wallet,
|
Wallet,
|
||||||
BulkAccountLoader,
|
BulkAccountLoader,
|
||||||
isVariant,
|
|
||||||
getMarketsAndOraclesForSubscription,
|
getMarketsAndOraclesForSubscription,
|
||||||
} from '@drift-labs/sdk';
|
} from '@drift-labs/sdk';
|
||||||
|
|
||||||
@@ -56,7 +55,7 @@ logger.info(`Commit: ${commitHash}`);
|
|||||||
class PriorityFeeSubscriber {
|
class PriorityFeeSubscriber {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
perpMarketPubkeys: { marketIndex: number; pubkey: string }[];
|
perpMarketPubkeys: { marketIndex: number; pubkey: string }[];
|
||||||
spotMarketPubkeys: { marketIndex: number; pubkey: string }[];
|
spotMarketPubkeys: { marketIndex: number; pubkeys: string[] }[];
|
||||||
redisClient: RedisClient;
|
redisClient: RedisClient;
|
||||||
frequencyMs: number;
|
frequencyMs: number;
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ class PriorityFeeSubscriber {
|
|||||||
endpoint: string;
|
endpoint: string;
|
||||||
redisClient: RedisClient;
|
redisClient: RedisClient;
|
||||||
perpMarketPubkeys: { marketIndex: number; pubkey: string }[];
|
perpMarketPubkeys: { marketIndex: number; pubkey: string }[];
|
||||||
spotMarketPubkeys: { marketIndex: number; pubkey: string }[];
|
spotMarketPubkeys: { marketIndex: number; pubkeys: string[] }[];
|
||||||
frequencyMs?: number;
|
frequencyMs?: number;
|
||||||
}) {
|
}) {
|
||||||
this.endpoint = config.endpoint;
|
this.endpoint = config.endpoint;
|
||||||
@@ -119,7 +118,7 @@ class PriorityFeeSubscriber {
|
|||||||
method: 'getPriorityFeeEstimate',
|
method: 'getPriorityFeeEstimate',
|
||||||
params: [
|
params: [
|
||||||
{
|
{
|
||||||
accountKeys: [xx.pubkey],
|
accountKeys: xx.pubkeys,
|
||||||
options: {
|
options: {
|
||||||
includeAllPriorityFeeLevels: true,
|
includeAllPriorityFeeLevels: true,
|
||||||
},
|
},
|
||||||
@@ -187,32 +186,27 @@ const main = async () => {
|
|||||||
const perpMarketPubkeys = driftClient.getPerpMarketAccounts().map((acct) => {
|
const perpMarketPubkeys = driftClient.getPerpMarketAccounts().map((acct) => {
|
||||||
return { marketIndex: acct.marketIndex, pubkey: acct.pubkey.toString() };
|
return { marketIndex: acct.marketIndex, pubkey: acct.pubkey.toString() };
|
||||||
});
|
});
|
||||||
const spotMarketPubkeys = [];
|
|
||||||
|
const usdcMarket = driftClient.getSpotMarketAccount(0).pubkey.toString();
|
||||||
|
const spotMarketPubkeys: { marketIndex: number; pubkeys: string[] }[] = [];
|
||||||
for (const market of sdkConfig.SPOT_MARKETS) {
|
for (const market of sdkConfig.SPOT_MARKETS) {
|
||||||
|
const pubkeysForMarket = [usdcMarket];
|
||||||
|
|
||||||
|
const driftMarket = driftClient.getSpotMarketAccount(market.marketIndex);
|
||||||
|
pubkeysForMarket.push(driftMarket.pubkey.toString());
|
||||||
|
|
||||||
if (market.serumMarket) {
|
if (market.serumMarket) {
|
||||||
const serumConfigAccount = await driftClient.getSerumV3FulfillmentConfig(
|
pubkeysForMarket.push(market.serumMarket.toString());
|
||||||
market.serumMarket
|
|
||||||
);
|
|
||||||
if (isVariant(serumConfigAccount.status, 'enabled')) {
|
|
||||||
spotMarketPubkeys.push({
|
|
||||||
marketIndex: market.marketIndex,
|
|
||||||
pubkey: market.serumMarket.toString(),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
if (market.phoenixMarket) {
|
|
||||||
const phoneixConfigAccount =
|
|
||||||
await driftClient.getPhoenixV1FulfillmentConfig(
|
|
||||||
market.phoenixMarket
|
|
||||||
);
|
|
||||||
if (isVariant(phoneixConfigAccount.status, 'enabled')) {
|
|
||||||
spotMarketPubkeys.push({
|
|
||||||
marketIndex: market.marketIndex,
|
|
||||||
pubkey: market.phoenixMarket.toString(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (market.phoenixMarket) {
|
||||||
|
pubkeysForMarket.push(market.phoenixMarket.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
spotMarketPubkeys.push({
|
||||||
|
marketIndex: market.marketIndex,
|
||||||
|
pubkeys: pubkeysForMarket,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
|
const redisClient = new RedisClient(REDIS_HOST, REDIS_PORT, REDIS_PASSWORD);
|
||||||
|
|||||||
Reference in New Issue
Block a user