@haven-fi/solauto-sdk 1.0.452 → 1.0.455
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/transactionUtils.d.ts +2 -1
- package/dist/transactions/transactionUtils.d.ts.map +1 -1
- package/dist/transactions/transactionUtils.js +13 -2
- 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 +12 -2
- package/package.json +1 -1
- package/src/transactions/transactionUtils.ts +21 -3
- package/src/utils/solauto/rebalanceUtils.ts +14 -3
- package/tests/transactions/solautoMarginfi.ts +22 -13
@@ -1,11 +1,12 @@
|
|
1
1
|
import { TransactionBuilder, Umi } from "@metaplex-foundation/umi";
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
3
3
|
import { SolautoClient } from "../clients/solautoClient";
|
4
|
+
import { RebalanceValues } from "../utils/solauto/rebalanceUtils";
|
4
5
|
import { ReferralStateManager } from "../clients";
|
5
6
|
import { TransactionItemInputs } from "../types";
|
6
7
|
export declare function rebalanceChoresBefore(client: SolautoClient, tx: TransactionBuilder, accountsGettingCreated: string[]): Promise<TransactionBuilder>;
|
7
8
|
export declare function getTransactionChores(client: SolautoClient, tx: TransactionBuilder): Promise<[TransactionBuilder, TransactionBuilder]>;
|
8
|
-
export declare function requiresRefreshBeforeRebalance(client: SolautoClient): Promise<boolean>;
|
9
|
+
export declare function requiresRefreshBeforeRebalance(client: SolautoClient, values: RebalanceValues): Promise<boolean>;
|
9
10
|
export declare function buildSolautoRebalanceTransaction(client: SolautoClient, targetLiqUtilizationRateBps?: number, attemptNum?: number): Promise<TransactionItemInputs | undefined>;
|
10
11
|
export declare function convertReferralFeesToDestination(referralManager: ReferralStateManager, tokenAccount: PublicKey, destinationMint: PublicKey): Promise<TransactionItemInputs | undefined>;
|
11
12
|
export declare function getErrorInfo(umi: Umi, txs: TransactionBuilder[], error: Error, simulationSuccessful?: boolean): {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,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,EAIL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AAqBxE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAOzD,OAAO,EAIL,eAAe,EAChB,MAAM,iCAAiC,CAAC;AA2BzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAOlD,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AA6LjD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAoH7B;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,EAAE,MAAM,EAAE,eAAe,oBAkElG;AAED,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC,CAqI5C;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,CAC1B,GAAG,EAAE,GAAG,EACR,GAAG,EAAE,kBAAkB,EAAE,EACzB,KAAK,EAAE,KAAK,EACZ,oBAAoB,CAAC,EAAE,OAAO;;;;EAiG/B"}
|
@@ -329,7 +329,17 @@ async function getTransactionChores(client, tx) {
|
|
329
329
|
choresAfter = choresAfter.add(transactionChoresAfter(client, solautoActions, client.livePositionUpdates.cancellingDca));
|
330
330
|
return [choresBefore, choresAfter];
|
331
331
|
}
|
332
|
-
async function requiresRefreshBeforeRebalance(client) {
|
332
|
+
async function requiresRefreshBeforeRebalance(client, values) {
|
333
|
+
// REMOVE ME
|
334
|
+
const state = client.solautoPositionState;
|
335
|
+
const settings = client.solautoPositionSettings();
|
336
|
+
if ((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint).equals(new web3_js_1.PublicKey(constants_1.JUP)) &&
|
337
|
+
(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint).equals(new web3_js_1.PublicKey(constants_1.USDC)) &&
|
338
|
+
settings &&
|
339
|
+
settings.boostToBps ===
|
340
|
+
(0, numberUtils_1.maxBoostToBps)(state.maxLtvBps, state.liqThresholdBps) && values.targetRateBps === 6500) {
|
341
|
+
return true;
|
342
|
+
}
|
333
343
|
const neverRefreshedBefore = client.solautoPositionData &&
|
334
344
|
client.solautoPositionData.state.supply.amountCanBeUsed.baseUnit ===
|
335
345
|
BigInt(0) &&
|
@@ -377,7 +387,8 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
|
|
377
387
|
const { jupQuote, lookupTableAddresses, setupInstructions, tokenLedgerIx, swapIx, } = await (0, jupiterUtils_1.getJupSwapTransaction)(client.signer, swapDetails, attemptNum);
|
378
388
|
const flashLoan = (0, rebalanceUtils_1.getFlashLoanDetails)(client, values, jupQuote);
|
379
389
|
let tx = (0, umi_1.transactionBuilder)();
|
380
|
-
|
390
|
+
// REVERT ME
|
391
|
+
if (await requiresRefreshBeforeRebalance(client, values)) {
|
381
392
|
tx = tx.add(client.refresh());
|
382
393
|
}
|
383
394
|
if (flashLoan) {
|
@@ -13,6 +13,7 @@ export interface RebalanceValues {
|
|
13
13
|
rebalanceAction: RebalanceAction;
|
14
14
|
rebalanceDirection: RebalanceDirection;
|
15
15
|
feesUsd: number;
|
16
|
+
targetRateBps: number;
|
16
17
|
}
|
17
18
|
export declare function getRebalanceValues(state: PositionState, settings: SolautoSettingsParameters | undefined, dca: DCASettings | undefined, currentUnixTime: number, supplyPrice: number, debtPrice: number, targetLiqUtilizationRateBps?: number): RebalanceValues;
|
18
19
|
export declare function rebalanceRequiresFlashLoan(client: SolautoClient, values: RebalanceValues): {
|
@@ -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,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAcjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoI9C,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;
|
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,iBAAiB,CAAC;AAOzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAcjD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAoI9C,MAAM,WAAW,eAAe;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,eAAe,EAAE,eAAe,CAAC;IACjC,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,yBAAyB,GAAG,SAAS,EAC/C,GAAG,EAAE,WAAW,GAAG,SAAS,EAC5B,eAAe,EAAE,MAAM,EACvB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,GACnC,eAAe,CAqEjB;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe;;;EAsDxB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;IAChB,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAmC9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CA4DhB"}
|
@@ -4,6 +4,7 @@ exports.getRebalanceValues = getRebalanceValues;
|
|
4
4
|
exports.rebalanceRequiresFlashLoan = rebalanceRequiresFlashLoan;
|
5
5
|
exports.getFlashLoanDetails = getFlashLoanDetails;
|
6
6
|
exports.getJupSwapRebalanceDetails = getJupSwapRebalanceDetails;
|
7
|
+
const web3_js_1 = require("@solana/web3.js");
|
7
8
|
const generated_1 = require("../../generated");
|
8
9
|
const generalUtils_1 = require("./generalUtils");
|
9
10
|
const umi_web3js_adapters_1 = require("@metaplex-foundation/umi-web3js-adapters");
|
@@ -11,6 +12,7 @@ const generalUtils_2 = require("../generalUtils");
|
|
11
12
|
const numberUtils_1 = require("../numberUtils");
|
12
13
|
const generalAccounts_1 = require("../../constants/generalAccounts");
|
13
14
|
const priceUtils_1 = require("../priceUtils");
|
15
|
+
const constants_1 = require("../../constants");
|
14
16
|
function getAdditionalAmountToDcaIn(dca) {
|
15
17
|
if (dca.dcaInBaseUnit === BigInt(0)) {
|
16
18
|
return 0;
|
@@ -83,7 +85,14 @@ function getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, target
|
|
83
85
|
}
|
84
86
|
function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice, debtPrice, targetLiqUtilizationRateBps) {
|
85
87
|
let { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, targetLiqUtilizationRateBps);
|
86
|
-
//
|
88
|
+
// REVERT ME AND GET TO THE ROOT OF THIS ISSUE
|
89
|
+
if ((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint).equals(new web3_js_1.PublicKey(constants_1.JUP)) &&
|
90
|
+
(0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint).equals(new web3_js_1.PublicKey(constants_1.USDC)) &&
|
91
|
+
settings &&
|
92
|
+
settings.boostToBps === (0, numberUtils_1.maxBoostToBps)(state.maxLtvBps, state.liqThresholdBps) &&
|
93
|
+
targetRateBps === settings.boostToBps) {
|
94
|
+
targetRateBps = 6500;
|
95
|
+
}
|
87
96
|
const amountUsdToDcaIn = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
|
88
97
|
(dca?.tokenType === generated_1.TokenType.Debt ? debtPrice : supplyPrice);
|
89
98
|
const rebalanceDirection = amountUsdToDcaIn > 0 || state.liqUtilizationRateBps <= targetRateBps
|
@@ -94,7 +103,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
|
|
94
103
|
amountUsdToDcaIn;
|
95
104
|
const debtUsd = (0, numberUtils_1.fromBaseUnit)(state.debt.amountUsed.baseAmountUsdValue, generalAccounts_1.USD_DECIMALS);
|
96
105
|
let debtAdjustmentUsd = (0, numberUtils_1.getDebtAdjustmentUsd)(state.liqThresholdBps, supplyUsd, debtUsd, targetRateBps, adjustmentFeeBps);
|
97
|
-
(0, generalUtils_2.consoleLog)("Target rate:", targetRateBps);
|
106
|
+
(0, generalUtils_2.consoleLog)("Target rate:", targetRateBps, (0, numberUtils_1.maxBoostToBps)(state.maxLtvBps, state.liqThresholdBps));
|
98
107
|
const maxRepayTo = (0, numberUtils_1.maxRepayToBps)(state.maxLtvBps, state.liqThresholdBps);
|
99
108
|
return {
|
100
109
|
debtAdjustmentUsd,
|
@@ -109,6 +118,7 @@ function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice,
|
|
109
118
|
: "repay",
|
110
119
|
rebalanceDirection,
|
111
120
|
feesUsd: Math.abs(debtAdjustmentUsd * (0, numberUtils_1.fromBps)(adjustmentFeeBps)),
|
121
|
+
targetRateBps
|
112
122
|
};
|
113
123
|
}
|
114
124
|
function rebalanceRequiresFlashLoan(client, values) {
|
package/package.json
CHANGED
@@ -19,6 +19,7 @@ import {
|
|
19
19
|
RebalanceDirection,
|
20
20
|
SolautoAction,
|
21
21
|
SolautoRebalanceType,
|
22
|
+
SolautoSettingsParameters,
|
22
23
|
TokenType,
|
23
24
|
convertReferralFees,
|
24
25
|
createSolautoProgram,
|
@@ -39,6 +40,7 @@ import {
|
|
39
40
|
getFlashLoanDetails,
|
40
41
|
getJupSwapRebalanceDetails,
|
41
42
|
getRebalanceValues,
|
43
|
+
RebalanceValues,
|
42
44
|
} from "../utils/solauto/rebalanceUtils";
|
43
45
|
import {
|
44
46
|
consoleLog,
|
@@ -49,6 +51,7 @@ import {
|
|
49
51
|
import { SolautoMarginfiClient } from "../clients/solautoMarginfiClient";
|
50
52
|
import {
|
51
53
|
getMaxLiqUtilizationRateBps,
|
54
|
+
maxBoostToBps,
|
52
55
|
uint8ArrayToBigInt,
|
53
56
|
} from "../utils/numberUtils";
|
54
57
|
import {
|
@@ -71,10 +74,11 @@ import {
|
|
71
74
|
getJupiterErrorFromCode,
|
72
75
|
JUPITER_PROGRAM_ID,
|
73
76
|
} from "../jupiter-sdk";
|
74
|
-
import { PRICES } from "../constants";
|
77
|
+
import { JUP, PRICES, USDC } from "../constants";
|
75
78
|
import { TransactionItemInputs } from "../types";
|
76
79
|
import { safeGetPrice } from "../utils";
|
77
80
|
import { BundleSimulationError } from "../types/transactions";
|
81
|
+
import { getPackedSettings } from "http2";
|
78
82
|
|
79
83
|
interface wSolTokenUsage {
|
80
84
|
wSolTokenAccount: PublicKey;
|
@@ -598,7 +602,20 @@ export async function getTransactionChores(
|
|
598
602
|
return [choresBefore, choresAfter];
|
599
603
|
}
|
600
604
|
|
601
|
-
export async function requiresRefreshBeforeRebalance(client: SolautoClient) {
|
605
|
+
export async function requiresRefreshBeforeRebalance(client: SolautoClient, values: RebalanceValues) {
|
606
|
+
// REMOVE ME
|
607
|
+
const state = client.solautoPositionState!;
|
608
|
+
const settings = client.solautoPositionSettings();
|
609
|
+
if (
|
610
|
+
toWeb3JsPublicKey(state.supply.mint).equals(new PublicKey(JUP)) &&
|
611
|
+
toWeb3JsPublicKey(state.debt.mint).equals(new PublicKey(USDC)) &&
|
612
|
+
settings &&
|
613
|
+
settings.boostToBps ===
|
614
|
+
maxBoostToBps(state.maxLtvBps, state.liqThresholdBps) && values.targetRateBps === 6500
|
615
|
+
) {
|
616
|
+
return true;
|
617
|
+
}
|
618
|
+
|
602
619
|
const neverRefreshedBefore =
|
603
620
|
client.solautoPositionData &&
|
604
621
|
client.solautoPositionData.state.supply.amountCanBeUsed.baseUnit ===
|
@@ -707,7 +724,8 @@ export async function buildSolautoRebalanceTransaction(
|
|
707
724
|
|
708
725
|
let tx = transactionBuilder();
|
709
726
|
|
710
|
-
|
727
|
+
// REVERT ME
|
728
|
+
if (await requiresRefreshBeforeRebalance(client, values)) {
|
711
729
|
tx = tx.add(client.refresh());
|
712
730
|
}
|
713
731
|
|
@@ -31,7 +31,7 @@ import {
|
|
31
31
|
import { USD_DECIMALS } from "../../constants/generalAccounts";
|
32
32
|
import { RebalanceAction } from "../../types";
|
33
33
|
import { safeGetPrice } from "../priceUtils";
|
34
|
-
import { TOKEN_INFO } from "../../constants";
|
34
|
+
import { JUP, TOKEN_INFO, USDC } from "../../constants";
|
35
35
|
|
36
36
|
function getAdditionalAmountToDcaIn(dca: DCASettings): number {
|
37
37
|
if (dca.dcaInBaseUnit === BigInt(0)) {
|
@@ -170,6 +170,7 @@ export interface RebalanceValues {
|
|
170
170
|
rebalanceAction: RebalanceAction;
|
171
171
|
rebalanceDirection: RebalanceDirection;
|
172
172
|
feesUsd: number;
|
173
|
+
targetRateBps: number;
|
173
174
|
}
|
174
175
|
|
175
176
|
export function getRebalanceValues(
|
@@ -189,7 +190,16 @@ export function getRebalanceValues(
|
|
189
190
|
targetLiqUtilizationRateBps
|
190
191
|
);
|
191
192
|
|
192
|
-
//
|
193
|
+
// REVERT ME AND GET TO THE ROOT OF THIS ISSUE
|
194
|
+
if (
|
195
|
+
toWeb3JsPublicKey(state.supply.mint).equals(new PublicKey(JUP)) &&
|
196
|
+
toWeb3JsPublicKey(state.debt.mint).equals(new PublicKey(USDC)) &&
|
197
|
+
settings &&
|
198
|
+
settings.boostToBps === maxBoostToBps(state.maxLtvBps, state.liqThresholdBps) &&
|
199
|
+
targetRateBps === settings.boostToBps
|
200
|
+
) {
|
201
|
+
targetRateBps = 6500;
|
202
|
+
}
|
193
203
|
|
194
204
|
const amountUsdToDcaIn =
|
195
205
|
fromBaseUnit(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
|
@@ -221,7 +231,7 @@ export function getRebalanceValues(
|
|
221
231
|
adjustmentFeeBps
|
222
232
|
);
|
223
233
|
|
224
|
-
consoleLog("Target rate:", targetRateBps);
|
234
|
+
consoleLog("Target rate:", targetRateBps, maxBoostToBps(state.maxLtvBps, state.liqThresholdBps));
|
225
235
|
const maxRepayTo = maxRepayToBps(state.maxLtvBps, state.liqThresholdBps);
|
226
236
|
return {
|
227
237
|
debtAdjustmentUsd,
|
@@ -238,6 +248,7 @@ export function getRebalanceValues(
|
|
238
248
|
: "repay",
|
239
249
|
rebalanceDirection,
|
240
250
|
feesUsd: Math.abs(debtAdjustmentUsd * fromBps(adjustmentFeeBps)),
|
251
|
+
targetRateBps
|
241
252
|
};
|
242
253
|
}
|
243
254
|
|
@@ -1,9 +1,5 @@
|
|
1
1
|
import { describe, it } from "mocha";
|
2
|
-
import {
|
3
|
-
none,
|
4
|
-
publicKey,
|
5
|
-
some,
|
6
|
-
} from "@metaplex-foundation/umi";
|
2
|
+
import { none, publicKey, some } from "@metaplex-foundation/umi";
|
7
3
|
import { setupTest } from "../shared";
|
8
4
|
import { SolautoMarginfiClient } from "../../src/clients/solautoMarginfiClient";
|
9
5
|
import {
|
@@ -29,19 +25,16 @@ import {
|
|
29
25
|
SOLAUTO_TEST_PROGRAM,
|
30
26
|
USDC,
|
31
27
|
} from "../../src/constants";
|
32
|
-
import {
|
33
|
-
buildHeliusApiUrl,
|
34
|
-
getSolautoManagedPositions,
|
35
|
-
} from "../../src/utils";
|
28
|
+
import { buildHeliusApiUrl, getSolautoManagedPositions } from "../../src/utils";
|
36
29
|
import { PriorityFeeSetting } from "../../src/types";
|
37
|
-
import { buildIronforgeApiUrl } from "../../dist";
|
30
|
+
import { buildIronforgeApiUrl, fetchSolautoPosition } from "../../dist";
|
38
31
|
|
39
32
|
describe("Solauto Marginfi tests", async () => {
|
40
33
|
// const signer = setupTest();
|
41
34
|
const signer = setupTest("solauto-manager");
|
42
35
|
|
43
36
|
const payForTransactions = true;
|
44
|
-
const testProgram =
|
37
|
+
const testProgram = true;
|
45
38
|
const positionId = 1;
|
46
39
|
|
47
40
|
it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
|
@@ -58,7 +51,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
58
51
|
await client.initialize({
|
59
52
|
signer,
|
60
53
|
positionId,
|
61
|
-
authority: new PublicKey("
|
54
|
+
authority: new PublicKey("rC5dMP5dmSsfQ66rynzfFzuc122Eex9h1RJHVDkeH6D"),
|
62
55
|
// new: true,
|
63
56
|
// marginfiAccount: new PublicKey(
|
64
57
|
// ""
|
@@ -68,7 +61,7 @@ describe("Solauto Marginfi tests", async () => {
|
|
68
61
|
// debtMint: new PublicKey(USDC),
|
69
62
|
});
|
70
63
|
|
71
|
-
// console.log(await
|
64
|
+
// console.log(await client.getFreshPositionState());
|
72
65
|
|
73
66
|
const transactionItems: TransactionItem[] = [];
|
74
67
|
// const settingParams: SolautoSettingsParametersInpArgs = {
|
@@ -86,6 +79,15 @@ describe("Solauto Marginfi tests", async () => {
|
|
86
79
|
// targetBoostToBps: none(),
|
87
80
|
// };
|
88
81
|
|
82
|
+
const settingParams: SolautoSettingsParametersInpArgs = {
|
83
|
+
boostToBps: client.solautoPositionSettings().boostToBps - 150,
|
84
|
+
boostGap: 50,
|
85
|
+
repayToBps: client.solautoPositionSettings().repayToBps - 150,
|
86
|
+
repayGap: 50,
|
87
|
+
automation: none(),
|
88
|
+
targetBoostToBps: none(),
|
89
|
+
};
|
90
|
+
|
89
91
|
// if (client.solautoPositionData === null) {
|
90
92
|
// transactionItems.push(
|
91
93
|
// new TransactionItem(async () => {
|
@@ -136,6 +138,13 @@ describe("Solauto Marginfi tests", async () => {
|
|
136
138
|
)
|
137
139
|
);
|
138
140
|
|
141
|
+
// transactionItems.push(
|
142
|
+
// new TransactionItem(
|
143
|
+
// async () => ({ tx: client.refresh() }),
|
144
|
+
// "refresh"
|
145
|
+
// )
|
146
|
+
// );
|
147
|
+
|
139
148
|
// transactionItems.push(
|
140
149
|
// new TransactionItem(
|
141
150
|
// async (attemptNum) =>
|