Skip to content

Commit b656c90

Browse files
committed
update jupiterSwap
1 parent 107df69 commit b656c90

File tree

5 files changed

+17
-23
lines changed

5 files changed

+17
-23
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
1+
import getJupiterQuote from '@/lib/jupiter/getJupiterQuote'
2+
13
const getQuote = async () => {
24
const inputMint = 'inputMint'
35
const outputMint = 'outputMint'
46
const inputAmountLamport = 100
57
const platformFeeBps = 0
68
const swapMode = 'ExactIn'
9+
const quote = await getJupiterQuote(
10+
inputMint,
11+
outputMint,
12+
inputAmountLamport,
13+
platformFeeBps,
14+
swapMode,
15+
)
716
}

packages/sol-swap/src/lib/jupiter/jupiterSwap.ts

+3-17
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,16 @@
11
import { readFile } from 'fs/promises'
22
import { Connection, Keypair, VersionedTransaction } from '@solana/web3.js'
3-
import getJupiterQuote, { JupiterSwapMode } from '@/lib/jupiter/getJupiterQuote'
43
import postJupiterSwap from '@/lib/jupiter/postJupiterSwap'
54
import 'dotenv/config'
5+
import type { QuoteResponse } from '@jup-ag/api'
66

77
const SOLANA_RPC_URL = process.env.SOLANA_RPC_URL || 'http://localhost:8899'
88
const KEY_FILE_PATH =
9-
process.env.KEY_FILE_PATH || '/home/solv/mainnet-validator-keypair.json'
9+
process.env.KEY_FILE_PATH || '~/mainnet-validator-keypair.json'
1010

11-
const jupiterSwap = async (
12-
inputMint: string,
13-
outputMint: string,
14-
inputAmountLamport: number,
15-
platformFeeBps = 0,
16-
swapMode = 'ExactIn' as JupiterSwapMode,
17-
maxRetries = 3,
18-
) => {
11+
const jupiterSwap = async (quoteResponse: QuoteResponse, maxRetries = 3) => {
1912
try {
2013
const connection = new Connection(SOLANA_RPC_URL, 'confirmed')
21-
const quoteResponse = await getJupiterQuote(
22-
inputMint,
23-
outputMint,
24-
inputAmountLamport,
25-
platformFeeBps,
26-
swapMode,
27-
)
2814

2915
if (typeof quoteResponse === 'string') {
3016
return quoteResponse

packages/sol-swap/tests/index.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// tests/cli.test.ts
22
import { describe, it, expect } from 'vitest'
3-
import { exec } from 'child_process'
4-
import util from 'util'
3+
import { exec } from 'node:child_process'
4+
import util from 'node:util'
55

66
const execPromise = util.promisify(exec)
77

packages/sol-swap/tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@
2424
}
2525
},
2626
"compileOnSave": true,
27-
"include": ["src/lib", "src/index.ts"],
28-
"exclude": ["node_modules", "**/*.spec.ts", "dist", "src/examples"]
27+
"include": ["src/lib", "src/**/*.ts"],
28+
"exclude": ["node_modules", "**/*.spec.ts", "dist"]
2929
}

packages/sol-swap/tsup.config.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ export default defineConfig({
99
sourcemap: true,
1010
clean: true,
1111
dts: true,
12-
external: [
13-
],
12+
external: [],
1413
})

0 commit comments

Comments
 (0)