@haven-fi/solauto-sdk 1.0.172 → 1.0.174
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/clients/solautoMarginfiClient.d.ts.map +1 -1
- package/dist/clients/solautoMarginfiClient.js +1 -3
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +1 -0
- package/dist/transactions/transactionsManager.js +1 -1
- package/dist/utils/generalUtils.d.ts.map +1 -1
- package/dist/utils/generalUtils.js +24 -19
- package/package.json +1 -1
- package/src/clients/solautoMarginfiClient.ts +1 -4
- package/src/transactions/transactionUtils.ts +5 -0
- package/src/transactions/transactionsManager.ts +1 -1
- package/src/utils/generalUtils.ts +38 -20
- package/tests/transactions/solautoMarginfi.ts +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EAEb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAUnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;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,eAAe,CAAC;IAE/C,UAAU,CAAC,IAAI,EAAE,yBAAyB;IA+D1C,8BAA8B;IA0CpC,eAAe,IAAI,SAAS;IAI5B,mBAAmB,IAAI,MAAM,EAAE;IAI/B,gBAAgB,IAAI,SAAS,EAAE;IAUzB,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IAyBvE,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA+C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAiErB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAwClE"}
|
@@ -334,9 +334,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
|
|
334
334
|
: undefined,
|
335
335
|
rebalanceType,
|
336
336
|
targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
|
337
|
-
targetInAmountBaseUnit:
|
338
|
-
? swapDetails.amount
|
339
|
-
: null,
|
337
|
+
targetInAmountBaseUnit: rebalanceStep === "A" ? swapDetails.amount : null,
|
340
338
|
limitGapBps: limitGapBps ?? null,
|
341
339
|
});
|
342
340
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAEL,aAAa,EAUd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyNzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAKxE,OAAO,EAEL,aAAa,EAUd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAyNzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA+G7B;AAmLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CAoIA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,SAAS,GACtB,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAmCrD"}
|
@@ -336,6 +336,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
336
336
|
const swapDetails = (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, targetLiqUtilizationRateBps, attemptNum);
|
337
337
|
const { jupQuote, priceImpactBps, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
|
338
338
|
const flashLoan = (0, rebalanceUtils_1.getFlashLoanDetails)(client, values, jupQuote, priceImpactBps);
|
339
|
+
console.log((0, generalUtils_1.safeGetPrice)(client.supplyMint), (0, generalUtils_1.safeGetPrice)(client.debtMint));
|
339
340
|
let tx = (0, umi_1.transactionBuilder)();
|
340
341
|
if (flashLoan) {
|
341
342
|
client.log("Flash loan details: ", flashLoan);
|
@@ -191,7 +191,7 @@ class TransactionsManager {
|
|
191
191
|
}
|
192
192
|
}
|
193
193
|
this.txHandler.log(`${name} is ${status.toString().toLowerCase()}`);
|
194
|
-
this.statusCallback?.(this.statuses);
|
194
|
+
this.statusCallback?.([...this.statuses]);
|
195
195
|
}
|
196
196
|
// TODO remove me
|
197
197
|
async debugAccounts(itemSet, tx) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,eAAe,EAEf,GAAG,EACH,SAAS,IAAI,YAAY,EAC1B,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,GACZ,OAAO,CAAC,OAAO,CAAC,CAKlB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAU1E;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAwD5E;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GACzC,MAAM,GAAG,SAAS,CAKpB;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,CAAC;AAEjE,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,GAAE,MAAU,EACnB,KAAK,GAAE,MAAY,EACnB,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
|
@@ -28,7 +28,9 @@ function currentUnixSeconds() {
|
|
28
28
|
return Math.round(new Date().getTime() / 1000);
|
29
29
|
}
|
30
30
|
async function getSolanaAccountCreated(umi, pk) {
|
31
|
-
const account = await umi.rpc.getAccount((0, umi_1.publicKey)(pk), {
|
31
|
+
const account = await umi.rpc.getAccount((0, umi_1.publicKey)(pk), {
|
32
|
+
commitment: "confirmed",
|
33
|
+
});
|
32
34
|
return rpcAccountCreated(account);
|
33
35
|
}
|
34
36
|
function rpcAccountCreated(account) {
|
@@ -53,25 +55,28 @@ async function fetchTokenPrices(mints) {
|
|
53
55
|
}
|
54
56
|
const priceFeedIds = mints.map((mint) => pythConstants_1.PYTH_PRICE_FEED_IDS[mint.toString()]);
|
55
57
|
const getReq = async () => await fetch(`https://hermes.pyth.network/v2/updates/price/latest?${priceFeedIds.map((x) => `ids%5B%5D=${x}`).join("&")}`);
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
const json = await resp.json();
|
64
|
-
const prices = json.parsed.map((x) => {
|
65
|
-
if (x.price.expo > 0) {
|
66
|
-
return Number((0, numberUtils_1.toBaseUnit)(Number(x.price.price), x.price.expo));
|
67
|
-
}
|
68
|
-
else if (x.price.expo < 0) {
|
69
|
-
return (0, numberUtils_1.fromBaseUnit)(BigInt(x.price.price), Math.abs(x.price.expo));
|
58
|
+
const prices = await retryWithExponentialBackoff(async () => {
|
59
|
+
let resp = await getReq();
|
60
|
+
let status = resp.status;
|
61
|
+
while (status !== 200) {
|
62
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
63
|
+
resp = await getReq();
|
64
|
+
status = resp.status;
|
70
65
|
}
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
66
|
+
const json = await resp.json();
|
67
|
+
const prices = json.parsed.map((x) => {
|
68
|
+
if (x.price.expo > 0) {
|
69
|
+
return Number((0, numberUtils_1.toBaseUnit)(Number(x.price.price), x.price.expo));
|
70
|
+
}
|
71
|
+
else if (x.price.expo < 0) {
|
72
|
+
return (0, numberUtils_1.fromBaseUnit)(BigInt(x.price.price), Math.abs(x.price.expo));
|
73
|
+
}
|
74
|
+
else {
|
75
|
+
return Number(x.price.price);
|
76
|
+
}
|
77
|
+
});
|
78
|
+
return prices;
|
79
|
+
}, 5, 200);
|
75
80
|
for (var i = 0; i < mints.length; i++) {
|
76
81
|
solautoConstants_1.PRICES[mints[i].toString()] = {
|
77
82
|
price: prices[i],
|
package/package.json
CHANGED
@@ -514,10 +514,7 @@ export class SolautoMarginfiClient extends SolautoClient {
|
|
514
514
|
: undefined,
|
515
515
|
rebalanceType,
|
516
516
|
targetLiqUtilizationRateBps: targetLiqUtilizationRateBps ?? null,
|
517
|
-
targetInAmountBaseUnit:
|
518
|
-
targetLiqUtilizationRateBps && rebalanceStep === "A"
|
519
|
-
? swapDetails.amount
|
520
|
-
: null,
|
517
|
+
targetInAmountBaseUnit: rebalanceStep === "A" ? swapDetails.amount : null,
|
521
518
|
limitGapBps: limitGapBps ?? null,
|
522
519
|
});
|
523
520
|
}
|
@@ -1,5 +1,10 @@
|
|
1
1
|
import { PublicKey } from "@solana/web3.js";
|
2
|
-
import {
|
2
|
+
import {
|
3
|
+
MaybeRpcAccount,
|
4
|
+
publicKey,
|
5
|
+
Umi,
|
6
|
+
PublicKey as UmiPublicKey,
|
7
|
+
} from "@metaplex-foundation/umi";
|
3
8
|
import { PYTH_PRICE_FEED_IDS } from "../constants/pythConstants";
|
4
9
|
import { fromBaseUnit, toBaseUnit } from "./numberUtils";
|
5
10
|
import { PRICES } from "../constants/solautoConstants";
|
@@ -25,7 +30,9 @@ export async function getSolanaAccountCreated(
|
|
25
30
|
umi: Umi,
|
26
31
|
pk: PublicKey
|
27
32
|
): Promise<boolean> {
|
28
|
-
const account = await umi.rpc.getAccount(publicKey(pk), {
|
33
|
+
const account = await umi.rpc.getAccount(publicKey(pk), {
|
34
|
+
commitment: "confirmed",
|
35
|
+
});
|
29
36
|
return rpcAccountCreated(account);
|
30
37
|
}
|
31
38
|
|
@@ -65,24 +72,33 @@ export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
|
|
65
72
|
await fetch(
|
66
73
|
`https://hermes.pyth.network/v2/updates/price/latest?${priceFeedIds.map((x) => `ids%5B%5D=${x}`).join("&")}`
|
67
74
|
);
|
68
|
-
let resp = await getReq();
|
69
|
-
let status = resp.status;
|
70
|
-
while (status !== 200) {
|
71
|
-
await new Promise((resolve) => setTimeout(resolve, 1000));
|
72
|
-
resp = await getReq();
|
73
|
-
status = resp.status;
|
74
|
-
}
|
75
75
|
|
76
|
-
const
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
76
|
+
const prices = await retryWithExponentialBackoff(
|
77
|
+
async () => {
|
78
|
+
let resp = await getReq();
|
79
|
+
let status = resp.status;
|
80
|
+
while (status !== 200) {
|
81
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
82
|
+
resp = await getReq();
|
83
|
+
status = resp.status;
|
84
|
+
}
|
85
|
+
|
86
|
+
const json = await resp.json();
|
87
|
+
const prices = json.parsed.map((x: any) => {
|
88
|
+
if (x.price.expo > 0) {
|
89
|
+
return Number(toBaseUnit(Number(x.price.price), x.price.expo));
|
90
|
+
} else if (x.price.expo < 0) {
|
91
|
+
return fromBaseUnit(BigInt(x.price.price), Math.abs(x.price.expo));
|
92
|
+
} else {
|
93
|
+
return Number(x.price.price);
|
94
|
+
}
|
95
|
+
});
|
96
|
+
|
97
|
+
return prices;
|
98
|
+
},
|
99
|
+
5,
|
100
|
+
200
|
101
|
+
);
|
86
102
|
|
87
103
|
for (var i = 0; i < mints.length; i++) {
|
88
104
|
PRICES[mints[i].toString()] = {
|
@@ -94,7 +110,9 @@ export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
|
|
94
110
|
return prices;
|
95
111
|
}
|
96
112
|
|
97
|
-
export function safeGetPrice(
|
113
|
+
export function safeGetPrice(
|
114
|
+
mint: PublicKey | UmiPublicKey | undefined
|
115
|
+
): number | undefined {
|
98
116
|
if (mint && mint?.toString() in PRICES) {
|
99
117
|
return PRICES[mint!.toString()].price;
|
100
118
|
}
|
@@ -24,7 +24,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
24
24
|
// const signer = setupTest();
|
25
25
|
const signer = setupTest("solauto-manager");
|
26
26
|
|
27
|
-
const payForTransactions =
|
27
|
+
const payForTransactions = true;
|
28
28
|
const useJitoBundle = false;
|
29
29
|
const positionId = 1;
|
30
30
|
|
@@ -40,7 +40,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
40
40
|
{
|
41
41
|
signer,
|
42
42
|
positionId,
|
43
|
-
authority: new PublicKey("
|
43
|
+
authority: new PublicKey("E5BBsR1sUToPc3jXVwhrK5ttSiy6xhWJDMdQLvkgNppe")
|
44
44
|
// marginfiAccount: new PublicKey(
|
45
45
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
46
46
|
// ),
|