@haven-fi/solauto-sdk 1.0.141 → 1.0.143
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":"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;IAkBrC,KAAK;
|
|
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,WA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
|
@@ -27,7 +27,7 @@ class LookupTables {
|
|
|
27
27
|
return this.cache;
|
|
28
28
|
}
|
|
29
29
|
reset() {
|
|
30
|
-
this.cache = this.cache.filter(x => this.defaultLuts.includes(x.publicKey.toString()));
|
|
30
|
+
this.cache = this.cache.filter((x) => this.defaultLuts.includes(x.publicKey.toString()));
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
class TransactionItem {
|
|
@@ -286,7 +286,7 @@ class TransactionsManager {
|
|
|
286
286
|
this.statuses.splice(statusesStartIdx + i, itemSets.length - i, ...newItemSets.map((x) => ({
|
|
287
287
|
name: x.name(),
|
|
288
288
|
status: TransactionStatus.Queued,
|
|
289
|
-
attemptNum: 0
|
|
289
|
+
attemptNum: 0,
|
|
290
290
|
})));
|
|
291
291
|
this.txHandler.log(this.statuses);
|
|
292
292
|
itemSets.splice(i + 1, itemSets.length - i - 1, ...newItemSets.slice(1));
|
|
@@ -311,8 +311,14 @@ class TransactionsManager {
|
|
|
311
311
|
if (this.txHandler.localTest) {
|
|
312
312
|
await this.debugAccounts(itemSet, tx);
|
|
313
313
|
}
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
try {
|
|
315
|
+
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, attemptNum, prioritySetting);
|
|
316
|
+
this.updateStatus(itemSet.name(), TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
|
|
317
|
+
}
|
|
318
|
+
catch (e) {
|
|
319
|
+
this.updateStatus(itemSet.name(), TransactionStatus.Failed, attemptNum);
|
|
320
|
+
throw e;
|
|
321
|
+
}
|
|
316
322
|
}
|
|
317
323
|
}, 4, 150, this.errorsToThrow);
|
|
318
324
|
}
|
|
@@ -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 (Math.max(0, positionState.liqUtilizationRateBps - boostFrom)
|
|
84
|
+
if (Math.max(0, positionState.liqUtilizationRateBps - boostFrom) <= bpsDistanceThreshold) {
|
|
85
85
|
return "boost";
|
|
86
86
|
}
|
|
87
|
-
else if (Math.max(0, repayFrom - 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
|
@@ -48,7 +48,9 @@ class LookupTables {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
reset() {
|
|
51
|
-
this.cache = this.cache.filter(x =>
|
|
51
|
+
this.cache = this.cache.filter((x) =>
|
|
52
|
+
this.defaultLuts.includes(x.publicKey.toString())
|
|
53
|
+
);
|
|
52
54
|
}
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -239,11 +241,18 @@ export class TransactionsManager {
|
|
|
239
241
|
return transactionSets;
|
|
240
242
|
}
|
|
241
243
|
|
|
242
|
-
updateStatus(
|
|
244
|
+
updateStatus(
|
|
245
|
+
name: string,
|
|
246
|
+
status: TransactionStatus,
|
|
247
|
+
attemptNum: number,
|
|
248
|
+
txSig?: string
|
|
249
|
+
) {
|
|
243
250
|
if (!this.statuses.filter((x) => x.name === name)) {
|
|
244
251
|
this.statuses.push({ name, status, txSig, attemptNum });
|
|
245
252
|
} else {
|
|
246
|
-
const idx = this.statuses.findIndex(
|
|
253
|
+
const idx = this.statuses.findIndex(
|
|
254
|
+
(x) => x.name === name && x.attemptNum === attemptNum
|
|
255
|
+
);
|
|
247
256
|
if (idx !== -1) {
|
|
248
257
|
this.statuses[idx].status = status;
|
|
249
258
|
this.statuses[idx].txSig = txSig;
|
|
@@ -292,7 +301,11 @@ export class TransactionsManager {
|
|
|
292
301
|
) {
|
|
293
302
|
await retryWithExponentialBackoff(
|
|
294
303
|
async (attemptNum) => {
|
|
295
|
-
this.updateStatus(
|
|
304
|
+
this.updateStatus(
|
|
305
|
+
updateLutTxName,
|
|
306
|
+
TransactionStatus.Processing,
|
|
307
|
+
attemptNum
|
|
308
|
+
);
|
|
296
309
|
try {
|
|
297
310
|
const txSig = await sendSingleOptimizedTransaction(
|
|
298
311
|
this.txHandler.umi,
|
|
@@ -302,9 +315,18 @@ export class TransactionsManager {
|
|
|
302
315
|
attemptNum,
|
|
303
316
|
prioritySetting
|
|
304
317
|
);
|
|
305
|
-
this.updateStatus(
|
|
318
|
+
this.updateStatus(
|
|
319
|
+
updateLutTxName,
|
|
320
|
+
TransactionStatus.Successful,
|
|
321
|
+
attemptNum,
|
|
322
|
+
txSig ? bs58.encode(txSig) : undefined
|
|
323
|
+
);
|
|
306
324
|
} catch (e) {
|
|
307
|
-
this.updateStatus(
|
|
325
|
+
this.updateStatus(
|
|
326
|
+
updateLutTxName,
|
|
327
|
+
TransactionStatus.Failed,
|
|
328
|
+
attemptNum
|
|
329
|
+
);
|
|
308
330
|
throw e;
|
|
309
331
|
}
|
|
310
332
|
},
|
|
@@ -367,7 +389,7 @@ export class TransactionsManager {
|
|
|
367
389
|
prioritySetting?: PriorityFeeSetting,
|
|
368
390
|
initialized?: boolean
|
|
369
391
|
): Promise<TransactionManagerStatuses> {
|
|
370
|
-
this.statuses = []
|
|
392
|
+
this.statuses = [];
|
|
371
393
|
this.lookupTables.reset();
|
|
372
394
|
|
|
373
395
|
if (!initialized) {
|
|
@@ -419,7 +441,7 @@ export class TransactionsManager {
|
|
|
419
441
|
...newItemSets.map((x) => ({
|
|
420
442
|
name: x.name(),
|
|
421
443
|
status: TransactionStatus.Queued,
|
|
422
|
-
attemptNum: 0
|
|
444
|
+
attemptNum: 0,
|
|
423
445
|
}))
|
|
424
446
|
);
|
|
425
447
|
this.txHandler.log(this.statuses);
|
|
@@ -445,28 +467,45 @@ export class TransactionsManager {
|
|
|
445
467
|
const tx = await itemSet.getSingleTransaction();
|
|
446
468
|
|
|
447
469
|
if (tx.getInstructions().length === 0) {
|
|
448
|
-
this.updateStatus(
|
|
470
|
+
this.updateStatus(
|
|
471
|
+
itemSet.name(),
|
|
472
|
+
TransactionStatus.Skipped,
|
|
473
|
+
attemptNum
|
|
474
|
+
);
|
|
449
475
|
} else {
|
|
450
|
-
this.updateStatus(
|
|
476
|
+
this.updateStatus(
|
|
477
|
+
itemSet.name(),
|
|
478
|
+
TransactionStatus.Processing,
|
|
479
|
+
attemptNum
|
|
480
|
+
);
|
|
451
481
|
|
|
452
482
|
if (this.txHandler.localTest) {
|
|
453
483
|
await this.debugAccounts(itemSet, tx);
|
|
454
484
|
}
|
|
455
485
|
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
486
|
+
try {
|
|
487
|
+
const txSig = await sendSingleOptimizedTransaction(
|
|
488
|
+
this.txHandler.umi,
|
|
489
|
+
this.txHandler.connection,
|
|
490
|
+
tx,
|
|
491
|
+
this.txType,
|
|
492
|
+
attemptNum,
|
|
493
|
+
prioritySetting
|
|
494
|
+
);
|
|
495
|
+
this.updateStatus(
|
|
496
|
+
itemSet.name(),
|
|
497
|
+
TransactionStatus.Successful,
|
|
498
|
+
attemptNum,
|
|
499
|
+
txSig ? bs58.encode(txSig) : undefined
|
|
500
|
+
);
|
|
501
|
+
} catch (e) {
|
|
502
|
+
this.updateStatus(
|
|
503
|
+
itemSet.name(),
|
|
504
|
+
TransactionStatus.Failed,
|
|
505
|
+
attemptNum
|
|
506
|
+
);
|
|
507
|
+
throw e;
|
|
508
|
+
}
|
|
470
509
|
}
|
|
471
510
|
},
|
|
472
511
|
4,
|
|
@@ -145,9 +145,9 @@ export function eligibleForRebalance(
|
|
|
145
145
|
const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
|
|
146
146
|
const boostFrom = boostToBps - positionSettings.boostGap;
|
|
147
147
|
|
|
148
|
-
if (Math.max(0, positionState.liqUtilizationRateBps - boostFrom)
|
|
148
|
+
if (Math.max(0, positionState.liqUtilizationRateBps - boostFrom) <= bpsDistanceThreshold) {
|
|
149
149
|
return "boost";
|
|
150
|
-
} else if (Math.max(0, repayFrom - positionState.liqUtilizationRateBps)
|
|
150
|
+
} else if (Math.max(0, repayFrom - positionState.liqUtilizationRateBps) <= bpsDistanceThreshold) {
|
|
151
151
|
return "repay";
|
|
152
152
|
}
|
|
153
153
|
|