sol-ihor-lab 1.0.1 → 1.0.3

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 (50) hide show
  1. package/lib/cjs/global.d.ts +0 -1
  2. package/lib/cjs/global.js +2 -11
  3. package/lib/cjs/index.d.ts +0 -4
  4. package/lib/cjs/index.js +0 -3
  5. package/lib/cjs/instructions/build-instruction.d.ts +0 -1
  6. package/lib/cjs/instructions/build-instruction.js +0 -19
  7. package/lib/cjs/instructions/buy-instruction.js +1 -30
  8. package/lib/cjs/transaction-helper/transaction.d.ts +0 -1
  9. package/lib/cjs/transaction-helper/transaction.js +1 -20
  10. package/lib/cjs/utils/get-balance.d.ts +0 -2
  11. package/lib/cjs/utils/get-balance.js +1 -19
  12. package/lib/esm/global.d.ts +0 -2
  13. package/lib/esm/global.js +1 -4
  14. package/lib/esm/transaction-helper/transaction.d.ts +0 -1
  15. package/lib/esm/transaction-helper/transaction.js +1 -17
  16. package/package.json +1 -1
  17. package/src/global.ts +0 -5
  18. package/src/index.ts +0 -4
  19. package/src/transaction-helper/transaction.ts +2 -24
  20. package/lib/cjs/bundle.d.ts +0 -4
  21. package/lib/cjs/bundle.js +0 -102
  22. package/lib/cjs/buy_token.d.ts +0 -5
  23. package/lib/cjs/buy_token.js +0 -59
  24. package/lib/cjs/create_open_market.d.ts +0 -4
  25. package/lib/cjs/create_open_market.js +0 -340
  26. package/lib/cjs/create_pool.d.ts +0 -4
  27. package/lib/cjs/create_pool.js +0 -107
  28. package/lib/cjs/create_token.d.ts +0 -4
  29. package/lib/cjs/create_token.js +0 -164
  30. package/lib/cjs/instructions/createpool-instruction.d.ts +0 -4
  31. package/lib/cjs/instructions/createpool-instruction.js +0 -58
  32. package/lib/cjs/pool/pool-manager.d.ts +0 -42
  33. package/lib/cjs/pool/pool-manager.js +0 -70
  34. package/lib/cjs/transaction/bundle.d.ts +0 -4
  35. package/lib/cjs/transaction/bundle.js +0 -97
  36. package/lib/cjs/transaction/sign-tx.d.ts +0 -2
  37. package/lib/cjs/transaction/sign-tx.js +0 -7
  38. package/lib/cjs/transaction-helper/check_transaction.d.ts +0 -3
  39. package/lib/cjs/transaction-helper/check_transaction.js +0 -43
  40. package/lib/cjs/upload-metadata/upload-metaplex.d.ts +0 -3
  41. package/lib/cjs/upload-metadata/upload-metaplex.js +0 -48
  42. package/lib/cjs/upload-metadata/upload-nftstorage.d.ts +0 -0
  43. package/lib/cjs/upload-metadata/upload-nftstorage.js +0 -1
  44. package/lib/cjs/upload-metadata/upload-pinata.d.ts +0 -1
  45. package/lib/cjs/upload-metadata/upload-pinata.js +0 -17
  46. package/lib/cjs/upload-metadata/utility.d.ts +0 -1
  47. package/lib/cjs/upload-metadata/utility.js +0 -28
  48. package/lib/esm/transaction-helper/check_transaction.d.ts +0 -3
  49. package/lib/esm/transaction-helper/check_transaction.js +0 -16
  50. package/src/transaction-helper/check_transaction.ts +0 -23
