@haven-fi/solauto-sdk 1.0.384 → 1.0.385

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.
@@ -190,19 +190,19 @@ exports.MARGINFI_ACCOUNTS = {
190
190
  priceOracle: USDC_PRICE_ORACLE,
191
191
  },
192
192
  },
193
- ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
194
- [tokens.HMTR]: {
195
- bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
196
- liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
197
- vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
198
- priceOracle: switchboardConstants_1.SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
199
- },
200
- [tokens.USDC]: {
201
- bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
202
- liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
203
- vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
204
- priceOracle: USDC_PRICE_ORACLE,
205
- }
206
- }
193
+ // ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
194
+ // [tokens.HMTR]: {
195
+ // bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
196
+ // liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
197
+ // vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
198
+ // priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
199
+ // },
200
+ // [tokens.USDC]: {
201
+ // bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
202
+ // liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
203
+ // vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
204
+ // priceOracle: USDC_PRICE_ORACLE,
205
+ // }
206
+ // }
207
207
  };
208
208
  exports.MARGINFI_ACCOUNTS_LOOKUP_TABLE = "GAjmWmBPcH5Gxbiykasydj6RsCEaCLyHEvK6kHdFigc6";
@@ -49,7 +49,7 @@ exports.ALL_SUPPORTED_TOKENS = [
49
49
  exports.POPCAT,
50
50
  exports.RETARDIO,
51
51
  exports.BILLY,
52
- exports.HMTR,
52
+ // HMTR,
53
53
  ];
54
54
  exports.TOKEN_INFO = {
55
55
  [web3_js_1.PublicKey.default.toString()]: {
@@ -161,9 +161,9 @@ exports.TOKEN_INFO = {
161
161
  decimals: 6,
162
162
  isMeme: true,
163
163
  },
164
- [exports.HMTR]: {
165
- ticker: "HMTR",
166
- decimals: 0,
167
- isMeme: true,
168
- },
164
+ // [HMTR]: {
165
+ // ticker: "HMTR",
166
+ // decimals: 0,
167
+ // isMeme: true,
168
+ // },
169
169
  };
@@ -19,4 +19,7 @@ export interface JupSwapTransaction {
19
19
  swapIx: TransactionBuilder;
20
20
  }
21
21
  export declare function getJupSwapTransaction(signer: Signer, swapDetails: JupSwapDetails, attemptNum?: number): Promise<JupSwapTransaction>;
22
+ export declare function getJupPriceData(mints: PublicKey[], extraInfo?: boolean): Promise<{
23
+ [key: string]: any;
24
+ }>;
22
25
  //# sourceMappingURL=jupiterUtils.d.ts.map
@@ -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;AAOrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgBD,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,EAAE,kBAAkB,CAAC;IAClC,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,CAsF7B"}
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;AAOrB,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;IACtB,iBAAiB,EAAE,SAAS,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAgBD,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,EAAE,kBAAkB,CAAC;IAClC,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,CAsF7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;GAY5E"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getJupSwapTransaction = getJupSwapTransaction;
4
+ exports.getJupPriceData = getJupPriceData;
4
5
  const umi_1 = require("@metaplex-foundation/umi");
5
6
  const web3_js_1 = require("@solana/web3.js");
6
7
  const solanaUtils_1 = require("./solanaUtils");
@@ -33,7 +34,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
33
34
  : swapDetails.exactIn
34
35
  ? "ExactIn"
35
36
  : undefined,
36
- slippageBps: memecoinSwap ? 150 : 50,
37
+ slippageBps: memecoinSwap ? 500 : 50,
37
38
  maxAccounts: !swapDetails.exactOut ? 50 : undefined,
38
39
  }), 4, 200);
39
40
  const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
@@ -70,3 +71,11 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
70
71
  swapIx: (0, umi_1.transactionBuilder)().add((0, solanaUtils_1.getWrappedInstruction)(signer, createTransactionInstruction(instructions.swapInstruction))),
71
72
  };
72
73
  }
