UNPKG

@renegade-fi/node

Version:
112 lines 3.45 kB
import { createConfig, getSDKConfig } from "@renegade-fi/core"; import { assignOrder, createMatchingPool, destroyMatchingPool, getOpenOrders, getOrderMatchingPool, getOrderMetadata, getWalletMatchableOrderIds, triggerRelayerSnapshot, } from "@renegade-fi/core/actions"; import * as rustUtils from "../../../renegade-utils/index.js"; /** * The client for interacting with the Renegade relayer's admin API with an API key. */ export class AdminRelayerClient { /** * @internal */ constructor(params) { Object.defineProperty(this, "config", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "configv2", { enumerable: true, configurable: true, writable: true, value: void 0 }); const defaultConfig = getSDKConfig(params.chainId); const configv2 = params.overrides ? { ...defaultConfig, ...params.overrides } : defaultConfig; this.configv2 = configv2; this.config = createConfig({ adminKey: params.apiKey, darkPoolAddress: configv2.darkpoolAddress, priceReporterUrl: configv2.priceReporterUrl, relayerUrl: configv2.relayerUrl, chainId: configv2.id, utils: rustUtils, }); } /** * Create a new AdminRelayerClient * * @param params.apiKey your API key * @param params.chainId the chain ID * @param params.overrides any SDKConfig field can be passed directly as an override */ static new({ apiKey, chainId, overrides, }) { return new AdminRelayerClient({ apiKey, chainId, overrides }); } /** * Assign an order to a matching pool * * @param params.orderId the order ID * @param params.matchingPool name of the matching pool */ async assignOrder(params) { return assignOrder(this.config, params); } /** * Create a matching pool * * @param params.matchingPool name of the matching pool */ async createMatchingPool(params) { return createMatchingPool(this.config, params); } /** * Destroy a matching pool * * @param params.matchingPool name of the matching pool */ async destroyMatchingPool(params) { return destroyMatchingPool(this.config, params); } /** * Get open orders managed by the relayer */ async getOpenOrders(params) { return getOpenOrders(this.config, params); } /** * Get the matching pool for an order */ async getOrderMatchingPool(params) { return getOrderMatchingPool(this.config, params); } /** * Get the metadata for an order */ async getOrderMetadata(params) { return getOrderMetadata(this.config, params); } /** * Get the matchable order IDs for a wallet */ async getWalletMatchableOrderIds(params) { return getWalletMatchableOrderIds(this.config, params); } /** * Trigger a relayer raft snapshot */ async triggerSnapshot() { return triggerRelayerSnapshot(this.config); } /** * Get the config * * TODO: Remove once we migrate to the SDK config */ getConfig() { return this.config; } } //# sourceMappingURL=index.js.map