@hawksightco/hawk-sdk 1.2.95 → 1.2.97

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.
@@ -1,5 +1,6 @@
1
1
  import * as web3 from "@solana/web3.js";
2
2
  import { Raydium, ApiV3PoolInfoConcentratedItem } from "@raydium-io/raydium-sdk-v2";
3
+ import BN from "bn.js";
3
4
  /**
4
5
  * Raydium SDK class
5
6
  *
@@ -39,6 +40,17 @@ export declare class RaydiumSDK {
39
40
  * @returns The pool info.
40
41
  */
41
42
  getPoolInfoFromRpc(poolId: web3.PublicKey): Promise<ApiV3PoolInfoConcentratedItem>;
43
+ getLiquidityFromAmounts(connection: web3.Connection, poolId: web3.PublicKey, amountA: BN, amountB: BN, tickLower: number, tickUpper: number, slippage: number, add: boolean): Promise<{
44
+ liquidity: BN;
45
+ amount0Max: BN;
46
+ amount1Max: BN;
47
+ }>;
48
+ getAmountsFromLiquidity(connection: web3.Connection, poolId: web3.PublicKey, liquidity: BN, tickLower: number, tickUpper: number, slippage: number, add: boolean): Promise<{
49
+ amount0Min: BN;
50
+ amount1Min: BN;
51
+ amountA: import("@raydium-io/raydium-sdk-v2").GetTransferAmountFee;
52
+ amountB: import("@raydium-io/raydium-sdk-v2").GetTransferAmountFee;
53
+ }>;
42
54
  }
43
55
  /**
44
56
  * Load the Raydium SDK
@@ -1 +1 @@
1
- {"version":3,"file":"RaydiumSDK.d.ts","sourceRoot":"","sources":["../../../src/classes/RaydiumSDK.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,iBAAiB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,6BAA6B,EAAE,MAAM,4BAA4B,CAAC;AAEpF;;;;GAIG;AACH,qBAAa,UAAU;IAErB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS,CAAa;IAErC;;OAEG;IACI,GAAG,EAAE,OAAO,CAAC;IAEpB;;;;OAIG;IACH,OAAO;IAIP;;;;OA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U,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO;;;;;;CAkDvK;AAED;;;;GAIG;AACH,wBAAsB,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,iBAErD;AAED;;;;GAIG;AACH,wBAAgB,OAAO,YAEtB"}
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.raydium = exports.load = exports.RaydiumSDK = void 0;
13
13
  const raydium_sdk_v2_1 = require("@raydium-io/raydium-sdk-v2");
14
+ const functions_1 = require("../functions");
14
15
  /**
15
16
  * Raydium SDK class
16
17
  *
@@ -106,6 +107,81 @@ class RaydiumSDK {
106
107
  return result;
107
108
  });
108
109
  }
110
+ getLiquidityFromAmounts(connection, poolId, amountA, amountB, tickLower, tickUpper, slippage, add) {
111
+ return __awaiter(this, void 0, void 0, function* () {
112
+ // Load the Raydium SDK
113
+ yield RaydiumSDK.load(connection);
114
+ // Benchmark the getPoolInfoFromRpc function
115
+ (0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getPoolInfoFromRpc` });
116
+ // Get the pool info
117
+ let poolInfo = yield RaydiumSDK.instance().getPoolInfoFromRpc(poolId);
118
+ // Benchmark the getPoolInfoFromRpc function (end)
119
+ (0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getPoolInfoFromRpc`, end: true });
120
+ // Benchmark the getEpochInfo function
121
+ (0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getEpochInfo` });
122
+ // Get the epoch info
123
+ let epochInfo = yield connection.getEpochInfo();
124
+ // Benchmark the getEpochInfo function (end)
125
+ (0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getEpochInfo`, end: true });
126
+ // Benchmark the getLiquidityFromAmounts function
127
+ (0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getLiquidityFromAmounts` });
128
+ const { liquidity, amountSlippageA, amountSlippageB, amountA: _amountA, amountB: _amountB, } = (0, raydium_sdk_v2_1.getLiquidityFromAmounts)({
129
+ poolInfo,
130
+ tickLower,
131
+ tickUpper,
132
+ amountA,
133
+ amountB,
134
+ slippage,
135
+ add: true,
136
+ epochInfo,
137
+ amountHasFee: false,
138
+ });
139
+ // Benchmark the getLiquidityFromAmounts function (end)
140
+ (0, functions_1.benchmark)({ name: `getLiquidityFromAmounts`, msg: `getLiquidityFromAmounts`, end: true });
141
+ return {
142
+ liquidity,
143
+ amount0Max: amountSlippageA.amount,
144
+ amount1Max: amountSlippageB.amount,
145
+ };
146
+ });
147
+ }
148
+ getAmountsFromLiquidity(connection, poolId, liquidity, tickLower, tickUpper, slippage, add) {
149
+ return __awaiter(this, void 0, void 0, function* () {
150
+ // Load the Raydium SDK
151
+ yield RaydiumSDK.load(connection);
152
+ // Benchmark the getPoolInfoFromRpc function
153
+ (0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getPoolInfoFromRpc` });
154
+ // Get the pool info
155
+ let poolInfo = yield RaydiumSDK.instance().getPoolInfoFromRpc(poolId);
156
+ (0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getPoolInfoFromRpc`, end: true });
157
+ // Benchmark the getEpochInfo function
158
+ (0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getEpochInfo` });
159
+ // Get the epoch info
160
+ let epochInfo = yield connection.getEpochInfo();
161
+ // Benchmark the getEpochInfo function (end)
162
+ (0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getEpochInfo`, end: true });
163
+ // Benchmark the getAmountsFromLiquidity function
164
+ (0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getAmountsFromLiquidity` });
165
+ // Get the amounts from liquidity
166
+ const { amountSlippageA, amountSlippageB, amountA, amountB, } = yield raydium_sdk_v2_1.PoolUtils.getAmountsFromLiquidity({
167
+ epochInfo,
168
+ poolInfo,
169
+ tickLower,
170
+ tickUpper,
171
+ liquidity,
172
+ slippage,
173
+ add,
174
+ });
175
+ // Benchmark the getAmountsFromLiquidity function (end)
176
+ (0, functions_1.benchmark)({ name: `getAmountsFromLiquidity`, msg: `getAmountsFromLiquidity`, end: true });
177
+ return {
178
+ amount0Min: amountSlippageA.amount,
179
+ amount1Min: amountSlippageB.amount,
180
+ amountA,
181
+ amountB,
182
+ };
183
+ });
184
+ }
109
185
  }
110
186
  exports.RaydiumSDK = RaydiumSDK;
111
187
  /**
@@ -855,7 +855,7 @@ function deserializeParametersFromIDL(idl, instruction, data) {
855
855
  const discriminator = tokens.readBuffer(8);
856
856
  const params = {};
857
857
  const ixDefinition = idl.instructions.find((ix) => ix.name === instruction);
858
- if (!discriminator.equals(Buffer.from(ixDefinition.discriminator))) {
858
+ if (!discriminator.equals(Uint8Array.from(ixDefinition.discriminator))) {
859
859
  throw new Error(`deserializeParametersFromIDL: Discriminator mismatch.`);
860
860
  }
861
861
  for (const arg of ixDefinition.args) {