diff --git a/packages/sol-swap/src/examples/jupiter/getQuote.ts b/packages/sol-swap/src/examples/jupiter/getQuote.ts index ad8857b..b5a0d93 100644 --- a/packages/sol-swap/src/examples/jupiter/getQuote.ts +++ b/packages/sol-swap/src/examples/jupiter/getQuote.ts @@ -1,7 +1,16 @@ +import getJupiterQuote from '@/lib/jupiter/getJupiterQuote' + const getQuote = async () => { const inputMint = 'inputMint' const outputMint = 'outputMint' const inputAmountLamport = 100 const platformFeeBps = 0 const swapMode = 'ExactIn' + const quote = await getJupiterQuote( + inputMint, + outputMint, + inputAmountLamport, + platformFeeBps, + swapMode, + ) } diff --git a/packages/sol-swap/src/lib/jupiter/jupiterSwap.ts b/packages/sol-swap/src/lib/jupiter/jupiterSwap.ts index bcf6c55..167a9fc 100644 --- a/packages/sol-swap/src/lib/jupiter/jupiterSwap.ts +++ b/packages/sol-swap/src/lib/jupiter/jupiterSwap.ts @@ -1,30 +1,16 @@ import { readFile } from 'fs/promises' import { Connection, Keypair, VersionedTransaction } from '@solana/web3.js' -import getJupiterQuote, { JupiterSwapMode } from '@/lib/jupiter/getJupiterQuote' import postJupiterSwap from '@/lib/jupiter/postJupiterSwap' import 'dotenv/config' +import type { QuoteResponse } from '@jup-ag/api' const SOLANA_RPC_URL = process.env.SOLANA_RPC_URL || 'http://localhost:8899' const KEY_FILE_PATH = - process.env.KEY_FILE_PATH || '/home/solv/mainnet-validator-keypair.json' + process.env.KEY_FILE_PATH || '~/mainnet-validator-keypair.json' -const jupiterSwap = async ( - inputMint: string, - outputMint: string, - inputAmountLamport: number, - platformFeeBps = 0, - swapMode = 'ExactIn' as JupiterSwapMode, - maxRetries = 3, -) => { +const jupiterSwap = async (quoteResponse: QuoteResponse, maxRetries = 3) => { try { const connection = new Connection(SOLANA_RPC_URL, 'confirmed') - const quoteResponse = await getJupiterQuote( - inputMint, - outputMint, - inputAmountLamport, - platformFeeBps, - swapMode, - ) if (typeof quoteResponse === 'string') { return quoteResponse diff --git a/packages/sol-swap/tests/index.test.ts b/packages/sol-swap/tests/index.test.ts index c8aafd1..84f276d 100644 --- a/packages/sol-swap/tests/index.test.ts +++ b/packages/sol-swap/tests/index.test.ts @@ -1,7 +1,7 @@ // tests/cli.test.ts import { describe, it, expect } from 'vitest' -import { exec } from 'child_process' -import util from 'util' +import { exec } from 'node:child_process' +import util from 'node:util' const execPromise = util.promisify(exec) diff --git a/packages/sol-swap/tsconfig.json b/packages/sol-swap/tsconfig.json index be3d5e4..2bbe8ec 100755 --- a/packages/sol-swap/tsconfig.json +++ b/packages/sol-swap/tsconfig.json @@ -24,6 +24,6 @@ } }, "compileOnSave": true, - "include": ["src/lib", "src/index.ts"], - "exclude": ["node_modules", "**/*.spec.ts", "dist", "src/examples"] + "include": ["src/lib", "src/**/*.ts"], + "exclude": ["node_modules", "**/*.spec.ts", "dist"] } diff --git a/packages/sol-swap/tsup.config.ts b/packages/sol-swap/tsup.config.ts index de86a77..302f08f 100644 --- a/packages/sol-swap/tsup.config.ts +++ b/packages/sol-swap/tsup.config.ts @@ -9,6 +9,5 @@ export default defineConfig({ sourcemap: true, clean: true, dts: true, - external: [ - ], + external: [], })