@drift-labs/common 1.0.0
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/Config.d.ts +26 -0
- package/lib/Config.js +29 -0
- package/lib/Config.js.map +1 -0
- package/lib/EnvironmentConstants.d.ts +40 -0
- package/lib/EnvironmentConstants.js +64 -0
- package/lib/EnvironmentConstants.js.map +1 -0
- package/lib/actions/actionHelpers/accountDeletionHelpers.d.ts +16 -0
- package/lib/actions/actionHelpers/accountDeletionHelpers.js +151 -0
- package/lib/actions/actionHelpers/accountDeletionHelpers.js.map +1 -0
- package/lib/actions/actionHelpers/actionHelpers.d.ts +13 -0
- package/lib/actions/actionHelpers/actionHelpers.js +8 -0
- package/lib/actions/actionHelpers/actionHelpers.js.map +1 -0
- package/lib/chartConstants.d.ts +2 -0
- package/lib/chartConstants.js +14 -0
- package/lib/chartConstants.js.map +1 -0
- package/lib/clients/candleClient.d.ts +74 -0
- package/lib/clients/candleClient.js +364 -0
- package/lib/clients/candleClient.js.map +1 -0
- package/lib/clients/dataApiWsClient.d.ts +33 -0
- package/lib/clients/dataApiWsClient.js +118 -0
- package/lib/clients/dataApiWsClient.js.map +1 -0
- package/lib/clients/index.d.ts +1 -0
- package/lib/clients/index.js +19 -0
- package/lib/clients/index.js.map +1 -0
- package/lib/clients/marketDataFeed.d.ts +42 -0
- package/lib/clients/marketDataFeed.js +422 -0
- package/lib/clients/marketDataFeed.js.map +1 -0
- package/lib/clients/redisClient.d.ts +89 -0
- package/lib/clients/redisClient.js +647 -0
- package/lib/clients/redisClient.js.map +1 -0
- package/lib/clients/swiftClient.d.ts +57 -0
- package/lib/clients/swiftClient.js +289 -0
- package/lib/clients/swiftClient.js.map +1 -0
- package/lib/clients/tvFeed.d.ts +63 -0
- package/lib/clients/tvFeed.js +351 -0
- package/lib/clients/tvFeed.js.map +1 -0
- package/lib/common-ui-utils/commonUiUtils.d.ts +211 -0
- package/lib/common-ui-utils/commonUiUtils.js +624 -0
- package/lib/common-ui-utils/commonUiUtils.js.map +1 -0
- package/lib/common-ui-utils/index.d.ts +6 -0
- package/lib/common-ui-utils/index.js +23 -0
- package/lib/common-ui-utils/index.js.map +1 -0
- package/lib/common-ui-utils/market.d.ts +27 -0
- package/lib/common-ui-utils/market.js +80 -0
- package/lib/common-ui-utils/market.js.map +1 -0
- package/lib/common-ui-utils/order.d.ts +11 -0
- package/lib/common-ui-utils/order.js +161 -0
- package/lib/common-ui-utils/order.js.map +1 -0
- package/lib/common-ui-utils/settings/settings.d.ts +51 -0
- package/lib/common-ui-utils/settings/settings.js +84 -0
- package/lib/common-ui-utils/settings/settings.js.map +1 -0
- package/lib/common-ui-utils/trading.d.ts +56 -0
- package/lib/common-ui-utils/trading.js +200 -0
- package/lib/common-ui-utils/trading.js.map +1 -0
- package/lib/common-ui-utils/user.d.ts +13 -0
- package/lib/common-ui-utils/user.js +124 -0
- package/lib/common-ui-utils/user.js.map +1 -0
- package/lib/constants/autogenerated/driftErrors.json +1787 -0
- package/lib/constants/autogenerated/jup-v4-error-codes.json +67 -0
- package/lib/constants/autogenerated/jup-v6-error-codes.json +115 -0
- package/lib/constants/dev.d.ts +15 -0
- package/lib/constants/dev.js +19 -0
- package/lib/constants/dev.js.map +1 -0
- package/lib/constants/geoblockList.d.ts +4 -0
- package/lib/constants/geoblockList.js +32 -0
- package/lib/constants/geoblockList.js.map +1 -0
- package/lib/constants/index.d.ts +9 -0
- package/lib/constants/index.js +26 -0
- package/lib/constants/index.js.map +1 -0
- package/lib/constants/markets.d.ts +1 -0
- package/lib/constants/markets.js +5 -0
- package/lib/constants/markets.js.map +1 -0
- package/lib/constants/misc.d.ts +23 -0
- package/lib/constants/misc.js +27 -0
- package/lib/constants/misc.js.map +1 -0
- package/lib/constants/orders.d.ts +12 -0
- package/lib/constants/orders.js +79 -0
- package/lib/constants/orders.js.map +1 -0
- package/lib/constants/pools.d.ts +5 -0
- package/lib/constants/pools.js +9 -0
- package/lib/constants/pools.js.map +1 -0
- package/lib/constants/predictionMarket.d.ts +3 -0
- package/lib/constants/predictionMarket.js +7 -0
- package/lib/constants/predictionMarket.js.map +1 -0
- package/lib/constants/superstake.d.ts +22 -0
- package/lib/constants/superstake.js +45 -0
- package/lib/constants/superstake.js.map +1 -0
- package/lib/constants/trade.d.ts +2 -0
- package/lib/constants/trade.js +9 -0
- package/lib/constants/trade.js.map +1 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftL2OrderbookManager.d.ts +68 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftL2OrderbookManager.js +146 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftL2OrderbookManager.js.map +1 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.d.ts +204 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js +530 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/index.js.map +1 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.d.ts +90 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.js +3 -0
- package/lib/drift/Drift/clients/AuthorityDrift/DriftOperations/types.js.map +1 -0
- package/lib/drift/Drift/clients/AuthorityDrift/SubscriptionManager.d.ts +139 -0
- package/lib/drift/Drift/clients/AuthorityDrift/SubscriptionManager.js +287 -0
- package/lib/drift/Drift/clients/AuthorityDrift/SubscriptionManager.js.map +1 -0
- package/lib/drift/Drift/clients/AuthorityDrift/index.d.ts +242 -0
- package/lib/drift/Drift/clients/AuthorityDrift/index.js +503 -0
- package/lib/drift/Drift/clients/AuthorityDrift/index.js.map +1 -0
- package/lib/drift/Drift/clients/CentralServerDrift.d.ts +91 -0
- package/lib/drift/Drift/clients/CentralServerDrift.js +326 -0
- package/lib/drift/Drift/clients/CentralServerDrift.js.map +1 -0
- package/lib/drift/Drift/clients/index.d.ts +3 -0
- package/lib/drift/Drift/clients/index.js +20 -0
- package/lib/drift/Drift/clients/index.js.map +1 -0
- package/lib/drift/Drift/constants/blockchain.d.ts +24 -0
- package/lib/drift/Drift/constants/blockchain.js +32 -0
- package/lib/drift/Drift/constants/blockchain.js.map +1 -0
- package/lib/drift/Drift/constants/errors.d.ts +6 -0
- package/lib/drift/Drift/constants/errors.js +14 -0
- package/lib/drift/Drift/constants/errors.js.map +1 -0
- package/lib/drift/Drift/constants/index.d.ts +3 -0
- package/lib/drift/Drift/constants/index.js +20 -0
- package/lib/drift/Drift/constants/index.js.map +1 -0
- package/lib/drift/Drift/constants/orderbook.d.ts +7 -0
- package/lib/drift/Drift/constants/orderbook.js +10 -0
- package/lib/drift/Drift/constants/orderbook.js.map +1 -0
- package/lib/drift/Drift/data/PollingDlob.d.ts +154 -0
- package/lib/drift/Drift/data/PollingDlob.js +387 -0
- package/lib/drift/Drift/data/PollingDlob.js.map +1 -0
- package/lib/drift/Drift/data/index.d.ts +1 -0
- package/lib/drift/Drift/data/index.js +18 -0
- package/lib/drift/Drift/data/index.js.map +1 -0
- package/lib/drift/Drift/index.d.ts +4 -0
- package/lib/drift/Drift/index.js +21 -0
- package/lib/drift/Drift/index.js.map +1 -0
- package/lib/drift/Drift/stores/MarkPriceCache.d.ts +27 -0
- package/lib/drift/Drift/stores/MarkPriceCache.js +59 -0
- package/lib/drift/Drift/stores/MarkPriceCache.js.map +1 -0
- package/lib/drift/Drift/stores/OraclePriceCache.d.ts +21 -0
- package/lib/drift/Drift/stores/OraclePriceCache.js +57 -0
- package/lib/drift/Drift/stores/OraclePriceCache.js.map +1 -0
- package/lib/drift/Drift/stores/UserAccountCache.d.ts +49 -0
- package/lib/drift/Drift/stores/UserAccountCache.js +107 -0
- package/lib/drift/Drift/stores/UserAccountCache.js.map +1 -0
- package/lib/drift/Drift/stores/index.d.ts +3 -0
- package/lib/drift/Drift/stores/index.js +20 -0
- package/lib/drift/Drift/stores/index.js.map +1 -0
- package/lib/drift/base/actions/index.d.ts +4 -0
- package/lib/drift/base/actions/index.js +21 -0
- package/lib/drift/base/actions/index.js.map +1 -0
- package/lib/drift/base/actions/perp/index.d.ts +2 -0
- package/lib/drift/base/actions/perp/index.js +19 -0
- package/lib/drift/base/actions/perp/index.js.map +1 -0
- package/lib/drift/base/actions/perp/settleFunding.d.ts +25 -0
- package/lib/drift/base/actions/perp/settleFunding.js +41 -0
- package/lib/drift/base/actions/perp/settleFunding.js.map +1 -0
- package/lib/drift/base/actions/perp/settlePnl.d.ts +35 -0
- package/lib/drift/base/actions/perp/settlePnl.js +44 -0
- package/lib/drift/base/actions/perp/settlePnl.js.map +1 -0
- package/lib/drift/base/actions/spot/borrow.d.ts +1 -0
- package/lib/drift/base/actions/spot/borrow.js +8 -0
- package/lib/drift/base/actions/spot/borrow.js.map +1 -0
- package/lib/drift/base/actions/spot/deposit.d.ts +40 -0
- package/lib/drift/base/actions/spot/deposit.js +82 -0
- package/lib/drift/base/actions/spot/deposit.js.map +1 -0
- package/lib/drift/base/actions/spot/index.d.ts +3 -0
- package/lib/drift/base/actions/spot/index.js +20 -0
- package/lib/drift/base/actions/spot/index.js.map +1 -0
- package/lib/drift/base/actions/spot/withdraw.d.ts +16 -0
- package/lib/drift/base/actions/spot/withdraw.js +39 -0
- package/lib/drift/base/actions/spot/withdraw.js.map +1 -0
- package/lib/drift/base/actions/trade/cancelOrder.d.ts +47 -0
- package/lib/drift/base/actions/trade/cancelOrder.js +55 -0
- package/lib/drift/base/actions/trade/cancelOrder.js.map +1 -0
- package/lib/drift/base/actions/trade/editOrder.d.ts +55 -0
- package/lib/drift/base/actions/trade/editOrder.js +35 -0
- package/lib/drift/base/actions/trade/editOrder.js.map +1 -0
- package/lib/drift/base/actions/trade/index.d.ts +4 -0
- package/lib/drift/base/actions/trade/index.js +21 -0
- package/lib/drift/base/actions/trade/index.js.map +1 -0
- package/lib/drift/base/actions/trade/openPerpOrder/index.d.ts +3 -0
- package/lib/drift/base/actions/trade/openPerpOrder/index.js +20 -0
- package/lib/drift/base/actions/trade/openPerpOrder/index.js.map +1 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.d.ts +84 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js +293 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openPerpMarketOrder/index.js.map +1 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.d.ts +19 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js +161 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openPerpNonMarketOrder/index.js.map +1 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.d.ts +166 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js +156 -0
- package/lib/drift/base/actions/trade/openPerpOrder/openSwiftOrder/index.js.map +1 -0
- package/lib/drift/base/actions/trade/swap.d.ts +62 -0
- package/lib/drift/base/actions/trade/swap.js +60 -0
- package/lib/drift/base/actions/trade/swap.js.map +1 -0
- package/lib/drift/base/actions/user/create.d.ts +75 -0
- package/lib/drift/base/actions/user/create.js +104 -0
- package/lib/drift/base/actions/user/create.js.map +1 -0
- package/lib/drift/base/actions/user/delete.d.ts +47 -0
- package/lib/drift/base/actions/user/delete.js +39 -0
- package/lib/drift/base/actions/user/delete.js.map +1 -0
- package/lib/drift/base/actions/user/index.d.ts +1 -0
- package/lib/drift/base/actions/user/index.js +18 -0
- package/lib/drift/base/actions/user/index.js.map +1 -0
- package/lib/drift/base/constants/accountNames.d.ts +1 -0
- package/lib/drift/base/constants/accountNames.js +13 -0
- package/lib/drift/base/constants/accountNames.js.map +1 -0
- package/lib/drift/base/details/index.d.ts +2 -0
- package/lib/drift/base/details/index.js +19 -0
- package/lib/drift/base/details/index.js.map +1 -0
- package/lib/drift/base/details/market/funding.d.ts +9 -0
- package/lib/drift/base/details/market/funding.js +50 -0
- package/lib/drift/base/details/market/funding.js.map +1 -0
- package/lib/drift/base/details/market/index.d.ts +2 -0
- package/lib/drift/base/details/market/index.js +19 -0
- package/lib/drift/base/details/market/index.js.map +1 -0
- package/lib/drift/base/details/market/openInterest.d.ts +5 -0
- package/lib/drift/base/details/market/openInterest.js +12 -0
- package/lib/drift/base/details/market/openInterest.js.map +1 -0
- package/lib/drift/base/details/user/balances.d.ts +40 -0
- package/lib/drift/base/details/user/balances.js +39 -0
- package/lib/drift/base/details/user/balances.js.map +1 -0
- package/lib/drift/base/details/user/index.d.ts +4 -0
- package/lib/drift/base/details/user/index.js +21 -0
- package/lib/drift/base/details/user/index.js.map +1 -0
- package/lib/drift/base/details/user/marginInfo.d.ts +29 -0
- package/lib/drift/base/details/user/marginInfo.js +49 -0
- package/lib/drift/base/details/user/marginInfo.js.map +1 -0
- package/lib/drift/base/details/user/orders.d.ts +3 -0
- package/lib/drift/base/details/user/orders.js +11 -0
- package/lib/drift/base/details/user/orders.js.map +1 -0
- package/lib/drift/base/details/user/positions.d.ts +70 -0
- package/lib/drift/base/details/user/positions.js +146 -0
- package/lib/drift/base/details/user/positions.js.map +1 -0
- package/lib/drift/cli.d.ts +25 -0
- package/lib/drift/cli.js +900 -0
- package/lib/drift/cli.js.map +1 -0
- package/lib/drift/constants/apiUrls.d.ts +27 -0
- package/lib/drift/constants/apiUrls.js +31 -0
- package/lib/drift/constants/apiUrls.js.map +1 -0
- package/lib/drift/example.d.ts +19 -0
- package/lib/drift/example.js +249 -0
- package/lib/drift/example.js.map +1 -0
- package/lib/drift/index.d.ts +3 -0
- package/lib/drift/index.js +20 -0
- package/lib/drift/index.js.map +1 -0
- package/lib/drift/utils/auctionParamsResponseMapper.d.ts +45 -0
- package/lib/drift/utils/auctionParamsResponseMapper.js +148 -0
- package/lib/drift/utils/auctionParamsResponseMapper.js.map +1 -0
- package/lib/drift/utils/funding.d.ts +2 -0
- package/lib/drift/utils/funding.js +9 -0
- package/lib/drift/utils/funding.js.map +1 -0
- package/lib/drift/utils/index.d.ts +3 -0
- package/lib/drift/utils/index.js +23 -0
- package/lib/drift/utils/index.js.map +1 -0
- package/lib/drift/utils/orderParams.d.ts +48 -0
- package/lib/drift/utils/orderParams.js +140 -0
- package/lib/drift/utils/orderParams.js.map +1 -0
- package/lib/index.d.ts +45 -0
- package/lib/index.js +68 -0
- package/lib/index.js.map +1 -0
- package/lib/serializableTypes.d.ts +961 -0
- package/lib/serializableTypes.js +3887 -0
- package/lib/serializableTypes.js.map +1 -0
- package/lib/types/MarketId.d.ts +26 -0
- package/lib/types/MarketId.js +64 -0
- package/lib/types/MarketId.js.map +1 -0
- package/lib/types/Superstake.d.ts +7 -0
- package/lib/types/Superstake.js +3 -0
- package/lib/types/Superstake.js.map +1 -0
- package/lib/types/UIEnv.d.ts +26 -0
- package/lib/types/UIEnv.js +49 -0
- package/lib/types/UIEnv.js.map +1 -0
- package/lib/types/UIMarket.d.ts +94 -0
- package/lib/types/UIMarket.js +224 -0
- package/lib/types/UIMarket.js.map +1 -0
- package/lib/types/candles.d.ts +4 -0
- package/lib/types/candles.js +9 -0
- package/lib/types/candles.js.map +1 -0
- package/lib/types/dataServer.d.ts +53 -0
- package/lib/types/dataServer.js +3 -0
- package/lib/types/dataServer.js.map +1 -0
- package/lib/types/historyServer.d.ts +38 -0
- package/lib/types/historyServer.js +11 -0
- package/lib/types/historyServer.js.map +1 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.js +29 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/leaderboard.d.ts +80 -0
- package/lib/types/leaderboard.js +11 -0
- package/lib/types/leaderboard.js.map +1 -0
- package/lib/types/remote-configs.d.ts +61 -0
- package/lib/types/remote-configs.js +3 -0
- package/lib/types/remote-configs.js.map +1 -0
- package/lib/types/trade.d.ts +18 -0
- package/lib/types/trade.js +3 -0
- package/lib/types/trade.js.map +1 -0
- package/lib/types/user.d.ts +40 -0
- package/lib/types/user.js +3 -0
- package/lib/types/user.js.map +1 -0
- package/lib/types/utility.d.ts +15 -0
- package/lib/types/utility.js +3 -0
- package/lib/types/utility.js.map +1 -0
- package/lib/utils/CircularBuffers/CircularBuffer.d.ts +22 -0
- package/lib/utils/CircularBuffers/CircularBuffer.js +73 -0
- package/lib/utils/CircularBuffers/CircularBuffer.js.map +1 -0
- package/lib/utils/CircularBuffers/UniqueCircularBuffer.d.ts +19 -0
- package/lib/utils/CircularBuffers/UniqueCircularBuffer.js +78 -0
- package/lib/utils/CircularBuffers/UniqueCircularBuffer.js.map +1 -0
- package/lib/utils/CircularBuffers/index.d.ts +2 -0
- package/lib/utils/CircularBuffers/index.js +19 -0
- package/lib/utils/CircularBuffers/index.js.map +1 -0
- package/lib/utils/MultiplexWebSocket.d.ts +95 -0
- package/lib/utils/MultiplexWebSocket.js +416 -0
- package/lib/utils/MultiplexWebSocket.js.map +1 -0
- package/lib/utils/NumLib.d.ts +106 -0
- package/lib/utils/NumLib.js +300 -0
- package/lib/utils/NumLib.js.map +1 -0
- package/lib/utils/SharedInterval.d.ts +21 -0
- package/lib/utils/SharedInterval.js +47 -0
- package/lib/utils/SharedInterval.js.map +1 -0
- package/lib/utils/SlotBasedResultValidator.d.ts +9 -0
- package/lib/utils/SlotBasedResultValidator.js +27 -0
- package/lib/utils/SlotBasedResultValidator.js.map +1 -0
- package/lib/utils/Stopwatch.d.ts +15 -0
- package/lib/utils/Stopwatch.js +31 -0
- package/lib/utils/Stopwatch.js.map +1 -0
- package/lib/utils/StrictEventEmitter.d.ts +15 -0
- package/lib/utils/StrictEventEmitter.js +55 -0
- package/lib/utils/StrictEventEmitter.js.map +1 -0
- package/lib/utils/WalletConnectionState.d.ts +31 -0
- package/lib/utils/WalletConnectionState.js +83 -0
- package/lib/utils/WalletConnectionState.js.map +1 -0
- package/lib/utils/assert.d.ts +1 -0
- package/lib/utils/assert.js +10 -0
- package/lib/utils/assert.js.map +1 -0
- package/lib/utils/candles/Candle.d.ts +94 -0
- package/lib/utils/candles/Candle.js +580 -0
- package/lib/utils/candles/Candle.js.map +1 -0
- package/lib/utils/candles/types.d.ts +8 -0
- package/lib/utils/candles/types.js +3 -0
- package/lib/utils/candles/types.js.map +1 -0
- package/lib/utils/dlob-server/DlobServerWebsocketUtils.d.ts +57 -0
- package/lib/utils/dlob-server/DlobServerWebsocketUtils.js +137 -0
- package/lib/utils/dlob-server/DlobServerWebsocketUtils.js.map +1 -0
- package/lib/utils/driftEvents.d.ts +10 -0
- package/lib/utils/driftEvents.js +123 -0
- package/lib/utils/driftEvents.js.map +1 -0
- package/lib/utils/equalityChecks.d.ts +12 -0
- package/lib/utils/equalityChecks.js +71 -0
- package/lib/utils/equalityChecks.js.map +1 -0
- package/lib/utils/featureFlags.d.ts +3 -0
- package/lib/utils/featureFlags.js +7 -0
- package/lib/utils/featureFlags.js.map +1 -0
- package/lib/utils/geoblock/index.d.ts +4 -0
- package/lib/utils/geoblock/index.js +20 -0
- package/lib/utils/geoblock/index.js.map +1 -0
- package/lib/utils/index.d.ts +181 -0
- package/lib/utils/index.js +608 -0
- package/lib/utils/index.js.map +1 -0
- package/lib/utils/insuranceFund.d.ts +15 -0
- package/lib/utils/insuranceFund.js +84 -0
- package/lib/utils/insuranceFund.js.map +1 -0
- package/lib/utils/logger.d.ts +5 -0
- package/lib/utils/logger.js +53 -0
- package/lib/utils/logger.js.map +1 -0
- package/lib/utils/math.d.ts +10 -0
- package/lib/utils/math.js +89 -0
- package/lib/utils/math.js.map +1 -0
- package/lib/utils/orderbook/index.d.ts +65 -0
- package/lib/utils/orderbook/index.js +80 -0
- package/lib/utils/orderbook/index.js.map +1 -0
- package/lib/utils/pollingSequenceGuard.d.ts +9 -0
- package/lib/utils/pollingSequenceGuard.js +24 -0
- package/lib/utils/pollingSequenceGuard.js.map +1 -0
- package/lib/utils/priority-fees/PriorityFeeCalculator.d.ts +24 -0
- package/lib/utils/priority-fees/PriorityFeeCalculator.js +53 -0
- package/lib/utils/priority-fees/PriorityFeeCalculator.js.map +1 -0
- package/lib/utils/priority-fees/PriorityFeeStrategies.d.ts +5 -0
- package/lib/utils/priority-fees/PriorityFeeStrategies.js +43 -0
- package/lib/utils/priority-fees/PriorityFeeStrategies.js.map +1 -0
- package/lib/utils/priority-fees/index.d.ts +2 -0
- package/lib/utils/priority-fees/index.js +19 -0
- package/lib/utils/priority-fees/index.js.map +1 -0
- package/lib/utils/priorityFees.d.ts +14 -0
- package/lib/utils/priorityFees.js +68 -0
- package/lib/utils/priorityFees.js.map +1 -0
- package/lib/utils/rpcLatency.d.ts +7 -0
- package/lib/utils/rpcLatency.js +49 -0
- package/lib/utils/rpcLatency.js.map +1 -0
- package/lib/utils/rxjs.d.ts +11 -0
- package/lib/utils/rxjs.js +24 -0
- package/lib/utils/rxjs.js.map +1 -0
- package/lib/utils/s3Buckets.d.ts +43 -0
- package/lib/utils/s3Buckets.js +108 -0
- package/lib/utils/s3Buckets.js.map +1 -0
- package/lib/utils/superstake.d.ts +86 -0
- package/lib/utils/superstake.js +224 -0
- package/lib/utils/superstake.js.map +1 -0
- package/lib/utils/token.d.ts +16 -0
- package/lib/utils/token.js +44 -0
- package/lib/utils/token.js.map +1 -0
- package/package.json +87 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import { DriftClient, DriftClientConfig, DriftEnv, IWallet, PerpMarketConfig, QuoteResponse, SpotMarketConfig, SwapMode, User } from '@drift-labs/sdk';
|
|
2
|
+
import { PublicKey, TransactionSignature } from '@solana/web3.js';
|
|
3
|
+
import { MarketId } from '../../../../types';
|
|
4
|
+
import { PollingDlob } from '../../data/PollingDlob';
|
|
5
|
+
import { MarkPriceLookup } from '../../stores/MarkPriceCache';
|
|
6
|
+
import { OraclePriceLookup } from '../../stores/OraclePriceCache';
|
|
7
|
+
import { DriftL2OrderbookManager } from './DriftL2OrderbookManager';
|
|
8
|
+
import { Subscription } from 'rxjs';
|
|
9
|
+
import { EnhancedAccountData, UserAccountLookup } from '../../stores/UserAccountCache';
|
|
10
|
+
import { PriorityFeeSubscriberConfig } from '@drift-labs/sdk';
|
|
11
|
+
import { CreateUserAndDepositParams, DepositParams, WithdrawParams, PerpOrderParams, SwapParams, SettleAccountPnlParams, CancelOrdersParams } from './DriftOperations/types';
|
|
12
|
+
import { L2WithOracleAndMarketData } from '../../../../utils/orderbook';
|
|
13
|
+
import { SwiftOrderResult } from '../../../base/actions/trade/openPerpOrder/openSwiftOrder';
|
|
14
|
+
import { OrderbookGrouping } from '../../../../utils/dlob-server/DlobServerWebsocketUtils';
|
|
15
|
+
export interface AuthorityDriftConfig {
|
|
16
|
+
solanaRpcEndpoint: string;
|
|
17
|
+
driftEnv: DriftEnv;
|
|
18
|
+
wallet?: IWallet;
|
|
19
|
+
driftDlobServerHttpUrl?: string;
|
|
20
|
+
tradableMarkets?: MarketId[];
|
|
21
|
+
selectedTradeMarket?: MarketId;
|
|
22
|
+
additionalDriftClientConfig?: Partial<Omit<DriftClientConfig, 'env'>>;
|
|
23
|
+
priorityFeeSubscriberConfig?: Partial<PriorityFeeSubscriberConfig>;
|
|
24
|
+
orderbookConfig?: {
|
|
25
|
+
dlobWebSocketUrl?: string;
|
|
26
|
+
orderbookGrouping?: OrderbookGrouping;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A Drift client that is used to subscribe to all accounts for a given authority.
|
|
31
|
+
*
|
|
32
|
+
* This is useful for applications that want to subscribe to all user accounts for a given authority,
|
|
33
|
+
* such as a UI to trade on Drift or a wallet application that allows trading on Drift.
|
|
34
|
+
*/
|
|
35
|
+
export declare class AuthorityDrift {
|
|
36
|
+
/**
|
|
37
|
+
* Handles all Drift program interactions e.g. trading, read account details, etc.
|
|
38
|
+
*/
|
|
39
|
+
private _driftClient;
|
|
40
|
+
/**
|
|
41
|
+
* Handles bulk account loading from the RPC.
|
|
42
|
+
*/
|
|
43
|
+
private accountLoader;
|
|
44
|
+
/**
|
|
45
|
+
* Handles polling the DLOB server for mark price and oracle price data for markets.
|
|
46
|
+
* It is also the fallback source for orderbook data, if the websocket DLOB subscriber is unavailable.
|
|
47
|
+
*/
|
|
48
|
+
private _pollingDlob;
|
|
49
|
+
/**
|
|
50
|
+
* Subscription to the polling DLOB data.
|
|
51
|
+
*/
|
|
52
|
+
private pollingDlobSubscription;
|
|
53
|
+
/**
|
|
54
|
+
* Subscription to the orderbook data.
|
|
55
|
+
*/
|
|
56
|
+
private orderbookSubscription;
|
|
57
|
+
/**
|
|
58
|
+
* Handles all trading operations including deposits, withdrawals, and position management.
|
|
59
|
+
*/
|
|
60
|
+
private driftOperations;
|
|
61
|
+
/**
|
|
62
|
+
* Manages all subscription operations including user accounts, market subscriptions, and polling optimization.
|
|
63
|
+
*/
|
|
64
|
+
private subscriptionManager;
|
|
65
|
+
/**
|
|
66
|
+
* Stores the fetched mark prices for all tradable markets.
|
|
67
|
+
* Mark price sources includes:
|
|
68
|
+
* - Websocket DLOB subscriber (active market, derived when fetching orderbook data)
|
|
69
|
+
* - Polling DLOB server (all non-active markets)
|
|
70
|
+
*/
|
|
71
|
+
private _markPriceCache;
|
|
72
|
+
/**
|
|
73
|
+
* Stores the fetched oracle prices for all tradable markets.
|
|
74
|
+
* Oracle price sources includes:
|
|
75
|
+
* - DriftClient oracle account subscriptions
|
|
76
|
+
* - Polling DLOB server (all non-active markets)
|
|
77
|
+
*/
|
|
78
|
+
private _oraclePriceCache;
|
|
79
|
+
/**
|
|
80
|
+
* Stores the fetched user account data for all user accounts.
|
|
81
|
+
*/
|
|
82
|
+
private _userAccountCache;
|
|
83
|
+
/**
|
|
84
|
+
* Manages real-time orderbook subscriptions via websocket.
|
|
85
|
+
*/
|
|
86
|
+
private _orderbookManager;
|
|
87
|
+
/**
|
|
88
|
+
* Handles priority fee tracking and calculation for optimized transaction costs.
|
|
89
|
+
*/
|
|
90
|
+
private priorityFeeSubscriber;
|
|
91
|
+
/**
|
|
92
|
+
* Stores whether the user is geographically blocked from using the service.
|
|
93
|
+
* This is checked during subscription and cached for decorator use.
|
|
94
|
+
*/
|
|
95
|
+
protected _isGeoBlocked: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* The selected trade market to use for the drift client. This is used to subscribe to the market account,
|
|
98
|
+
* oracle data and mark price more frequently compared to the other markets.
|
|
99
|
+
*
|
|
100
|
+
* Example usage:
|
|
101
|
+
* - When the UI wants to display the orderbook of this market.
|
|
102
|
+
* - When the user is interacting with the trade form to trade on this market.
|
|
103
|
+
*/
|
|
104
|
+
private selectedTradeMarket;
|
|
105
|
+
/**
|
|
106
|
+
* The markets that are tradable through this client. This affects oracle price, mark price and market account subscriptions.
|
|
107
|
+
*/
|
|
108
|
+
private _tradableMarkets;
|
|
109
|
+
private _spotMarketConfigs;
|
|
110
|
+
private _perpMarketConfigs;
|
|
111
|
+
/**
|
|
112
|
+
* The public endpoints that can be used to retrieve Drift data / interact with the Drift program.
|
|
113
|
+
*/
|
|
114
|
+
private _driftEndpoints;
|
|
115
|
+
/**
|
|
116
|
+
* @param solanaRpcEndpoint - The Solana RPC endpoint to use for reading RPC data.
|
|
117
|
+
* @param driftEnv - The drift environment to use for the drift client.
|
|
118
|
+
* @param authority - The authority (wallet) whose user accounts to subscribe to.
|
|
119
|
+
* @param tradableMarkets - The markets that are tradable through this client.
|
|
120
|
+
* @param selectedTradeMarket - The active trade market to use for the drift client. This is used to subscribe to the market account, oracle data and mark price more frequently compared to the other markets.
|
|
121
|
+
* @param additionalDriftClientConfig - Additional DriftClient config to use for the DriftClient.
|
|
122
|
+
*/
|
|
123
|
+
constructor(config: AuthorityDriftConfig);
|
|
124
|
+
get driftClient(): DriftClient;
|
|
125
|
+
get authority(): PublicKey;
|
|
126
|
+
get pollingDlob(): PollingDlob;
|
|
127
|
+
get oraclePriceCache(): OraclePriceLookup;
|
|
128
|
+
get markPriceCache(): MarkPriceLookup;
|
|
129
|
+
get userAccountCache(): UserAccountLookup;
|
|
130
|
+
get orderbookCache(): L2WithOracleAndMarketData | null;
|
|
131
|
+
get orderbookManager(): DriftL2OrderbookManager;
|
|
132
|
+
get tradableMarkets(): MarketId[];
|
|
133
|
+
/**
|
|
134
|
+
* Gets the current geoblock status of the user.
|
|
135
|
+
*
|
|
136
|
+
* @returns True if the user is geographically blocked, false otherwise
|
|
137
|
+
*/
|
|
138
|
+
get isGeoBlocked(): boolean;
|
|
139
|
+
/**
|
|
140
|
+
* The public endpoints that can be used to retrieve Drift data / interact with the Drift program.
|
|
141
|
+
*/
|
|
142
|
+
get driftEndpoints(): {
|
|
143
|
+
dlobServerHttpUrl: string;
|
|
144
|
+
swiftServerUrl: string;
|
|
145
|
+
};
|
|
146
|
+
private set tradableMarkets(value);
|
|
147
|
+
get spotMarketConfigs(): SpotMarketConfig[];
|
|
148
|
+
get perpMarketConfigs(): PerpMarketConfig[];
|
|
149
|
+
private initializeStores;
|
|
150
|
+
private initializeOrderbookManager;
|
|
151
|
+
private initializePollingDlob;
|
|
152
|
+
private initializePriorityFeeSubscriber;
|
|
153
|
+
private setupDriftClient;
|
|
154
|
+
private setupOrderbookManager;
|
|
155
|
+
private setupPollingDlob;
|
|
156
|
+
private initializeManagers;
|
|
157
|
+
private unsubscribeFromPollingDlob;
|
|
158
|
+
private unsubscribeFromOrderbook;
|
|
159
|
+
subscribe(): Promise<void>;
|
|
160
|
+
unsubscribe(): Promise<void>;
|
|
161
|
+
onOraclePricesUpdate(callback: (oraclePrice: OraclePriceLookup) => void): Subscription;
|
|
162
|
+
onMarkPricesUpdate(callback: (markPrice: MarkPriceLookup) => void): Subscription;
|
|
163
|
+
onUserAccountUpdate(callback: (userAccount: EnhancedAccountData) => void): Subscription;
|
|
164
|
+
onOrderbookUpdate(callback: (orderbook: L2WithOracleAndMarketData) => void): Subscription;
|
|
165
|
+
/**
|
|
166
|
+
* Updates the authority (wallet) for the drift client and reestablishes subscriptions.
|
|
167
|
+
*
|
|
168
|
+
* @param wallet - The new wallet to use as authority
|
|
169
|
+
* @param activeSubAccountId - Optional subaccount ID to switch to after wallet update
|
|
170
|
+
*/
|
|
171
|
+
updateAuthority(wallet: IWallet, activeSubAccountId?: number): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Updates the selected trade market and optimizes subscription polling.
|
|
174
|
+
*
|
|
175
|
+
* @param newSelectedTradeMarket - The new market to prioritize for trading
|
|
176
|
+
*/
|
|
177
|
+
updateSelectedTradeMarket(newSelectedTradeMarket: MarketId | null): void;
|
|
178
|
+
/**
|
|
179
|
+
* Creates a new user account and deposits initial collateral.
|
|
180
|
+
*
|
|
181
|
+
* @param params - Parameters for creating user and depositing collateral
|
|
182
|
+
* @returns Promise resolving to transaction signature and user account public key
|
|
183
|
+
*/
|
|
184
|
+
createUserAndDeposit(params: CreateUserAndDepositParams): Promise<{
|
|
185
|
+
txSig: TransactionSignature;
|
|
186
|
+
user: User;
|
|
187
|
+
}>;
|
|
188
|
+
/**
|
|
189
|
+
* Deposits collateral into a user's spot market position.
|
|
190
|
+
*
|
|
191
|
+
* @param params - Parameters for the deposit operation
|
|
192
|
+
* @returns Promise resolving to the transaction signature
|
|
193
|
+
*/
|
|
194
|
+
deposit(params: DepositParams): Promise<TransactionSignature>;
|
|
195
|
+
/**
|
|
196
|
+
* Withdraws collateral from a user's spot market position.
|
|
197
|
+
*
|
|
198
|
+
* @param params - Parameters for the withdrawal operation
|
|
199
|
+
* @returns Promise resolving to the transaction signature
|
|
200
|
+
*/
|
|
201
|
+
withdraw(params: WithdrawParams): Promise<TransactionSignature>;
|
|
202
|
+
/**
|
|
203
|
+
* Opens a perpetual market order.
|
|
204
|
+
*
|
|
205
|
+
* @param params - Parameters for the perp order
|
|
206
|
+
* @returns Promise resolving to the transaction signature
|
|
207
|
+
*/
|
|
208
|
+
openPerpOrder(params: PerpOrderParams): Promise<TransactionSignature | SwiftOrderResult>;
|
|
209
|
+
/**
|
|
210
|
+
* Executes a swap between two spot markets.
|
|
211
|
+
*
|
|
212
|
+
* @param params - Parameters for the swap operation
|
|
213
|
+
* @returns Promise resolving to the transaction signature
|
|
214
|
+
*/
|
|
215
|
+
swap(params: SwapParams): Promise<TransactionSignature>;
|
|
216
|
+
getSwapQuote(params: Omit<SwapParams, 'jupiterQuote'> & {
|
|
217
|
+
slippageBps?: number;
|
|
218
|
+
swapMode?: SwapMode;
|
|
219
|
+
onlyDirectRoutes?: boolean;
|
|
220
|
+
}): Promise<QuoteResponse>;
|
|
221
|
+
/**
|
|
222
|
+
* Settles profit and loss for a perpetual position.
|
|
223
|
+
*
|
|
224
|
+
* @param params - Parameters for the settle PnL operation
|
|
225
|
+
* @returns Promise resolving to the transaction signature
|
|
226
|
+
*/
|
|
227
|
+
settleAccountPnl(params: SettleAccountPnlParams): Promise<TransactionSignature>;
|
|
228
|
+
/**
|
|
229
|
+
* Deletes a user account from the Drift protocol.
|
|
230
|
+
*
|
|
231
|
+
* @param subAccountId - The ID of the sub-account to delete
|
|
232
|
+
* @returns Promise resolving to the transaction signature of the deletion
|
|
233
|
+
*/
|
|
234
|
+
deleteUser(subAccountId: number): Promise<TransactionSignature>;
|
|
235
|
+
/**
|
|
236
|
+
* Cancels a list of open orders.
|
|
237
|
+
*
|
|
238
|
+
* @param params - See `CancelOrdersParams`
|
|
239
|
+
* @returns Promise resolving to the transaction signature of the cancellation
|
|
240
|
+
*/
|
|
241
|
+
cancelOrders(params: CancelOrdersParams): Promise<TransactionSignature>;
|
|
242
|
+
}
|