@haven-fi/solauto-sdk 1.0.691 → 1.0.692
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/services/rebalance/rebalanceTxBuilder.d.ts.map +1 -1
- package/dist/services/rebalance/rebalanceTxBuilder.js +6 -0
- package/dist/services/transactions/transactionUtils.js +1 -1
- package/dist/solautoPosition/marginfiSolautoPositionEx.d.ts +2 -2
- package/dist/solautoPosition/marginfiSolautoPositionEx.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/services/rebalance/rebalanceTxBuilder.ts +8 -0
- package/src/services/transactions/transactionUtils.ts +1 -1
- package/src/solautoPosition/marginfiSolautoPositionEx.ts +2 -2
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,CAAC;
|
1
|
+
{"version":3,"file":"rebalanceTxBuilder.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceTxBuilder.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAGL,qBAAqB,EACtB,MAAM,aAAa,CAAC;AAgCrB,qBAAa,kBAAkB;IAQ3B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,2BAA2B,CAAC;IACpC,OAAO,CAAC,YAAY,CAAC;IATvB,OAAO,CAAC,MAAM,CAAmB;IACjC,OAAO,CAAC,aAAa,CAAwB;IAC7C,OAAO,CAAC,WAAW,CAAwB;IAC3C,OAAO,CAAC,cAAc,CAAC,CAAwB;IAC/C,OAAO,CAAC,SAAS,CAAiC;gBAGxC,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,YAAA,EACpC,YAAY,CAAC,EAAE,OAAO,YAAA;IAGhC,OAAO,CAAC,0BAA0B;IAclC,OAAO,CAAC,kBAAkB;IAc1B,OAAO,CAAC,oBAAoB;IAwC5B,OAAO,CAAC,iCAAiC;YAgC3B,qBAAqB;IA0CnC,OAAO,CAAC,mBAAmB;IAwB3B,OAAO,CAAC,gBAAgB;IA+BxB,OAAO,CAAC,yBAAyB;YAqBnB,mBAAmB;YAyBnB,sBAAsB;YAyBtB,mBAAmB;IA8EpB,gBAAgB,CAC3B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,qBAAqB,GAAG,SAAS,CAAC;CAe9C"}
|
@@ -200,6 +200,12 @@ class RebalanceTxBuilder {
|
|
200
200
|
};
|
201
201
|
(0, utils_1.consoleLog)("Rebalance details:", rebalanceDetails);
|
202
202
|
(0, utils_1.consoleLog)("Prices:", (0, utils_1.safeGetPrice)(this.client.pos.supplyMint, this.priceType), (0, utils_1.safeGetPrice)(this.client.pos.debtMint, this.priceType));
|
203
|
+
// TODO: remove me
|
204
|
+
if ((0, utils_1.isMarginfiPosition)(this.client.pos)) {
|
205
|
+
const weightedAssets = this.values.endResult.supplyUsd * (0, utils_1.bytesToI80F48)(this.client.pos.supplyBank.config.assetWeightInit.value);
|
206
|
+
const weightedLiabs = this.values.endResult.debtUsd * (0, utils_1.bytesToI80F48)(this.client.pos.debtBank.config.assetWeightInit.value);
|
207
|
+
(0, utils_1.consoleLog)("Weighted assets & liabs:", weightedAssets, weightedLiabs);
|
208
|
+
}
|
203
209
|
const firstRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PreSwap, rebalanceDetails);
|
204
210
|
const lastRebalance = this.client.rebalanceIx(generated_1.RebalanceStep.PostSwap, rebalanceDetails);
|
205
211
|
if (!flashLoanDetails) {
|
@@ -348,7 +348,7 @@ function getErrorInfo(umi, txs, error, simulationSuccessful) {
|
|
348
348
|
let errCode;
|
349
349
|
let errName;
|
350
350
|
// sub ixs to account for computeUnitLimit and computeUnitPrice that get added
|
351
|
-
const getComputeIxs = (txIdx) => (0, utils_1.addTxOptimizations)(umi, txs[txIdx], 1, !simulationSuccessful ? 1 : undefined).getInstructions().length - txs.length;
|
351
|
+
const getComputeIxs = (txIdx) => (0, utils_1.addTxOptimizations)(umi, txs[txIdx], 1, !simulationSuccessful ? 1 : undefined).getInstructions().length - txs[txIdx].getInstructions().length;
|
352
352
|
try {
|
353
353
|
if (error instanceof types_1.BundleSimulationError) {
|
354
354
|
errTxIdx = error.details.transactionIdx;
|
@@ -5,8 +5,8 @@ import { LendingPlatform, PriceType } from "../generated";
|
|
5
5
|
export declare class MarginfiSolautoPositionEx extends SolautoPositionEx {
|
6
6
|
lendingPlatform: LendingPlatform;
|
7
7
|
maxLtvPriceType: PriceType;
|
8
|
-
|
9
|
-
|
8
|
+
supplyBank: Bank | null;
|
9
|
+
debtBank: Bank | null;
|
10
10
|
private getBankAccounts;
|
11
11
|
getBanks(): Promise<Bank[]>;
|
12
12
|
priceOracles(): Promise<PublicKey[]>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"marginfiSolautoPositionEx.d.ts","sourceRoot":"","sources":["../../src/solautoPosition/marginfiSolautoPositionEx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAoB,MAAM,iBAAiB,CAAC;AAezD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,qBAAa,yBAA0B,SAAQ,iBAAiB;IAC9D,eAAe,kBAA4B;IAC3C,eAAe,YAAiB;
|
1
|
+
{"version":3,"file":"marginfiSolautoPositionEx.d.ts","sourceRoot":"","sources":["../../src/solautoPosition/marginfiSolautoPositionEx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAoB,MAAM,iBAAiB,CAAC;AAezD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE1D,qBAAa,yBAA0B,SAAQ,iBAAiB;IAC9D,eAAe,kBAA4B;IAC3C,eAAe,YAAiB;IAEzB,UAAU,EAAE,IAAI,GAAG,IAAI,CAAQ;IAC/B,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAQ;IAEpC,OAAO,CAAC,eAAe;IAMjB,QAAQ,IAAI,OAAO,CAAC,IAAI,EAAE,CAAC;IAW3B,YAAY,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IASpC,wBAAwB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAa3D,OAAO,CAAC,6BAA6B;IAwBrC,gCAAgC,CAAC,KAAK,EAAE,IAAI,EAAE;IAK9C,4BAA4B,CAAC,KAAK,EAAE,IAAI,EAAE;IAQ1C,IAAI,eAAe,cAElB;IAED,IAAI,aAAa,cAEhB;IAED,IAAI,wBAAwB,IAAI,MAAM,CAKrC;IAEK,oBAAoB,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CA2BjE"}
|
package/package.json
CHANGED
@@ -8,6 +8,7 @@ import {
|
|
8
8
|
TransactionItemInputs,
|
9
9
|
} from "../../types";
|
10
10
|
import {
|
11
|
+
bytesToI80F48,
|
11
12
|
consoleLog,
|
12
13
|
fromBaseUnit,
|
13
14
|
fromBps,
|
@@ -15,6 +16,7 @@ import {
|
|
15
16
|
getTokenAccount,
|
16
17
|
hasFirstRebalance,
|
17
18
|
hasLastRebalance,
|
19
|
+
isMarginfiPosition,
|
18
20
|
safeGetPrice,
|
19
21
|
tokenInfo,
|
20
22
|
} from "../../utils";
|
@@ -345,6 +347,12 @@ export class RebalanceTxBuilder {
|
|
345
347
|
safeGetPrice(this.client.pos.supplyMint, this.priceType),
|
346
348
|
safeGetPrice(this.client.pos.debtMint, this.priceType)
|
347
349
|
);
|
350
|
+
// TODO: remove me
|
351
|
+
if (isMarginfiPosition(this.client.pos)) {
|
352
|
+
const weightedAssets = this.values.endResult.supplyUsd * bytesToI80F48(this.client.pos.supplyBank!.config.assetWeightInit.value);
|
353
|
+
const weightedLiabs = this.values.endResult.debtUsd * bytesToI80F48(this.client.pos.debtBank!.config.assetWeightInit.value);
|
354
|
+
consoleLog("Weighted assets & liabs:", weightedAssets, weightedLiabs);
|
355
|
+
}
|
348
356
|
|
349
357
|
const firstRebalance = this.client.rebalanceIx(
|
350
358
|
RebalanceStep.PreSwap,
|
@@ -622,7 +622,7 @@ export function getErrorInfo(
|
|
622
622
|
txs[txIdx],
|
623
623
|
1,
|
624
624
|
!simulationSuccessful ? 1 : undefined
|
625
|
-
).getInstructions().length - txs.length;
|
625
|
+
).getInstructions().length - txs[txIdx].getInstructions().length;
|
626
626
|
|
627
627
|
try {
|
628
628
|
if (error instanceof BundleSimulationError) {
|
@@ -21,8 +21,8 @@ export class MarginfiSolautoPositionEx extends SolautoPositionEx {
|
|
21
21
|
lendingPlatform = LendingPlatform.Marginfi;
|
22
22
|
maxLtvPriceType = PriceType.Ema;
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
public supplyBank: Bank | null = null;
|
25
|
+
public debtBank: Bank | null = null;
|
26
26
|
|
27
27
|
private getBankAccounts(mint: PublicKey) {
|
28
28
|
const group = this.lpPoolAccount.toString();
|