File tree Expand file tree Collapse file tree 5 files changed +125
-13
lines changed Expand file tree Collapse file tree 5 files changed +125
-13
lines changed Original file line number Diff line number Diff line change 1+ RPC_URL = YOUR_RPC_URL
2+ WALLET_PRIVATE_KEY = YOUR_PRIVATE_KEY
Original file line number Diff line number Diff line change 1+ # Logs
2+ logs
3+ * .log
4+ npm-debug.log *
5+ yarn-debug.log *
6+ yarn-error.log *
7+ lerna-debug.log *
8+ .pnpm-debug.log *
9+
10+ # Diagnostic reports (https://nodejs.org/api/report.html)
11+ report. [0-9 ]* . [0-9 ]* . [0-9 ]* . [0-9 ]* .json
12+
13+ # Runtime data
14+ pids
15+ * .pid
16+ * .seed
17+ * .pid.lock
18+
19+ # Directory for instrumented libs generated by jscoverage/JSCover
20+ lib-cov
21+
22+ # Coverage directory used by tools like istanbul
23+ coverage
24+ * .lcov
25+
26+ # nyc test coverage
27+ .nyc_output
28+
29+ # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
30+ .grunt
31+
32+ # Bower dependency directory (https://bower.io/)
33+ bower_components
34+
35+ # node-waf configuration
36+ .lock-wscript
37+
38+ # Compiled binary addons (https://nodejs.org/api/addons.html)
39+ build /Release
40+
41+ # Dependency directories
42+ node_modules /
43+ jspm_packages /
44+
45+ # Snowpack dependency directory (https://snowpack.dev/)
46+ web_modules /
47+
48+ # TypeScript cache
49+ * .tsbuildinfo
50+
51+ # Optional npm cache directory
52+ .npm
53+
54+ # Optional eslint cache
55+ .eslintcache
56+
57+ # Microbundle cache
58+ .rpt2_cache /
59+ .rts2_cache_cjs /
60+ .rts2_cache_es /
61+ .rts2_cache_umd /
62+
63+ # Optional REPL history
64+ .node_repl_history
65+
66+ # Output of 'npm pack'
67+ * .tgz
68+
69+ # Yarn Integrity file
70+ .yarn-integrity
71+
72+ # dotenv environment variables file
73+ .env
74+ .env.test
75+ .env.production
76+
77+ # parcel-bundler cache (https://parceljs.org/)
78+ .cache
79+ .parcel-cache
80+
81+ # Next.js build output
82+ .next
83+ out
84+
85+ # Nuxt.js build / generate output
86+ .nuxt
87+ dist
88+
89+ # Gatsby files
90+ .cache /
91+ # Comment in the public line in if your project uses Gatsby and not Next.js
92+ # https://nextjs.org/blog/next-9-1#public-directory-support
93+ # public
94+
95+ # vuepress build output
96+ .vuepress /dist
97+
98+ # Serverless directories
99+ .serverless /
100+
101+ # FuseBox cache
102+ .fusebox /
103+
104+ # DynamoDB Local files
105+ .dynamodb /
106+
107+ # TernJS port file
108+ .tern-port
109+
110+ # Stores VSCode versions used for testing VSCode extensions
111+ .vscode-test
112+
113+ # yarn v2
114+ .yarn /cache
115+ .yarn /unplugged
116+ .yarn /build-state.yml
117+ .yarn /install-state.gz
118+ .pnp. *
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ const swap = async () => {
1212 */
1313 const raydiumSwap = new RaydiumSwap ( process . env . RPC_URL , process . env . WALLET_PRIVATE_KEY ) ;
1414 console . log ( `Raydium swap initialized` ) ;
15+ console . log ( `Swapping ${ swapConfig . tokenAAmount } of ${ swapConfig . tokenAAddress } for ${ swapConfig . tokenBAddress } ...` )
1516
1617 /**
1718 * Load pool keys from the Raydium API to enable finding pool information.
@@ -32,7 +33,7 @@ const swap = async () => {
3233 swapConfig . tokenBAddress ,
3334 swapConfig . tokenAAmount ,
3435 poolInfo ,
35- swapConfig . maxLamports , // Max amount of lamports
36+ swapConfig . maxLamports ,
3637 swapConfig . useVersionedTransaction ,
3738 swapConfig . direction
3839 ) ;
@@ -49,6 +50,7 @@ const swap = async () => {
4950 : await raydiumSwap . sendLegacyTransaction ( tx as Transaction ) ;
5051
5152 console . log ( `https://solscan.io/tx/${ txid } ` ) ;
53+
5254 } else {
5355 /**
5456 * Simulate the transaction and log the result.
Original file line number Diff line number Diff line change @@ -2,8 +2,8 @@ export const swapConfig = {
22 executeSwap : true , // Send tx when true, simulate tx when false
33 useVersionedTransaction : true ,
44 tokenAAmount : 0.01 , // Swap 0.01 SOL for USDT in this example
5- tokenAAddress : 'So11111111111111111111111111111111111111112' , // Token to swap for the other
6- tokenBAddress : 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' ,
5+ tokenAAddress : 'So11111111111111111111111111111111111111112' , // Token to swap for the other, SOL in this case
6+ tokenBAddress : 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v' , // USDC address
77 LPpoolAddress : '8HoQnePLqPj4M7PUDzfw8e3Ymdwgc7NLGnaTUapubyvu' ,
88 maxLamports : 1000000 , // Max lamports allowed for fees
99 direction : 'in' as 'in' | 'out' , // Swap direction: 'in' or 'out'
You can’t perform that action at this time.
0 commit comments