@haven-fi/solauto-sdk 1.0.394 → 1.0.395

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":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AAwMD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAuE/B"}
1
+ {"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAIV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEJ,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAKlE,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,SAAS,CAAC,CAa9D;AA2MD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CAuE/B"}
@@ -75,16 +75,17 @@ async function simulateJitoBundle(umi, txs) {
75
75
  "Content-Type": "application/json",
76
76
  },
77
77
  });
78
- const res = resp.data.result.value;
79
- if (res && res.summary.failed) {
80
- const transactionResults = res.transactionResults;
78
+ const res = resp.data;
79
+ if (res.result.value && res.result.value.summary.failed) {
80
+ const resValue = res.result.value;
81
+ const transactionResults = resValue.transactionResults;
81
82
  transactionResults.forEach((x) => {
82
83
  x.logs?.forEach((y) => {
83
84
  (0, generalUtils_1.consoleLog)(y);
84
85
  });
85
86
  });
86
87
  const failedTxIdx = transactionResults.length;
87
- const txFailure = res.summary.failed.error.TransactionFailure;
88
+ const txFailure = resValue.summary.failed.error.TransactionFailure;
88
89
  if (txFailure) {
89
90
  const info = parseJitoErrorMessage(txFailure[1]);
90
91
  if (info) {
@@ -95,7 +96,10 @@ async function simulateJitoBundle(umi, txs) {
95
96
  });
96
97
  }
97
98
  }
98
- throw new Error(txFailure ? txFailure[1] : res.summary.failed.toString());
99
+ throw new Error(txFailure ? txFailure[1] : resValue.summary.failed.toString());
100
+ }
101
+ else if (res.error.message) {
102
+ throw new Error(res.error.message);
99
103
  }
100
104
  return res;
101
105
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.394",
3
+ "version": "1.0.395",
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",
@@ -103,11 +103,12 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
103
103
  }
104
104
  );
105
105
 
106
- const res = resp.data.result.value as any;
106
+ const res = resp.data as any;
107
107
 
