@haven-fi/solauto-sdk 1.0.234 → 1.0.236
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/constants/solautoConstants.d.ts +1 -1
- package/dist/constants/solautoConstants.d.ts.map +1 -1
- package/dist/constants/solautoConstants.js +1 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +0 -5
- package/dist/transactions/transactionsManager.d.ts +1 -2
- package/dist/transactions/transactionsManager.d.ts.map +1 -1
- package/dist/transactions/transactionsManager.js +2 -3
- package/dist/types/solauto.d.ts +2 -0
- package/dist/types/solauto.d.ts.map +1 -1
- package/dist/types/solauto.js +2 -0
- package/dist/utils/solanaUtils.d.ts +2 -2
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +40 -56
- package/package.json +1 -1
- package/src/constants/solautoConstants.ts +1 -1
- package/src/transactions/transactionUtils.ts +1 -11
- package/src/transactions/transactionsManager.ts +0 -2
- package/src/types/solauto.ts +2 -0
- package/src/utils/solanaUtils.ts +44 -60
- package/tests/transactions/solautoMarginfi.ts +27 -43
|
@@ -5,7 +5,7 @@ export declare const BASIS_POINTS = 10000;
|
|
|
5
5
|
export declare const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
|
|
6
6
|
export declare const MIN_REPAY_GAP_BPS = 50;
|
|
7
7
|
export declare const MIN_BOOST_GAP_BPS = 50;
|
|
8
|
-
export declare const MIN_USD_SUPPORTED_POSITION =
|
|
8
|
+
export declare const MIN_USD_SUPPORTED_POSITION = 1000;
|
|
9
9
|
export declare const PRICES: {
|
|
10
10
|
[key: string]: {
|
|
11
11
|
price: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,
|
|
1
|
+
{"version":3,"file":"solautoConstants.d.ts","sourceRoot":"","sources":["../../src/constants/solautoConstants.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,SAAS,EACV,MAAM,iBAAiB,CAAC;AASzB,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AACF,eAAO,MAAM,oBAAoB,WAEhC,CAAC;AAIF,eAAO,MAAM,YAAY,QAAQ,CAAC;AAElC,eAAO,MAAM,iCAAiC,IAAI,CAAC;AACnD,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C,eAAO,MAAM,MAAM,EAAE;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;CAAO,CAAC;AAE7E,eAAO,MAAM,WAAW,iDAAiD,CAAC;AAC1E,eAAO,MAAM,qBAAqB,UAYR,CAAC"}
|
|
@@ -13,7 +13,7 @@ exports.BASIS_POINTS = 10000;
|
|
|
13
13
|
exports.MIN_POSITION_STATE_FRESHNESS_SECS = 5;
|
|
14
14
|
exports.MIN_REPAY_GAP_BPS = 50;
|
|
15
15
|
exports.MIN_BOOST_GAP_BPS = 50;
|
|
16
|
-
exports.MIN_USD_SUPPORTED_POSITION =
|
|
16
|
+
exports.MIN_USD_SUPPORTED_POSITION = 1000;
|
|
17
17
|
exports.PRICES = {};
|
|
18
18
|
exports.SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
|
19
19
|
exports.STANDARD_LUT_ACCOUNTS = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAoBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAsCzD,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAO7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAqLjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAkH7B;AA2LD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA0BnD;AAED,wBAAsB,8BAA8B,CAAC,MAAM,EAAE,aAAa,oBA2CzE;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsH5C;AAED,wBAAsB,gCAAgC,CACpD,eAAe,EAAE,oBAAoB,EACrC,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,GACzB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAsC5C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,kBAAkB,EAAE,KAAK,EAAE,GAAG;;;;EAuDxE"}
|
|
@@ -364,11 +364,6 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
|
364
364
|
}
|
|
365
365
|
const values = (0, rebalanceUtils_1.getRebalanceValues)(client.solautoPositionState, client.solautoPositionSettings(), client.solautoPositionActiveDca(), (0, generalUtils_1.currentUnixSeconds)(), (0, generalUtils_1.safeGetPrice)(client.supplyMint), (0, generalUtils_1.safeGetPrice)(client.debtMint), targetLiqUtilizationRateBps);
|
|
366
366
|
client.log("Rebalance values: ", values);
|
|
367
|
-
if (targetLiqUtilizationRateBps === undefined &&
|
|
368
|
-
(0, numberUtils_1.fromBaseUnit)(client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0), constants_1.USD_DECIMALS) < constants_1.MIN_USD_SUPPORTED_POSITION &&
|
|
369
|
-
values.feesUsd < 0.5) {
|
|
370
|
-
return undefined;
|
|
371
|
-
}
|
|
372
367
|
const swapDetails = (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, targetLiqUtilizationRateBps, attemptNum);
|
|
373
368
|
const { jupQuote, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
|
|
374
369
|
const flashLoan = (0, rebalanceUtils_1.getFlashLoanDetails)(client, values, jupQuote);
|
|
@@ -36,10 +36,9 @@ export declare class TransactionsManager {
|
|
|
36
36
|
private errorsToThrow?;
|
|
37
37
|
private retries;
|
|
38
38
|
private retryDelay;
|
|
39
|
-
private confirmTimeout;
|
|
40
39
|
private statuses;
|
|
41
40
|
private lookupTables;
|
|
42
|
-
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined, retries?: number, retryDelay?: number
|
|
41
|
+
constructor(txHandler: SolautoClient | ReferralStateManager, statusCallback?: ((statuses: TransactionManagerStatuses) => void) | undefined, txType?: TransactionRunType | undefined, mustBeAtomic?: boolean | undefined, errorsToThrow?: ErrorsToThrow | undefined, retries?: number, retryDelay?: number);
|
|
43
42
|
private assembleTransactionSets;
|
|
44
43
|
private updateStatus;
|
|
45
44
|
private debugAccounts;
|
|
@@ -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;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAsC7D,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IAPtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC,IAAI,CAAC,EAAE,MAAM,YAAA;IAGhB,UAAU;IAIV,OAAO,CAAC,UAAU,EAAE,MAAM;IAMhC,cAAc,IAAI,MAAM,EAAE;CAY3B;AAgFD,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;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;
|
|
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;AAKzD,OAAO,EACL,aAAa,EAEd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,EACnB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,oBAAoB,EAAa,MAAM,YAAY,CAAC;AAsC7D,qBAAa,eAAe;IAKjB,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACxC,IAAI,CAAC,EAAE,MAAM;IAPtB,oBAAoB,EAAG,MAAM,EAAE,CAAC;IAChC,EAAE,CAAC,EAAE,kBAAkB,CAAC;gBAGf,OAAO,EAAE,CACd,UAAU,EAAE,MAAM,KACf,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,EACxC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AAK,EAAE,eAAe,EAAE,EACxB,eAAe,CAAC,EAAE,kBAAkB,EACpC,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,0BAA0B,CAAC;YAwGxB,eAAe;CAkD9B"}
|
|
@@ -119,7 +119,7 @@ var TransactionStatus;
|
|
|
119
119
|
TransactionStatus["Failed"] = "Failed";
|
|
120
120
|
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
|
121
121
|
class TransactionsManager {
|
|
122
|
-
constructor(txHandler, statusCallback, txType, mustBeAtomic, errorsToThrow, retries = 4, retryDelay = 150
|
|
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;
|
|
@@ -127,7 +127,6 @@ class TransactionsManager {
|
|
|
127
127
|
this.errorsToThrow = errorsToThrow;
|
|
128
128
|
this.retries = retries;
|
|
129
129
|
this.retryDelay = retryDelay;
|
|
130
|
-
this.confirmTimeout = confirmTimeout;
|
|
131
130
|
this.statuses = [];
|
|
132
131
|
this.lookupTables = new LookupTables(this.txHandler.defaultLookupTables(), this.txHandler.umi);
|
|
133
132
|
}
|
|
@@ -331,7 +330,7 @@ class TransactionsManager {
|
|
|
331
330
|
async sendTransaction(tx, txName, attemptNum, prioritySetting) {
|
|
332
331
|
this.updateStatus(txName, TransactionStatus.Processing, attemptNum);
|
|
333
332
|
try {
|
|
334
|
-
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType,
|
|
333
|
+
const txSig = await (0, solanaUtils_1.sendSingleOptimizedTransaction)(this.txHandler.umi, this.txHandler.connection, tx, this.txType, prioritySetting, () => this.updateStatus(txName, TransactionStatus.Processing, attemptNum, undefined, true));
|
|
335
334
|
this.updateStatus(txName, TransactionStatus.Successful, attemptNum, txSig ? bs58_1.default.encode(txSig) : undefined);
|
|
336
335
|
}
|
|
337
336
|
catch (e) {
|
package/dist/types/solauto.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,GAAG,QAAQ;IACX,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC"}
|
|
1
|
+
{"version":3,"file":"solauto.d.ts","sourceRoot":"","sources":["../../src/types/solauto.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAE9D,MAAM,WAAW,sBAAsB;IACrC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,YAAY,CAAC;IAC3B,eAAe,EAAE,eAAe,CAAC;IACjC,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;CACtB;AAED,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,GAAG,QAAQ;IACX,GAAG,QAAQ;IACX,OAAO,WAAW;IAClB,IAAI,SAAS;CACd;AAED,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;AAExD,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,GAAG,eAAe,GAAG,QAAQ,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,CAAC,EAAE,MAAM,EAAE,CAAC;CACjC"}
|
package/dist/types/solauto.js
CHANGED
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PriorityFeeSetting = void 0;
|
|
4
4
|
var PriorityFeeSetting;
|
|
5
5
|
(function (PriorityFeeSetting) {
|
|
6
|
+
PriorityFeeSetting["None"] = "None";
|
|
7
|
+
PriorityFeeSetting["Min"] = "Min";
|
|
6
8
|
PriorityFeeSetting["Low"] = "Low";
|
|
7
9
|
PriorityFeeSetting["Default"] = "Medium";
|
|
8
10
|
PriorityFeeSetting["High"] = "High";
|
|
@@ -12,7 +12,7 @@ export declare function systemTransferUmiIx(signer: Signer, destination: PublicK
|
|
|
12
12
|
export declare function closeTokenAccountUmiIx(signer: Signer, tokenAccount: PublicKey, authority: PublicKey): WrappedInstruction;
|
|
13
13
|
export declare function splTokenTransferUmiIx(signer: Signer, fromTa: PublicKey, toTa: PublicKey, authority: PublicKey, amount: bigint): WrappedInstruction;
|
|
14
14
|
export declare function getAddressLookupInputs(umi: Umi, lookupTableAddresses: string[]): Promise<AddressLookupTableInput[]>;
|
|
15
|
-
export declare function assembleFinalTransaction(signer: Signer, tx: TransactionBuilder, computeUnitPrice
|
|
15
|
+
export declare function assembleFinalTransaction(signer: Signer, tx: TransactionBuilder, computeUnitPrice?: number, computeUnitLimit?: number): TransactionBuilder;
|
|
16
16
|
export declare function getComputeUnitPriceEstimate(umi: Umi, tx: TransactionBuilder, prioritySetting: PriorityFeeSetting): Promise<number | undefined>;
|
|
17
|
-
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, txType?: TransactionRunType,
|
|
17
|
+
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, txType?: TransactionRunType, prioritySetting?: PriorityFeeSetting, onAwaitingSign?: () => void): Promise<Uint8Array | undefined>;
|
|
18
18
|
//# sourceMappingURL=solanaUtils.d.ts.map
|
|
@@ -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,EAKL,UAAU,EACV,SAAS,EAKT,sBAAsB,EAEvB,MAAM,iBAAiB,CAAC;AAgBzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAIlE,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,UAErD;AAED,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,UAE3D;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAgC,GAC1C,CAAC,UAAU,EAAE,GAAG,CAAC,CAQnB;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,M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EACd,EAAE,EAAE,kBAAkB,EACtB,gBAAgB,CAAC,EAAE,MAAM,EACzB,gBAAgB,CAAC,EAAE,MAAM,sBAgE1B;AAmBD,wBAAsB,2BAA2B,CAC/C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,kBAAkB,EACtB,eAAe,EAAE,kBAAkB,GAClC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAsB7B;AA8CD,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA6EjC"}
|
|
@@ -92,7 +92,9 @@ async function getAddressLookupInputs(umi, lookupTableAddresses) {
|
|
|
92
92
|
}
|
|
93
93
|
function assembleFinalTransaction(signer, tx, computeUnitPrice, computeUnitLimit) {
|
|
94
94
|
tx = tx
|
|
95
|
-
.prepend(
|
|
95
|
+
.prepend(computeUnitPrice !== undefined
|
|
96
|
+
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
|
97
|
+
: (0, umi_1.transactionBuilder)())
|
|
96
98
|
.prepend(computeUnitLimit
|
|
97
99
|
? setComputeUnitLimitUmiIx(signer, computeUnitLimit)
|
|
98
100
|
: (0, umi_1.transactionBuilder)());
|
|
@@ -164,73 +166,54 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
|
|
|
164
166
|
}
|
|
165
167
|
return feeEstimate;
|
|
166
168
|
}
|
|
167
|
-
async function spamSendTransactionUntilConfirmed(connection, transaction, blockhash,
|
|
168
|
-
let spamAttempts = 0;
|
|
169
|
+
async function spamSendTransactionUntilConfirmed(connection, transaction, blockhash, spamInterval = 1000) {
|
|
169
170
|
let confirmed = false;
|
|
170
171
|
let transactionSignature = null;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
if (value.err) {
|
|
197
|
-
reject(value.err);
|
|
198
|
-
}
|
|
199
|
-
confirmed = true;
|
|
200
|
-
resolve(transactionSignature);
|
|
201
|
-
}
|
|
202
|
-
catch (error) {
|
|
203
|
-
(0, generalUtils_1.consoleLog)("Error during confirmation:", error);
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
if (!confirmed) {
|
|
207
|
-
setTimeout(confirmTransaction, 1000);
|
|
208
|
-
}
|
|
209
|
-
};
|
|
210
|
-
spamSend();
|
|
211
|
-
confirmTransaction();
|
|
212
|
-
setTimeout(() => {
|
|
213
|
-
if (!confirmed) {
|
|
214
|
-
reject(new Error("Failed to confirm transaction within timeout"));
|
|
215
|
-
}
|
|
216
|
-
}, confirmTimeout);
|
|
172
|
+
const sendTx = async () => {
|
|
173
|
+
try {
|
|
174
|
+
const txSignature = await connection.sendRawTransaction(Buffer.from(transaction.serialize()), { skipPreflight: true, maxRetries: 0 });
|
|
175
|
+
transactionSignature = txSignature;
|
|
176
|
+
(0, generalUtils_1.consoleLog)(`Transaction sent`);
|
|
177
|
+
}
|
|
178
|
+
catch (error) {
|
|
179
|
+
(0, generalUtils_1.consoleLog)("Error sending transaction:", error);
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
await sendTx();
|
|
183
|
+
const sendIntervalId = setInterval(async () => {
|
|
184
|
+
await sendTx();
|
|
185
|
+
}, spamInterval);
|
|
186
|
+
if (!transactionSignature) {
|
|
187
|
+
throw new Error("Failed to send");
|
|
188
|
+
}
|
|
189
|
+
await connection
|
|
190
|
+
.confirmTransaction({
|
|
191
|
+
...blockhash,
|
|
192
|
+
signature: transactionSignature,
|
|
193
|
+
})
|
|
194
|
+
.finally(() => {
|
|
195
|
+
clearInterval(sendIntervalId);
|
|
217
196
|
});
|
|
197
|
+
return transactionSignature;
|
|
218
198
|
}
|
|
219
|
-
async function sendSingleOptimizedTransaction(umi, connection, tx, txType,
|
|
199
|
+
async function sendSingleOptimizedTransaction(umi, connection, tx, txType, prioritySetting = types_1.PriorityFeeSetting.Default, onAwaitingSign) {
|
|
220
200
|
(0, generalUtils_1.consoleLog)("Sending single optimized transaction...");
|
|
221
201
|
(0, generalUtils_1.consoleLog)("Instructions: ", tx.getInstructions().length);
|
|
222
202
|
(0, generalUtils_1.consoleLog)("Serialized transaction size: ", tx.getTransactionSize(umi));
|
|
223
|
-
let cuPrice
|
|
224
|
-
if (
|
|
225
|
-
cuPrice =
|
|
203
|
+
let cuPrice;
|
|
204
|
+
if (prioritySetting !== types_1.PriorityFeeSetting.None) {
|
|
205
|
+
cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
|
|
206
|
+
if (!cuPrice) {
|
|
207
|
+
cuPrice = 1000000;
|
|
208
|
+
}
|
|
209
|
+
(0, generalUtils_1.consoleLog)("Compute unit price: ", cuPrice);
|
|
226
210
|
}
|
|
227
|
-
(0, generalUtils_1.consoleLog)("Compute unit price: ", cuPrice);
|
|
228
211
|
let computeUnitLimit = undefined;
|
|
229
212
|
if (txType !== "skip-simulation") {
|
|
230
213
|
// TODO: we should only retry simulation if it's not a solauto error
|
|
231
214
|
const simulationResult = await (0, generalUtils_1.retryWithExponentialBackoff)(async () => await simulateTransaction(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(await (await assembleFinalTransaction(umi.identity, tx, cuPrice, 1400000).setLatestBlockhash(umi)).build(umi))), 3);
|
|
232
215
|
simulationResult.value.err;
|
|
233
|
-
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.
|
|
216
|
+
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
|
|
234
217
|
(0, generalUtils_1.consoleLog)("Compute unit limit: ", computeUnitLimit);
|
|
235
218
|
}
|
|
236
219
|
if (txType !== "only-simulate") {
|
|
@@ -248,11 +231,12 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, confi
|
|
|
248
231
|
// },
|
|
249
232
|
// confirm: { commitment: "confirmed" },
|
|
250
233
|
// });
|
|
234
|
+
// const txSig = bs58.encode(result.signature);
|
|
251
235
|
const blockhash = await connection.getLatestBlockhash("confirmed");
|
|
252
236
|
const signedTx = await assembleFinalTransaction(umi.identity, tx, cuPrice, computeUnitLimit)
|
|
253
237
|
.setBlockhash(blockhash)
|
|
254
238
|
.buildAndSign(umi);
|
|
255
|
-
const txSig = await spamSendTransactionUntilConfirmed(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(signedTx), blockhash
|
|
239
|
+
const txSig = await spamSendTransactionUntilConfirmed(connection, (0, umi_web3js_adapters_1.toWeb3JsTransaction)(signedTx), blockhash);
|
|
256
240
|
(0, generalUtils_1.consoleLog)(`Transaction signature: ${txSig}`);
|
|
257
241
|
(0, generalUtils_1.consoleLog)(`https://solscan.io/tx/${txSig}`);
|
|
258
242
|
return bs58_1.default.decode(txSig);
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@ export const BASIS_POINTS = 10000;
|
|
|
27
27
|
export const MIN_POSITION_STATE_FRESHNESS_SECS = 5;
|
|
28
28
|
export const MIN_REPAY_GAP_BPS = 50;
|
|
29
29
|
export const MIN_BOOST_GAP_BPS = 50;
|
|
30
|
-
export const MIN_USD_SUPPORTED_POSITION =
|
|
30
|
+
export const MIN_USD_SUPPORTED_POSITION = 1000;
|
|
31
31
|
|
|
32
32
|
export const PRICES: { [key: string]: { price: number; time: number } } = {};
|
|
33
33
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
InvalidRebalanceConditionError,
|
|
17
17
|
LendingPlatform,
|
|
18
|
+
RebalanceDirection,
|
|
18
19
|
SolautoAction,
|
|
19
20
|
SolautoRebalanceType,
|
|
20
21
|
TokenType,
|
|
@@ -665,17 +666,6 @@ export async function buildSolautoRebalanceTransaction(
|
|
|
665
666
|
);
|
|
666
667
|
client.log("Rebalance values: ", values);
|
|
667
668
|
|
|
668
|
-
if (
|
|
669
|
-
targetLiqUtilizationRateBps === undefined &&
|
|
670
|
-
fromBaseUnit(
|
|
671
|
-
client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
|
|
672
|
-
USD_DECIMALS
|
|
673
|
-
) < MIN_USD_SUPPORTED_POSITION &&
|
|
674
|
-
values.feesUsd < 0.5
|
|
675
|
-
) {
|
|
676
|
-
return undefined;
|
|
677
|
-
}
|
|
678
|
-
|
|
679
669
|
const swapDetails = getJupSwapRebalanceDetails(
|
|
680
670
|
client,
|
|
681
671
|
values,
|
|
@@ -200,7 +200,6 @@ export class TransactionsManager {
|
|
|
200
200
|
private errorsToThrow?: ErrorsToThrow,
|
|
201
201
|
private retries: number = 4,
|
|
202
202
|
private retryDelay: number = 150,
|
|
203
|
-
private confirmTimeout: number = 10000
|
|
204
203
|
) {
|
|
205
204
|
this.lookupTables = new LookupTables(
|
|
206
205
|
this.txHandler.defaultLookupTables(),
|
|
@@ -511,7 +510,6 @@ export class TransactionsManager {
|
|
|
511
510
|
this.txHandler.connection,
|
|
512
511
|
tx,
|
|
513
512
|
this.txType,
|
|
514
|
-
this.confirmTimeout,
|
|
515
513
|
prioritySetting,
|
|
516
514
|
() =>
|
|
517
515
|
this.updateStatus(
|
package/src/types/solauto.ts
CHANGED
package/src/utils/solanaUtils.ts
CHANGED
|
@@ -184,11 +184,15 @@ export async function getAddressLookupInputs(
|
|
|
184
184
|
export function assembleFinalTransaction(
|
|
185
185
|
signer: Signer,
|
|
186
186
|
tx: TransactionBuilder,
|
|
187
|
-
computeUnitPrice
|
|
187
|
+
computeUnitPrice?: number,
|
|
188
188
|
computeUnitLimit?: number
|
|
189
189
|
) {
|
|
190
190
|
tx = tx
|
|
191
|
-
.prepend(
|
|
191
|
+
.prepend(
|
|
192
|
+
computeUnitPrice !== undefined
|
|
193
|
+
? setComputeUnitPriceUmiIx(signer, computeUnitPrice)
|
|
194
|
+
: transactionBuilder()
|
|
195
|
+
)
|
|
192
196
|
.prepend(
|
|
193
197
|
computeUnitLimit
|
|
194
198
|
? setComputeUnitLimitUmiIx(signer, computeUnitLimit)
|
|
@@ -296,67 +300,44 @@ async function spamSendTransactionUntilConfirmed(
|
|
|
296
300
|
connection: Connection,
|
|
297
301
|
transaction: Transaction | VersionedTransaction,
|
|
298
302
|
blockhash: BlockhashWithExpiryBlockHeight,
|
|
299
|
-
confirmTimeout: number = 10000,
|
|
300
303
|
spamInterval: number = 1000
|
|
301
304
|
): Promise<string> {
|
|
302
|
-
let spamAttempts = 0;
|
|
303
305
|
let confirmed = false;
|
|
304
306
|
let transactionSignature: string | null = null;
|
|
305
307
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
308
|
+
const sendTx = async () => {
|
|
309
|
+
try {
|
|
310
|
+
const txSignature = await connection.sendRawTransaction(
|
|
311
|
+
Buffer.from(transaction.serialize()),
|
|
312
|
+
{ skipPreflight: true, maxRetries: 0 }
|
|
313
|
+
);
|
|
314
|
+
transactionSignature = txSignature;
|
|
315
|
+
consoleLog(`Transaction sent`);
|
|
316
|
+
} catch (error) {
|
|
317
|
+
consoleLog("Error sending transaction:", error);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
311
320
|
|
|
312
|
-
|
|
313
|
-
const txSignature = await connection.sendRawTransaction(
|
|
314
|
-
Buffer.from(transaction.serialize()),
|
|
315
|
-
{ skipPreflight: true, maxRetries: 0 }
|
|
316
|
-
);
|
|
317
|
-
transactionSignature = txSignature;
|
|
318
|
-
consoleLog(`Transaction sent`);
|
|
319
|
-
} catch (error) {
|
|
320
|
-
consoleLog("Error sending transaction:", error);
|
|
321
|
-
}
|
|
321
|
+
await sendTx();
|
|
322
322
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
const confirmTransaction = async () => {
|
|
330
|
-
if (transactionSignature) {
|
|
331
|
-
try {
|
|
332
|
-
const { value } = await connection.confirmTransaction({
|
|
333
|
-
...blockhash,
|
|
334
|
-
signature: transactionSignature,
|
|
335
|
-
});
|
|
336
|
-
if (value.err) {
|
|
337
|
-
reject(value.err);
|
|
338
|
-
}
|
|
339
|
-
confirmed = true;
|
|
340
|
-
resolve(transactionSignature);
|
|
341
|
-
} catch (error) {
|
|
342
|
-
consoleLog("Error during confirmation:", error);
|
|
343
|
-
}
|
|
344
|
-
}
|
|
323
|
+
const sendIntervalId = setInterval(async () => {
|
|
324
|
+
await sendTx();
|
|
325
|
+
}, spamInterval);
|
|
345
326
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
};
|
|
327
|
+
if (!transactionSignature) {
|
|
328
|
+
throw new Error("Failed to send");
|
|
329
|
+
}
|
|
350
330
|
|
|
351
|
-
|
|
352
|
-
confirmTransaction(
|
|
331
|
+
await connection
|
|
332
|
+
.confirmTransaction({
|
|
333
|
+
...blockhash,
|
|
334
|
+
signature: transactionSignature,
|
|
335
|
+
})
|
|
336
|
+
.finally(() => {
|
|
337
|
+
clearInterval(sendIntervalId);
|
|
338
|
+
});
|
|
353
339
|
|
|
354
|
-
|
|
355
|
-
if (!confirmed) {
|
|
356
|
-
reject(new Error("Failed to confirm transaction within timeout"));
|
|
357
|
-
}
|
|
358
|
-
}, confirmTimeout);
|
|
359
|
-
});
|
|
340
|
+
return transactionSignature;
|
|
360
341
|
}
|
|
361
342
|
|
|
362
343
|
export async function sendSingleOptimizedTransaction(
|
|
@@ -364,7 +345,6 @@ export async function sendSingleOptimizedTransaction(
|
|
|
364
345
|
connection: Connection,
|
|
365
346
|
tx: TransactionBuilder,
|
|
366
347
|
txType?: TransactionRunType,
|
|
367
|
-
confirmTimeout: number = 10000,
|
|
368
348
|
prioritySetting: PriorityFeeSetting = PriorityFeeSetting.Default,
|
|
369
349
|
onAwaitingSign?: () => void
|
|
370
350
|
): Promise<Uint8Array | undefined> {
|
|
@@ -372,11 +352,14 @@ export async function sendSingleOptimizedTransaction(
|
|
|
372
352
|
consoleLog("Instructions: ", tx.getInstructions().length);
|
|
373
353
|
consoleLog("Serialized transaction size: ", tx.getTransactionSize(umi));
|
|
374
354
|
|
|
375
|
-
let cuPrice
|
|
376
|
-
if (
|
|
377
|
-
cuPrice =
|
|
355
|
+
let cuPrice: number | undefined;
|
|
356
|
+
if (prioritySetting !== PriorityFeeSetting.None) {
|
|
357
|
+
cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
|
|
358
|
+
if (!cuPrice) {
|
|
359
|
+
cuPrice = 1000000;
|
|
360
|
+
}
|
|
361
|
+
consoleLog("Compute unit price: ", cuPrice);
|
|
378
362
|
}
|
|
379
|
-
consoleLog("Compute unit price: ", cuPrice);
|
|
380
363
|
|
|
381
364
|
let computeUnitLimit = undefined;
|
|
382
365
|
if (txType !== "skip-simulation") {
|
|
@@ -399,7 +382,7 @@ export async function sendSingleOptimizedTransaction(
|
|
|
399
382
|
3
|
|
400
383
|
);
|
|
401
384
|
simulationResult.value.err;
|
|
402
|
-
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed! * 1.
|
|
385
|
+
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed! * 1.1);
|
|
403
386
|
consoleLog("Compute unit limit: ", computeUnitLimit);
|
|
404
387
|
}
|
|
405
388
|
|
|
@@ -418,6 +401,8 @@ export async function sendSingleOptimizedTransaction(
|
|
|
418
401
|
// },
|
|
419
402
|
// confirm: { commitment: "confirmed" },
|
|
420
403
|
// });
|
|
404
|
+
// const txSig = bs58.encode(result.signature);
|
|
405
|
+
|
|
421
406
|
const blockhash = await connection.getLatestBlockhash("confirmed");
|
|
422
407
|
const signedTx = await assembleFinalTransaction(
|
|
423
408
|
umi.identity,
|
|
@@ -431,7 +416,6 @@ export async function sendSingleOptimizedTransaction(
|
|
|
431
416
|
connection,
|
|
432
417
|
toWeb3JsTransaction(signedTx),
|
|
433
418
|
blockhash,
|
|
434
|
-
confirmTimeout
|
|
435
419
|
);
|
|
436
420
|
|
|
437
421
|
consoleLog(`Transaction signature: ${txSig}`);
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
TransactionsManager,
|
|
21
21
|
} from "../../src/transactions/transactionsManager";
|
|
22
22
|
import { PublicKey } from "@solana/web3.js";
|
|
23
|
-
import {
|
|
23
|
+
import { USDC } from "../../src/constants";
|
|
24
24
|
import { buildHeliusApiUrl } from "../../src/utils";
|
|
25
25
|
import { PriorityFeeSetting } from "../../src/types";
|
|
26
26
|
|
|
@@ -35,7 +35,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
35
35
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
|
36
36
|
const client = new SolautoMarginfiClient(
|
|
37
37
|
buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
|
|
38
|
-
true
|
|
38
|
+
true
|
|
39
39
|
);
|
|
40
40
|
|
|
41
41
|
const supply = NATIVE_MINT;
|
|
@@ -45,7 +45,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
45
45
|
await client.initialize({
|
|
46
46
|
signer,
|
|
47
47
|
positionId,
|
|
48
|
-
authority: new PublicKey("
|
|
48
|
+
authority: new PublicKey("rC5dMP5dmSsfQ66rynzfFzuc122Eex9h1RJHVDkeH6D"),
|
|
49
49
|
// marginfiAccount: new PublicKey(
|
|
50
50
|
// "4nNvUXF5YqHFcH2nGweSiuvy1ct7V5FXfoCLKFYUN36z"
|
|
51
51
|
// ),
|
|
@@ -55,36 +55,34 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
55
55
|
|
|
56
56
|
const transactionItems: TransactionItem[] = [];
|
|
57
57
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|
|
58
|
-
// boostToBps:
|
|
59
|
-
// boostGap:
|
|
60
|
-
// repayToBps:
|
|
61
|
-
// repayGap:
|
|
58
|
+
// boostToBps: 6950,
|
|
59
|
+
// boostGap: 100,
|
|
60
|
+
// repayToBps: 7000,
|
|
61
|
+
// repayGap: 100,
|
|
62
62
|
// automation: none(),
|
|
63
63
|
// targetBoostToBps: none(),
|
|
64
64
|
// };
|
|
65
65
|
|
|
66
66
|
// if (client.solautoPositionData === null) {
|
|
67
|
-
//
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
//
|
|
72
|
-
//
|
|
73
|
-
//
|
|
67
|
+
// transactionItems.push(
|
|
68
|
+
// new TransactionItem(async () => {
|
|
69
|
+
// return {
|
|
70
|
+
// tx: client.openPosition(settingParams),
|
|
71
|
+
// };
|
|
72
|
+
// }, "open position")
|
|
73
|
+
// );
|
|
74
74
|
|
|
75
|
-
// const initialSupplyUsd = 150;
|
|
76
|
-
//
|
|
77
|
-
//
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
//
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
// }, "deposit")
|
|
87
|
-
// );
|
|
75
|
+
// // const initialSupplyUsd = 150;
|
|
76
|
+
// transactionItems.push(
|
|
77
|
+
// new TransactionItem(async () => {
|
|
78
|
+
// // const [supplyPrice] = await fetchTokenPrices([supply]);
|
|
79
|
+
// return {
|
|
80
|
+
// tx: client.protocolInteraction(
|
|
81
|
+
// solautoAction("Deposit", [toBaseUnit(9, supplyDecimals)])
|
|
82
|
+
// ),
|
|
83
|
+
// };
|
|
84
|
+
// }, "deposit")
|
|
85
|
+
// );
|
|
88
86
|
// }
|
|
89
87
|
|
|
90
88
|
// const maxLtvBps = client.solautoPositionState!.maxLtvBps;
|
|
@@ -111,20 +109,6 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
111
109
|
// )
|
|
112
110
|
// );
|
|
113
111
|
|
|
114
|
-
// const initialSupplyUsd = 50;
|
|
115
|
-
// transactionItems.push(
|
|
116
|
-
// new TransactionItem(async () => {
|
|
117
|
-
// const [supplyPrice] = await fetchTokenPrices([supply]);
|
|
118
|
-
// return {
|
|
119
|
-
// tx: client.protocolInteraction(
|
|
120
|
-
// solautoAction("Deposit", [
|
|
121
|
-
// toBaseUnit(initialSupplyUsd / supplyPrice, supplyDecimals),
|
|
122
|
-
// ])
|
|
123
|
-
// ),
|
|
124
|
-
// };
|
|
125
|
-
// }, "deposit")
|
|
126
|
-
// );
|
|
127
|
-
|
|
128
112
|
transactionItems.push(
|
|
129
113
|
new TransactionItem(
|
|
130
114
|
async (attemptNum) =>
|
|
@@ -157,7 +141,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
|
157
141
|
client,
|
|
158
142
|
undefined,
|
|
159
143
|
!payForTransactions ? "only-simulate" : "normal",
|
|
160
|
-
useJitoBundle
|
|
161
|
-
).clientSend(transactionItems, PriorityFeeSetting.
|
|
144
|
+
useJitoBundle
|
|
145
|
+
).clientSend(transactionItems, PriorityFeeSetting.Min);
|
|
162
146
|
});
|
|
163
147
|
});
|