@haven-fi/solauto-sdk 1.0.153 → 1.0.154
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +2 -1
- package/dist/transactions/transactionsManager.d.ts +3 -1
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +4 -2
- package/dist/utils/numberUtils.js +3 -3
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +8 -2
- package/src/transactions/transactionsManager.ts +5 -3
- package/src/utils/numberUtils.ts +3 -3
@@ -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;AAoLD,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;AAoLD,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,CAmIA;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"}
|
@@ -325,7 +325,8 @@ async function getTransactionChores(client, tx) {
|
|
325
325
|
}
|
326
326
|
async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRateBps, attemptNum) {
|
327
327
|
client.solautoPositionState = await client.getFreshPositionState();
|
328
|
-
if (client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0)
|
328
|
+
if ((client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0) &&
|
329
|
+
client.livePositionUpdates.supplyAdjustment === BigInt(0)) ||
|
329
330
|
(targetLiqUtilizationRateBps === undefined &&
|
330
331
|
!(0, generalUtils_2.eligibleForRebalance)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(), (0, generalUtils_1.currentUnixSeconds)()))) {
|
331
332
|
client.log("Not eligible for a rebalance");
|
@@ -58,9 +58,11 @@ export declare class TransactionsManager {
|
|
58
58
|
private txType?;
|
59
59
|
private mustBeAtomic?;
|
60
60
|
private errorsToThrow?;
|
61
|
+
private retries;
|
62
|
+
private retryDelay;
|
61
63
|
private statuses;
|
62
64
|
private lookupTables;
|
63
|
-
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined);
|
65
|
+
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined, retries?: number, retryDelay?: number);
|
64
66
|
private assembleTransactionSets;
|
65
67
|
updateStatus(name: string, status: TransactionStatus, attemptNum: number, txSig?: string): void;
|
66
68
|
debugAccounts(itemSet: TransactionSet, tx: TransactionBuilder): Promise<void>;
|
@@ -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,EA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AAkB,CAAC;IAYzD,YAAY,IAAI,MAAM,EAAE;IAMxB,IAAI,IAAI,MAAM;CAYf;AAED,oBAAY,iBAAiB;IAC3B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,iBAAiB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,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;
|
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;CAKN;AAED,qBAAa,eAAe;IAKj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C;IACf,UAAU,EAAE,MAAM,CAAC;CACpB,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;IACtB,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,UAAU;IAVpB,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,EAC7B,OAAO,GAAE,MAAU,EACnB,UAAU,GAAE,MAAY;YAQpB,uBAAuB;IAwCrC,YAAY,CACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,iBAAiB,EACzB,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,MAAM;IAoBV,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;IAgGhC,IAAI,CACR,KAAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;CAiIvC"}
|
@@ -119,12 +119,14 @@ var TransactionStatus;
|
|
119
119
|
TransactionStatus["Failed"] = "Failed";
|
120
120
|
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
121
121
|
class TransactionsManager {
|
122
|
-
constructor(txHandler, statusCallback, txType, mustBeAtomic, errorsToThrow) {
|
122
|
+
constructor(txHandler, statusCallback, txType, mustBeAtomic, errorsToThrow, retries = 4, retryDelay = 150) {
|
123
123
|
this.txHandler = txHandler;
|
124
124
|
this.statusCallback = statusCallback;
|
125
125
|
this.txType = txType;
|
126
126
|
this.mustBeAtomic = mustBeAtomic;
|
127
127
|
this.errorsToThrow = errorsToThrow;
|
128
|
+
this.retries = retries;
|
129
|
+
this.retryDelay = retryDelay;
|
128
130
|
this.statuses = [];
|
129
131
|
this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
|
130
132
|
}
|
@@ -320,7 +322,7 @@ class TransactionsManager {
|
|
320
322
|
throw e;
|
321
323
|
}
|
322
324
|
}
|
323
|
-
},
|
325
|
+
}, this.retries, this.retryDelay, this.errorsToThrow);
|
324
326
|
}
|
325
327
|
}
|
326
328
|
return this.statuses;
|
@@ -101,11 +101,11 @@ function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLt
|
|
101
101
|
return toBps((fromBps(maxLtvBps) - offsetFromMaxLtv) / fromBps(liqThresholdBps)) - 1; // -1 to account for any rounding issues
|
102
102
|
}
|
103
103
|
function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
|
104
|
-
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.
|
104
|
+
return Math.min(9000, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.0075));
|
105
105
|
}
|
106
106
|
function maxRepayToBps(maxLtvBps, liqThresholdBps) {
|
107
|
-
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.
|
107
|
+
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.0075));
|
108
108
|
}
|
109
109
|
function maxBoostToBps(maxLtvBps, liqThresholdBps) {
|
110
|
-
return Math.min(maxRepayToBps(maxLtvBps, liqThresholdBps), getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.
|
110
|
+
return Math.min(maxRepayToBps(maxLtvBps, liqThresholdBps), getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
|
111
111
|
}
|
package/package.json
CHANGED
@@ -580,7 +580,8 @@ export async function buildSolautoRebalanceTransaction(
|
|
580
580
|
> {
|
581
581
|
client.solautoPositionState = await client.getFreshPositionState();
|
582
582
|
if (
|
583
|
-
client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0)
|
583
|
+
(client.solautoPositionState?.supply.amountUsed.baseUnit === BigInt(0) &&
|
584
|
+
client.livePositionUpdates.supplyAdjustment === BigInt(0)) ||
|
584
585
|
(targetLiqUtilizationRateBps === undefined &&
|
585
586
|
!eligibleForRebalance(
|
586
587
|
client.solautoPositionState!,
|
@@ -618,7 +619,12 @@ export async function buildSolautoRebalanceTransaction(
|
|
618
619
|
tokenLedgerIx,
|
619
620
|
swapIx,
|
620
621
|
} = await getJupSwapTransaction(client.signer, swapDetails, attemptNum);
|
621
|
-
const flashLoan = getFlashLoanDetails(
|
622
|
+
const flashLoan = getFlashLoanDetails(
|
623
|
+
client,
|
624
|
+
values,
|
625
|
+
jupQuote,
|
626
|
+
priceImpactBps
|
627
|
+
);
|
622
628
|
|
623
629
|
let tx = transactionBuilder();
|
624
630
|
|
@@ -193,7 +193,9 @@ export class TransactionsManager {
|
|
193
193
|
private statusCallback?: (statuses: TransactionManagerStatuses) => void,
|
194
194
|
private txType?: TransactionRunType,
|
195
195
|
private mustBeAtomic?: boolean,
|
196
|
-
private errorsToThrow?: ErrorsToThrow
|
196
|
+
private errorsToThrow?: ErrorsToThrow,
|
197
|
+
private retries: number = 4,
|
198
|
+
private retryDelay: number = 150
|
197
199
|
) {
|
198
200
|
this.lookupTables = new LookupTables(
|
199
201
|
this.txHandler.defaultLookupTables(),
|
@@ -508,8 +510,8 @@ export class TransactionsManager {
|
|
508
510
|
}
|
509
511
|
}
|
510
512
|
},
|
511
|
-
|
512
|
-
|
513
|
+
this.retries,
|
514
|
+
this.retryDelay,
|
513
515
|
this.errorsToThrow
|
514
516
|
);
|
515
517
|
}
|
package/src/utils/numberUtils.ts
CHANGED
@@ -139,20 +139,20 @@ export function getMaxLiqUtilizationRateBps(
|
|
139
139
|
export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
|
140
140
|
return Math.min(
|
141
141
|
9000,
|
142
|
-
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.
|
142
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.0075)
|
143
143
|
);
|
144
144
|
}
|
145
145
|
|
146
146
|
export function maxRepayToBps(maxLtvBps: number, liqThresholdBps: number) {
|
147
147
|
return Math.min(
|
148
148
|
maxRepayFromBps(maxLtvBps, liqThresholdBps) - MIN_REPAY_GAP_BPS,
|
149
|
-
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.
|
149
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.0075)
|
150
150
|
);
|
151
151
|
}
|
152
152
|
|
153
153
|
export function maxBoostToBps(maxLtvBps: number, liqThresholdBps: number) {
|
154
154
|
return Math.min(
|
155
155
|
maxRepayToBps(maxLtvBps, liqThresholdBps),
|
156
|
-
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.
|
156
|
+
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01)
|
157
157
|
);
|
158
158
|
}
|