@haven-fi/solauto-sdk 1.0.545 → 1.0.547

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.
@@ -23,8 +23,8 @@ function createTransactionInstruction(instruction) {
23
23
  });
24
24
  }
25
25
  async function getJupQuote(swapDetails) {
26
- const memecoinSwap = (0, generalUtils_1.tokenInfo)(swapDetails.inputMint).isMeme ||
27
- (0, generalUtils_1.tokenInfo)(swapDetails.outputMint).isMeme;
26
+ const memecoinSwap = (0, generalUtils_1.tokenInfo)(swapDetails.inputMint)?.isMeme ||
27
+ (0, generalUtils_1.tokenInfo)(swapDetails.outputMint)?.isMeme;
28
28
  return await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await jupApi.quoteGet({
29
29
  amount: Number(swapDetails.amount),
30
30
  inputMint: swapDetails.inputMint.toString(),
@@ -1,13 +1,8 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { PublicKey as UmiPublicKey } from "@metaplex-foundation/umi";
3
- import { QuoteGetSwapModeEnum } from "@jup-ag/api";
4
3
  export declare function fetchTokenPrices(mints: PublicKey[]): Promise<number[]>;
5
4
  export declare function getPythPrices(mints: PublicKey[]): Promise<number[]>;
6
5
  export declare function getSwitchboardPrices(mints: PublicKey[]): Promise<number[]>;
7
6
  export declare function getJupTokenPrices(mints: PublicKey[], mayIncludeSpamTokens?: boolean): Promise<number[]>;
8
- export declare function safeGetPrice(mint: PublicKey | UmiPublicKey | undefined): number | undefined;
9
- export declare function getPriceImpact(inputMint: PublicKey, outputMint: PublicKey, amount: bigint, swapMode: QuoteGetSwapModeEnum): Promise<{
10
- priceImpact: number;
11
- quote: import("@jup-ag/api").QuoteResponse;
12
- }>;
7
+ export declare function safeGetPrice(mint: PublicKey | UmiPublicKey | string | undefined): number | undefined;
13
8
  //# sourceMappingURL=priceUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/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BAAiB,CACrC,KAAK,EAAE,SAAS,EAAE,EAClB,oBAAoB,CAAC,EAAE,OAAO,qBAqB/B;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,GAClD,MAAM,GAAG,SAAS,CAKpB"}
@@ -28,7 +28,6 @@ exports.getPythPrices = getPythPrices;
28
28
  exports.getSwitchboardPrices = getSwitchboardPrices;
29
29
  exports.getJupTokenPrices = getJupTokenPrices;
30
30
  exports.safeGetPrice = safeGetPrice;
31
- exports.getPriceImpact = getPriceImpact;
32
31
  const pythConstants_1 = require("../constants/pythConstants");
33
32
  const numberUtils_1 = require("./numberUtils");
34
33
  const solautoConstants_1 = require("../constants/solautoConstants");
@@ -140,16 +139,3 @@ function safeGetPrice(mint) {
140
139
  }
141
140
  return undefined;
142
141
  }
143
- async function getPriceImpact(inputMint, outputMint, amount, swapMode) {
144
- const quoteResponse = await (0, jupiterUtils_1.getJupQuote)({
145
- inputMint,
146
- outputMint,
147
- amount,
148
- exactIn: swapMode === "ExactIn",
149
- exactOut: swapMode === "ExactOut",
150
- });
151
- return {
152
- priceImpact: parseFloat(quoteResponse.priceImpactPct),
153
- quote: quoteResponse,
154
- };
155
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.545",
3
+ "version": "1.0.547",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -51,8 +51,8 @@ function createTransactionInstruction(
51
51
 
52
52
  export async function getJupQuote(swapDetails: JupSwapInput) {
53
53
  const memecoinSwap =
54
- tokenInfo(swapDetails.inputMint).isMeme ||
55
- tokenInfo(swapDetails.outputMint).isMeme;
54
+ tokenInfo(swapDetails.inputMint)?.isMeme ||
55
+ tokenInfo(swapDetails.outputMint)?.isMeme;
56
56
 
57
57
  return await retryWithExponentialBackoff(
58
58
  async (attemptNum: number) =>
@@ -181,30 +181,10 @@ export async function getJupTokenPrices(
181
181
  }
182
182
 
183
183
  export function safeGetPrice(
184
- mint: PublicKey | UmiPublicKey | undefined
184
+ mint: PublicKey | UmiPublicKey | string | undefined
185
185
  ): number | undefined {
186
186
  if (mint && mint?.toString() in PRICES) {
187
187
  return PRICES[mint!.toString()].price;
188
188
  }
189
189
  return undefined;
190
- }
191
-
192
- export async function getPriceImpact(
193
- inputMint: PublicKey,
194
- outputMint: PublicKey,
195
- amount: bigint,
196
- swapMode: QuoteGetSwapModeEnum
197
- ) {
198
- const quoteResponse = await getJupQuote({
199
- inputMint,
200
- outputMint,
201
- amount,
202
- exactIn: swapMode === "ExactIn",
203
- exactOut: swapMode === "ExactOut",
204
- });
205
-
206
- return {
207
- priceImpact: parseFloat(quoteResponse.priceImpactPct),
208
- quote: quoteResponse,
209
- };
210
- }
190
+ }
@@ -1,5 +1,5 @@
1
1
  import { describe, it } from "mocha";
2
- import { none, publicKey, some, Umi } from "@metaplex-foundation/umi";
2
+ import { none, publicKey, some } from "@metaplex-foundation/umi";
3
3
  import { setupTest } from "../shared";
4
4
  import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
5
5
  import {
@@ -43,29 +43,6 @@ import {
43
43
  import { PriorityFeeSetting } from "../../src/types";
44
44
  import { buildIronforgeApiUrl, fromBaseUnit, tokenInfo, USD_DECIMALS } from "../../dist";
45
45
 
46
- async function getAssets(
47
- umi: Umi,
48
- mints: PublicKey[]
49
- ) {
50
- const response = await fetch(umi.rpc.getEndpoint(), {
51
- method: 'POST',
52
- headers: {
53
- 'Content-Type': 'application/json',
54
- },
55
- body: JSON.stringify({
56
- jsonrpc: '2.0',
57
- id: 'get-assets',
58
- method: 'getAssetBatch',
59
- params: {
60
- ids: mints.map((x) => x.toString()),
61
- },
62
- }),
63
- });
64
- const res = await response.json();
65
- return res;
66
- }
67
-
68
-
69
46
  describe("Solauto Marginfi tests", async () => {
70
47
  // const signer = setupTest();
71
48
  const signer = setupTest("solauto-manager");
@@ -85,21 +62,18 @@ describe("Solauto Marginfi tests", async () => {
85
62
  const supplyDecimals = 6;
86
63
  const debtDecimals = 6;
87
64
 
88
- // await client.initialize({
89
- // signer,
90
- // positionId,
91
- // authority: new PublicKey("FKYQs7KgRvaKQHxXwb8HKfoBcFdSxLL3JvHWpPdVQ16v"),
92
- // // new: true,
93
- // // marginfiAccount: new PublicKey(
94
- // // ""
95
- // // ),
96
- // // marginfiGroup: new PublicKey(""),
97
- // // supplyMint: new PublicKey(""),
98
- // // debtMint: new PublicKey(USDC),
99
- // });
100
-
101
- console.log(await getAssets(client.umi, [NATIVE_MINT, new PublicKey(USDC)]));
102
- return;
65
+ await client.initialize({
66
+ signer,
67
+ positionId,
68
+ authority: new PublicKey("FKYQs7KgRvaKQHxXwb8HKfoBcFdSxLL3JvHWpPdVQ16v"),
69
+ // new: true,
70
+ // marginfiAccount: new PublicKey(
71
+ // ""
72
+ // ),
73
+ // marginfiGroup: new PublicKey(""),
74
+ // supplyMint: new PublicKey(""),
75
+ // debtMint: new PublicKey(USDC),
76
+ });
103
77
 
104
78
  const transactionItems: TransactionItem[] = [];
105
79
  // const settingParams: SolautoSettingsParametersInpArgs = {