@haven-fi/solauto-sdk 1.0.819 → 1.0.820

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":"transactionUtils.d.ts","sourceRoot":"","sources":["../../../src/services/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAiBlC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA4BjE,OAAO,EACL,qBAAqB,EAErB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAyLrB,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAyF7B;AA+LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAuC5C;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO,EAC9B,kBAAkB,CAAC,EAAE,kBAAkB;;;;EAyHxC;AAED,wBAAgB,cAAc,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,8JAKrE"}
1
+ {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../../src/services/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAiBlC,OAAO,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA4BjE,OAAO,EACL,qBAAqB,EAErB,kBAAkB,EACnB,MAAM,aAAa,CAAC;AAyLrB,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAyF7B;AA+LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAuC5C;AAED,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO,EAC9B,kBAAkB,CAAC,EAAE,kBAAkB;;;;EA0IxC;AAED,wBAAgB,cAAc,CAAC,kBAAkB,CAAC,EAAE,kBAAkB,8JAKrE"}
@@ -383,6 +383,14 @@ function getErrorInfo(umi, txs, error, simulationSuccessful, priorityFeeSetting)
383
383
  (0, utils_1.consoleLog)("Error instruction index:", errIxIdx);
384
384
  (0, utils_1.consoleLog)("Error code:", errCode);
385
385
  (0, utils_1.consoleLog)("Error instruction program:", errIx?.programId.toString());
386
+ if (errIx) {
387
+ (0, utils_1.consoleLog)("Error ix data length:", errIx.data.length);
388
+ (0, utils_1.consoleLog)("Error ix num keys:", errIx.keys.length);
389
+ (0, utils_1.consoleLog)("Error ix data (first 64 bytes hex):", Buffer.from(errIx.data.slice(0, 64)).toString("hex"));
390
+ }
391
+ (0, utils_1.consoleLog)("All ixs in failing tx:", txs[errTxIdx]
392
+ ?.getInstructions()
393
+ .map((ix, i) => `[${i}] ${ix.programId.toString()} (data: ${ix.data.length}B, keys: ${ix.keys.length})`));
386
394
  const solautoError = (0, generated_1.getSolautoErrorFromCode)(errCode ?? -1, (0, generated_1.createSolautoProgram)());
387
395
  const marginfiError = (0, marginfi_1.getMarginfiErrorFromCode)(errCode ?? -1, (0, marginfi_1.createMarginfiProgram)());
388
396
  if (errCode !== undefined &&
@@ -1 +1 @@
1
- {"version":3,"file":"switchboardUtils.d.ts","sourceRoot":"","sources":["../../src/utils/switchboardUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAsB,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAC;AAOvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAQjD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,SAAS;;;GAkCnB;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAiD5C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,CAAC,CAuB/D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,WAEzD;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,eAAe,EAAE,iBAkCvB"}
1
+ {"version":3,"file":"switchboardUtils.d.ts","sourceRoot":"","sources":["../../src/utils/switchboardUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAGV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,MAAM,EAAsB,MAAM,0BAA0B,CAAC;AAGtE,OAAO,KAAK,QAAQ,MAAM,4BAA4B,CAAC;AAOvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAQjD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE7D,wBAAsB,WAAW,CAC/B,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,EACf,MAAM,CAAC,EAAE,SAAS;;;GAkCnB;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,GACd,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsE5C;AAED,wBAAsB,sBAAsB,CAC1C,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,EAAE,CAAC,CAuB/D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,MAAM,WAEzD;AAED,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,eAAe,EAAE,iBAkCvB"}
@@ -85,6 +85,21 @@ async function buildSwbSubmitResponseTx(conn, signer, mint) {
85
85
  if (!pullIxs || !pullIxs.length) {
86
86
  throw new Error("Unable to fetch SWB crank IX");
87
87
  }
88
+ (0, generalUtils_1.consoleLog)("SWB pullIxs count:", pullIxs.length);
89
+ pullIxs.forEach((ix, i) => {
90
+ (0, generalUtils_1.consoleLog)(`SWB pullIx[${i}] programId: ${ix.programId.toString()}`);
91
+ (0, generalUtils_1.consoleLog)(`SWB pullIx[${i}] data length: ${ix.data.length}`);
92
+ (0, generalUtils_1.consoleLog)(`SWB pullIx[${i}] keys count: ${ix.keys.length}`);
93
+ if (ix.data.length > 0) {
94
+ (0, generalUtils_1.consoleLog)(`SWB pullIx[${i}] data (first 128 bytes hex): ${Buffer.from(ix.data.slice(0, 128)).toString("hex")}`);
95
+ }
96
+ });
97
+ (0, generalUtils_1.consoleLog)("SWB oracle responses:", responses.length);
98
+ (0, generalUtils_1.consoleLog)("SWB oracle response details:", responses.map((r) => ({
99
+ value: r.value?.toString(),
100
+ error: r.error,
101
+ oracle: r.oracle.pubkey.toString(),
102
+ })));
88
103
  (0, generalUtils_1.consoleLog)("Setting price locally...");
89
104
  const price = responses[0].value.toNumber();
90
105
  (0, generalUtils_1.consoleLog)(price);
@@ -1,5 +1,5 @@
1
1
  import { Keypair, PublicKey } from "@solana/web3.js";
2
- import { createSignerFromKeypair, publicKey } from "@metaplex-foundation/umi";
2
+ import { createSignerFromKeypair, publicKey, signerIdentity } from "@metaplex-foundation/umi";
3
3
  import { fromWeb3JsKeypair } from "@metaplex-foundation/umi-web3js-adapters";
4
4
  import {
5
5
  buildSwbSubmitResponseTx,
@@ -8,10 +8,10 @@ import {
8
8
  fetchBank,
9
9
  getBatches,
10
10
  getClient,
11
- getMarginfiAccounts,
12
11
  getPositionExBulk,
13
12
  getSolanaRpcConnection,
14
13
  getSolautoManagedPositions,
14
+ JITO_SOL,
15
15
  LendingPlatform,
16
16
  LOCAL_IRONFORGE_API_URL,
17
17
  PriceType,
@@ -20,14 +20,13 @@ import {
20
20
  rebalance,
21
21
  safeFetchBank,
22
22
  safeFetchMarginfiAccount,
23
+ sendSingleOptimizedTransaction,
23
24
  SOLAUTO_PROD_PROGRAM,
24
25
  SOLAUTO_TEST_PROGRAM,
25
26
  SolautoClient,
26
27
  TransactionItem,
27
- USDC,
28
28
  } from "../src";
29
29
  import { getSecretKey } from "./shared";
30
- import { NATIVE_MINT } from "@solana/spl-token";
31
30
 
32
31
  const payForTransaction = true;
33
32
  const testProgram = false;
@@ -53,30 +52,15 @@ export async function main() {
53
52
  lpEnv,
54
53
  });
55
54
 
56
- await client.initializeNewSolautoPosition({
57
- // positionId: 1,
58
- positionId: 99,
59
- supplyMint: NATIVE_MINT,
60
- debtMint: new PublicKey(USDC),
61
- lpPoolAccount: getMarginfiAccounts().defaultGroup,
62
- // lpPoolAccount: new PublicKey("GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz")
55
+ await client.initializeExistingSolautoPosition({
56
+ positionId: 1,
57
+ authority: new PublicKey("61rtn5tzVkesapo6Cz83SPoShUfAePSxJsqniuF2wRKC"),
63
58
  // lpUserAccount: new PublicKey(
64
59
  // "GEokw9jqbh6d1xUNA3qaeYFFetbSR5Y1nt7C3chwwgSz"
65
60
  // ),
66
61
  });
67
62
 
68
- // const transactionItems = [rebalance(client)];
69
- const transactionItems: TransactionItem[] = [
70
- new TransactionItem(
71
- async () =>
72
- await buildSwbSubmitResponseTx(
73
- client.connection,
74
- client.signer,
75
- new PublicKey(NATIVE_MINT)
76
- // new PublicKey(JITO_SOL)
77
- )!
78
- ),
79
- ];
63
+ const transactionItems = [rebalance(client)];
80
64
 
81
65
  const txManager = new ClientTransactionsManager({
82
66
  txHandler: client,
@@ -134,5 +118,45 @@ async function refreshAll() {
134
118
  }
135
119
  }
136
120
 
137
- main();
121
+ async function testSwbOracleUpdate() {
122
+ (globalThis as any).SHOW_LOGS = true;
123
+
124
+ let [conn, umiLocal] = getSolanaRpcConnection(
125
+ LOCAL_IRONFORGE_API_URL,
126
+ testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM,
127
+ lpEnv
128
+ );
129
+ umiLocal = umiLocal.use(signerIdentity(signer));
130
+
131
+ const mint = new PublicKey(JITO_SOL);
132
+ console.log("Building SWB oracle update tx for JitoSOL...");
133
+
134
+ const result = await buildSwbSubmitResponseTx(conn, signer, mint);
135
+ if (!result) {
136
+ console.log("No oracle update needed");
137
+ return;
138
+ }
139
+
140
+ console.log("Instructions count:", result.tx.getInstructions().length);
141
+ console.log("Lookup tables:", result.lookupTableAddresses);
142
+
143
+ console.log("Sending transaction...");
144
+ const sig = await sendSingleOptimizedTransaction(
145
+ umiLocal,
146
+ conn,
147
+ result.tx,
148
+ payForTransaction ? "normal" : "only-simulate",
149
+ PriorityFeeSetting.Default
150
+ );
151
+
152
+ if (sig) {
153
+ const bs58 = await import("bs58");
154
+ console.log("Transaction signature:", bs58.default.encode(sig));
155
+ } else {
156
+ console.log("Transaction simulation complete (no sig returned)");
157
+ }
158
+ }
159
+
160
+ // main();
138
161
  // refreshAll();
162
+ testSwbOracleUpdate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.819",
3
+ "version": "1.0.820",
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",
@@ -674,6 +674,23 @@ export function getErrorInfo(
674
674
  consoleLog("Error instruction index:", errIxIdx);
675
675
  consoleLog("Error code:", errCode);
676
676
  consoleLog("Error instruction program:", errIx?.programId.toString());
677
+ if (errIx) {
678
+ consoleLog("Error ix data length:", errIx.data.length);
679
+ consoleLog("Error ix num keys:", errIx.keys.length);
680
+ consoleLog(
681
+ "Error ix data (first 64 bytes hex):",
682
+ Buffer.from(errIx.data.slice(0, 64)).toString("hex")
683
+ );
684
+ }
685
+ consoleLog(
686
+ "All ixs in failing tx:",
687
+ txs[errTxIdx]
688
+ ?.getInstructions()
689
+ .map(
690
+ (ix, i) =>
691
+ `[${i}] ${ix.programId.toString()} (data: ${ix.data.length}B, keys: ${ix.keys.length})`
692
+ )
693
+ );
677
694
 
678
695
  const solautoError = getSolautoErrorFromCode(
679
696
  errCode ?? -1,
@@ -95,6 +95,27 @@ export async function buildSwbSubmitResponseTx(
95
95
  throw new Error("Unable to fetch SWB crank IX");
96
96
  }
97
97
 
98
+ consoleLog("SWB pullIxs count:", pullIxs.length);
99
+ pullIxs.forEach((ix, i) => {
100
+ consoleLog(`SWB pullIx[${i}] programId: ${ix.programId.toString()}`);
101
+ consoleLog(`SWB pullIx[${i}] data length: ${ix.data.length}`);
102
+ consoleLog(`SWB pullIx[${i}] keys count: ${ix.keys.length}`);
103
+ if (ix.data.length > 0) {
104
+ consoleLog(
105
+ `SWB pullIx[${i}] data (first 128 bytes hex): ${Buffer.from(ix.data.slice(0, 128)).toString("hex")}`
106
+ );
107
+ }
108
+ });
109
+ consoleLog("SWB oracle responses:", responses.length);
110
+ consoleLog(
111
+ "SWB oracle response details:",
112
+ responses.map((r) => ({
113
+ value: r.value?.toString(),
114
+ error: r.error,
115
+ oracle: r.oracle.pubkey.toString(),
116
+ }))
117
+ );
118
+
98
119
  consoleLog("Setting price locally...");
99
120
  const price = (responses[0].value as Big).toNumber();
100
121
  consoleLog(price);
package/local/.env DELETED
@@ -1 +0,0 @@
1
- ADDRESS_WHITELIST=5UqsR2PGzbP8pGPbXEeXx86Gjz2N2UFBAuFZUSVydAEe,He4ka5Q3N1UvZikZvykdi47xyk5PoVP2tcQL5sVp31Sz,E5BBsR1sUToPc3jXVwhrK5ttSiy6xhWJDMdQLvkgNppe,DRP5cgM1JpnMySvwg3jqRP2VA2DXSWUjo6VGLkNZ2etb,FtwMsLNn4kBy2kpawC4izM8oUPbmfmbjjKNTcTUUDPzN