@haven-fi/solauto-sdk 1.0.455 → 1.0.456
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/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +10 -8
- package/dist/utils/marginfiUtils.d.ts.map +1 -1
- package/dist/utils/marginfiUtils.js +0 -2
- package/local/logPositions.ts +29 -6
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +12 -8
- package/src/utils/marginfiUtils.ts +0 -3
- package/tests/transactions/solautoMarginfi.ts +45 -9
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAW7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,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oB3B,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,mBAAmB;YAoBb,SAAS;IAiBV,UAAU,CACrB,YAAY,EAAE,eAAe,EAAE,GAC9B,OAAO,CAAC,0BAA0B,CAAC;IA+FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA4BxB,6BAA6B;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,kBAAkB,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAMzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAElB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAW7D,qBAAa,wBAAyB,SAAQ,KAAK;gBACrC,OAAO,EAAE,MAAM;CAK5B;AAqCD,qBAAa,eAAe;IAMjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IARtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;IACjB,WAAW,EAAE,OAAO,CAAS;gBAG3B,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAKV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA0FD,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IAC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FzB,IAAI,CACf,KAAK,EAAE,eAAe,EAAE,GACvB,OAAO,CAAC,0BAA0B,CAAC;YA4BxB,6BAA6B;YAmI7B,qBAAqB;YAmDrB,cAAc;YAqCd,eAAe;CA4D9B"}
|
@@ -379,13 +379,14 @@ class TransactionsManager {
|
|
379
379
|
this.txHandler.log("Capturing error info...");
|
380
380
|
const errorDetails = (0, transactionUtils_1.getErrorInfo)(this.txHandler.umi, transactions, e, itemSets.filter((x) => this.statuses.find((y) => x.name() === y.name)?.simulationSuccessful).length === itemSets.length);
|
381
381
|
const errorString = `${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo?.split("\n")[0] ?? "unknown"}`;
|
382
|
+
const errorInfo = errorDetails.errorName || errorDetails.errorInfo
|
383
|
+
? errorString
|
384
|
+
: e.message;
|
382
385
|
this.updateStatusForSets(itemSets, errorDetails.canBeIgnored
|
383
386
|
? TransactionStatus.Skipped
|
384
|
-
: TransactionStatus.Failed, num, undefined, undefined,
|
385
|
-
? errorString
|
386
|
-
: e.message);
|
387
|
+
: TransactionStatus.Failed, num, undefined, undefined, errorInfo);
|
387
388
|
if (!errorDetails.canBeIgnored) {
|
388
|
-
throw
|
389
|
+
throw new Error(errorInfo);
|
389
390
|
}
|
390
391
|
});
|
391
392
|
}
|
@@ -442,13 +443,14 @@ class TransactionsManager {
|
|
442
443
|
this.txHandler.log("Capturing error info...");
|
443
444
|
const errorDetails = (0, transactionUtils_1.getErrorInfo)(this.txHandler.umi, [tx], e, this.statuses.find((x) => x.name === txName)?.simulationSuccessful);
|
444
445
|
const errorString = `${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo?.split("\n")[0] ?? "unknown"}`;
|
446
|
+
const errorInfo = errorDetails.errorName || errorDetails.errorInfo
|
447
|
+
? errorString
|
448
|
+
: e.message;
|
445
449
|
this.updateStatus(txName, errorDetails.canBeIgnored
|
446
450
|
? TransactionStatus.Skipped
|
447
|
-
: TransactionStatus.Failed, attemptNum, undefined, undefined,
|
448
|
-
? errorString
|
449
|
-
: e.message);
|
451
|
+
: TransactionStatus.Failed, attemptNum, undefined, undefined, errorInfo);
|
450
452
|
if (!errorDetails.canBeIgnored) {
|
451
|
-
throw
|
453
|
+
throw new Error(errorInfo);
|
452
454
|
}
|
453
455
|
}
|
454
456
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAGJ,eAAe,EAGhB,MAAM,iBAAiB,CAAC;AAazB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAI7D,UAAU,wBAAyB,SAAQ,qBAAqB;IAC9D,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,SAAS,GACd,wBAAwB,CAY1B;AAED,wBAAgB,iCAAiC,CAC/C,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,EAAE,MAAM,GAClB,CAAC,MAAM,EAAE,MAAM,CAAC,CA6BlB;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE;IACN,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,IAAI,EAAE;IACJ,IAAI,EAAE,SAAS,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;CACpB,EACD,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM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AAK,UAAU,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAA;CAAE,CAAC;AAEhE,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,eAAe,EAAE;IAAE,EAAE,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,eAAe,CAAA;CAAE,EAC1D,aAAa,CAAC,EAAE,SAAS,EACzB,MAAM,CAAC,EAAE,aAAa,EACtB,IAAI,CAAC,EAAE,aAAa,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA0LpC;AA+DD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,IAAI,oBAU7C;AAED,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBnE;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,eAAe,WASpE"}
|
@@ -253,8 +253,6 @@ async function getMarginfiAccountPositionState(umi, protocolAccount, marginfiGro
|
|
253
253
|
}, supplyPrice);
|
254
254
|
const supplyUsd = (0, numberUtils_1.fromBaseUnit)(supplyUsage.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
|
255
255
|
const debtUsd = (0, numberUtils_1.fromBaseUnit)(debtUsage?.amountUsed?.baseAmountUsdValue ?? BigInt(0), generalAccounts_1.USD_DECIMALS);
|
256
|
-
console.log("Asset weight init", (0, numberUtils_1.bytesToI80F48)(supplyBank.config.assetWeightInit.value));
|
257
|
-
console.log("Liability weight init", (0, numberUtils_1.bytesToI80F48)(debtBank.config.liabilityWeightInit.value));
|
258
256
|
return {
|
259
257
|
liqUtilizationRateBps: (0, numberUtils_1.getLiqUtilzationRateBps)(supplyUsd, debtUsd, (0, numberUtils_1.toBps)(liqThreshold)),
|
260
258
|
netWorth: {
|
package/local/logPositions.ts
CHANGED
@@ -188,6 +188,8 @@ async function main(filterWhitelist: boolean) {
|
|
188
188
|
|
189
189
|
const latestStates: PositionState[] = [];
|
190
190
|
let unhealthyPositions = 0;
|
191
|
+
let awaitingBoostPositions = 0;
|
192
|
+
|
191
193
|
for (const pos of solautoPositionsData) {
|
192
194
|
const latestState = await positionStateWithLatestPrices(
|
193
195
|
pos.state,
|
@@ -201,21 +203,42 @@ async function main(filterWhitelist: boolean) {
|
|
201
203
|
toWeb3JsPublicKey(pos.state.debt.mint)
|
202
204
|
);
|
203
205
|
|
204
|
-
const repayFrom =
|
206
|
+
const repayFrom =
|
207
|
+
pos.position.settingParams.repayToBps +
|
208
|
+
pos.position.settingParams.repayGap;
|
205
209
|
const unhealthy = latestState.liqUtilizationRateBps > repayFrom;
|
206
|
-
const healthText = unhealthy
|
210
|
+
const healthText = unhealthy
|
211
|
+
? `(Unhealthy: ${latestState.liqUtilizationRateBps - repayFrom}bps)`
|
212
|
+
: "";
|
207
213
|
if (unhealthy) {
|
208
214
|
unhealthyPositions += 1;
|
209
215
|
}
|
210
216
|
|
211
|
-
|
217
|
+
const awaitingBoost =
|
218
|
+
latestState.liqUtilizationRateBps <
|
219
|
+
pos.position.settingParams.boostToBps -
|
220
|
+
pos.position.settingParams.boostGap;
|
221
|
+
const boostText = awaitingBoost ? " (awaiting boost)" : "";
|
222
|
+
if (awaitingBoost) {
|
223
|
+
awaitingBoostPositions += 1;
|
224
|
+
}
|
225
|
+
|
212
226
|
console.log(
|
213
|
-
|
227
|
+
pos.publicKey.toString(),
|
228
|
+
`(${pos.authority.toString()} ${pos.positionId})`
|
229
|
+
);
|
230
|
+
console.log(
|
231
|
+
`${strategy}: $${formatNumber(fromBaseUnit(latestState.netWorth.baseAmountUsdValue, USD_DECIMALS), 2, 10000, 2)} ${healthText} ${boostText}`
|
214
232
|
);
|
215
233
|
// console.log(latestState.liqUtilizationRateBps, repayFrom);
|
216
234
|
}
|
217
235
|
|
218
|
-
console.log(
|
236
|
+
console.log(
|
237
|
+
"\nTotal positions:",
|
238
|
+
solautoPositionsData.length,
|
239
|
+
unhealthyPositions ? ` (unhealthy: ${unhealthyPositions})` : "",
|
240
|
+
awaitingBoostPositions ? ` (awaiting boost: ${awaitingBoostPositions})` : ""
|
241
|
+
);
|
219
242
|
console.log(
|
220
243
|
"Total users:",
|
221
244
|
Array.from(new Set(solautoPositionsData.map((x) => x.authority.toString())))
|
@@ -229,4 +252,4 @@ async function main(filterWhitelist: boolean) {
|
|
229
252
|
}
|
230
253
|
|
231
254
|
const filterWhitelist = true;
|
232
|
-
main(filterWhitelist).then((x) => x);
|
255
|
+
main(filterWhitelist).then((x) => x);
|
package/package.json
CHANGED
@@ -646,6 +646,10 @@ export class TransactionsManager {
|
|
646
646
|
);
|
647
647
|
|
648
648
|
const errorString = `${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo?.split("\n")[0] ?? "unknown"}`;
|
649
|
+
const errorInfo =
|
650
|
+
errorDetails.errorName || errorDetails.errorInfo
|
651
|
+
? errorString
|
652
|
+
: e.message;
|
649
653
|
this.updateStatusForSets(
|
650
654
|
itemSets,
|
651
655
|
errorDetails.canBeIgnored
|
@@ -654,13 +658,11 @@ export class TransactionsManager {
|
|
654
658
|
num,
|
655
659
|
undefined,
|
656
660
|
undefined,
|
657
|
-
|
658
|
-
? errorString
|
659
|
-
: e.message
|
661
|
+
errorInfo
|
660
662
|
);
|
661
663
|
|
662
664
|
if (!errorDetails.canBeIgnored) {
|
663
|
-
throw
|
665
|
+
throw new Error(errorInfo);
|
664
666
|
}
|
665
667
|
});
|
666
668
|
}
|
@@ -793,6 +795,10 @@ export class TransactionsManager {
|
|
793
795
|
);
|
794
796
|
|
795
797
|
const errorString = `${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo?.split("\n")[0] ?? "unknown"}`;
|
798
|
+
const errorInfo =
|
799
|
+
errorDetails.errorName || errorDetails.errorInfo
|
800
|
+
? errorString
|
801
|
+
: e.message;
|
796
802
|
this.updateStatus(
|
797
803
|
txName,
|
798
804
|
errorDetails.canBeIgnored
|
@@ -801,13 +807,11 @@ export class TransactionsManager {
|
|
801
807
|
attemptNum,
|
802
808
|
undefined,
|
803
809
|
undefined,
|
804
|
-
|
805
|
-
? errorString
|
806
|
-
: e.message
|
810
|
+
errorInfo
|
807
811
|
);
|
808
812
|
|
809
813
|
if (!errorDetails.canBeIgnored) {
|
810
|
-
throw
|
814
|
+
throw new Error(errorInfo);
|
811
815
|
}
|
812
816
|
}
|
813
817
|
}
|
@@ -464,9 +464,6 @@ export async function getMarginfiAccountPositionState(
|
|
464
464
|
USD_DECIMALS
|
465
465
|
);
|
466
466
|
|
467
|
-
console.log("Asset weight init", bytesToI80F48(supplyBank.config.assetWeightInit.value));
|
468
|
-
console.log("Liability weight init", bytesToI80F48(debtBank.config.liabilityWeightInit.value));
|
469
|
-
|
470
467
|
return {
|
471
468
|
liqUtilizationRateBps: getLiqUtilzationRateBps(
|
472
469
|
supplyUsd,
|
@@ -9,6 +9,9 @@ import {
|
|
9
9
|
} from "../../src/generated";
|
10
10
|
import { buildSolautoRebalanceTransaction } from "../../src/transactions/transactionUtils";
|
11
11
|
import {
|
12
|
+
bytesToI80F48,
|
13
|
+
getLiqUtilzationRateBps,
|
14
|
+
getMaxLiqUtilizationRateBps,
|
12
15
|
maxBoostToBps,
|
13
16
|
maxRepayFromBps,
|
14
17
|
maxRepayToBps,
|
@@ -21,21 +24,39 @@ import {
|
|
21
24
|
} from "../../src/transactions/transactionsManager";
|
22
25
|
import { PublicKey } from "@solana/web3.js";
|
23
26
|
import {
|
27
|
+
DEFAULT_MARGINFI_GROUP,
|
28
|
+
MARGINFI_ACCOUNTS,
|
24
29
|
SOLAUTO_PROD_PROGRAM,
|
25
30
|
SOLAUTO_TEST_PROGRAM,
|
26
31
|
USDC,
|
32
|
+
USDT,
|
27
33
|
} from "../../src/constants";
|
28
|
-
import {
|
34
|
+
import {
|
35
|
+
buildHeliusApiUrl,
|
36
|
+
getMarginfiAccountPositionState,
|
37
|
+
getSolautoManagedPositions,
|
38
|
+
retryWithExponentialBackoff,
|
39
|
+
} from "../../src/utils";
|
29
40
|
import { PriorityFeeSetting } from "../../src/types";
|
30
|
-
import { buildIronforgeApiUrl, fetchSolautoPosition } from "../../dist";
|
41
|
+
import { buildIronforgeApiUrl, fetchSolautoPosition, fetchTokenPrices } from "../../dist";
|
42
|
+
import { safeFetchBank } from "../../src/marginfi-sdk";
|
43
|
+
|
44
|
+
export function getFlooredTimestampByMinute(
|
45
|
+
unixSeconds: number,
|
46
|
+
intervalInMinutes: number = 1
|
47
|
+
): number {
|
48
|
+
const unixTime = Math.floor(new Date(unixSeconds * 1000).getTime() / 1000);
|
49
|
+
const interval = intervalInMinutes * 60;
|
50
|
+
return Math.floor(unixTime / interval) * interval;
|
51
|
+
}
|
31
52
|
|
32
53
|
describe("Solauto Marginfi tests", async () => {
|
33
|
-
|
34
|
-
const signer = setupTest("solauto-manager");
|
54
|
+
const signer = setupTest();
|
55
|
+
// const signer = setupTest("solauto-manager");
|
35
56
|
|
36
|
-
const payForTransactions =
|
37
|
-
const testProgram =
|
38
|
-
const positionId =
|
57
|
+
const payForTransactions = false;
|
58
|
+
const testProgram = false;
|
59
|
+
const positionId = 3;
|
39
60
|
|
40
61
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
41
62
|
const client = new SolautoMarginfiClient(
|
@@ -51,7 +72,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
51
72
|
await client.initialize({
|
52
73
|
signer,
|
53
74
|
positionId,
|
54
|
-
authority: new PublicKey("
|
75
|
+
authority: new PublicKey("7GMmfZdCgJSCawA7roGiGgvueU3XoEHQXUtiCnuDYUde"),
|
55
76
|
// new: true,
|
56
77
|
// marginfiAccount: new PublicKey(
|
57
78
|
// ""
|
@@ -63,6 +84,21 @@ describe("Solauto Marginfi tests", async () => {
|
|
63
84
|
|
64
85
|
// console.log(await client.getFreshPositionState());
|
65
86
|
|
87
|
+
// const debtBank = await safeFetchBank(
|
88
|
+
// client.umi,
|
89
|
+
// publicKey(MARGINFI_ACCOUNTS[DEFAULT_MARGINFI_GROUP][USDC].bank)
|
90
|
+
// );
|
91
|
+
// const state = await getMarginfiAccountPositionState(client.umi, {
|
92
|
+
// pk: new PublicKey("85YaXXB1uyDMLYf4ob6jfV1kr29muVNm7mpmM8qjbVq6"),
|
93
|
+
// });
|
94
|
+
// console.log(state);
|
95
|
+
// console.log(maxBoostToBps(state.maxLtvBps, state.liqThresholdBps));
|
96
|
+
// console.log(
|
97
|
+
// getMaxLiqUtilizationRateBps(state.maxLtvBps, state.liqThresholdBps, 0)
|
98
|
+
// );
|
99
|
+
// console.log(getLiqUtilzationRateBps(18.78, 7.47, state.liqThresholdBps));
|
100
|
+
// return;
|
101
|
+
|
66
102
|
const transactionItems: TransactionItem[] = [];
|
67
103
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|
68
104
|
// boostToBps: maxBoostToBps(
|
@@ -133,7 +169,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
133
169
|
transactionItems.push(
|
134
170
|
new TransactionItem(
|
135
171
|
async (attemptNum) =>
|
136
|
-
await buildSolautoRebalanceTransaction(client,
|
172
|
+
await buildSolautoRebalanceTransaction(client, 4000, attemptNum),
|
137
173
|
"rebalance"
|
138
174
|
)
|
139
175
|
);
|