@haven-fi/solauto-sdk 1.0.450 → 1.0.451
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 +10 -3
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +16 -5
- package/dist/utils/jitoUtils.d.ts.map +1 -1
- package/dist/utils/jitoUtils.js +5 -6
- package/dist/utils/numberUtils.js +1 -1
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +31 -4
- package/src/utils/jitoUtils.ts +5 -4
- package/src/utils/numberUtils.ts +1 -1
@@ -32,6 +32,11 @@ export type TransactionManagerStatuses = {
|
|
32
32
|
simulationSuccessful?: boolean;
|
33
33
|
txSig?: string;
|
34
34
|
}[];
|
35
|
+
interface RetryConfig {
|
36
|
+
signableRetries?: number;
|
37
|
+
totalRetries?: number;
|
38
|
+
retryDelay?: number;
|
39
|
+
}
|
35
40
|
export declare class TransactionsManager {
|
36
41
|
private txHandler;
|
37
42
|
private statusCallback?;
|
@@ -39,11 +44,12 @@ export declare class TransactionsManager {
|
|
39
44
|
private priorityFeeSetting;
|
40
45
|
private atomically;
|
41
46
|
private errorsToThrow?;
|
42
|
-
private retries;
|
43
|
-
private retryDelay;
|
44
47
|
private statuses;
|
45
48
|
private lookupTables;
|
46
|
-
|
49
|
+
private signableRetries;
|
50
|
+
private totalRetries;
|
51
|
+
private retryDelay;
|
52
|
+
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, priorityFeeSetting?: PriorityFeeSetting, atomically?: boolean, errorsToThrow?: ErrorsToThrow | undefined, retryConfig?: RetryConfig);
|
47
53
|
private assembleTransactionSets;
|
48
54
|
private updateStatus;
|
49
55
|
private debugAccounts;
|
@@ -57,4 +63,5 @@ export declare class TransactionsManager {
|
|
57
63
|
private refreshItemSet;
|
58
64
|
private sendTransaction;
|
59
65
|
}
|
66
|
+
export {};
|
60
67
|
//# sourceMappingURL=transactionsManager.d.ts.map
|
@@ -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,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AA0FD,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,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,qBAAa,mBAAmB;
|
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;IACzB,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,0BAA0B,GAAG;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,EAAE,CAAC;AAEJ,UAAU,WAAW;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,qBAAa,mBAAmB;IAQ5B,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,MAAM,CAAC;IACf,OAAO,CAAC,kBAAkB;IAC1B,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,aAAa,CAAC;IAZxB,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,UAAU,CAAS;gBAGjB,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,kBAAkB,GAAE,kBAA2C,EAC/D,UAAU,GAAE,OAAe,EAC3B,aAAa,CAAC,EAAE,aAAa,YAAA,EACrC,WAAW,CAAC,EAAE,WAAW;YAWb,uBAAuB;IAwCrC,OAAO,CAAC,YAAY;YA6CN,aAAa;IAoB3B,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;YAiI7B,qBAAqB;YAmDrB,cAAc;YAqCd,eAAe;CA0D9B"}
|
@@ -142,17 +142,18 @@ var TransactionStatus;
|
|
142
142
|
TransactionStatus["Failed"] = "Failed";
|
143
143
|
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
144
144
|
class TransactionsManager {
|
145
|
-
constructor(txHandler, statusCallback, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, atomically = false, errorsToThrow,
|
145
|
+
constructor(txHandler, statusCallback, txType, priorityFeeSetting = types_1.PriorityFeeSetting.Min, atomically = false, errorsToThrow, retryConfig) {
|
146
146
|
this.txHandler = txHandler;
|
147
147
|
this.statusCallback = statusCallback;
|
148
148
|
this.txType = txType;
|
149
149
|
this.priorityFeeSetting = priorityFeeSetting;
|
150
150
|
this.atomically = atomically;
|
151
151
|
this.errorsToThrow = errorsToThrow;
|
152
|
-
this.retries = retries;
|
153
|
-
this.retryDelay = retryDelay;
|
154
152
|
this.statuses = [];
|
155
153
|
this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
|
154
|
+
this.signableRetries = retryConfig?.signableRetries ?? 3;
|
155
|
+
this.totalRetries = retryConfig?.totalRetries ?? 4;
|
156
|
+
this.retryDelay = retryConfig?.retryDelay ?? 150;
|
156
157
|
}
|
157
158
|
async assembleTransactionSets(items) {
|
158
159
|
let transactionSets = [];
|
@@ -335,6 +336,11 @@ class TransactionsManager {
|
|
335
336
|
let num = 0;
|
336
337
|
let transactions = [];
|
337
338
|
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => {
|
339
|
+
if (prevError &&
|
340
|
+
this.statuses.filter((x) => x.simulationSuccessful).length >
|
341
|
+
this.signableRetries) {
|
342
|
+
throw prevError;
|
343
|
+
}
|
338
344
|
num = attemptNum;
|
339
345
|
if (attemptNum > 0) {
|
340
346
|
for (let i = 0; i < itemSets.length; i++) {
|
@@ -367,7 +373,7 @@ class TransactionsManager {
|
|
367
373
|
throw error ? error : new Error("Unknown error");
|
368
374
|
}
|
369
375
|
this.updateStatusForSets(itemSets, TransactionStatus.Successful, attemptNum, txSigs);
|
370
|
-
}, this.
|
376
|
+
}, this.totalRetries, this.retryDelay, this.errorsToThrow).catch((e) => {
|
371
377
|
this.txHandler.log("Capturing error info...");
|
372
378
|
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);
|
373
379
|
const errorString = `${errorDetails.errorName ?? "Unknown error"}: ${errorDetails.errorInfo?.split("\n")[0] ?? "unknown"}`;
|
@@ -385,6 +391,11 @@ class TransactionsManager {
|
|
385
391
|
let itemSet = itemSets[currentIndex];
|
386
392
|
let num = 0;
|
387
393
|
await (0, generalUtils_1.retryWithExponentialBackoff)(async (attemptNum, prevError) => {
|
394
|
+
if (prevError &&
|
395
|
+
this.statuses.filter((x) => x.simulationSuccessful).length >
|
396
|
+
this.signableRetries) {
|
397
|
+
throw prevError;
|
398
|
+
}
|
388
399
|
num = attemptNum;
|
389
400
|
if (currentIndex > 0 || attemptNum > 0) {
|
390
401
|
itemSet = await this.refreshItemSet(itemSets, currentIndex, attemptNum);
|
@@ -399,7 +410,7 @@ class TransactionsManager {
|
|
399
410
|
await this.debugAccounts(itemSet, tx);
|
400
411
|
await this.sendTransaction(tx, itemSet.name(), attemptNum, this.getUpdatedPriorityFeeSetting(prevError, attemptNum));
|
401
412
|
}
|
402
|
-
}, this.
|
413
|
+
}, this.totalRetries, this.retryDelay, this.errorsToThrow);
|
403
414
|
}
|
404
415
|
async refreshItemSet(itemSets, currentIndex, attemptNum) {
|
405
416
|
const itemSet = itemSets[currentIndex];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAKV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMlE,wBAAgB,mBAAmB,IAAI,SAAS,CAa/C;
|
1
|
+
{"version":3,"file":"jitoUtils.d.ts","sourceRoot":"","sources":["../../src/utils/jitoUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EAKV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAEH,kBAAkB,EACnB,MAAM,0BAA0B,CAAC;AAQlC,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAMlE,wBAAgB,mBAAmB,IAAI,SAAS,CAa/C;AA+ND,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB;;;;IAkB7D;AAED,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,MAAM,EAClB,YAAY,EAAE,MAAM,EAAE,EACtB,GAAG,EAAE,kBAAkB,EAAE,EACzB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,kBAAkB,GAAE,kBAA2C,EAC/D,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,MAAM,EAAE,GAAG,SAAS,CAAC,CA8F/B"}
|
package/dist/utils/jitoUtils.js
CHANGED
@@ -8,7 +8,6 @@ exports.getRequiredSigners = getRequiredSigners;
|
|
8
8
|
exports.sendJitoBundledTransactions = sendJitoBundledTransactions;
|
9
9
|
const web3_js_1 = require("@solana/web3.js");
|
10
10
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
11
|
-
const solautoConstants_1 = require("../constants/solautoConstants");
|
12
11
|
const solanaUtils_1 = require("./solanaUtils");
|
13
12
|
const generalUtils_1 = require("./generalUtils");
|
14
13
|
const types_1 = require("../types");
|
@@ -129,8 +128,8 @@ async function umiToVersionedTransactions(umi, blockhash, userSigner, otherSigne
|
|
129
128
|
}
|
130
129
|
return builtTxs.map((x) => (0, umi_web3js_adapters_1.toWeb3JsTransaction)(x));
|
131
130
|
}
|
132
|
-
async function getBundleStatus(bundleId) {
|
133
|
-
const res = await axios_1.default.post(
|
131
|
+
async function getBundleStatus(umi, bundleId) {
|
132
|
+
const res = await axios_1.default.post(umi.rpc.getEndpoint(), {
|
134
133
|
jsonrpc: "2.0",
|
135
134
|
id: 1,
|
136
135
|
method: "getBundleStatuses",
|
@@ -141,11 +140,11 @@ async function getBundleStatus(bundleId) {
|
|
141
140
|
}
|
142
141
|
return res.data.result;
|
143
142
|
}
|
144
|
-
async function pollBundleStatus(bundleId, interval = 1000, timeout = 40000) {
|
143
|
+
async function pollBundleStatus(umi, bundleId, interval = 1000, timeout = 40000) {
|
145
144
|
const endTime = Date.now() + timeout;
|
146
145
|
while (Date.now() < endTime) {
|
147
146
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
148
|
-
const statuses = await getBundleStatus(bundleId);
|
147
|
+
const statuses = await getBundleStatus(umi, bundleId);
|
149
148
|
if (statuses?.value?.length > 0) {
|
150
149
|
(0, generalUtils_1.consoleLog)("Statuses:", statuses);
|
151
150
|
const status = statuses.value[0].confirmation_status;
|
@@ -182,7 +181,7 @@ async function sendJitoBundle(umi, transactions) {
|
|
182
181
|
}
|
183
182
|
const bundleId = resp.data.result;
|
184
183
|
(0, generalUtils_1.consoleLog)("Bundle ID:", bundleId);
|
185
|
-
return bundleId ? await pollBundleStatus(bundleId) : [];
|
184
|
+
return bundleId ? await pollBundleStatus(umi, bundleId) : [];
|
186
185
|
}
|
187
186
|
function getRequiredSigners(message) {
|
188
187
|
const { numRequiredSignatures, numReadonlySignedAccounts } = message.header;
|
@@ -119,7 +119,7 @@ function getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, offsetFromMaxLt
|
|
119
119
|
1); // -1 to account for any rounding issues
|
120
120
|
}
|
121
121
|
function maxRepayFromBps(maxLtvBps, liqThresholdBps) {
|
122
|
-
return Math.min(
|
122
|
+
return Math.min(8700, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01));
|
123
123
|
}
|
124
124
|
function maxRepayToBps(maxLtvBps, liqThresholdBps) {
|
125
125
|
return Math.min(maxRepayFromBps(maxLtvBps, liqThresholdBps) - constants_1.MIN_REPAY_GAP_BPS, getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps, 0.01));
|
package/package.json
CHANGED
@@ -218,9 +218,18 @@ export type TransactionManagerStatuses = {
|
|
218
218
|
txSig?: string;
|
219
219
|
}[];
|
220
220
|
|
221
|
+
interface RetryConfig {
|
222
|
+
signableRetries?: number;
|
223
|
+
totalRetries?: number;
|
224
|
+
retryDelay?: number;
|
225
|
+
}
|
226
|
+
|
221
227
|
export class TransactionsManager {
|
222
228
|
private statuses: TransactionManagerStatuses = [];
|
223
229
|
private lookupTables: LookupTables;
|
230
|
+
private signableRetries: number;
|
231
|
+
private totalRetries: number;
|
232
|
+
private retryDelay: number;
|
224
233
|
|
225
234
|
constructor(
|
226
235
|
private txHandler: SolautoClient | ReferralStateManager,
|
@@ -229,13 +238,15 @@ export class TransactionsManager {
|
|
229
238
|
private priorityFeeSetting: PriorityFeeSetting = PriorityFeeSetting.Min,
|
230
239
|
private atomically: boolean = false,
|
231
240
|
private errorsToThrow?: ErrorsToThrow,
|
232
|
-
|
233
|
-
private retryDelay: number = 150
|
241
|
+
retryConfig?: RetryConfig
|
234
242
|
) {
|
235
243
|
this.lookupTables = new LookupTables(
|
236
244
|
this.txHandler.defaultLookupTables(),
|
237
245
|
this.txHandler.umi
|
238
246
|
);
|
247
|
+
this.signableRetries = retryConfig?.signableRetries ?? 3;
|
248
|
+
this.totalRetries = retryConfig?.totalRetries ?? 4;
|
249
|
+
this.retryDelay = retryConfig?.retryDelay ?? 150;
|
239
250
|
}
|
240
251
|
|
241
252
|
private async assembleTransactionSets(
|
@@ -529,6 +540,14 @@ export class TransactionsManager {
|
|
529
540
|
|
530
541
|
await retryWithExponentialBackoff(
|
531
542
|
async (attemptNum, prevError) => {
|
543
|
+
if (
|
544
|
+
prevError &&
|
545
|
+
this.statuses.filter((x) => x.simulationSuccessful).length >
|
546
|
+
this.signableRetries
|
547
|
+
) {
|
548
|
+
throw prevError;
|
549
|
+
}
|
550
|
+
|
532
551
|
num = attemptNum;
|
533
552
|
|
534
553
|
if (attemptNum > 0) {
|
@@ -609,7 +628,7 @@ export class TransactionsManager {
|
|
609
628
|
txSigs
|
610
629
|
);
|
611
630
|
},
|
612
|
-
this.
|
631
|
+
this.totalRetries,
|
613
632
|
this.retryDelay,
|
614
633
|
this.errorsToThrow
|
615
634
|
).catch((e: Error) => {
|
@@ -653,6 +672,14 @@ export class TransactionsManager {
|
|
653
672
|
|
654
673
|
await retryWithExponentialBackoff(
|
655
674
|
async (attemptNum, prevError) => {
|
675
|
+
if (
|
676
|
+
prevError &&
|
677
|
+
this.statuses.filter((x) => x.simulationSuccessful).length >
|
678
|
+
this.signableRetries
|
679
|
+
) {
|
680
|
+
throw prevError;
|
681
|
+
}
|
682
|
+
|
656
683
|
num = attemptNum;
|
657
684
|
|
658
685
|
if (currentIndex > 0 || attemptNum > 0) {
|
@@ -681,7 +708,7 @@ export class TransactionsManager {
|
|
681
708
|
);
|
682
709
|
}
|
683
710
|
},
|
684
|
-
this.
|
711
|
+
this.totalRetries,
|
685
712
|
this.retryDelay,
|
686
713
|
this.errorsToThrow
|
687
714
|
);
|
package/src/utils/jitoUtils.ts
CHANGED
@@ -196,8 +196,8 @@ async function umiToVersionedTransactions(
|
|
196
196
|
return builtTxs.map((x) => toWeb3JsTransaction(x));
|
197
197
|
}
|
198
198
|
|
199
|
-
async function getBundleStatus(bundleId: string) {
|
200
|
-
const res = await axios.post(
|
199
|
+
async function getBundleStatus(umi: Umi, bundleId: string) {
|
200
|
+
const res = await axios.post(umi.rpc.getEndpoint(), {
|
201
201
|
jsonrpc: "2.0",
|
202
202
|
id: 1,
|
203
203
|
method: "getBundleStatuses",
|
@@ -211,6 +211,7 @@ async function getBundleStatus(bundleId: string) {
|
|
211
211
|
}
|
212
212
|
|
213
213
|
async function pollBundleStatus(
|
214
|
+
umi: Umi,
|
214
215
|
bundleId: string,
|
215
216
|
interval = 1000,
|
216
217
|
timeout = 40000
|
@@ -218,7 +219,7 @@ async function pollBundleStatus(
|
|
218
219
|
const endTime = Date.now() + timeout;
|
219
220
|
while (Date.now() < endTime) {
|
220
221
|
await new Promise((resolve) => setTimeout(resolve, interval));
|
221
|
-
const statuses = await getBundleStatus(bundleId);
|
222
|
+
const statuses = await getBundleStatus(umi, bundleId);
|
222
223
|
if (statuses?.value?.length > 0) {
|
223
224
|
consoleLog("Statuses:", statuses);
|
224
225
|
const status = statuses.value[0].confirmation_status;
|
@@ -260,7 +261,7 @@ async function sendJitoBundle(
|
|
260
261
|
|
261
262
|
const bundleId = resp.data.result;
|
262
263
|
consoleLog("Bundle ID:", bundleId);
|
263
|
-
return bundleId ? await pollBundleStatus(bundleId) : [];
|
264
|
+
return bundleId ? await pollBundleStatus(umi, bundleId) : [];
|
264
265
|
}
|
265
266
|
|
266
267
|
export function getRequiredSigners(message: TransactionMessage) {
|
package/src/utils/numberUtils.ts
CHANGED
@@ -166,7 +166,7 @@ export function getMaxLiqUtilizationRateBps(
|
|
166
166
|
|
167
167
|
export function maxRepayFromBps(maxLtvBps: number, liqThresholdBps: number) {
|
168
168
|
return Math.min(
|
169
|
-
|
169
|
+
8700,
|
170
170
|
getMaxLiqUtilizationRateBps(maxLtvBps, liqThresholdBps - 1000, 0.01)
|
171
171
|
);
|
172
172
|
}
|