@haven-fi/solauto-sdk 1.0.233 → 1.0.235
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/constants/solautoConstants.d.ts +1 -0
- package/dist/constants/solautoConstants.d.ts.map +1 -1
- package/dist/constants/solautoConstants.js +2 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +10 -3
- package/dist/transactions/transactionsManager.js +1 -1
- 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 +1 -1
- package/dist/utils/solanaUtils.d.ts.map +1 -1
- package/dist/utils/solanaUtils.js +15 -8
- package/dist/utils/solauto/rebalanceUtils.d.ts +1 -0
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +1 -0
- package/package.json +1 -1
- package/src/constants/solautoConstants.ts +1 -0
- package/src/transactions/transactionUtils.ts +27 -11
- package/src/transactions/transactionsManager.ts +1 -1
- package/src/types/solauto.ts +2 -0
- package/src/utils/solanaUtils.ts +19 -10
- package/src/utils/solauto/rebalanceUtils.ts +4 -1
- package/tests/transactions/solautoMarginfi.ts +27 -50
@@ -5,6 +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 = 1000;
|
8
9
|
export declare const PRICES: {
|
9
10
|
[key: string]: {
|
10
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;
|
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"}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.BASIS_POINTS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
|
3
|
+
exports.STANDARD_LUT_ACCOUNTS = exports.SOLAUTO_LUT = exports.PRICES = exports.MIN_USD_SUPPORTED_POSITION = exports.MIN_BOOST_GAP_BPS = exports.MIN_REPAY_GAP_BPS = exports.MIN_POSITION_STATE_FRESHNESS_SECS = exports.BASIS_POINTS = exports.SOLAUTO_TEST_PROGRAM = exports.SOLAUTO_PROD_PROGRAM = void 0;
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
5
5
|
const spl_token_1 = require("@solana/spl-token");
|
6
6
|
// import { JitoRpcConnection } from "jito-ts";
|
@@ -13,6 +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 = 1000;
|
16
17
|
exports.PRICES = {};
|
17
18
|
exports.SOLAUTO_LUT = "9D4xwZwDf46n9ft5gQxZzq3rBbdRXsXojKQLZbBdskPY";
|
18
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,CA2H5C;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"}
|
@@ -186,7 +186,8 @@ function transactionChoresAfter(client, solautoActions, cancellingDcaIn) {
|
|
186
186
|
}
|
187
187
|
function getRebalanceInstructions(umi, tx) {
|
188
188
|
return tx.getInstructions().filter((x) => {
|
189
|
-
if (x.programId.toString() ===
|
189
|
+
if (x.programId.toString() ===
|
190
|
+
umi.programs.get("solauto").publicKey.toString()) {
|
190
191
|
try {
|
191
192
|
const serializer = (0, generated_1.getMarginfiRebalanceInstructionDataSerializer)();
|
192
193
|
const discriminator = serializer.serialize({
|
@@ -207,7 +208,8 @@ function getRebalanceInstructions(umi, tx) {
|
|
207
208
|
function getSolautoActions(umi, tx) {
|
208
209
|
let solautoActions = [];
|
209
210
|
tx.getInstructions().forEach((x) => {
|
210
|
-
if (x.programId.toString() ===
|
211
|
+
if (x.programId.toString() ===
|
212
|
+
umi.programs.get("solauto").publicKey.toString()) {
|
211
213
|
try {
|
212
214
|
const serializer = (0, generated_1.getMarginfiProtocolInteractionInstructionDataSerializer)();
|
213
215
|
const discriminator = serializer.serialize({
|
@@ -362,6 +364,10 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
362
364
|
}
|
363
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);
|
364
366
|
client.log("Rebalance values: ", values);
|
367
|
+
// Don't perform automated solauto manager boost if the fees are less than the transaction cost
|
368
|
+
if (targetLiqUtilizationRateBps === undefined && values.rebalanceDirection === generated_1.RebalanceDirection.Boost && values.feesUsd < 1) {
|
369
|
+
return undefined;
|
370
|
+
}
|
365
371
|
const swapDetails = (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, targetLiqUtilizationRateBps, attemptNum);
|
366
372
|
const { jupQuote, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
|
367
373
|
const flashLoan = (0, rebalanceUtils_1.getFlashLoanDetails)(client, values, jupQuote);
|
@@ -441,7 +447,8 @@ function getErrorInfo(umi, tx, error) {
|
|
441
447
|
const errCode = typeof err[1] === "object" ? err[1]["Custom"] : undefined;
|
442
448
|
const errName = errCode === undefined ? err[1] : undefined;
|
443
449
|
let programName = "";
|
444
|
-
if (errIx.programId.toString() ===
|
450
|
+
if (errIx.programId.toString() ===
|
451
|
+
umi.programs.get("solauto").publicKey.toString()) {
|
445
452
|
programError = (0, generated_1.getSolautoErrorFromCode)(errCode, (0, generated_1.createSolautoProgram)());
|
446
453
|
programName = "Haven";
|
447
454
|
if (programError?.name ===
|
@@ -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, confirmTimeout =
|
122
|
+
constructor(txHandler, statusCallback, txType, mustBeAtomic, errorsToThrow, retries = 4, retryDelay = 150, confirmTimeout = 15000) {
|
123
123
|
this.txHandler = txHandler;
|
124
124
|
this.statusCallback = statusCallback;
|
125
125
|
this.txType = txType;
|
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
17
|
export declare function sendSingleOptimizedTransaction(umi: Umi, connection: Connection, tx: TransactionBuilder, txType?: TransactionRunType, confirmTimeout?: number, 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,oB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b,kBAAkB,CAKpB;AAED,wBAAsB,sBAAsB,CAC1C,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,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;AAsED,wBAAsB,8BAA8B,CAClD,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,UAAU,EACtB,EAAE,EAAE,kBAAkB,EACtB,MAAM,CAAC,EAAE,kBAAkB,EAC3B,cAAc,GAAE,MAAc,EAC9B,eAAe,GAAE,kBAA+C,EAChE,cAAc,CAAC,EAAE,MAAM,IAAI,GAC1B,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA8EjC"}
|
@@ -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,7 +166,7 @@ async function getComputeUnitPriceEstimate(umi, tx, prioritySetting) {
|
|
164
166
|
}
|
165
167
|
return feeEstimate;
|
166
168
|
}
|
167
|
-
async function spamSendTransactionUntilConfirmed(connection, transaction, blockhash, confirmTimeout =
|
169
|
+
async function spamSendTransactionUntilConfirmed(connection, transaction, blockhash, confirmTimeout = 15000, spamInterval = 1000) {
|
168
170
|
let spamAttempts = 0;
|
169
171
|
let confirmed = false;
|
170
172
|
let transactionSignature = null;
|
@@ -211,26 +213,30 @@ async function spamSendTransactionUntilConfirmed(connection, transaction, blockh
|
|
211
213
|
confirmTransaction();
|
212
214
|
setTimeout(() => {
|
213
215
|
if (!confirmed) {
|
216
|
+
confirmed = true;
|
214
217
|
reject(new Error("Failed to confirm transaction within timeout"));
|
215
218
|
}
|
216
219
|
}, confirmTimeout);
|
217
220
|
});
|
218
221
|
}
|
219
|
-
async function sendSingleOptimizedTransaction(umi, connection, tx, txType, confirmTimeout =
|
222
|
+
async function sendSingleOptimizedTransaction(umi, connection, tx, txType, confirmTimeout = 15000, prioritySetting = types_1.PriorityFeeSetting.Default, onAwaitingSign) {
|
220
223
|
(0, generalUtils_1.consoleLog)("Sending single optimized transaction...");
|
221
224
|
(0, generalUtils_1.consoleLog)("Instructions: ", tx.getInstructions().length);
|
222
225
|
(0, generalUtils_1.consoleLog)("Serialized transaction size: ", tx.getTransactionSize(umi));
|
223
|
-
let cuPrice
|
224
|
-
if (
|
225
|
-
cuPrice =
|
226
|
+
let cuPrice;
|
227
|
+
if (prioritySetting !== types_1.PriorityFeeSetting.None) {
|
228
|
+
cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
|
229
|
+
if (!cuPrice) {
|
230
|
+
cuPrice = 1000000;
|
231
|
+
}
|
232
|
+
(0, generalUtils_1.consoleLog)("Compute unit price: ", cuPrice);
|
226
233
|
}
|
227
|
-
(0, generalUtils_1.consoleLog)("Compute unit price: ", cuPrice);
|
228
234
|
let computeUnitLimit = undefined;
|
229
235
|
if (txType !== "skip-simulation") {
|
230
236
|
// TODO: we should only retry simulation if it's not a solauto error
|
231
237
|
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
238
|
simulationResult.value.err;
|
233
|
-
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.
|
239
|
+
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed * 1.1);
|
234
240
|
(0, generalUtils_1.consoleLog)("Compute unit limit: ", computeUnitLimit);
|
235
241
|
}
|
236
242
|
if (txType !== "only-simulate") {
|
@@ -248,6 +254,7 @@ async function sendSingleOptimizedTransaction(umi, connection, tx, txType, confi
|
|
248
254
|
// },
|
249
255
|
// confirm: { commitment: "confirmed" },
|
250
256
|
// });
|
257
|
+
// const txSig = bs58.encode(result.signature);
|
251
258
|
const blockhash = await connection.getLatestBlockhash("confirmed");
|
252
259
|
const signedTx = await assembleFinalTransaction(umi.identity, tx, cuPrice, computeUnitLimit)
|
253
260
|
.setBlockhash(blockhash)
|
@@ -12,6 +12,7 @@ export interface RebalanceValues {
|
|
12
12
|
dcaTokenType?: TokenType;
|
13
13
|
rebalanceAction: RebalanceAction;
|
14
14
|
rebalanceDirection: RebalanceDirection;
|
15
|
+
feesUsd: number;
|
15
16
|
}
|
16
17
|
export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number): RebalanceValues;
|
17
18
|
export interface FlashLoanDetails {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/rebalanceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EACL,WAAW,EACX,aAAa,EAEb,kBAAkB,EAClB,yBAAyB,EACzB,SAAS,EACV,MAAM,i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AM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CA0D9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAyChB"}
|
@@ -98,6 +98,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
|
|
98
98
|
dcaTokenType: dca?.tokenType,
|
99
99
|
rebalanceAction: (amountToDcaIn ?? 0) > 0 ? "dca" : rebalanceDirection === generated_1.RebalanceDirection.Boost ? "boost" : "repay",
|
100
100
|
rebalanceDirection,
|
101
|
+
feesUsd: debtAdjustmentUsd * (0, numberUtils_1.fromBps)(adjustmentFeeBps)
|
101
102
|
};
|
102
103
|
}
|
103
104
|
function getFlashLoanDetails(client, values, jupQuote) {
|
package/package.json
CHANGED
@@ -27,6 +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 = 1000;
|
30
31
|
|
31
32
|
export const PRICES: { [key: string]: { price: number; time: number } } = {};
|
32
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,
|
@@ -46,6 +47,7 @@ import {
|
|
46
47
|
} from "../utils/generalUtils";
|
47
48
|
import { SolautoMarginfiClient } from "../clients/solautoMarginfiClient";
|
48
49
|
import {
|
50
|
+
fromBaseUnit,
|
49
51
|
getMaxLiqUtilizationRateBps,
|
50
52
|
uint8ArrayToBigInt,
|
51
53
|
} from "../utils/numberUtils";
|
@@ -53,10 +55,7 @@ import {
|
|
53
55
|
eligibleForRebalance,
|
54
56
|
positionStateWithLatestPrices,
|
55
57
|
} from "../utils/solauto/generalUtils";
|
56
|
-
import {
|
57
|
-
getTokenAccount,
|
58
|
-
getTokenAccountData,
|
59
|
-
} from "../utils/accountUtils";
|
58
|
+
import { getTokenAccount, getTokenAccountData } from "../utils/accountUtils";
|
60
59
|
import {
|
61
60
|
createMarginfiProgram,
|
62
61
|
getLendingAccountBorrowInstructionDataSerializer,
|
@@ -72,7 +71,7 @@ import {
|
|
72
71
|
getJupiterErrorFromName,
|
73
72
|
JUPITER_PROGRAM_ID,
|
74
73
|
} from "../jupiter-sdk";
|
75
|
-
import { PRICES } from "../constants";
|
74
|
+
import { MIN_USD_SUPPORTED_POSITION, PRICES, USD_DECIMALS } from "../constants";
|
76
75
|
import { TransactionItemInputs } from "../types";
|
77
76
|
|
78
77
|
interface wSolTokenUsage {
|
@@ -400,9 +399,15 @@ function transactionChoresAfter(
|
|
400
399
|
return chores;
|
401
400
|
}
|
402
401
|
|
403
|
-
function getRebalanceInstructions(
|
402
|
+
function getRebalanceInstructions(
|
403
|
+
umi: Umi,
|
404
|
+
tx: TransactionBuilder
|
405
|
+
): Instruction[] {
|
404
406
|
return tx.getInstructions().filter((x) => {
|
405
|
-
if (
|
407
|
+
if (
|
408
|
+
x.programId.toString() ===
|
409
|
+
umi.programs.get("solauto").publicKey.toString()
|
410
|
+
) {
|
406
411
|
try {
|
407
412
|
const serializer = getMarginfiRebalanceInstructionDataSerializer();
|
408
413
|
const discriminator = serializer.serialize({
|
@@ -424,7 +429,10 @@ function getSolautoActions(umi: Umi, tx: TransactionBuilder): SolautoAction[] {
|
|
424
429
|
let solautoActions: SolautoAction[] = [];
|
425
430
|
|
426
431
|
tx.getInstructions().forEach((x) => {
|
427
|
-
if (
|
432
|
+
if (
|
433
|
+
x.programId.toString() ===
|
434
|
+
umi.programs.get("solauto").publicKey.toString()
|
435
|
+
) {
|
428
436
|
try {
|
429
437
|
const serializer =
|
430
438
|
getMarginfiProtocolInteractionInstructionDataSerializer();
|
@@ -658,6 +666,11 @@ export async function buildSolautoRebalanceTransaction(
|
|
658
666
|
);
|
659
667
|
client.log("Rebalance values: ", values);
|
660
668
|
|
669
|
+
// Don't perform automated solauto manager boost if the fees are less than the transaction cost
|
670
|
+
if (targetLiqUtilizationRateBps === undefined && values.rebalanceDirection === RebalanceDirection.Boost && values.feesUsd < 1) {
|
671
|
+
return undefined;
|
672
|
+
}
|
673
|
+
|
661
674
|
const swapDetails = getJupSwapRebalanceDetails(
|
662
675
|
client,
|
663
676
|
values,
|
@@ -806,11 +819,14 @@ export function getErrorInfo(umi: Umi, tx: TransactionBuilder, error: any) {
|
|
806
819
|
const err = (error as any)["InstructionError"];
|
807
820
|
const errIx = tx.getInstructions()[Math.max(0, err[0] - 2)];
|
808
821
|
const errCode = typeof err[1] === "object" ? err[1]["Custom"] : undefined;
|
809
|
-
const errName = errCode === undefined ? err[1] as string : undefined;
|
822
|
+
const errName = errCode === undefined ? (err[1] as string) : undefined;
|
810
823
|
let programName = "";
|
811
824
|
|
812
|
-
if (
|
813
|
-
|
825
|
+
if (
|
826
|
+
errIx.programId.toString() ===
|
827
|
+
umi.programs.get("solauto").publicKey.toString()
|
828
|
+
) {
|
829
|
+
programError = getSolautoErrorFromCode(errCode, createSolautoProgram());
|
814
830
|
programName = "Haven";
|
815
831
|
if (
|
816
832
|
programError?.name ===
|
@@ -200,7 +200,7 @@ export class TransactionsManager {
|
|
200
200
|
private errorsToThrow?: ErrorsToThrow,
|
201
201
|
private retries: number = 4,
|
202
202
|
private retryDelay: number = 150,
|
203
|
-
private confirmTimeout: number =
|
203
|
+
private confirmTimeout: number = 15000
|
204
204
|
) {
|
205
205
|
this.lookupTables = new LookupTables(
|
206
206
|
this.txHandler.defaultLookupTables(),
|
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,7 +300,7 @@ async function spamSendTransactionUntilConfirmed(
|
|
296
300
|
connection: Connection,
|
297
301
|
transaction: Transaction | VersionedTransaction,
|
298
302
|
blockhash: BlockhashWithExpiryBlockHeight,
|
299
|
-
confirmTimeout: number =
|
303
|
+
confirmTimeout: number = 15000,
|
300
304
|
spamInterval: number = 1000
|
301
305
|
): Promise<string> {
|
302
306
|
let spamAttempts = 0;
|
@@ -353,6 +357,7 @@ async function spamSendTransactionUntilConfirmed(
|
|
353
357
|
|
354
358
|
setTimeout(() => {
|
355
359
|
if (!confirmed) {
|
360
|
+
confirmed = true;
|
356
361
|
reject(new Error("Failed to confirm transaction within timeout"));
|
357
362
|
}
|
358
363
|
}, confirmTimeout);
|
@@ -364,7 +369,7 @@ export async function sendSingleOptimizedTransaction(
|
|
364
369
|
connection: Connection,
|
365
370
|
tx: TransactionBuilder,
|
366
371
|
txType?: TransactionRunType,
|
367
|
-
confirmTimeout: number =
|
372
|
+
confirmTimeout: number = 15000,
|
368
373
|
prioritySetting: PriorityFeeSetting = PriorityFeeSetting.Default,
|
369
374
|
onAwaitingSign?: () => void
|
370
375
|
): Promise<Uint8Array | undefined> {
|
@@ -372,11 +377,14 @@ export async function sendSingleOptimizedTransaction(
|
|
372
377
|
consoleLog("Instructions: ", tx.getInstructions().length);
|
373
378
|
consoleLog("Serialized transaction size: ", tx.getTransactionSize(umi));
|
374
379
|
|
375
|
-
let cuPrice
|
376
|
-
if (
|
377
|
-
cuPrice =
|
380
|
+
let cuPrice: number | undefined;
|
381
|
+
if (prioritySetting !== PriorityFeeSetting.None) {
|
382
|
+
cuPrice = await getComputeUnitPriceEstimate(umi, tx, prioritySetting);
|
383
|
+
if (!cuPrice) {
|
384
|
+
cuPrice = 1000000;
|
385
|
+
}
|
386
|
+
consoleLog("Compute unit price: ", cuPrice);
|
378
387
|
}
|
379
|
-
consoleLog("Compute unit price: ", cuPrice);
|
380
388
|
|
381
389
|
let computeUnitLimit = undefined;
|
382
390
|
if (txType !== "skip-simulation") {
|
@@ -399,7 +407,7 @@ export async function sendSingleOptimizedTransaction(
|
|
399
407
|
3
|
400
408
|
);
|
401
409
|
simulationResult.value.err;
|
402
|
-
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed! * 1.
|
410
|
+
computeUnitLimit = Math.round(simulationResult.value.unitsConsumed! * 1.1);
|
403
411
|
consoleLog("Compute unit limit: ", computeUnitLimit);
|
404
412
|
}
|
405
413
|
|
@@ -418,6 +426,7 @@ export async function sendSingleOptimizedTransaction(
|
|
418
426
|
// },
|
419
427
|
// confirm: { commitment: "confirmed" },
|
420
428
|
// });
|
429
|
+
// const txSig = bs58.encode(result.signature);
|
421
430
|
|
422
431
|
const blockhash = await connection.getLatestBlockhash("confirmed");
|
423
432
|
const signedTx = await assembleFinalTransaction(
|
@@ -428,13 +437,13 @@ export async function sendSingleOptimizedTransaction(
|
|
428
437
|
)
|
429
438
|
.setBlockhash(blockhash)
|
430
439
|
.buildAndSign(umi);
|
431
|
-
|
432
440
|
const txSig = await spamSendTransactionUntilConfirmed(
|
433
441
|
connection,
|
434
442
|
toWeb3JsTransaction(signedTx),
|
435
443
|
blockhash,
|
436
444
|
confirmTimeout
|
437
445
|
);
|
446
|
+
|
438
447
|
consoleLog(`Transaction signature: ${txSig}`);
|
439
448
|
consoleLog(`https://solscan.io/tx/${txSig}`);
|
440
449
|
return bs58.decode(txSig);
|
@@ -19,6 +19,7 @@ import { JupSwapDetails } from "../jupiterUtils";
|
|
19
19
|
import { currentUnixSeconds, safeGetPrice } from "../generalUtils";
|
20
20
|
import {
|
21
21
|
fromBaseUnit,
|
22
|
+
fromBps,
|
22
23
|
getDebtAdjustmentUsd,
|
23
24
|
getLiqUtilzationRateBps,
|
24
25
|
getMaxLiqUtilizationRateBps,
|
@@ -164,7 +165,8 @@ export interface RebalanceValues {
|
|
164
165
|
amountUsdToDcaIn: number;
|
165
166
|
dcaTokenType?: TokenType;
|
166
167
|
rebalanceAction: RebalanceAction;
|
167
|
-
rebalanceDirection: RebalanceDirection
|
168
|
+
rebalanceDirection: RebalanceDirection;
|
169
|
+
feesUsd: number;
|
168
170
|
}
|
169
171
|
|
170
172
|
export function getRebalanceValues(
|
@@ -222,6 +224,7 @@ export function getRebalanceValues(
|
|
222
224
|
rebalanceAction:
|
223
225
|
(amountToDcaIn ?? 0) > 0 ? "dca" : rebalanceDirection === RebalanceDirection.Boost ? "boost" : "repay",
|
224
226
|
rebalanceDirection,
|
227
|
+
feesUsd: debtAdjustmentUsd * fromBps(adjustmentFeeBps)
|
225
228
|
};
|
226
229
|
}
|
227
230
|
|
@@ -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) =>
|
@@ -133,13 +117,6 @@ describe("Solauto Marginfi tests", async () => {
|
|
133
117
|
)
|
134
118
|
);
|
135
119
|
|
136
|
-
// transactionItems.push(
|
137
|
-
// new TransactionItem(
|
138
|
-
// async (attemptNum) => await buildSolautoRebalanceTransaction(client, 0),
|
139
|
-
// "repay all debt"
|
140
|
-
// )
|
141
|
-
// );
|
142
|
-
|
143
120
|
// transactionItems.push(
|
144
121
|
// new TransactionItem(
|
145
122
|
// async () => ({
|
@@ -164,7 +141,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
164
141
|
client,
|
165
142
|
undefined,
|
166
143
|
!payForTransactions ? "only-simulate" : "normal",
|
167
|
-
useJitoBundle
|
168
|
-
).clientSend(transactionItems, PriorityFeeSetting.
|
144
|
+
useJitoBundle
|
145
|
+
).clientSend(transactionItems, PriorityFeeSetting.None);
|
169
146
|
});
|
170
147
|
});
|