108
- if (res && res.summary.failed) {
108
+ if (res.result.value && res.result.value.summary.failed) {
109
+ const resValue = res.result.value;
109
110
  const transactionResults =
110
- res.transactionResults as SimulatedTransactionResponse[];
111
+ resValue.transactionResults as SimulatedTransactionResponse[];
111
112
  transactionResults.forEach((x) => {
112
113
  x.logs?.forEach((y) => {
113
114
  consoleLog(y);
@@ -115,7 +116,7 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
115
116
  });
116
117
 
117
118
  const failedTxIdx = transactionResults.length;
118
- const txFailure = res.summary.failed.error.TransactionFailure;
119
+ const txFailure = resValue.summary.failed.error.TransactionFailure;
119
120
 
120
121
  if (txFailure) {
121
122
  const info = parseJitoErrorMessage(txFailure[1] as string);
@@ -128,7 +129,9 @@ async function simulateJitoBundle(umi: Umi, txs: VersionedTransaction[]) {
128
129
  }
129
130
  }
130
131
 
131
- throw new Error(txFailure ? txFailure[1] : res.summary.failed.toString());
132
+ throw new Error(txFailure ? txFailure[1] : resValue.summary.failed.toString());
133
+ } else if (res.error.message) {
134
+ throw new Error(res.error.message);
132
135
  }
133
136
 
134
137
  return res;
@@ -60,12 +60,12 @@ export function getLeverageFactor(
60
60
  }
61
61
 
62
62
  describe("Solauto Marginfi tests", async () => {
63
- const signer = setupTest();
64
- // const signer = setupTest("solauto-manager");
63
+ // const signer = setupTest();
64
+ const signer = setupTest("solauto-manager");
65
65
 
66
66
  const payForTransactions = false;
67
- const testProgram = true;
68
- const positionId = 1;
67
+ const testProgram = false;
68
+ const positionId = 4;
69
69
 
70
70
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
71
71
  const client = new SolautoMarginfiClient(
@@ -78,18 +78,20 @@ describe("Solauto Marginfi tests", async () => {
78
78
  const supplyDecimals = 6;
79
79
  const debtDecimals = 6;
80
80
 
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
- // });
81
+ await client.initialize({
82
+ signer,
83
+ positionId,
84
+ authority: new PublicKey("5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe"),
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(await client.getFreshPositionState());
93
95
 
94
96
  // console.log(JSON.stringify(await getJupPriceData([new PublicKey("7JhmUcZrrfhyt5nTSu3AfsrUq2L9992a7AhwdSDxdoL2")], true), null, 2));
95
97
  // console.log(JSON.stringify(await getJupPriceData([new PublicKey(POPCAT)], true), null, 2));
@@ -133,7 +135,7 @@ describe("Solauto Marginfi tests", async () => {
133
135
  // );
134
136
  // console.log(stateKeverage);
135
137
 
136
- console.log(await fetchTokenPrices([new PublicKey(HMTR)]));
138
+ // console.log(await fetchTokenPrices([new PublicKey(HMTR)]));
137
139
 
138
140
  const transactionItems: TransactionItem[] = [];
139
141
  // const settingParams: SolautoSettingsParametersInpArgs = {
@@ -203,13 +205,13 @@ describe("Solauto Marginfi tests", async () => {
203
205
  // )
204
206
  // );
205
207
 
206
- // transactionItems.push(
207
- // new TransactionItem(
208
- // async (attemptNum) =>
209
- // await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
210
- // "rebalance"
211
- // )
212
- // );
208
+ transactionItems.push(
209
+ new TransactionItem(
210
+ async (attemptNum) =>
211
+ await buildSolautoRebalanceTransaction(client, undefined, attemptNum),
212
+ "rebalance"
213
+ )
214
+ );
213
215
 
214
216
  // transactionItems.push(
215
217
  // new TransactionItem(
@@ -240,44 +242,44 @@ describe("Solauto Marginfi tests", async () => {
240
242
  // )
241
243
  // );
242
244
 
243
- transactionItems.push(
244
- new TransactionItem(
245
- async () => ({
246
- tx: transactionBuilder()
247
- .add(
248
- client.protocolInteraction(
249
- solautoAction("Withdraw", [
250
- { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
251
- ])
252
- )
253
- )
254
- }),
255
- "withdraw"
256
- )
257
- );
245
+ // transactionItems.push(
246
+ // new TransactionItem(
247
+ // async () => ({
248
+ // tx: transactionBuilder()
249
+ // .add(
250
+ // client.protocolInteraction(
251
+ // solautoAction("Withdraw", [
252
+ // { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
253
+ // ])
254
+ // )
255
+ // )
256
+ // }),
257
+ // "withdraw"
258
+ // )
259
+ // );
258
260
 
259
- transactionItems.push(
260
- new TransactionItem(
261
- async () => ({
262
- tx: transactionBuilder()
263
- .add(
264
- client.protocolInteraction(
265
- solautoAction("Withdraw", [
266
- { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
267
- ])
268
- )
269
- )
270
- .add(
271
- client.protocolInteraction(
272
- solautoAction("Withdraw", [
273
- { __kind: "Some", fields: [toBaseUnit(300, 9)] },
274
- ])
275
- )
276
- )
277
- }),
278
- "withdraw"
279
- )
280
- );
261
+ // transactionItems.push(
262
+ // new TransactionItem(
263
+ // async () => ({
264
+ // tx: transactionBuilder()
265
+ // .add(
266
+ // client.protocolInteraction(
267
+ // solautoAction("Withdraw", [
268
+ // { __kind: "Some", fields: [toBaseUnit(0.01, 9)] },
269
+ // ])
270
+ // )
271
+ // )
272
+ // .add(
273
+ // client.protocolInteraction(
274
+ // solautoAction("Withdraw", [
275
+ // { __kind: "Some", fields: [toBaseUnit(300, 9)] },
276
+ // ])
277
+ // )
278
+ // )
279
+ // }),
280
+ // "withdraw"
281
+ // )
282
+ // );
281
283
 
282
284
  // transactionItems.push(
283
285
  // new TransactionItem(
@@ -288,19 +290,19 @@ describe("Solauto Marginfi tests", async () => {
288
290
  // )
289
291
  // );
290
292
 
291
- // const temp = (statuses: TransactionManagerStatuses) =>
292
- // console.log(statuses);
293
+ const temp = (statuses: TransactionManagerStatuses) =>
294
+ console.log(statuses);
293
295
 
294
- // const statuses = await new TransactionsManager(
295
- // client,
296
- // temp,
297
- // !payForTransactions ? "only-simulate" : "normal",
298
- // PriorityFeeSetting.Low,
299
- // true,
300
- // undefined,
301
- // 0
302
- // ).clientSend(transactionItems);
296
+ const statuses = await new TransactionsManager(
297
+ client,
298
+ temp,
299
+ !payForTransactions ? "only-simulate" : "normal",
300
+ PriorityFeeSetting.Low,
301
+ true,
302
+ undefined,
303
+ 0
304
+ ).clientSend(transactionItems);
303
305
 
304
- // console.log(statuses);
306
+ console.log(statuses);
305
307
  });
306
308
  });