@haven-fi/solauto-sdk 1.0.129 → 1.0.131
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/transactions/transactionsManager.js +1 -1
- package/dist/utils/generalUtils.d.ts +1 -1
- package/dist/utils/generalUtils.d.ts.map +1 -1
- package/dist/utils/generalUtils.js +1 -1
- package/dist/utils/solauto/rebalanceUtils.d.ts.map +1 -1
- package/dist/utils/solauto/rebalanceUtils.js +0 -5
- package/package.json +1 -1
- package/src/transactions/transactionsManager.ts +1 -1
- package/src/utils/generalUtils.ts +3 -3
- package/src/utils/solauto/rebalanceUtils.ts +0 -10
@@ -217,7 +217,7 @@ class TransactionsManager {
|
|
217
217
|
this.txHandler.log("Chores before: ", choresBefore.getInstructions().length);
|
218
218
|
}
|
219
219
|
if (choresAfter.getInstructions().length > 0) {
|
220
|
-
const chore = new TransactionItem(async () => ({ tx: choresAfter }), "
|
220
|
+
const chore = new TransactionItem(async () => ({ tx: choresAfter }), "close temp accounts");
|
221
221
|
await chore.initialize();
|
222
222
|
items.push(chore);
|
223
223
|
this.txHandler.log("Chores after: ", choresAfter.getInstructions().length);
|
@@ -7,7 +7,7 @@ export declare function getSolanaAccountCreated(umi: Umi, pk: PublicKey): Promis
|
|
7
7
|
export declare function rpcAccountCreated(account: MaybeRpcAccount): boolean;
|
8
8
|
export declare function arraysAreEqual(arrayA: number[], arrayB: number[]): boolean;
|
9
9
|
export declare function fetchTokenPrices(mints: PublicKey[]): Promise<number[]>;
|
10
|
-
export declare function safeGetPrice(mint: PublicKey | UmiPublicKey): number | undefined;
|
10
|
+
export declare function safeGetPrice(mint: PublicKey | UmiPublicKey | undefined): number | undefined;
|
11
11
|
export type ErrorsToThrow = Array<new (...args: any[]) => Error>;
|
12
12
|
export declare function retryWithExponentialBackoff<T>(fn: (attemptNum: number) => Promise<T>, retries?: number, delay?: number, errorsToThrow?: ErrorsToThrow): Promise<T>;
|
13
13
|
//# sourceMappingURL=generalUtils.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,GAAG,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKtG,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,GACZ,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAU1E;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+C5E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,
|
1
|
+
{"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../src/utils/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAa,GAAG,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAKtG,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,CAO1C;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,uBAAuB,CAC3C,GAAG,EAAE,GAAG,EACR,EAAE,EAAE,SAAS,GACZ,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAEnE;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAU1E;AAED,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CA+C5E;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAK3F;AAED,MAAM,MAAM,aAAa,GAAG,KAAK,CAAC,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC,CAAC;AAEjE,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,EAAE,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,CAAC,CAAC,EACtC,OAAO,GAAE,MAAU,EACnB,KAAK,GAAE,MAAY,EACnB,aAAa,CAAC,EAAE,aAAa,GAC5B,OAAO,CAAC,CAAC,CAAC,CA8BZ"}
|
@@ -81,7 +81,7 @@ async function fetchTokenPrices(mints) {
|
|
81
81
|
return prices;
|
82
82
|
}
|
83
83
|
function safeGetPrice(mint) {
|
84
|
-
if (mint
|
84
|
+
if (mint && mint?.toString() in solautoConstants_1.PRICES) {
|
85
85
|
return solautoConstants_1.PRICES[mint.toString()].price;
|
86
86
|
}
|
87
87
|
return undefined;
|
@@ -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,yBAAyB,EAC1B,MAAM,iBAAiB,CAAC;AAOzB,OAAO,EAAE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M,EACnB,SAAS,EAAE,MAAM,EACjB,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,CAgEjB;AAED,MAAM,WAAW,gBAAgB;IAC/B,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,QAAQ,EAAE,aAAa,GACtB,gBAAgB,GAAG,SAAS,CAmE9B;AAED,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,cAAc,CAkChB"}
|
@@ -80,11 +80,6 @@ function getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, target
|
|
80
80
|
}
|
81
81
|
}
|
82
82
|
function getRebalanceValues(state, settings, dca, currentUnixTime, supplyPrice, debtPrice, targetLiqUtilizationRateBps, limitGapBps) {
|
83
|
-
if (state === undefined ||
|
84
|
-
state.lastUpdated <
|
85
|
-
BigInt(Math.round((0, generalUtils_2.currentUnixSeconds)() - solautoConstants_1.MIN_POSITION_STATE_FRESHNESS_SECS))) {
|
86
|
-
throw new Error("Requires a fresh position state to get rebalance details");
|
87
|
-
}
|
88
83
|
const { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(state, settings, dca, currentUnixTime, targetLiqUtilizationRateBps);
|
89
84
|
const amountUsdToDcaIn = (0, numberUtils_1.fromBaseUnit)(BigInt(Math.round(amountToDcaIn ?? 0)), state.debt.decimals) *
|
90
85
|
debtPrice;
|
package/package.json
CHANGED
@@ -331,7 +331,7 @@ export class TransactionsManager {
|
|
331
331
|
if (choresAfter.getInstructions().length > 0) {
|
332
332
|
const chore = new TransactionItem(
|
333
333
|
async () => ({ tx: choresAfter }),
|
334
|
-
"
|
334
|
+
"close temp accounts"
|
335
335
|
);
|
336
336
|
await chore.initialize();
|
337
337
|
items.push(chore);
|
@@ -94,9 +94,9 @@ export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
|
|
94
94
|
return prices;
|
95
95
|
}
|
96
96
|
|
97
|
-
export function safeGetPrice(mint: PublicKey | UmiPublicKey): number | undefined {
|
98
|
-
if (mint
|
99
|
-
return PRICES[mint
|
97
|
+
export function safeGetPrice(mint: PublicKey | UmiPublicKey | undefined): number | undefined {
|
98
|
+
if (mint && mint?.toString() in PRICES) {
|
99
|
+
return PRICES[mint!.toString()].price;
|
100
100
|
}
|
101
101
|
return undefined;
|
102
102
|
}
|
@@ -176,16 +176,6 @@ export function getRebalanceValues(
|
|
176
176
|
targetLiqUtilizationRateBps?: number,
|
177
177
|
limitGapBps?: number
|
178
178
|
): RebalanceValues {
|
179
|
-
if (
|
180
|
-
state === undefined ||
|
181
|
-
state.lastUpdated <
|
182
|
-
BigInt(
|
183
|
-
Math.round(currentUnixSeconds() - MIN_POSITION_STATE_FRESHNESS_SECS)
|
184
|
-
)
|
185
|
-
) {
|
186
|
-
throw new Error("Requires a fresh position state to get rebalance details");
|
187
|
-
}
|
188
|
-
|
189
179
|
const { targetRateBps, amountToDcaIn } = getTargetRateAndDcaAmount(
|
190
180
|
state,
|
191
181
|
settings,
|