74
+ async function getJupPriceData(mints, extraInfo) {
75
+ const data = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
76
+ const res = (await fetch("https://api.jup.ag/price/v2?ids=" +
77
+ mints.map((x) => x.toString()).join(",") + (extraInfo ? "&showExtraInfo=true" : ""))).json();
78
+ return res;
79
+ }, 6);
80
+ return data.data;
81
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAarE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CA6CnB;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,qBAoBzD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB"}
1
+ {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAcrE,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAqC5E;AAED,wBAAsB,aAAa,CAAC,KAAK,EAAE,SAAS,EAAE,qBAwCrD;AAED,wBAAsB,oBAAoB,CACxC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,EAAE,CAAC,CA+CnB;AAED,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,qBAYzD;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB"}
@@ -11,6 +11,7 @@ const solautoConstants_1 = require("../constants/solautoConstants");
11
11
  const switchboardConstants_1 = require("../constants/switchboardConstants");
12
12
  const generalUtils_1 = require("./generalUtils");
13
13
  const on_demand_1 = require("@switchboard-xyz/on-demand");
14
+ const jupiterUtils_1 = require("./jupiterUtils");
14
15
  async function fetchTokenPrices(mints) {
15
16
  const currentTime = (0, generalUtils_1.currentUnixSeconds)();
16
17
  if (!mints.some((mint) => !(mint.toString() in solautoConstants_1.PRICES) ||
@@ -94,12 +95,8 @@ async function getJupTokenPrices(mints) {
94
95
  if (mints.length == 0) {
95
96
  return [];
96
97
  }
97
- const data = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
98
- const res = (await fetch("https://api.jup.ag/price/v2?ids=" +
99
- mints.map((x) => x.toString()).join(","))).json();
100
- return res;
101
- }, 6);
102
- const prices = Object.values(data.data).map((x) => parseFloat(x.price));
98
+ const data = await (0, jupiterUtils_1.getJupPriceData)(mints);
99
+ const prices = Object.values(data).map((x) => parseFloat(x.price));
103
100
  return prices;
104
101
  }
105
102
  function safeGetPrice(mint) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.384",
3
+ "version": "1.0.385",
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",
@@ -172,20 +172,20 @@ export const MARGINFI_ACCOUNTS: {
172
172
  priceOracle: USDC_PRICE_ORACLE,
173
173
  },
174
174
  },
175
- ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
176
- [tokens.HMTR]: {
177
- bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
178
- liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
179
- vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
180
- priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
181
- },
182
- [tokens.USDC]: {
183
- bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
184
- liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
185
- vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
186
- priceOracle: USDC_PRICE_ORACLE,
187
- }
188
- }
175
+ // ["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"]: {
176
+ // [tokens.HMTR]: {
177
+ // bank: "Br3yzg2WSb81RaFWK9UsKtq8fD5viwooZG34mKqQWxdM",
178
+ // liquidityVault: "J45Je52qv2rDBuCQWPwp3bjRhf3bGzRWhKZtGDuLooCX",
179
+ // vaultAuthority: "CKDsAKjNruDSz4tmUairh8PDGD1Rqh9WMTLWERYnnZrH",
180
+ // priceOracle: SWITCHBOARD_PRICE_FEED_IDS[tokens.HMTR.toString()],
181
+ // },
182
+ // [tokens.USDC]: {
183
+ // bank: "9yNnhJ8c1vGbu3DMf6eeeUi6TDJ2ddGgaRA88rL2R3rP",
184
+ // liquidityVault: "4U1UBjXrPrW7JuQ894JbLUBqcb5LFfK9rfkWFwT7EdQ9",
185
+ // vaultAuthority: "CY74V1r48kuuHA6APD3AaU2oPV1mBqe9srikrQQSHNR6",
186
+ // priceOracle: USDC_PRICE_ORACLE,
187
+ // }
188
+ // }
189
189
  };
190
190
 
191
191
  export const MARGINFI_ACCOUNTS_LOOKUP_TABLE =
@@ -48,7 +48,7 @@ export const ALL_SUPPORTED_TOKENS = [
48
48
  POPCAT,
49
49
  RETARDIO,
50
50
  BILLY,
51
- HMTR,
51
+ // HMTR,
52
52
  ];
