@haven-fi/solauto-sdk 1.0.447 → 1.0.449
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.
- package/dist/transactions/transactionUtils.js +1 -1
- package/dist/utils/jupiterUtils.d.ts.map +1 -1
- package/dist/utils/jupiterUtils.js +5 -2
- package/local/logPositions.ts +4 -4
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +1 -1
- package/src/utils/jupiterUtils.ts +7 -2
- package/tests/transactions/solautoMarginfi.ts +8 -8
@@ -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;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;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,CAiG7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;
|
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;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;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,CAiG7B;AAED,wBAAsB,eAAe,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC,EAAE,OAAO;;GAsB5E"}
|
@@ -35,7 +35,7 @@ async function getJupSwapTransaction(signer, swapDetails, attemptNum) {
|
|
35
35
|
? "ExactIn"
|
36
36
|
: undefined,
|
37
37
|
slippageBps: memecoinSwap ? 500 : 300,
|
38
|
-
maxAccounts: !swapDetails.exactOut ?
|
38
|
+
maxAccounts: !swapDetails.exactOut ? 40 : undefined,
|
39
39
|
}), 4, 200);
|
40
40
|
const priceImpactBps = Math.round((0, numberUtils_1.toBps)(parseFloat(quoteResponse.priceImpactPct))) + 1;
|
41
41
|
const finalPriceSlippageBps = Math.round(Math.max(50, quoteResponse.slippageBps, priceImpactBps) *
|
@@ -82,7 +82,10 @@ async function getJupPriceData(mints, extraInfo) {
|
|
82
82
|
mints.map((x) => x.toString()).join(",") +
|
83
83
|
(extraInfo ? "&showExtraInfo=true" : ""))).json();
|
84
84
|
const result = res.data;
|
85
|
-
if (!result
|
85
|
+
if (!result ||
|
86
|
+
result === null ||
|
87
|
+
(typeof result === "object" &&
|
88
|
+
Object.values(result).find((x) => !x || x === null))) {
|
86
89
|
throw new Error("Failed to get token prices using Jupiter");
|
87
90
|
}
|
88
91
|
return result;
|
package/local/logPositions.ts
CHANGED
@@ -19,7 +19,6 @@ import { NATIVE_MINT } from "@solana/spl-token";
|
|
19
19
|
import { toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
|
20
20
|
import path from "path";
|
21
21
|
import { config } from "dotenv";
|
22
|
-
import { safeFetchMarginfiAccount } from "../src/marginfi-sdk";
|
23
22
|
|
24
23
|
config({ path: path.join(__dirname, ".env") });
|
25
24
|
|
@@ -203,16 +202,17 @@ async function main(filterWhitelist: boolean) {
|
|
203
202
|
);
|
204
203
|
|
205
204
|
const repayFrom = pos.position.settingParams.repayToBps + pos.position.settingParams.repayGap;
|
206
|
-
const unhealthy =
|
207
|
-
const healthText = unhealthy ? `(Unhealthy: ${
|
205
|
+
const unhealthy = latestState.liqUtilizationRateBps > repayFrom;
|
206
|
+
const healthText = unhealthy ? `(Unhealthy: ${latestState.liqUtilizationRateBps - repayFrom}bps)` : "";
|
208
207
|
if (unhealthy) {
|
209
208
|
unhealthyPositions += 1;
|
210
209
|
}
|
211
210
|
|
212
|
-
console.log(pos.publicKey.toString(), `(${pos.authority.toString()})`);
|
211
|
+
console.log(pos.publicKey.toString(), `(${pos.authority.toString()} ${pos.positionId})`);
|
213
212
|
console.log(
|
214
213
|
`${strategy}: $${formatNumber(fromBaseUnit(latestState.netWorth.baseAmountUsdValue, USD_DECIMALS), 2, 10000, 2)} ${healthText}`
|
215
214
|
);
|
215
|
+
// console.log(latestState.liqUtilizationRateBps, repayFrom);
|
216
216
|
}
|
217
217
|
|
218
218
|
console.log("\nTotal positions:", solautoPositionsData.length, unhealthyPositions ? ` (unhealthy: ${unhealthyPositions})` : "");
|
package/package.json
CHANGED
@@ -845,7 +845,7 @@ export function getErrorInfo(
|
|
845
845
|
let errorName: string | undefined = undefined;
|
846
846
|
let errorInfo: string | undefined = undefined;
|
847
847
|
|
848
|
-
let errTxIdx: number
|
848
|
+
let errTxIdx: number = 0;
|
849
849
|
let errIxIdx: number | undefined;
|
850
850
|
let errCode: number | undefined;
|
851
851
|
let errName: string | undefined;
|
@@ -72,7 +72,7 @@ export async function getJupSwapTransaction(
|
|
72
72
|
? "ExactIn"
|
73
73
|
: undefined,
|
74
74
|
slippageBps: memecoinSwap ? 500 : 300,
|
75
|
-
maxAccounts: !swapDetails.exactOut ?
|
75
|
+
maxAccounts: !swapDetails.exactOut ? 40 : undefined,
|
76
76
|
}),
|
77
77
|
4,
|
78
78
|
200
|
@@ -164,7 +164,12 @@ export async function getJupPriceData(mints: PublicKey[], extraInfo?: boolean) {
|
|
164
164
|
)
|
165
165
|
).json();
|
166
166
|
const result = res.data;
|
167
|
-
if (
|
167
|
+
if (
|
168
|
+
!result ||
|
169
|
+
result === null ||
|
170
|
+
(typeof result === "object" &&
|
171
|
+
Object.values(result).find((x) => !x || x === null))
|
172
|
+
) {
|
168
173
|
throw new Error("Failed to get token prices using Jupiter");
|
169
174
|
}
|
170
175
|
return result;
|
@@ -34,19 +34,19 @@ import {
|
|
34
34
|
getSolautoManagedPositions,
|
35
35
|
} from "../../src/utils";
|
36
36
|
import { PriorityFeeSetting } from "../../src/types";
|
37
|
+
import { buildIronforgeApiUrl } from "../../dist";
|
37
38
|
|
38
39
|
describe("Solauto Marginfi tests", async () => {
|
39
40
|
// const signer = setupTest();
|
40
41
|
const signer = setupTest("solauto-manager");
|
41
42
|
|
42
|
-
const payForTransactions =
|
43
|
+
const payForTransactions = false;
|
43
44
|
const testProgram = false;
|
44
45
|
const positionId = 1;
|
45
46
|
|
46
47
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
47
48
|
const client = new SolautoMarginfiClient(
|
48
|
-
|
49
|
-
"https://staked.helius-rpc.com?api-key=6a7423cf-35ef-44ce-b02b-02567f57d181",
|
49
|
+
buildIronforgeApiUrl(process.env.IRONFORGE_API_KEY!),
|
50
50
|
true,
|
51
51
|
testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM
|
52
52
|
);
|
@@ -58,13 +58,13 @@ describe("Solauto Marginfi tests", async () => {
|
|
58
58
|
await client.initialize({
|
59
59
|
signer,
|
60
60
|
positionId,
|
61
|
-
authority: new PublicKey("
|
61
|
+
authority: new PublicKey("He4ka5Q3N1UvZikZvykdi47xyk5PoVP2tcQL5sVp31Sz"),
|
62
62
|
// new: true,
|
63
63
|
// marginfiAccount: new PublicKey(
|
64
|
-
// "
|
64
|
+
// ""
|
65
65
|
// ),
|
66
|
-
// marginfiGroup: new PublicKey("
|
67
|
-
// supplyMint: new PublicKey("
|
66
|
+
// marginfiGroup: new PublicKey(""),
|
67
|
+
// supplyMint: new PublicKey(""),
|
68
68
|
// debtMint: new PublicKey(USDC),
|
69
69
|
});
|
70
70
|
|
@@ -168,7 +168,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
168
168
|
client,
|
169
169
|
undefined,
|
170
170
|
!payForTransactions ? "only-simulate" : "normal",
|
171
|
-
PriorityFeeSetting.
|
171
|
+
PriorityFeeSetting.Min,
|
172
172
|
true
|
173
173
|
).clientSend(transactionItems);
|
174
174
|
|