@haven-fi/solauto-sdk 1.0.139 → 1.0.140
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionsManager.d.ts +3 -2
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +9 -2
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +4 -2
- package/dist/utils/solauto/generalUtils.d.ts +1 -1
- package/dist/utils/solauto/generalUtils.d.ts.map +1 -1
- package/dist/utils/solauto/generalUtils.js +3 -3
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +15 -7
- package/src/utils/solanaUtils.ts +4 -2
- package/src/utils/solauto/generalUtils.ts +4 -3
- package/tests/transactions/solautoMarginfi.ts +0 -2
@@ -9,6 +9,7 @@ declare class LookupTables {
|
|
9
9
|
cache: AddressLookupTableInput[];
|
10
10
|
constructor(defaultLuts: string[], umi: Umi);
|
11
11
|
getLutInputs(additionalAddresses: string[]): Promise<AddressLookupTableInput[]>;
|
12
|
+
reset(): void;
|
12
13
|
}
|
13
14
|
export declare class TransactionItem {
|
14
15
|
fetchTx: (attemptNum: number) => Promise<{
|
@@ -61,8 +62,8 @@ export declare class TransactionsManager {
|
|
61
62
|
private assembleTransactionSets;
|
62
63
|
updateStatus(name: string, status: TransactionStatus, txSig?: string): void;
|
63
64
|
debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder): Promise<void>;
|
64
|
-
clientSend(transactions: TransactionItem[], prioritySetting?: PriorityFeeSetting): Promise<
|
65
|
-
send(items: TransactionItem[], prioritySetting?: PriorityFeeSetting, initialized?: boolean): Promise<
|
65
|
+
clientSend(transactions: TransactionItem[], prioritySetting?: PriorityFeeSetting): Promise<TransactionManagerStatuses>;
|
66
|
+
send(items: TransactionItem[], prioritySetting?: PriorityFeeSetting, initialized?: boolean): Promise<TransactionManagerStatuses>;
|
66
67
|
}
|
67
68
|
export {};
|
68
69
|
//# sourceMappingURL=transactionsManager.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7D,cAAM,YAAY;IAIP,WAAW,EAAE,MAAM,EAAE;IAC5B,OAAO,CAAC,GAAG;IAJb,KAAK,EAAE,uBAAuB,EAAE,CAAM;gBAG7B,WAAW,EAAE,MAAM,EAAE,EACpB,GAAG,EAAE,GAAG;IAGZ,YAAY,CAChB,mBAAmB,EAAE,MAAM,EAAE,GAC5B,OAAO,CAAC,uBAAuB,EAAE,CAAC;
|
1
|
+
{"version":3,"file":"transactionsManager.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionsManager.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EAEvB,kBAAkB,EAClB,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAG7D,cAAM,YAAY;IAIP,WAAW,EAAE,MAAM,EAAE;IAC5B,OAAO,CAAC,GAAG;IAJb,KAAK,EAAE,uBAAuB,EAAE,CAAM;gBAG7B,WAAW,EAAE,MAAM,EAAE,EACpB,GAAG,EAAE,GAAG;IAGZ,YAAY,CA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IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;IAK5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,YAAY,CAAC;IACrB,OAAO,CAAC,aAAa,CAAC;IARxB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;gBAGzB,SAAS,EAAE,aAAa,GAAG,oBAAoB,EAC/C,cAAc,CAAC,GAAE,CAAC,QAAQ,EAAE,0BAA0B,KAAK,IAAI,aAAA,EAC/D,MAAM,CAAC,EAAE,kBAAkB,YAAA,EAC3B,YAAY,CAAC,EAAE,OAAO,YAAA,EACtB,aAAa,CAAC,EAAE,aAAa,YAAA;YAQzB,uBAAuB;IAwCrC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,CAAC,EAAE,MAAM;IAiB9D,aAAa,CAAC,OAAO,EAAE,cAAc,EAAE,EAAE,EAAE,kBAAkB;IAoB7D,UAAU,CACd,YAAY,EAAE,eAAe,EAAE,EAC/B,eAAe,CAAC,EAAE,kBAAkB,GACnC,OAAO,CAAC,0BAA0B,CAAC;IA6EhC,IAAI,CACR,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;CA8GvC"}
|
@@ -26,6 +26,9 @@ class LookupTables {
|
|
26
26
|
}
|
27
27
|
return this.cache;
|
28
28
|
}
|
29
|
+
reset() {
|
30
|
+
this.cache = this.cache.filter(x => this.defaultLuts.includes(x.publicKey.toString()));
|
31
|
+
}
|
29
32
|
}
|
30
33
|
class TransactionItem {
|
31
34
|
constructor(fetchTx, name) {
|
@@ -217,20 +220,23 @@ class TransactionsManager {
|
|
217
220
|
this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
|
218
221
|
}
|
219
222
|
if (choresAfter.getInstructions().length > 0) {
|
220
|
-
const chore = new TransactionItem(async () => ({ tx: choresAfter })
|
223
|
+
const chore = new TransactionItem(async () => ({ tx: choresAfter }));
|
221
224
|
await chore.initialize();
|
222
225
|
items.push(chore);
|
223
226
|
this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
|
224
227
|
}
|
225
|
-
await this.send(items, prioritySetting, true).catch((e) => {
|
228
|
+
const result = await this.send(items, prioritySetting, true).catch((e) => {
|
226
229
|
client.resetLiveTxUpdates(false);
|
227
230
|
throw e;
|
228
231
|
});
|
229
232
|
if (this.txType !== "only-simulate") {
|
230
233
|
await client.resetLiveTxUpdates();
|
231
234
|
}
|
235
|
+
return result;
|
232
236
|
}
|
233
237
|
async send(items, prioritySetting, initialized) {
|
238
|
+
this.statuses = [];
|
239
|
+
this.lookupTables.reset();
|
234
240
|
if (!initialized) {
|
235
241
|
for (const item of items) {
|
236
242
|
await item.initialize();
|
@@ -301,6 +307,7 @@ class TransactionsManager {
|
|
301
307
|
}, 4, 150, this.errorsToThrow);
|
302
308
|
}
|
303
309
|
}
|
310
|
+
return this.statuses;
|
304
311
|
}
|
305
312
|
}
|
306
313
|
exports.TransactionsManager = TransactionsManager;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"solanaUtils.d.ts","sourceRoot":"","sources":["../../src/utils/solanaUtils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,uBAAuB,EACvB,MAAM,EACN,kBAAkB,EAClB,GAAG,EACH,kBAAkB,EAGnB,MAAM,0BAA0B,CAAC;AAOlC,OAAO,EAGL,UAAU,EACV,SAAS,EAIT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAYzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAElE,wBAAgB,sBAAsB,CACpC,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ACd,kBAAkB,CAUpB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,SAAS,EACtB,QAAQ,EAAE,MAAM,GACf,kBAAkB,CASpB;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,SAAS,EACvB,SAAS,EAAE,SAAS,GACnB,kBAAkB,CAKpB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,EACf,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,GACb,kBAAkB,CAKpB;AAED,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,GAAG,EACR,oBAAoB,EAAE,MAAM,EAAE,GAC7B,OAAO,CAAC,uBAAuB,EAAE,CAAC,CAkBpC;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,kBAAkB,EACtB,gBAAgB,EAAE,MAAM,EACxB,gBAAgB,CAAC,EAAE,MAAM,sBA4D1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,CAAC,CAgBjB;AAED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,UAAU,CAAC,EAAE,MAAM,EACnB,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA8DjC"}
|
@@ -33,7 +33,7 @@ function getSolanaRpcConnection(heliusApiKey) {
|
|
33
33
|
}
|
34
34
|
async function currentUnixSecondsSolana(umi) {
|
35
35
|
return await (0, generalUtils_1.retryWithExponentialBackoff)(async () => {
|
36
|
-
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot());
|
36
|
+
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot(), { commitment: "confirmed" });
|
37
37
|
if (blockTime === null) {
|
38
38
|
throw new Error("Unable to retrieve block time");
|
39
39
|
}
|
@@ -175,7 +175,9 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, attem
|
|
175
175
|
},
|
176
176
|
confirm: { commitment: "confirmed" },
|
177
177
|
});
|
178
|
-
|
178
|
+
const txSig = bs58_1.default.encode(result.signature);
|
179
|
+
console.log(`Transaction signature: ${txSig}`);
|
180
|
+
console.log(`https://solscan.io/tx/${txSig}`);
|
179
181
|
if (result.result.value.err !== null) {
|
180
182
|
throw new Error(result.result.value.err.toString());
|
181
183
|
}
|
@@ -7,7 +7,7 @@ export declare function nextAutomationPeriodTimestamp(automation: AutomationSett
|
|
7
7
|
export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixTime: number): boolean;
|
8
8
|
export declare function getUpdatedValueFromAutomation(currValue: number, targetValue: number, automation: AutomationSettings, currentUnixTimestamp: number): number;
|
9
9
|
export declare function getAdjustedSettingsFromAutomation(settings: SolautoSettingsParameters, currentUnixTime: number): SolautoSettingsParameters;
|
10
|
-
export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings | undefined, currentUnixTime: number): RebalanceAction | undefined;
|
10
|
+
export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings | undefined, currentUnixTime: number, bpsDistanceThreshold?: number): RebalanceAction | undefined;
|
11
11
|
export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters, currentUnixTime: number): boolean;
|
12
12
|
export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicKey): Promise<SolautoPositionDetails[]>;
|
13
13
|
export declare function getAllReferralStates(umi: Umi): Promise<PublicKey[]>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAChC,SAAS,EAKV,MAAM,iBAAiB,CAAC;AAezB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE9E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAW1D;AAgBD,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,EAC9B,eAAe,EAAE,MAAM,GACtB,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,MAAM,UAY7B;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,EACnC,eAAe,EAAE,MAAM,GACtB,yBAAyB,CAgB3B;AAED,wBAAgB,oBAAoB,CAClC,aAAa,EAAE,aAAa,EAC5B,gBAAgB,EAAE,yBAAyB,EAC3C,WAAW,EAAE,WAAW,GAAG,SAAS,EACpC,eAAe,EAAE,MAAM,
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC5E,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAElB,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C5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAC/C,YAAY,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAC;KAAE,CAAa;IACrE,aAAa,EAAE,SAAS,GAAG,SAAS,CAAa;IAExD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IA6B9B,KAAK;IASL,UAAU,IAAI,OAAO;CAStB"}
|
@@ -66,7 +66,7 @@ function getAdjustedSettingsFromAutomation(settings, currentUnixTime) {
|
|
66
66
|
boostToBps,
|
67
67
|
};
|
68
68
|
}
|
69
|
-
function eligibleForRebalance(positionState, positionSettings, positionDca, currentUnixTime) {
|
69
|
+
function eligibleForRebalance(positionState, positionSettings, positionDca, currentUnixTime, bpsDistanceThreshold = 0) {
|
70
70
|
if (positionDca &&
|
71
71
|
positionDca.automation.targetPeriods > 0 &&
|
72
72
|
eligibleForNextAutomationPeriod(positionDca.automation, currentUnixTime)) {
|
@@ -81,10 +81,10 @@ function eligibleForRebalance(positionState, positionSettings, positionDca, curr
|
|
81
81
|
: positionSettings.boostToBps;
|
82
82
|
const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
|
83
83
|
const boostFrom = boostToBps - positionSettings.boostGap;
|
84
|
-
if (positionState.liqUtilizationRateBps
|
84
|
+
if (Math.max(0, positionState.liqUtilizationRateBps - boostFrom) / boostFrom >= bpsDistanceThreshold) {
|
85
85
|
return "boost";
|
86
86
|
}
|
87
|
-
else if (positionState.liqUtilizationRateBps
|
87
|
+
else if (Math.max(0, repayFrom - positionState.liqUtilizationRateBps) >= bpsDistanceThreshold) {
|
88
88
|
return "repay";
|
89
89
|
}
|
90
90
|
return undefined;
|
package/package.json
CHANGED
@@ -46,6 +46,10 @@ class LookupTables {
|
|
46
46
|
|
47
47
|
return this.cache;
|
48
48
|
}
|
49
|
+
|
50
|
+
reset() {
|
51
|
+
this.cache = this.cache.filter(x => this.defaultLuts.includes(x.publicKey.toString()));
|
52
|
+
}
|
49
53
|
}
|
50
54
|
|
51
55
|
export class TransactionItem {
|
@@ -273,7 +277,7 @@ export class TransactionsManager {
|
|
273
277
|
async clientSend(
|
274
278
|
transactions: TransactionItem[],
|
275
279
|
prioritySetting?: PriorityFeeSetting
|
276
|
-
) {
|
280
|
+
): Promise<TransactionManagerStatuses> {
|
277
281
|
const items = [...transactions];
|
278
282
|
const client = this.txHandler as SolautoClient;
|
279
283
|
|
@@ -329,10 +333,7 @@ export class TransactionsManager {
|
|
329
333
|
);
|
330
334
|
}
|
331
335
|
if (choresAfter.getInstructions().length > 0) {
|
332
|
-
const chore = new TransactionItem(
|
333
|
-
async () => ({ tx: choresAfter }),
|
334
|
-
"close temp accounts"
|
335
|
-
);
|
336
|
+
const chore = new TransactionItem(async () => ({ tx: choresAfter }));
|
336
337
|
await chore.initialize();
|
337
338
|
items.push(chore);
|
338
339
|
this.txHandler.log(
|
@@ -341,7 +342,7 @@ export class TransactionsManager {
|
|
341
342
|
);
|
342
343
|
}
|
343
344
|
|
344
|
-
await this.send(items, prioritySetting, true).catch((e) => {
|
345
|
+
const result = await this.send(items, prioritySetting, true).catch((e) => {
|
345
346
|
client.resetLiveTxUpdates(false);
|
346
347
|
throw e;
|
347
348
|
});
|
@@ -349,13 +350,18 @@ export class TransactionsManager {
|
|
349
350
|
if (this.txType !== "only-simulate") {
|
350
351
|
await client.resetLiveTxUpdates();
|
351
352
|
}
|
353
|
+
|
354
|
+
return result;
|
352
355
|
}
|
353
356
|
|
354
357
|
async send(
|
355
358
|
items: TransactionItem[],
|
356
359
|
prioritySetting?: PriorityFeeSetting,
|
357
360
|
initialized?: boolean
|
358
|
-
) {
|
361
|
+
): Promise<TransactionManagerStatuses> {
|
362
|
+
this.statuses = []
|
363
|
+
this.lookupTables.reset();
|
364
|
+
|
359
365
|
if (!initialized) {
|
360
366
|
for (const item of items) {
|
361
367
|
await item.initialize();
|
@@ -459,5 +465,7 @@ export class TransactionsManager {
|
|
459
465
|
);
|
460
466
|
}
|
461
467
|
}
|
468
|
+
|
469
|
+
return this.statuses;
|
462
470
|
}
|
463
471
|
}
|
package/src/utils/solanaUtils.ts
CHANGED
@@ -51,7 +51,7 @@ export function getSolanaRpcConnection(
|
|
51
51
|
|
52
52
|
export async function currentUnixSecondsSolana(umi: Umi): Promise<number> {
|
53
53
|
return await retryWithExponentialBackoff(async () => {
|
54
|
-
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot());
|
54
|
+
const blockTime = await umi.rpc.getBlockTime(await umi.rpc.getSlot(), { commitment: "confirmed" });
|
55
55
|
if (blockTime === null) {
|
56
56
|
throw new Error("Unable to retrieve block time");
|
57
57
|
}
|
@@ -337,7 +337,9 @@ export async function sendSingleOptimizedTransaction(
|
|
337
337
|
},
|
338
338
|
confirm: { commitment: "confirmed" },
|
339
339
|
});
|
340
|
-
|
340
|
+
const txSig = bs58.encode(result.signature);
|
341
|
+
console.log(`Transaction signature: ${txSig}`)
|
342
|
+
console.log(`https://solscan.io/tx/${txSig}`);
|
341
343
|
if (result.result.value.err !== null) {
|
342
344
|
throw new Error(result.result.value.err.toString());
|
343
345
|
}
|
@@ -117,7 +117,8 @@ export function eligibleForRebalance(
|
|
117
117
|
positionState: PositionState,
|
118
118
|
positionSettings: SolautoSettingsParameters,
|
119
119
|
positionDca: DCASettings | undefined,
|
120
|
-
currentUnixTime: number
|
120
|
+
currentUnixTime: number,
|
121
|
+
bpsDistanceThreshold = 0
|
121
122
|
): RebalanceAction | undefined {
|
122
123
|
if (
|
123
124
|
positionDca &&
|
@@ -144,9 +145,9 @@ export function eligibleForRebalance(
|
|
144
145
|
const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
|
145
146
|
const boostFrom = boostToBps - positionSettings.boostGap;
|
146
147
|
|
147
|
-
if (positionState.liqUtilizationRateBps
|
148
|
+
if (Math.max(0, positionState.liqUtilizationRateBps - boostFrom) / boostFrom >= bpsDistanceThreshold) {
|
148
149
|
return "boost";
|
149
|
-
} else if (positionState.liqUtilizationRateBps
|
150
|
+
} else if (Math.max(0, repayFrom - positionState.liqUtilizationRateBps) >= bpsDistanceThreshold) {
|
150
151
|
return "repay";
|
151
152
|
}
|
152
153
|
|
@@ -120,8 +120,6 @@ describe("Solauto Marginfi tests", async () => {
|
|
120
120
|
// }, "deposit")
|
121
121
|
// );
|
122
122
|
|
123
|
-
console.log("POSITION SUPPLY TA:", client.positionSupplyTa);
|
124
|
-
console.log("POSITION DEBT TA:", client.positionDebtTa);
|
125
123
|
transactionItems.push(
|
126
124
|
new TransactionItem(
|
127
125
|
async (attemptNum) =>
|