-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolana.test.ts
34 lines (30 loc) · 993 Bytes
/
solana.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { expect, test, describe } from "bun:test";
import { createSolanaService, raydiumSwap } from "./src/solana";
import dotenv from "dotenv";
dotenv.config();
describe("test_raydium_swap", async () => {
test("test_raydium_swap", async () => {
const config = {
rpcUrl: process.env.SOLANA_RPC_URL!,
privateKey: process.env.SOLANA_PRIVATE_KEY!,
jitoEnabled: false,
tipAmount: 0,
feeAddress: process.env.FEE_ADDRESS!,
feePercentage: parseFloat(process.env.FEE_PERCENTAGE!),
};
const payload = {
inputMint: "So11111111111111111111111111111111111111112",
outputMint: "AkukwSXUTkDSeh2c1ypyvN4unzyr4xb2T4SmKkix6bT8",
amount: 0.0001,
maxSlippage: 10,
};
try {
const txHash = await raydiumSwap(config, payload);
console.log("Swap transaction hash:", txHash);
expect(txHash).toBeTruthy();
} catch (error) {
console.error("Test failed:", error);
throw error;
}
}, 50000);
});