@haven-fi/solauto-sdk 1.0.60 → 1.0.61

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,21 +11,20 @@ export declare function getSolautoFeesBps(isReferred: boolean, feeType: FeeType)
11
11
  referrer: number;
12
12
  total: number;
13
13
  };
14
- export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings, currentUnixSecs: number): RebalanceAction | undefined;
14
+ export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings | undefined, currentUnixSecs: number): RebalanceAction | undefined;
15
15
  export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters, currentUnixTime: number): boolean;
16
16
  export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicKey): Promise<SolautoPositionDetails[]>;
17
17
  export declare function getAllReferralStates(umi: Umi): Promise<PublicKey[]>;
18
18
  export declare function getReferralsByUser(umi: Umi, user: PublicKey): Promise<PublicKey[]>;
19
19
  export declare function getAllPositionsByAuthority(umi: Umi, user: PublicKey): Promise<SolautoPositionDetails[]>;
20
- interface GetLatestStateProps {
20
+ export declare function positionStateWithPrices({ state, supplyPrice, debtPrice, umi, protocolAccount, lendingPlatform, }: {
21
21
  state: PositionState;
22
22
  umi?: Umi;
23
23
  protocolAccount?: PublicKey;
24
24
  lendingPlatform?: LendingPlatform;
25
25
  supplyPrice?: number;
26
26
  debtPrice?: number;
27
- }
28
- export declare function positionStateWithPrices({ state, supplyPrice, debtPrice, umi, protocolAccount, lendingPlatform, }: GetLatestStateProps): Promise<PositionState | undefined>;
27
+ }): Promise<PositionState | undefined>;
29
28
  interface AssetProps {
30
29
  amountUsedBaseUnit: bigint;
31
30
  decimals: number;
@@ -1 +1 @@
1
- {"version":3,"file":"generalUtils.d.ts","sourceRoot":"","sources":["../../../src/utils/solauto/generalUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAA+B,GAAG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C,aAAa,GAAG,SAAS,CAAC,CAgErC;AAED,UAAU,UAAU;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,CAAC;CACjB;AAED,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,UAAU,EAChB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,GACtB,aAAa,CA8Df;AAED,KAAK,kBAAkB,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/C,qBAAa,mBAAmB;IACvB,gBAAgB,EAAE,MAAM,CAAa;IACrC,cAAc,EAAE,MAAM,CAAa;IACnC,uBAAuB,EAAE,MAAM,CAAa;IAC5C,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAEtD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IAyD9B,KAAK;IAQL,UAAU,IAAI,OAAO;CAQtB"}
@@ -68,7 +68,8 @@ function getSolautoFeesBps(isReferred, feeType) {
68
68
  };
69
69
  }
70
70
  function eligibleForRebalance(positionState, positionSettings, positionDca, currentUnixSecs) {
71
- if (positionDca.automation.targetPeriods > 0 &&
71
+ if (positionDca &&
72
+ positionDca.automation.targetPeriods > 0 &&
72
73
  eligibleForNextAutomationPeriod(positionDca.automation, currentUnixSecs)) {
73
74
  return "dca";
74
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.60",
3
+ "version": "1.0.61",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "Typescript SDK for the Solauto program on the Solana blockchain",
@@ -122,10 +122,11 @@ export function getSolautoFeesBps(
122
122
  export function eligibleForRebalance(
123
123
  positionState: PositionState,
124
124
  positionSettings: SolautoSettingsParameters,
125
- positionDca: DCASettings,
125
+ positionDca: DCASettings | undefined,
126
126
  currentUnixSecs: number
127
127
  ): RebalanceAction | undefined {
128
128
  if (
129
+ positionDca &&
129
130
  positionDca.automation.targetPeriods > 0 &&
130
131
  eligibleForNextAutomationPeriod(positionDca.automation, currentUnixSecs)
131
132
  ) {
@@ -325,15 +326,6 @@ export async function getAllPositionsByAuthority(
325
326
  return allPositions;
326
327
  }
327
328
 
328
- interface GetLatestStateProps {
329
- state: PositionState;
330
- umi?: Umi;
331
- protocolAccount?: PublicKey;
332
- lendingPlatform?: LendingPlatform;
333
- supplyPrice?: number;
334
- debtPrice?: number;
335
- }
336
-
337
329
  export async function positionStateWithPrices({
338
330
  state,
339
331
  supplyPrice,
@@ -341,7 +333,14 @@ export async function positionStateWithPrices({
341
333
  umi,
342
334
  protocolAccount,
343
335
  lendingPlatform,
344
- }: GetLatestStateProps): Promise<PositionState | undefined> {
336
+ }: {
337
+ state: PositionState;
338
+ umi?: Umi;
339
+ protocolAccount?: PublicKey;
340
+ lendingPlatform?: LendingPlatform;
341
+ supplyPrice?: number;
342
+ debtPrice?: number;
343
+ }): Promise<PositionState | undefined> {
345
344
  if (currentUnixSeconds() - Number(state.lastUpdated) > 60 * 60 * 24 * 7) {
346
345
  if (
347
346
  umi === undefined ||
@@ -19,7 +19,6 @@ import {
19
19
  } from "../../src/transactions/transactionsManager";
20
20
  import { PublicKey } from "@solana/web3.js";
21
21
  import { USDC_MINT } from "../../src/constants";
22
- import { positionStateWithLatestPrices } from "../../src/utils/solauto/generalUtils";
23
22
 
24
23
  describe("Solauto Marginfi tests", async () => {
25
24
  // const signer = setupTest();