UNPKG

@okx-dex/okx-dex-sdk

Version:
29 lines (28 loc) 899 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); // example.ts or test.ts const index_1 = require("../../index"); require("dotenv/config"); const client = new index_1.OKXDexClient({ apiKey: process.env.OKX_API_KEY, secretKey: process.env.OKX_SECRET_KEY, apiPassphrase: process.env.OKX_API_PASSPHRASE, projectId: process.env.OKX_PROJECT_ID }); async function main() { try { // Get a quote const quote = await client.dex.getQuote({ chainId: '501', fromTokenAddress: 'So11111111111111111111111111111111111111112', toTokenAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', amount: '1000000000', slippage: '0.1' }); console.log('Swap Quote:', JSON.stringify(quote, null, 2)); } catch (error) { console.error('Error:', error); } } main();