@haven-fi/solauto-sdk 1.0.546 → 1.0.548

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 +1 @@
1
- {"version":3,"file":"jupiterUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jupiterUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA0B,MAAM,iBAAiB,CAAC;AAGpE,OAAO,EAGL,aAAa,EACd,MAAM,aAAa,CAAC;AAUrB,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,YAAY;IAClD,iBAAiB,EAAE,SAAS,CAAC;IAC7B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAgBD,wBAAsB,WAAW,CAAC,WAAW,EAAE,YAAY,0BAsB1D;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;IAC/B,iBAAiB,EAAE,kBAAkB,CAAC;IACtC,aAAa,CAAC,EAAE,kBAAkB,CAAC;IACnC,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,cAAc,EAC3B,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,kBAAkB,CAAC,CAoF7B;AAED,wBAAsB,eAAe,CACnC,KAAK,E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 +23,6 @@ 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;
28
26
  return await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum) => await jupApi.quoteGet({
29
27
  amount: Number(swapDetails.amount),
30
28
  inputMint: swapDetails.inputMint.toString(),
@@ -34,7 +32,7 @@ async function getJupQuote(swapDetails) {
34
32
  : swapDetails.exactIn
35
33
  ? "ExactIn"
36
34
  : undefined,
37
- slippageBps: memecoinSwap ? 500 : 200,
35
+ slippageBps: 300,
38
36
  maxAccounts: !swapDetails.exactOut ? 15 + attemptNum * 5 : undefined,
39
37
  }), 3, 200);
40
38
  }
@@ -1,6 +1,7 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  export declare const StrategyTypes: readonly ["Long", "Short", "Ratio"];
3
3
  export type StrategyType = (typeof StrategyTypes)[number];
4
+ export declare function ratioName(supplyMint?: PublicKey, debtMint?: PublicKey): string;
4
5
  export declare function solautoStrategyName(supplyMint?: PublicKey, debtMint?: PublicKey): string;
5
6
  export declare function strategyType(supplyMint: PublicKey, debtMint: PublicKey): StrategyType;
6
7
  //# sourceMappingURL=stringUtils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,aAAa,qCAAsC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAoB1D,wBAAgB,mBAAmB,CACjC,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,UAwBrB;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,GAClB,YAAY,CAWd"}
