Skip to content

Commit f80c99d

Browse files
committed
Increase max retries
1 parent 5b2a232 commit f80c99d

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
8195
Then run:
8296

8397
```sh

src/RaydiumSwap.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

src/swapConfig.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
export 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
};

0 commit comments

Comments
 (0)