@haven-fi/solauto-sdk 1.0.234 → 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 -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 +2 -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/package.json +1 -1
- package/src/constants/solautoConstants.ts +1 -1
- package/src/transactions/transactionUtils.ts +3 -8
- package/src/transactions/transactionsManager.ts +1 -1
- package/src/types/solauto.ts +2 -0
- package/src/utils/solanaUtils.ts +19 -9
- 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":[],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AE,GAAG;;;;EAuDxE"}
|
@@ -364,9 +364,8 @@ 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
|
368
|
-
|
369
|
-
values.feesUsd < 0.5) {
|
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) {
|
370
369
|
return undefined;
|
371
370
|
}
|
372
371
|
const swapDetails = (0, rebalanceUtils_1.getJupSwapRebalanceDetails)(client, values, targetLiqUtilizationRateBps, attemptNum);
|
@@ -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,cA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AAC;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,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,MAAM,EACd,EAAE,EAAE,sBAAsB,GACzB,kBAAkB,CAMpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,kBAAkB,CAOpB;AAED,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,kBAAkB,CAOpB;AAED,wBAAgB,iCAAiC,CAC/C,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE,SAAS,GACd,kBAAkB,CAUpB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,MAAM,E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AE,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)
|
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,14 +666,8 @@ export async function buildSolautoRebalanceTransaction(
|
|
665
666
|
);
|
666
667
|
client.log("Rebalance values: ", values);
|
667
668
|
|
668
|
-
if
|
669
|
-
|
670
|
-
fromBaseUnit(
|
671
|
-
client.solautoPositionState?.netWorth.baseAmountUsdValue ?? BigInt(0),
|
672
|
-
USD_DECIMALS
|
673
|
-
) < MIN_USD_SUPPORTED_POSITION &&
|
674
|
-
values.feesUsd < 0.5
|
675
|
-
) {
|
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) {
|
676
671
|
return undefined;
|
677
672
|
}
|
678
673
|
|
@@ -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,8 @@ export async function sendSingleOptimizedTransaction(
|
|
418
426
|
// },
|
419
427
|
// confirm: { commitment: "confirmed" },
|
420
428
|
// });
|
429
|
+
// const txSig = bs58.encode(result.signature);
|
430
|
+
|
421
431
|
const blockhash = await connection.getLatestBlockhash("confirmed");
|
422
432
|
const signedTx = await assembleFinalTransaction(
|
423
433
|
umi.identity,
|
@@ -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.None);
|
162
146
|
});
|
163
147
|
});
|