1
+ {"version":3,"file":"stringUtils.d.ts","sourceRoot":"","sources":["../../src/utils/stringUtils.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG5C,eAAO,MAAM,aAAa,qCAAsC,CAAC;AACjE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,CAAC,CAAC;AAoB1D,wBAAgB,SAAS,CAAC,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,SAAS,UAWrE;AAED,wBAAgB,mBAAmB,CACjC,UAAU,CAAC,EAAE,SAAS,EACtB,QAAQ,CAAC,EAAE,SAAS,UAcrB;AAED,wBAAgB,YAAY,CAC1B,UAAU,EAAE,SAAS,EACrB,QAAQ,EAAE,SAAS,GAClB,YAAY,CAWd"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.StrategyTypes = void 0;
4
+ exports.ratioName = ratioName;
4
5
  exports.solautoStrategyName = solautoStrategyName;
5
6
  exports.strategyType = strategyType;
6
7
  const spl_token_1 = require("@solana/spl-token");
@@ -25,22 +26,24 @@ function adjustedTicker(mint) {
25
26
  return info.ticker;
26
27
  }
27
28
  }
29
+ function ratioName(supplyMint, debtMint) {
30
+ if (((0, generalUtils_1.tokenInfo)(supplyMint).isLST && debtMint?.equals(spl_token_1.NATIVE_MINT)) ||
31
+ (supplyMint &&
32
+ debtMint &&
33
+ MAJORS_PRIO[supplyMint.toString()] > MAJORS_PRIO[debtMint.toString()])) {
34
+ return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
35
+ }
36
+ else {
37
+ return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
38
+ }
39
+ }
28
40
  function solautoStrategyName(supplyMint, debtMint) {
29
- const supplyInfo = (0, generalUtils_1.tokenInfo)(supplyMint);
30
41
  const strat = strategyType(supplyMint ?? web3_js_1.PublicKey.default, debtMint ?? web3_js_1.PublicKey.default);
31
42
  if (strat === "Long") {
32
43
  return `${adjustedTicker(supplyMint)} Long`;
33
44
  }
34
45
  else if (strat === "Ratio") {
35
- if ((supplyInfo.isLST && debtMint?.equals(spl_token_1.NATIVE_MINT)) ||
36
- (supplyMint &&
37
- debtMint &&
38
- MAJORS_PRIO[supplyMint.toString()] > MAJORS_PRIO[debtMint.toString()])) {
39
- return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
40
- }
41
- else {
42
- return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
43
- }
46
+ return ratioName(supplyMint, debtMint);
44
47
  }
45
48
  else {
46
49
  return `${adjustedTicker(debtMint)} Short`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.546",
3
+ "version": "1.0.548",
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",
@@ -50,10 +50,6 @@ function createTransactionInstruction(
50
50
  }
51
51
 
52
52
  export async function getJupQuote(swapDetails: JupSwapInput) {
53
- const memecoinSwap =
54
- tokenInfo(swapDetails.inputMint).isMeme ||
55
- tokenInfo(swapDetails.outputMint).isMeme;
56
-
57
53
  return await retryWithExponentialBackoff(
58
54
  async (attemptNum: number) =>
59
55
  await jupApi.quoteGet({
@@ -65,7 +61,7 @@ export async function getJupQuote(swapDetails: JupSwapInput) {
65
61
  : swapDetails.exactIn
66
62
  ? "ExactIn"
67
63
  : undefined,
68
- slippageBps: memecoinSwap ? 500 : 200,
64
+ slippageBps: 300,
69
65
  maxAccounts: !swapDetails.exactOut ? 15 + attemptNum * 5 : undefined,
70
66
  }),
71
67
  3,
@@ -24,11 +24,23 @@ function adjustedTicker(mint?: PublicKey) {
24
24
  }
25
25
  }
26
26
 
27
+ export function ratioName(supplyMint?: PublicKey, debtMint?: PublicKey) {
28
+ if (
29
+ (tokenInfo(supplyMint).isLST && debtMint?.equals(NATIVE_MINT)) ||
30
+ (supplyMint &&
31
+ debtMint &&
32
+ MAJORS_PRIO[supplyMint!.toString()] > MAJORS_PRIO[debtMint!.toString()])
33
+ ) {
34
+ return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
35
+ } else {
36
+ return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
37
+ }
38
+ }
39
+
27
40
  export function solautoStrategyName(
28
41
  supplyMint?: PublicKey,
29
42
  debtMint?: PublicKey
30
43
  ) {
31
- const supplyInfo = tokenInfo(supplyMint);
32
44
  const strat = strategyType(
33
45
  supplyMint ?? PublicKey.default,
34
46
  debtMint ?? PublicKey.default
@@ -37,16 +49,7 @@ export function solautoStrategyName(
37
49
  if (strat === "Long") {
38
50
  return `${adjustedTicker(supplyMint)} Long`;
39
51
  } else if (strat === "Ratio") {
40
- if (
41
- (supplyInfo.isLST && debtMint?.equals(NATIVE_MINT)) ||
42
- (supplyMint &&
43
- debtMint &&
44
- MAJORS_PRIO[supplyMint!.toString()] > MAJORS_PRIO[debtMint!.toString()])
45
- ) {
46
- return `${adjustedTicker(supplyMint)}/${adjustedTicker(debtMint)} Long`;
47
- } else {
48
- return `${adjustedTicker(debtMint)}/${adjustedTicker(supplyMint)} Short`;
49
- }
52
+ return ratioName(supplyMint, debtMint);
50
53
  } else {
51
54
  return `${adjustedTicker(debtMint)} Short`;
52
55
  }
@@ -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 = {