UNPKG

@drift-labs/common

Version:

Common functions for Drift

29 lines 1.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Initialize = exports.Config = void 0; const sdk_1 = require("@drift-labs/sdk"); exports.Config = { initialized: false, spotMarketsLookup: [], perpMarketsLookup: [], sdkConfig: undefined, }; const Initialize = (env) => { const SDKConfig = (0, sdk_1.initialize)({ env }); const maxSpotMarketIndex = Math.max(...SDKConfig.SPOT_MARKETS.map((market) => market.marketIndex)); const maxPerpMarketIndex = Math.max(...SDKConfig.PERP_MARKETS.map((market) => market.marketIndex)); const spotMarkets = new Array(maxSpotMarketIndex); const markets = new Array(maxPerpMarketIndex); SDKConfig.SPOT_MARKETS.forEach((spotMarket) => { spotMarkets[spotMarket.marketIndex] = spotMarket; }); SDKConfig.PERP_MARKETS.forEach((perpMarket) => { markets[perpMarket.marketIndex] = perpMarket; }); exports.Config.spotMarketsLookup = spotMarkets; exports.Config.perpMarketsLookup = markets; exports.Config.initialized = true; return SDKConfig; }; exports.Initialize = Initialize; //# sourceMappingURL=Config.js.map