File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,20 @@ Edit the configuration in `src/swapConfig.ts` editing:
7878- The tokens to swap
7979- The liquidity file to pull the pool info from
8080
81+ ``` ts
82+ export const swapConfig = {
83+ executeSwap: false , // Send tx when true, simulate tx when false
84+ useVersionedTransaction: true ,
85+ tokenAAmount: 0.01 , // Swap 0.01 SOL for USDT in this example
86+ tokenAAddress: " So11111111111111111111111111111111111111112" , // Token to swap for the other, SOL in this case
87+ tokenBAddress: " EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" , // USDC address
88+ maxLamports: 1000000 , // Max lamports allowed for fees
89+ direction: " in" as " in" | " out" , // Swap direction: 'in' or 'out'
90+ liquidityFile: " https://api.raydium.io/v2/sdk/liquidity/mainnet.json" ,
91+ maxRetries: 10
92+ };
93+ ```
94+
8195Then run:
8296
8397``` sh
Original file line number Diff line number Diff line change @@ -164,7 +164,7 @@ class RaydiumSwap {
164164 async sendLegacyTransaction ( tx : Transaction ) {
165165 const txid = await this . connection . sendTransaction ( tx , [ this . wallet . payer ] , {
166166 skipPreflight : true ,
167- maxRetries : 2 ,
167+ maxRetries : swapConfig . maxRetries ,
168168 } )
169169
170170 return txid
@@ -179,7 +179,7 @@ class RaydiumSwap {
179179 async sendVersionedTransaction ( tx : VersionedTransaction ) {
180180 const txid = await this . connection . sendTransaction ( tx , {
181181 skipPreflight : true ,
182- maxRetries : 2 ,
182+ maxRetries : swapConfig . maxRetries ,
183183 } )
184184
185185 return txid
Original file line number Diff line number Diff line change 11export const swapConfig = {
22 executeSwap : false , // Send tx when true, simulate tx when false
33 useVersionedTransaction : true ,
4- tokenAAmount : 0.01 , // Swap 0.01 SOL for USDT in this example
4+ tokenAAmount : 0.001 , // Swap 0.01 SOL for USDT in this example
55 tokenAAddress : "So11111111111111111111111111111111111111112" , // Token to swap for the other, SOL in this case
66 tokenBAddress : "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" , // USDC address
77 maxLamports : 1000000 , // Max lamports allowed for fees
88 direction : "in" as "in" | "out" , // Swap direction: 'in' or 'out'
99 liquidityFile : "https://api.raydium.io/v2/sdk/liquidity/mainnet.json" ,
10+ maxRetries : 10
1011} ;
You can’t perform that action at this time.
0 commit comments