UNPKG

@renegade-fi/node

Version:
164 lines 5.07 kB
import { assembleExternalQuote, assembleMalleableQuote, createAuthConfig, createConfig, getExternalMatchBundle, getExternalMatchQuote, getSDKConfig, getSupportedTokens, getTokenPrices, } from "@renegade-fi/core"; import { CHAIN_IDS } from "@renegade-fi/core/constants"; import * as rustUtils from "../../../renegade-utils/index.js"; /** * A client for interacting with a Renegade relayer. * * Authentication is handled by providing an API key and secret. */ export class ExternalMatchClient { /** * @internal */ constructor(params) { // TODO: Delete once we migrate to v2 Object.defineProperty(this, "config", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "relayerConfig", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "configv2", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "apiKey", { enumerable: true, configurable: true, writable: true, value: void 0 }); Object.defineProperty(this, "apiSecret", { enumerable: true, configurable: true, writable: true, value: void 0 }); const defaultConfig = getSDKConfig(params.chainId); const configv2 = params.overrides ? { ...defaultConfig, ...params.overrides } : defaultConfig; this.relayerConfig = createConfig({ darkPoolAddress: configv2.darkpoolAddress, priceReporterUrl: configv2.priceReporterUrl, relayerUrl: configv2.relayerUrl, chainId: configv2.id, utils: rustUtils, }); this.configv2 = configv2; this.apiKey = params.apiKey; this.apiSecret = params.apiSecret; this.config = createAuthConfig({ apiKey: params.apiKey, apiSecret: params.apiSecret, authServerUrl: configv2.authServerUrl, utils: rustUtils, }); } /** * Create a new ExternalMatchClient for a given chain. * * @param params.apiKey your API key * @param params.apiSecret your API secret * @param params.chainId the chain ID * @param params.overrides any SDKConfig field can be passed directly as an override */ static new({ apiKey, apiSecret, chainId, overrides, }) { return new ExternalMatchClient({ rustUtils, chainId, apiKey, apiSecret, overrides, }); } /** * Create a new ExternalMatchClient for Arbitrum One. * * @param params.apiKey your API key * @param params.apiSecret your API secret */ static newArbitrumOneClient({ apiKey, apiSecret, }) { return new ExternalMatchClient({ rustUtils, chainId: CHAIN_IDS.ArbitrumOne, apiKey, apiSecret, }); } /** * Create a new ExternalMatchClient for Arbitrum Sepolia. * * @param params.apiKey your API key * @param params.apiSecret your API secret */ static newArbitrumSepoliaClient({ apiKey, apiSecret, }) { return new ExternalMatchClient({ rustUtils, chainId: CHAIN_IDS.ArbitrumSepolia, apiKey, apiSecret, }); } // -- Direct Match -- // /** * @deprecated use ExternalMatchClient.getQuote and ExternalMatchClient.assembleQuote instead */ async getExternalMatch(params) { return getExternalMatchBundle(this.getConfig(), params); } // -- Quote + Assmeble // /** * Get a quote for an external match */ async getQuote(params) { return getExternalMatchQuote(this.getConfig(), params); } /** * Assemble a quote into a match bundle, ready for settlement */ async assembleQuote(params) { return assembleExternalQuote(this.getConfig(), params); } /** * Assemble a quote into a malleable match bundle, ready for settlement */ async assembleMalleableQuote(params) { return assembleMalleableQuote(this.getConfig(), params); } // -- Token -- // /** * Get the list of supported tokens */ async getSupportedTokens() { return getSupportedTokens(this.getConfig()); } /** * Get the token prices for all supported tokens */ async getTokenPrices() { return getTokenPrices(this.getConfig()); } // -- Private -- /** * Get the config for the auth server */ getConfig() { return this.config; } /** * Get the config for the relayer */ getRelayerConfig() { return this.relayerConfig; } } //# sourceMappingURL=index.js.map