Update wallet configuration and dependencies

This commit is contained in:
Al366io
2024-01-20 01:49:32 +01:00
parent dee6078e03
commit 35a6e1a19a
6 changed files with 63 additions and 11 deletions

2
.env.copy Normal file
View File

@ -0,0 +1,2 @@
PRIVATE_KEY=
```

View File

@ -12,7 +12,7 @@ In order to run the script you need to:
- Transfer some SOL to it. - Transfer some SOL to it.
- Convert some SOL to USDC. - Convert some SOL to USDC.
- We need USDC because the script is buying USDC pairs. - We need USDC because the script is buying USDC pairs.
- Export wallet private key and paste it into: `wallet.json` - Set your Private Key in the .env file (remove the .copy from the file name when done)
- Modify the buy.ts file and enter your RPC endpoint - Modify the buy.ts file and enter your RPC endpoint
- Find line where it says: `ENTER RPC ENDPOINT HERE` and `ENTER RPC WEBSOCKET ENDPOINT HERE` - Find line where it says: `ENTER RPC ENDPOINT HERE` and `ENTER RPC WEBSOCKET ENDPOINT HERE`
and replace it with your endpoint and replace it with your endpoint

11
buy.ts
View File

@ -14,7 +14,6 @@ import {
TransactionMessage, TransactionMessage,
VersionedTransaction, VersionedTransaction,
} from '@solana/web3.js'; } from '@solana/web3.js';
import secret from './wallet.json';
import { import {
getAllAccountsV4, getAllAccountsV4,
getTokenAccounts, getTokenAccounts,
@ -26,6 +25,9 @@ import { retry } from './utils';
import { USDC_AMOUNT, USDC_TOKEN_ID } from './common'; import { USDC_AMOUNT, USDC_TOKEN_ID } from './common';
import { getAllMarketsV3 } from './market'; import { getAllMarketsV3 } from './market';
import pino from 'pino'; import pino from 'pino';
import dotenv from 'dotenv';
import bs58 from "bs58";
dotenv.config();
const transport = pino.transport({ const transport = pino.transport({
targets: [ targets: [
@ -80,9 +82,14 @@ let existingTokenAccounts: Map<string, MinimalTokenAccountData> = new Map<
let wallet: Keypair; let wallet: Keypair;
let usdcTokenKey: PublicKey; let usdcTokenKey: PublicKey;
const PRIVATE_KEY: string = process.env.PRIVATE_KEY || '';
async function init(): Promise<void> { async function init(): Promise<void> {
wallet = Keypair.fromSecretKey(new Uint8Array(secret)); if (!PRIVATE_KEY) {
console.error('PRIVATE_KEY is not set');
process.exit(1);
}
wallet = Keypair.fromSecretKey(bs58.decode(PRIVATE_KEY));
logger.info(`Wallet Address: ${wallet.publicKey.toString()}`); logger.info(`Wallet Address: ${wallet.publicKey.toString()}`);
const allLiquidityPools = await getAllAccountsV4(solanaConnection); const allLiquidityPools = await getAllAccountsV4(solanaConnection);
existingLiquidityPools = new Set( existingLiquidityPools = new Set(

56
package-lock.json generated
View File

@ -10,6 +10,8 @@
"@solana/spl-token": "^0.3.11", "@solana/spl-token": "^0.3.11",
"bigint-buffer": "^1.1.5", "bigint-buffer": "^1.1.5",
"bn.js": "^5.2.1", "bn.js": "^5.2.1",
"bs58": "^5.0.0",
"dotenv": "^16.3.2",
"pino": "^8.17.2", "pino": "^8.17.2",
"pino-pretty": "^10.3.1", "pino-pretty": "^10.3.1",
"pino-std-serializers": "^6.2.2" "pino-std-serializers": "^6.2.2"
@ -248,6 +250,22 @@
"superstruct": "^0.14.2" "superstruct": "^0.14.2"
} }
}, },
"node_modules/@solana/web3.js/node_modules/base-x": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz",
"integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/@solana/web3.js/node_modules/bs58": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
"integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
"dependencies": {
"base-x": "^3.0.2"
}
},
"node_modules/@tsconfig/node10": { "node_modules/@tsconfig/node10": {
"version": "1.0.9", "version": "1.0.9",
"resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.9.tgz",
@ -375,12 +393,9 @@
} }
}, },
"node_modules/base-x": { "node_modules/base-x": {
"version": "3.0.9", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz", "resolved": "https://registry.npmjs.org/base-x/-/base-x-4.0.0.tgz",
"integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==", "integrity": "sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw=="
"dependencies": {
"safe-buffer": "^5.0.1"
}
}, },
"node_modules/base64-js": { "node_modules/base64-js": {
"version": "1.5.1", "version": "1.5.1",
@ -456,7 +471,15 @@
"text-encoding-utf-8": "^1.0.2" "text-encoding-utf-8": "^1.0.2"
} }
}, },
"node_modules/bs58": { "node_modules/borsh/node_modules/base-x": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz",
"integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/borsh/node_modules/bs58": {
"version": "4.0.1", "version": "4.0.1",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz", "resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
"integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==", "integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
@ -464,6 +487,14 @@
"base-x": "^3.0.2" "base-x": "^3.0.2"
} }
}, },
"node_modules/bs58": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-5.0.0.tgz",
"integrity": "sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==",
"dependencies": {
"base-x": "^4.0.0"
}
},
"node_modules/buffer": { "node_modules/buffer": {
"version": "6.0.3", "version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
@ -573,6 +604,17 @@
"node": ">=0.3.1" "node": ">=0.3.1"
} }
}, },
"node_modules/dotenv": {
"version": "16.3.2",
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.2.tgz",
"integrity": "sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/motdotla/dotenv?sponsor=1"
}
},
"node_modules/end-of-stream": { "node_modules/end-of-stream": {
"version": "1.4.4", "version": "1.4.4",
"resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz", "resolved": "https://registry.npmjs.org/end-of-stream/-/end-of-stream-1.4.4.tgz",

View File

@ -9,6 +9,8 @@
"@solana/spl-token": "^0.3.11", "@solana/spl-token": "^0.3.11",
"bigint-buffer": "^1.1.5", "bigint-buffer": "^1.1.5",
"bn.js": "^5.2.1", "bn.js": "^5.2.1",
"bs58": "^5.0.0",
"dotenv": "^16.3.2",
"pino": "^8.17.2", "pino": "^8.17.2",
"pino-pretty": "^10.3.1", "pino-pretty": "^10.3.1",
"pino-std-serializers": "^6.2.2" "pino-std-serializers": "^6.2.2"

View File

@ -1 +0,0 @@
[]