UNPKG

orca-clmm-agent

Version:

Orca Whirlpool clmm library for automated position management

23 lines (22 loc) 896 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getOkxSwapInstruction = void 0; /** * Requests a swap instruction for Solana tokens from the OKX DEX aggregator API. * * API docs: https://web3.okx.com/de/build/dev-docs/dex-api/dex-solana-swap-instruction */ const getOkxSwapInstruction = async (params) => { // TODO: requires OKX API auth const url = new URL("https://web3.okx.com/api/v5/dex/aggregator/swap-instruction"); Object.entries(params).forEach(([key, value]) => { if (value !== undefined) url.searchParams.append(key, String(value)); }); const resp = await fetch(url.toString(), { method: "GET" }); if (!resp.ok) { throw new Error(`[getOkxSwapInstruction] HTTP ${resp.status} ${resp.statusText}`); } return (await resp.json()); }; exports.getOkxSwapInstruction = getOkxSwapInstruction;