diff --git a/scripts/dex-router/src/index.ts b/scripts/dex-router/src/index.ts index 11d4f699..738dec91 100644 --- a/scripts/dex-router/src/index.ts +++ b/scripts/dex-router/src/index.ts @@ -25,23 +25,15 @@ import { import * as anchor from "@coral-xyz/anchor"; import * as limo from "@kamino-finance/limo-sdk"; import { - getMintDecimals, getPdaAuthority, OrderStateAndAddress, } from "@kamino-finance/limo-sdk/dist/utils"; -import { - HEALTH_RPC_THRESHOLD, - HEALTH_EXPRESS_RELAY_INTERVAL, - HEALTH_RPC_INTERVAL, - MAX_TX_SIZE, -} from "./const"; -import { checkExpressRelayHealth, checkRpcHealth } from "./utils/health"; +import { MAX_TX_SIZE } from "./const"; const MINUTE_IN_SECS = 60; export class DexRouter { private client: Client; - private mintDecimals: Record = {}; private baseLookupTableAddresses: PublicKey[] = []; private lookupTableAccounts: Record = {}; private connectionSvm: Connection; @@ -129,16 +121,6 @@ export class DexRouter { this.latestChainUpdate[update.chainId] = update; } - async getMintDecimalsCached(mint: PublicKey): Promise { - const mintAddress = mint.toBase58(); - if (this.mintDecimals[mintAddress]) { - return this.mintDecimals[mintAddress]; - } - const decimals = await getMintDecimals(this.connectionSvm, mint); - this.mintDecimals[mintAddress] = decimals; - return decimals; - } - /** * Generates a bid that routes through on-chain liquidity for the provided opportunity * @param opportunity The SVM opportunity to generate a bid for @@ -430,7 +412,6 @@ const argv = yargs(hideBin(process.argv)) description: "API key to authenticate with the express relay server for submitting bids.", type: "string", - demandOption: true, }) .help() .alias("help", "h") @@ -451,13 +432,6 @@ async function run() { argv["lookup-table-addresses"]?.map((address) => new PublicKey(address)), argv["express-relay-server-api-key"] ); - checkRpcHealth(connection, HEALTH_RPC_THRESHOLD, HEALTH_RPC_INTERVAL).catch( - console.error - ); - checkExpressRelayHealth( - argv["endpoint-express-relay"], - HEALTH_EXPRESS_RELAY_INTERVAL - ).catch(console.error); await dexRouter.start(); } diff --git a/scripts/dex-router/src/router/jupiter.ts b/scripts/dex-router/src/router/jupiter.ts index d5862ee8..e44c6b55 100644 --- a/scripts/dex-router/src/router/jupiter.ts +++ b/scripts/dex-router/src/router/jupiter.ts @@ -9,19 +9,16 @@ import { const MAX_SLIPPAGE_BPS = 50; export class JupiterRouter implements Router { - private chainId: string; private executor: PublicKey; private maxAccounts: number; private jupiterClient: DefaultApi; constructor( - chainId: string, executor: PublicKey, maxAccounts: number, basePath: string, apiKey?: string ) { - this.chainId = chainId; this.executor = executor; this.maxAccounts = maxAccounts; if (apiKey) { @@ -41,10 +38,6 @@ export class JupiterRouter implements Router { tokenOut: PublicKey, amountIn: bigint ): Promise { - if (!["mainnet-beta-solana", "development-solana"].includes(this.chainId)) { - throw new Error("Jupiter error: chain id not supported"); - } - const quoteResponse = await this.jupiterClient.quoteGet({ inputMint: tokenIn.toBase58(), outputMint: tokenOut.toBase58(), diff --git a/scripts/dex-router/src/utils/health.ts b/scripts/dex-router/src/utils/health.ts deleted file mode 100644 index 81c77123..00000000 --- a/scripts/dex-router/src/utils/health.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { Connection } from "@solana/web3.js"; - -export async function checkRpcHealth( - connection: Connection, - threshold: number, - interval: number -) { - //eslint-disable-next-line no-constant-condition - while (true) { - try { - const slot = await connection.getSlot("finalized"); - const blockTime = await connection.getBlockTime(slot); - const timeNow = Date.now() / 1000; - if (blockTime === null) { - console.error( - `Health Error (RPC endpoint): unable to poll block time for slot ${slot}` - ); - } else if (blockTime < timeNow - threshold) { - console.error( - `Health Error (RPC endpoint): block time is stale by ${ - timeNow - blockTime - } seconds` - ); - } - } catch (e) { - if (e instanceof Error) { - if (!e.message.includes("Block not available for slot")) { - console.error("Health Error (RPC endpoint), failure to fetch: ", e); - } - } else { - console.error("Health Error (RPC endpoint), failure to fetch: ", e); - } - } - await new Promise((resolve) => setTimeout(resolve, interval * 1000)); - } -} - -export async function checkExpressRelayHealth( - endpoint: string, - interval: number -) { - const urlExpressRelayHealth = new URL("/live", endpoint); - //eslint-disable-next-line no-constant-condition - while (true) { - try { - const responseHealth = await fetch(urlExpressRelayHealth); - if (responseHealth.status !== 200) { - console.error( - "Health Error (Express Relay endpoint): ", - responseHealth - ); - } - } catch (e) { - console.error( - "Health Error (Express Relay endpoint), failure to fetch: ", - e - ); - } - await new Promise((resolve) => setTimeout(resolve, interval * 1000)); - } -}