53
53
 
54
54
  interface TokenInfo {
@@ -170,9 +170,9 @@ export const TOKEN_INFO: { [key: string]: TokenInfo } = {
170
170
  decimals: 6,
171
171
  isMeme: true,
172
172
  },
173
- [HMTR]: {
174
- ticker: "HMTR",
175
- decimals: 0,
176
- isMeme: true,
177
- },
173
+ // [HMTR]: {
174
+ // ticker: "HMTR",
175
+ // decimals: 0,
176
+ // isMeme: true,
177
+ // },
178
178
  };
@@ -70,7 +70,7 @@ export async function getJupSwapTransaction(
70
70
  : swapDetails.exactIn
71
71
  ? "ExactIn"
72
72
  : undefined,
73
- slippageBps: memecoinSwap ? 150 : 50,
73
+ slippageBps: memecoinSwap ? 500 : 50,
74
74
  maxAccounts: !swapDetails.exactOut ? 50 : undefined,
75
75
  }),
76
76
  4,
@@ -140,4 +140,18 @@ export async function getJupSwapTransaction(
140
140
  )
141
141
  ),
142
142
  };
143
- }
143
+ }
144
+
145
+ export async function getJupPriceData(mints: PublicKey[], extraInfo?: boolean) {
146
+ const data = await retryWithExponentialBackoff(async () => {
147
+ const res = (
148
+ await fetch(
149
+ "https://api.jup.ag/price/v2?ids=" +
150
+ mints.map((x) => x.toString()).join(",") + (extraInfo ? "&showExtraInfo=true" : "")
151
+ )
152
+ ).json();
153
+ return res;
154
+ }, 6);
155
+
156
+ return data.data as { [key: string]: any };
157
+ }
@@ -11,6 +11,7 @@ import {
11
11
  zip,
12
12
  } from "./generalUtils";
13
13
  import { CrossbarClient } from "@switchboard-xyz/on-demand";
14
+ import { getJupPriceData } from "./jupiterUtils";
14
15
 
15
16
  export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
16
17
  const currentTime = currentUnixSeconds();
@@ -110,12 +111,12 @@ export async function getSwitchboardPrices(
110
111
  "mainnet",
111
112
  mints.map((x) => SWITCHBOARD_PRICE_FEED_IDS[x.toString()])
112
113
  );
113
-
114
+
114
115
  const p = res.flatMap((x) => x.results[0]);
115
116
  if (p.filter((x) => !x || isNaN(Number(x))).length > 0) {
116
117
  throw new Error("Unable to fetch Switchboard prices");
117
118
  }
118
-
119
+
119
120
  return p;
120
121
  },
121
122
  2,
@@ -129,7 +130,9 @@ export async function getSwitchboardPrices(
129
130
  prices = Array(mints.length).fill(0);
130
131
  }
131
132
 