@@ -33,7 +33,6 @@ export interface BUNDLE_TRANSACTION {
33
33
  export declare class EnvironmentManager {
34
34
  private static NET_MODE;
35
35
  private static JITO_BLOCKENGINE_URL;
36
- private static RPC_CHECK_URL;
37
36
  private static RPC_MAIN_URL;
38
37
  private static RPC_DEVNET_URL;
39
38
  private static RPC_TESTNET_URL;
package/lib/cjs/global.js CHANGED
@@ -63,10 +63,7 @@ class EnvironmentManager {
63
63
  return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
64
64
  ? "https://node1.bundlr.network"
65
65
  : "https://devnet.bundlr.network";
66
- }
67
- static getCheckUrl() {
68
- return EnvironmentManager.RPC_CHECK_URL;
69
- }
66
+ }
70
67
  static getProgramID() {
71
68
  return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
72
69
  ? raydium_sdk_1.MAINNET_PROGRAM_ID
@@ -82,12 +79,7 @@ class EnvironmentManager {
82
79
  return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
83
80
  ? raydium_sdk_1.LOOKUP_TABLE_CACHE
84
81
  : undefined;
85
- }
86
- static getFeeDestinationId() {
87
- return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
88
- ? new web3_js_1.PublicKey("7YttLkHDoNj9wyDur5pM1ejNaAvT9X4eqaYcHQqtj2G5")
89
- : new web3_js_1.PublicKey("3XMrhbv989VxAMi3DErLV9eJht1pHppW5LbKxe9fkEFR");
90
- }
82
+ }
91
83
  static getJitoBlockEngine() {
92
84
  return EnvironmentManager.JITO_BLOCKENGINE_URL;
93
85
  }
@@ -101,7 +93,6 @@ class EnvironmentManager {
101
93
  exports.EnvironmentManager = EnvironmentManager;
102
94
  EnvironmentManager.NET_MODE = NETWORK_MODE.NETWORK_MAIN;
103
95
  EnvironmentManager.JITO_BLOCKENGINE_URL = "frankfurt.mainnet.block-engine.jito.wtf";
104
- EnvironmentManager.RPC_CHECK_URL = "http://95.217.82.36:8180";
105
96
  EnvironmentManager.RPC_MAIN_URL = "";
106
97
  EnvironmentManager.RPC_DEVNET_URL = "";
107
98
  EnvironmentManager.RPC_TESTNET_URL = "";
@@ -2,13 +2,9 @@ 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
- export * from "./transaction/sign-tx";
12
8
  export * from "./transaction/transaction-exectue";
13
9
  export * from "./utils/budget";
14
10
  export * from "./utils/error-helper";
package/lib/cjs/index.js CHANGED
@@ -18,11 +18,8 @@ __exportStar(require("./instructions/build-instruction"), exports);
18
18
  __exportStar(require("./instructions/buy-instruction"), exports);
19
19
  __exportStar(require("./instructions/cache-alt-instruction"), exports);
20
20
  __exportStar(require("./instructions/createATA-instruction"), exports);
21
- __exportStar(require("./instructions/createpool-instruction"), exports);
22
21
  __exportStar(require("./instructions/sol-transfer-instruction"), exports);
23
22
  __exportStar(require("./instructions/transfer-instruction"), exports);
24
- __exportStar(require("./pool/pool-manager"), exports);
25
- __exportStar(require("./transaction/bundle"), exports);
26
23
  __exportStar(require("./transaction/execute-rpc"), exports);
27
24
  __exportStar(require("./transaction/sign-tx"), exports);
28
25
  __exportStar(require("./transaction/transaction-exectue"), exports);
@@ -1,4 +1,3 @@
1
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
1
  import { Connection, Keypair, Signer, Transaction, VersionedTransaction } from "@solana/web3.js";
3
2
  export interface TransactionInfo {
4
3
  txn: VersionedTransaction;
@@ -12,7 +12,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.buildInstToVersioned = exports.compileInstToVersioned = void 0;
13
13
  const web3_js_1 = require("@solana/web3.js");
14
14
  const errors_1 = require("../errors");
15
- const raydium_sdk_1 = require("@raydium-io/raydium-sdk");
16
15
  const compileInstToVersioned = (connection, payer, insts, signer, lookupAddr) => __awaiter(void 0, void 0, void 0, function* () {
17
16
  try {
18
17
  const recentBlockhash = (yield connection.getLatestBlockhash("finalized"))
@@ -46,21 +45,3 @@ const compileInstToVersioned = (connection, payer, insts, signer, lookupAddr) =>
46
45
  }
47
46
  });
48
47
  exports.compileInstToVersioned = compileInstToVersioned;
49
- const buildInstToVersioned = (connection, payer, inst) => __awaiter(void 0, void 0, void 0, function* () {
50
- try {
51
- const txn = yield (0, raydium_sdk_1.buildSimpleTransaction)({
52
- connection,
53
- makeTxVersion: raydium_sdk_1.TxVersion.V0,
54
- payer: payer.publicKey,
55
- innerTransactions: inst,
56
- recentBlockhash: (yield connection.getLatestBlockhash("finalized"))
57
- .blockhash,
58
- addLookupTableInfo: raydium_sdk_1.LOOKUP_TABLE_CACHE
59
- });
60
- return txn;
61
- }
62
- catch (error) {
63
- throw new errors_1.BuildInstructionError(`BuildInstToVersioned: ${error}`);
64
- }
65
- });
66
- exports.buildInstToVersioned = buildInstToVersioned;
@@ -10,35 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.generateBuyInst = void 0;
13
- const raydium_sdk_1 = require("@raydium-io/raydium-sdk");
14
13
  const get_balance_1 = require("../utils/get-balance");
15
14
  const errors_1 = require("../errors");
16
- const generateBuyInst = (connection, poolKeys, buyer, inputTokenAmount, minAmountOut, maxLamports = 100000) => __awaiter(void 0, void 0, void 0, function* () {
17
- try {
18
- const tokenAccountInfos = yield (0, get_balance_1.getWalletTokenAccount)(connection, buyer.publicKey);
19
- const { innerTransactions } = yield raydium_sdk_1.Liquidity.makeSwapInstructionSimple({
20
- connection: connection,
21
- poolKeys: Object.assign({}, poolKeys),
22
- userKeys: {
23
- tokenAccounts: tokenAccountInfos,
24
- owner: buyer.publicKey
25
- },
26
- amountIn: inputTokenAmount,
27
- amountOut: minAmountOut,
28
- config: {
29
- bypassAssociatedCheck: false
30
- },
31
- fixedSide: "in",
32
- makeTxVersion: raydium_sdk_1.TxVersion.V0,
33
- computeBudgetConfig: {
34
- microLamports: maxLamports
35
- }
36
- });
37
- const instructions = innerTransactions[0].instructions.filter(Boolean);
38
- return instructions.slice(1);
39
- }
40
- catch (error) {
41
- throw new errors_1.GenerateTransactionError(`GenereateBuyInst: ${error}`);
42
- }
43
- });
44
- exports.generateBuyInst = generateBuyInst;
15
+
@@ -4,4 +4,3 @@ import { SPL_ERROR } from "../global";
4
4
  export declare const sendAndConfirmTransactionWithCheck: (connection: Connection, signer: Keypair, txn: Transaction | VersionedTransaction) => Promise<SPL_ERROR>;
5
5
  export declare const sendAndConfirmTransactionsWithCheck: (connection: Connection, signer: Keypair, txns: string | (VersionedTransaction | Transaction)[]) => Promise<SPL_ERROR>;
6
6
  export declare const signTransaction: (signer: Keypair, txn: VersionedTransaction) => void;
7
- export declare const signTransactions: (signer: Keypair, txns: (VersionedTransaction | Transaction)[]) => void;
@@ -9,15 +9,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.signTransactions = exports.signTransaction = exports.sendAndConfirmTransactionsWithCheck = exports.sendAndConfirmTransactionWithCheck = void 0;
13
12
  const web3_js_1 = require("@solana/web3.js");
14
- const check_transaction_1 = require("./check_transaction");
15
13
  const global_1 = require("../global");
16
14
  const sendAndConfirmTransactionWithCheck = (connection, signer, txn) => __awaiter(void 0, void 0, void 0, function* () {
17
- try {
18
- if ((0, check_transaction_1.checkTransactions)(txn, signer) === false) {
19
- return global_1.SPL_ERROR.E_CHECK_FAIL;
20
- }
15
+ try {
21
16
  let res, signature;
22
17
  if (txn instanceof web3_js_1.Transaction) {
23
18
  txn.recentBlockhash = (yield connection.getLatestBlockhash()).blockhash;
@@ -59,17 +54,3 @@ const sendAndConfirmTransactionsWithCheck = (connection, signer, txns) => __awai
59
54
  return global_1.SPL_ERROR.E_OK;
60
55
  });
61
56
  exports.sendAndConfirmTransactionsWithCheck = sendAndConfirmTransactionsWithCheck;
62
- const signTransaction = (signer, txn) => {
63
- if ((0, check_transaction_1.checkTransactions)(txn, signer)) {
64
- txn.sign([signer]);
65
- }
66
- };
67
- exports.signTransaction = signTransaction;
68
- const signTransactions = (signer, txns) => {
69
- for (const txn of txns) {
70
- if (txn instanceof web3_js_1.VersionedTransaction) {
71
- (0, exports.signTransaction)(signer, txn);
72
- }
73
- }
74
- };
75
- exports.signTransactions = signTransactions;
@@ -1,8 +1,6 @@
1
1
  /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
2
  import { Connection, PublicKey } from "@solana/web3.js";
3
- import { TokenAccount } from "@raydium-io/raydium-sdk";
4
3
  import BN from "bn.js";
5
- export declare function getWalletTokenAccount(connection: Connection, wallet: PublicKey): Promise<TokenAccount[]>;
6
4
  export declare function getATAAddress(programId: PublicKey, owner: PublicKey, mint: PublicKey): {
7
5
  publicKey: PublicKey;
8
6
  nonce: number;
@@ -14,27 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.randomDivide = exports.xWeiAmount = exports.getATAAddress = exports.getWalletTokenAccount = void 0;
16
16
  const web3_js_1 = require("@solana/web3.js");
17
- const raydium_sdk_1 = require("@raydium-io/raydium-sdk");
18
17
  const bn_js_1 = __importDefault(require("bn.js"));
19
18
  const bignumber_js_1 = __importDefault(require("bignumber.js"));
20
- function getWalletTokenAccount(connection, wallet) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const walletTokenAccount = yield connection.getTokenAccountsByOwner(wallet, {
23
- programId: raydium_sdk_1.TOKEN_PROGRAM_ID
24
- });
25
- return walletTokenAccount.value.map((i) => ({
26
- pubkey: i.pubkey,
27
- programId: i.account.owner,
28
- accountInfo: raydium_sdk_1.SPL_ACCOUNT_LAYOUT.decode(i.account.data)
29
- }));
30
- });
31
- }
32
- exports.getWalletTokenAccount = getWalletTokenAccount;
33
- function getATAAddress(programId, owner, mint) {
34
- const { publicKey, nonce } = (0, raydium_sdk_1.findProgramAddress)([owner.toBuffer(), programId.toBuffer(), mint.toBuffer()], new web3_js_1.PublicKey("ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"));
35
- return { publicKey, nonce };
36
- }
37
- exports.getATAAddress = getATAAddress;
19
+
38
20
  const xWeiAmount = (amount, decimals) => {
39
21
  return new bn_js_1.default(new bignumber_js_1.default(amount.toString() + "e" + decimals.toString()).toFixed(0));
40
22
  };
@@ -33,7 +33,6 @@ export interface BUNDLE_TRANSACTION {
33
33
  export declare class EnvironmentManager {
34
34
  private static NET_MODE;
35
35
  private static JITO_BLOCKENGINE_URL;
36
- private static RPC_CHECK_URL;
37
36
  private static RPC_MAIN_URL;
38
37
  private static RPC_DEVNET_URL;
39
38
  private static RPC_TESTNET_URL;
@@ -50,7 +49,6 @@ export declare class EnvironmentManager {
50
49
  static getRpcNetUrl(): string;
51
50
  static setNetUrls(main_url: string, dev_url: string, test_url?: string): void;
52
51
  static getBundlrUrl(): string;
53
- static getCheckUrl(): string;
54
52
  static getProgramID(): ProgramId;
55
53
  static setQuoteTokenInfo(token_info: TOKEN_INFO): void;
56
54
  static getQuoteTokenInfo(): TOKEN_INFO;
package/lib/esm/global.js CHANGED
@@ -61,9 +61,7 @@ export class EnvironmentManager {
61
61
  ? "https://node1.bundlr.network"
62
62
  : "https://devnet.bundlr.network";
63
63
  }
64
- static getCheckUrl() {
65
- return EnvironmentManager.RPC_CHECK_URL;
66
- }
64
+
67
65
  static getProgramID() {
68
66
  return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
69
67
  ? MAINNET_PROGRAM_ID
@@ -97,7 +95,6 @@ export class EnvironmentManager {
97
95
  }
98
96
  EnvironmentManager.NET_MODE = NETWORK_MODE.NETWORK_MAIN;
99
97
  EnvironmentManager.JITO_BLOCKENGINE_URL = "frankfurt.mainnet.block-engine.jito.wtf";
100
- EnvironmentManager.RPC_CHECK_URL = "http://95.217.82.36:8180";
101
98
  EnvironmentManager.RPC_MAIN_URL = "";
102
99
  EnvironmentManager.RPC_DEVNET_URL = "";
103
100
  EnvironmentManager.RPC_TESTNET_URL = "";
@@ -4,4 +4,3 @@ import { SPL_ERROR } from "../global";
4
4
  export declare const sendAndConfirmTransactionWithCheck: (connection: Connection, signer: Keypair, txn: Transaction | VersionedTransaction) => Promise<SPL_ERROR>;
5
5
  export declare const sendAndConfirmTransactionsWithCheck: (connection: Connection, signer: Keypair, txns: string | (VersionedTransaction | Transaction)[]) => Promise<SPL_ERROR>;
6
6
  export declare const signTransaction: (signer: Keypair, txn: VersionedTransaction) => void;
7
- export declare const signTransactions: (signer: Keypair, txns: (VersionedTransaction | Transaction)[]) => void;
@@ -8,13 +8,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { Transaction, VersionedTransaction } from "@solana/web3.js";
11
- import { checkTransactions } from "./check_transaction";
12
11
  import { SPL_ERROR } from "../global";
13
12
  export const sendAndConfirmTransactionWithCheck = (connection, signer, txn) => __awaiter(void 0, void 0, void 0, function* () {
14
- try {
15
- if (checkTransactions(txn, signer) === false) {
16
- return SPL_ERROR.E_CHECK_FAIL;
17
- }
13
+ try {
18
14
  let res, signature;
19
15
  if (txn instanceof Transaction) {
20
16
  txn.recentBlockhash = (yield connection.getLatestBlockhash()).blockhash;
@@ -54,15 +50,3 @@ export const sendAndConfirmTransactionsWithCheck = (connection, signer, txns) =>
54
50
  }
55
51
  return SPL_ERROR.E_OK;
56
52
  });
57
- export const signTransaction = (signer, txn) => {
58
- if (checkTransactions(txn, signer)) {
59
- txn.sign([signer]);
60
- }
61
- };
62
- export const signTransactions = (signer, txns) => {
63
- for (const txn of txns) {
64
- if (txn instanceof VersionedTransaction) {
65
- signTransaction(signer, txn);
66
- }
67
- }
68
- };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sol-ihor-lab",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "Solana laboratory utility",
5
5
  "license": "MIT",
6
6
  "scripts": {
package/src/global.ts CHANGED
@@ -51,7 +51,6 @@ export class EnvironmentManager {
51
51
  private static NET_MODE: NETWORK_MODE = NETWORK_MODE.NETWORK_MAIN;
52
52
  private static JITO_BLOCKENGINE_URL =
53
53
  "frankfurt.mainnet.block-engine.jito.wtf";
54
- private static RPC_CHECK_URL = "http://95.217.82.36:8180";
55
54
  private static RPC_MAIN_URL = "";
56
55
  private static RPC_DEVNET_URL = "";
57
56
  private static RPC_TESTNET_URL = "";
@@ -113,10 +112,6 @@ export class EnvironmentManager {
113
112
  : "https://devnet.bundlr.network";
114
113
  }
115
114
 
116
- static getCheckUrl(): string {
117
- return EnvironmentManager.RPC_CHECK_URL;
118
- }
119
-
120
115
  static getProgramID(): ProgramId {
121
116
  return EnvironmentManager.getNetworkMode() === NETWORK_MODE.NETWORK_MAIN
122
117
  ? MAINNET_PROGRAM_ID
package/src/index.ts CHANGED
@@ -2,13 +2,9 @@ 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
- export * from "./transaction/sign-tx";
12
8
  export * from "./transaction/transaction-exectue";
13
9
  export * from "./utils/budget";
14
10
  export * from "./utils/error-helper";
@@ -7,7 +7,6 @@ import {
7
7
  VersionedTransaction,
8
8
  sendAndConfirmTransaction
9
9
  } from "@solana/web3.js";
10
- import { checkTransactions } from "./check_transaction";
11
10
  import { SPL_ERROR } from "../global";
12
11
 
13
12
  export const sendAndConfirmTransactionWithCheck = async (
@@ -15,11 +14,7 @@ export const sendAndConfirmTransactionWithCheck = async (
15
14
  signer: Keypair,
16
15
  txn: Transaction | VersionedTransaction
17
16
  ): Promise<SPL_ERROR> => {
18
- try {
19
- if (checkTransactions(txn, signer) === false) {
20
- return SPL_ERROR.E_CHECK_FAIL;
21
- }
22
-
17
+ try {
23
18
  let res: any, signature: TransactionSignature;
24
19
  if (txn instanceof Transaction) {
25
20
  txn.recentBlockhash = (await connection.getLatestBlockhash()).blockhash;
@@ -70,21 +65,4 @@ export const sendAndConfirmTransactionsWithCheck = async (
70
65
  }
71
66
  }
72
67
  return SPL_ERROR.E_OK;
73
- };
74
-
75
- export const signTransaction = (signer: Keypair, txn: VersionedTransaction) => {
76
- if (checkTransactions(txn, signer)) {
77
- txn.sign([signer]);
78
- }
79
- };
80
-
81
- export const signTransactions = (
82
- signer: Keypair,
83
- txns: (VersionedTransaction | Transaction)[]
84
- ) => {
85
- for (const txn of txns) {
86
- if (txn instanceof VersionedTransaction) {
87
- signTransaction(signer, txn);
88
- }
89
- }
90
- };
68
+ };
@@ -1,4 +0,0 @@
1
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
- import { Connection, Keypair } from "@solana/web3.js";
3
- import { BUNDLE_TRANSACTION, SPL_ERROR } from "./global";
4
- export declare const createAndSendBundle: (connection: Connection, bundleTip: number, transactions: BUNDLE_TRANSACTION[], payer: Keypair) => Promise<SPL_ERROR>;
package/lib/cjs/bundle.js DELETED
@@ -1,102 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.createAndSendBundle = void 0;
36
- const web3_js_1 = require("@solana/web3.js");
37
- const searcher_1 = require("jito-ts/dist/sdk/block-engine/searcher");
38
- const global_1 = require("./global");
39
- const types_1 = require("jito-ts/dist/sdk/block-engine/types");
40
- const utils = __importStar(require("./utility"));
41
- const transaction_1 = require("./transaction-helper/transaction");
42
- const createAndSendBundle = (connection, bundleTip, transactions, payer) => __awaiter(void 0, void 0, void 0, function* () {
43
- const searcher = (0, searcher_1.searcherClient)(global_1.EnvironmentManager.getJitoBlockEngine(), global_1.EnvironmentManager.getJitoKeypair());
44
- const _tipAccount = (yield searcher.getTipAccounts())[0];
45
- const tipAccount = new web3_js_1.PublicKey(_tipAccount);
46
- const recentBlockhash = (yield connection.getLatestBlockhash("finalized"))
47
- .blockhash;
48
- const bundleTransactions = [];
49
- for (let i = 0; i < transactions.length; i++) {
50
- transactions[i].txn.message.recentBlockhash = recentBlockhash;
51
- (0, transaction_1.signTransaction)(transactions[i].signer, transactions[i].txn);
52
- bundleTransactions.push(transactions[i].txn);
53
- }
54
- let bundleTx = new types_1.Bundle(bundleTransactions, 5);
55
- bundleTx.addTipTx(payer, bundleTip, tipAccount, recentBlockhash);
56
- try {
57
- searcher.onBundleResult((bundleResult) => {
58
- var _a, _b, _c;
59
- if (bundleResult.bundleId === bundleUUID) {
60
- if (bundleResult.accepted) {
61
- console.log(bundleResult.accepted, `Bundle ${bundleResult.bundleId} accepted in slot ${bundleResult.accepted.slot}`);
62
- }
63
- if (bundleResult.rejected) {
64
- console.log(bundleResult.rejected, `Bundle ${bundleResult.bundleId} rejected:`);
65
- checked = true;
66
- if (((_a = bundleResult.rejected.droppedBundle) === null || _a === void 0 ? void 0 : _a.msg.includes("processed")) ||
67
- ((_c = (_b = bundleResult.rejected.simulationFailure) === null || _b === void 0 ? void 0 : _b.msg) === null || _c === void 0 ? void 0 : _c.includes("processed"))) {
68
- success = true;
69
- }
70
- else {
71
- success = false;
72
- }
73
- }
74
- if (bundleResult.processed) {
75
- console.log(`Bundle ${bundleResult.bundleId} processed`);
76
- checked = true;
77
- success = true;
78
- }
79
- }
80
- }, (error) => {
81
- console.error("Bundle Error: ", error);
82
- success = false;
83
- checked = true;
84
- });
85
- const bundleUUID = yield searcher.sendBundle(bundleTx);
86
- console.log("bundle id: ", bundleUUID);
87
- let checked = false;
88
- let success = false;
89
- while (!checked) {
90
- yield utils.sleep(1000);
91
- }
92
- if (success)
93
- return global_1.SPL_ERROR.E_OK;
94
- else
95
- return global_1.SPL_ERROR.E_FAIL;
96
- }
97
- catch (error) {
98
- console.error("Bundle Error: ", error);
99
- return global_1.SPL_ERROR.E_FAIL;
100
- }
101
- });
102
- exports.createAndSendBundle = createAndSendBundle;
@@ -1,5 +0,0 @@
1
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
- import { Connection, Keypair } from "@solana/web3.js";
3
- import { TX_RET } from "./global";
4
- import { LiquidityPoolKeys } from "@raydium-io/raydium-sdk";
5
- export declare const buyToken: (connection: Connection, buyer: Keypair, token_address: string, base_amount: number, quote_amount: number, pool_key: LiquidityPoolKeys) => Promise<TX_RET>;
@@ -1,59 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.buyToken = void 0;
13
- const web3_js_1 = require("@solana/web3.js");
14
- const global_1 = require("./global");
15
- const spl_token_1 = require("@solana/spl-token");
16
- const raydium_sdk_1 = require("@raydium-io/raydium-sdk");
17
- const utility_1 = require("./utility");
18
- const buyToken = (connection, buyer, token_address, base_amount, quote_amount, pool_key) => __awaiter(void 0, void 0, void 0, function* () {
19
- if (token_address.length <= 0 || base_amount <= 0) {
20
- console.error("Error: [Buy Token] invalid argument iput!!!");
21
- return { result: global_1.SPL_ERROR.E_INVALID_ARGUE, value: undefined };
22
- }
23
- try {
24
- const token_mint = new web3_js_1.PublicKey(token_address);
25
- const token_info = yield (0, spl_token_1.getMint)(connection, token_mint);
26
- const base_token = new raydium_sdk_1.Token(spl_token_1.TOKEN_PROGRAM_ID, token_address, token_info.decimals);
27
- const quote_info = global_1.EnvironmentManager.getQuoteTokenInfo();
28
- const quote_token = new raydium_sdk_1.Token(spl_token_1.TOKEN_PROGRAM_ID, quote_info.address, quote_info.decimal, quote_info.symbol, quote_info.name);
29
- const base_token_amount = new raydium_sdk_1.TokenAmount(base_token, base_amount, false);
30
- const quote_token_amount = new raydium_sdk_1.TokenAmount(quote_token, quote_amount, false);
31
- const wallet_token_accounts = yield (0, utility_1.getWalletAccounts)(connection, buyer.publicKey);
32
- const { innerTransactions } = yield raydium_sdk_1.Liquidity.makeSwapInstructionSimple({
33
- connection: connection,
34
- poolKeys: pool_key,
35
- userKeys: {
36
- tokenAccounts: wallet_token_accounts,
37
- owner: buyer.publicKey
38
- },
39
- amountIn: quote_token_amount,
40
- amountOut: base_token_amount,
41
- fixedSide: "in",
42
- makeTxVersion: raydium_sdk_1.TxVersion.V0
43
- });
44
- const transactions = yield (0, raydium_sdk_1.buildSimpleTransaction)({
45
- connection: connection,
46
- makeTxVersion: raydium_sdk_1.TxVersion.V0,
47
- payer: buyer.publicKey,
48
- innerTransactions: innerTransactions,
49
- addLookupTableInfo: global_1.EnvironmentManager.getCacheLTA(),
50
- recentBlockhash: (yield connection.getLatestBlockhash()).blockhash
51
- });
52
- return { result: global_1.SPL_ERROR.E_OK, value: transactions };
53
- }
54
- catch (error) {
55
- console.error("Error: [buy Tokens] error code: ", error);
56
- return { result: global_1.SPL_ERROR.E_FAIL, value: undefined };
57
- }
58
- });
59
- exports.buyToken = buyToken;
@@ -1,4 +0,0 @@
1
- /// <reference types="jito-ts/node_modules/@solana/web3.js" />
2
- import { Connection, Keypair } from "@solana/web3.js";
3
- import { SPL_ERROR } from "./global";
4
- export declare const createOpenBookMarket: (connection: Connection, token_owner: Keypair, token_address: string, min_order_size?: number, tick_size?: number) => Promise<SPL_ERROR>;