132
- const missingPrices = zip(mints, prices).filter((x) => !x[1] || isNaN(Number(x)));
133
+ const missingPrices = zip(mints, prices).filter(
134
+ (x) => !x[1] || isNaN(Number(x))
135
+ );
133
136
  const jupPrices = zip(
134
137
  missingPrices.map((x) => x[0]),
135
138
  await getJupTokenPrices(missingPrices.map((x) => x[0]))
@@ -147,17 +150,9 @@ export async function getJupTokenPrices(mints: PublicKey[]) {
147
150
  return [];
148
151
  }
149
152
 
150
- const data = await retryWithExponentialBackoff(async () => {
151
- const res = (
152
- await fetch(
153
- "https://api.jup.ag/price/v2?ids=" +
154
- mints.map((x) => x.toString()).join(",")
155
- )
156
- ).json();
157
- return res;
158
- }, 6);
159
-
160
- const prices = Object.values(data.data as { [key: string]: any }).map(
153
+ const data = await getJupPriceData(mints);
154
+
155
+ const prices = Object.values(data).map(
161
156
  (x) => parseFloat(x.price as string) as number
162
157
  );
163
158
 
@@ -10,10 +10,14 @@ import {
10
10
  } from "../../src/generated";
11
11
  import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
12
12
  import {
13
+ fromBaseUnit,
14
+ getDebtAdjustmentUsd,
15
+ getMaxLiqUtilizationRateBps,
13
16
  maxBoostToBps,
14
17
  maxRepayFromBps,
15
18
  maxRepayToBps,
16
19
  toBaseUnit,
20
+ toBps,
17
21
  } from "../../src/utils/numberUtils";
18
22
  import { NATIVE_MINT } from "@solana/spl-token";
19
23
  import {
@@ -22,16 +26,38 @@ import {
22
26
  } from "../../src/transactions/transactionsManager";
23
27
  import { PublicKey } from "@solana/web3.js";
24
28
  import {
29
+ B_SOL,
30
+ DEFAULT_MARGINFI_GROUP,
25
31
  HMTR,
32
+ JITO_SOL,
33
+ JLP,
34
+ POPCAT,
35
+ RETARDIO,
26
36
  SOLAUTO_PROD_PROGRAM,
27
37
  SOLAUTO_TEST_PROGRAM,
38
+ USD_DECIMALS,
28
39
  USDC,
40
+ WETH,
29
41
  } from "../../src/constants";
30
- import { buildHeliusApiUrl, getAllPositionsByAuthority, getJupTokenPrices, getSolautoManagedPositions } from "../../src/utils";
42
+ import { buildHeliusApiUrl, calcMarginfiMaxLtvAndLiqThreshold, fetchTokenPrices, getAllPositionsByAuthority, getJupPriceData, getJupTokenPrices, getMarginfiAccountPositionState, getSolautoManagedPositions, safeGetPrice } from "../../src/utils";
31
43
  import { PriorityFeeSetting } from "../../src/types";
32
- import { buildIronforgeApiUrl, TransactionManagerStatuses } from "../../dist";
44
+ import { buildIronforgeApiUrl, MARGINFI_ACCOUNTS, TransactionManagerStatuses } from "../../dist";
33
45
  import { connect } from "http2";
34
46
  import CommonClient from "rpc-websockets/dist/lib/client";
47
+ import { safeFetchAllBank } from "../../src/marginfi-sdk";
48
+
49
+ export function getLeverageFactor(
50
+ strategyType: "Long" | "Short",
51
+ supplyUsd: number,
52
+ debtUsd: number
53
+ ): number {
54
+ let levFactor =
55
+ (strategyType === 'Long' ? supplyUsd : debtUsd) / (supplyUsd - debtUsd);
56
+ if (strategyType === 'Short') {
57
+ levFactor += 1;
58
+ }
59
+ return levFactor;
60
+ }
35
61
 
36
62
  describe("Solauto Marginfi tests", async () => {
37
63
  const signer = setupTest();
@@ -52,18 +78,57 @@ describe("Solauto Marginfi tests", async () => {
52
78
  const supplyDecimals = 6;
53
79
  const debtDecimals = 6;
54
80
 
55
- await client.initialize({
56
- signer,
57
- positionId,
58
- authority: new PublicKey("rC5dMP5dmSsfQ66rynzfFzuc122Eex9h1RJHVDkeH6D"),
59
- // new: true,
60
- // marginfiAccount: new PublicKey(
61
- // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
62
- // ),
63
- // marginfiGroup: new PublicKey("G1rt3EpQ43K3bY457rhukQGRAo2QxydFAGRKqnjKzyr5"),
64
- // supplyMint: new PublicKey("3B5wuUrMEi5yATD7on46hKfej3pfmd7t1RKgrsN3pump"),
65
- // debtMint: new PublicKey(USDC),
66
- });
81
+ // await client.initialize({
82
+ // signer,
83
+ // positionId,
84
+ // authority: new PublicKey("rC5dMP5dmSsfQ66rynzfFzuc122Eex9h1RJHVDkeH6D"),
85
+ // // new: true,
86
+ // // marginfiAccount: new PublicKey(
87
+ // // "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
88
+ // // ),
89
+ // // marginfiGroup: new PublicKey("G1rt3EpQ43K3bY457rhukQGRAo2QxydFAGRKqnjKzyr5"),
90
+ // // supplyMint: new PublicKey("3B5wuUrMEi5yATD7on46hKfej3pfmd7t1RKgrsN3pump"),
91
+ // // debtMint: new PublicKey(USDC),
92
+ // });
93
+
94
+ // console.log(JSON.stringify(await getJupPriceData([new PublicKey("7JhmUcZrrfhyt5nTSu3AfsrUq2L9992a7AhwdSDxdoL2")], true), null, 2));
95
+ // console.log(JSON.stringify(await getJupPriceData([new PublicKey(POPCAT)], true), null, 2));
96
+
97
+ // const accounts = MARGINFI_ACCOUNTS["DESG67cExEcw7d6MmENLEzaocR8pLrhfiw9VrNtGWUKD"];
98
+ // const accounts = MARGINFI_ACCOUNTS[DEFAULT_MARGINFI_GROUP];
99
+ // const [supplyBank, debtBank] = await safeFetchAllBank(client.umi, [publicKey(accounts[USDC].bank), publicKey(accounts[tokenMint].bank)]);
100
+
101
+ // console.log(supplyBank, debtBank);
102
+ // const [maxLtv, liqThreshold] = calcMarginfiMaxLtvAndLiqThreshold(
103
+ // supplyBank,
104
+ // debtBank,
105
+ // safeGetPrice(new PublicKey(USDC)) ?? 0
106
+ // );
107
+
108
+ // console.log(maxLtv, liqThreshold);
109
+
110
+ // const supplyUsd = 100;
111
+ // const debtAdjustmentUsd = getDebtAdjustmentUsd(
112
+ // toBps(liqThreshold),
113
+ // supplyUsd,
114
+ // 0,
115
+ // maxBoostToBps(toBps(maxLtv), toBps(liqThreshold))
116
+ // // getMaxLiqUtilizationRateBps(toBps(maxLtv), toBps(liqThreshold), 0.005)
117
+ // );
118
+ // const maxLeverage = getLeverageFactor(
119
+ // "Short",
120
+ // supplyUsd + debtAdjustmentUsd,
121
+ // debtAdjustmentUsd
122
+ // );
123
+ // console.log(maxLeverage, supplyUsd + debtAdjustmentUsd, debtAdjustmentUsd);
124
+
125
+ // const state = await getMarginfiAccountPositionState(client.umi, { pk: new PublicKey("GSw9ewsUgmuzDRJGYvSzkPPZgXfDszuGx7y22zMWSQkS") });
126
+ // const stateKeverage = getLeverageFactor(
127
+ // "Short",
128
+ // fromBaseUnit(state.supply.amountUsed.baseAmountUsdValue, USD_DECIMALS),
129
+ // fromBaseUnit(state.debt.amountUsed.baseAmountUsdValue, USD_DECIMALS)
130
+ // );
131
+ // console.log(stateKeverage);
67
132
 
68
133
  // console.log(await getJupTokenPrices([new PublicKey(HMTR)]));
69
134
 
@@ -220,19 +285,19 @@ describe("Solauto Marginfi tests", async () => {
220
285
  // )
221
286
  // );
222
287
 
223
- const temp = (statuses: TransactionManagerStatuses) =>
224
- console.log(statuses);
288
+ // const temp = (statuses: TransactionManagerStatuses) =>
289
+ // console.log(statuses);
225
290
 
226
- const statuses = await new TransactionsManager(
227
- client,
228
- temp,
229
- !payForTransactions ? "only-simulate" : "normal",
230
- PriorityFeeSetting.Low,
231
- true,
232
- undefined,
233
- 0
234
- ).clientSend(transactionItems);
291
+ // const statuses = await new TransactionsManager(
292
+ // client,
293
+ // temp,
294
+ // !payForTransactions ? "only-simulate" : "normal",
295
+ // PriorityFeeSetting.Low,
296
+ // true,
297
+ // undefined,
298
+ // 0
299
+ // ).clientSend(transactionItems);
235
300
 
236
- console.log(statuses);
301
+ // console.log(statuses);
237
302
  });
238
303
  });