@haven-fi/solauto-sdk 1.0.61 → 1.0.62

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  import { PublicKey } from "@solana/web3.js";
2
2
  import { Umi } from "@metaplex-foundation/umi";
3
- import { AutomationSettings, DCASettings, DCASettingsInpArgs, FeeType, LendingPlatform, PositionState, SolautoSettingsParameters, SolautoSettingsParametersInpArgs } from "../../generated";
3
+ import { AutomationSettings, DCASettings, DCASettingsInpArgs, FeeType, PositionState, SolautoSettingsParameters, SolautoSettingsParametersInpArgs } from "../../generated";
4
4
  import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
5
5
  export declare function nextAutomationPeriodTimestamp(automation: AutomationSettings): number;
6
6
  export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixTime: number): boolean;
@@ -17,14 +17,7 @@ export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicK
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
- export declare function positionStateWithPrices({ state, supplyPrice, debtPrice, umi, protocolAccount, lendingPlatform, }: {
21
- state: PositionState;
22
- umi?: Umi;
23
- protocolAccount?: PublicKey;
24
- lendingPlatform?: LendingPlatform;
25
- supplyPrice?: number;
26
- debtPrice?: number;
27
- }): Promise<PositionState | undefined>;
20
+ export declare function positionStateWithPrices(state: PositionState, supplyPrice?: number, debtPrice?: number): Promise<PositionState | undefined>;
28
21
  interface AssetProps {
29
22
  amountUsedBaseUnit: bigint;
30
23
  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,EAAE,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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"}
@@ -213,20 +213,7 @@ async function getAllPositionsByAuthority(umi, user) {
213
213
  // TODO support other platforms
214
214
  return allPositions;
215
215
  }
216
- async function positionStateWithPrices({ state, supplyPrice, debtPrice, umi, protocolAccount, lendingPlatform, }) {
217
- if ((0, generalUtils_1.currentUnixSeconds)() - Number(state.lastUpdated) > 60 * 60 * 24 * 7) {
218
- if (umi === undefined ||
219
- protocolAccount === undefined ||
220
- lendingPlatform === undefined) {
221
- throw new Error("Missing required parameters");
222
- }
223
- if (lendingPlatform === generated_1.LendingPlatform.Marginfi) {
224
- return await (0, marginfiUtils_1.getMarginfiAccountPositionState)(umi, protocolAccount, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint), (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.debt.mint));
225
- }
226
- else {
227
- throw new Error("Lending platorm not yet supported");
228
- }
229
- }
216
+ async function positionStateWithPrices(state, supplyPrice, debtPrice) {
230
217
  if (!supplyPrice || !debtPrice) {
231
218
  [supplyPrice, debtPrice] = await (0, generalUtils_1.getTokenPrices)([
232
219
  (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(state.supply.mint),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.61",
3
+ "version": "1.0.62",
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",
@@ -326,42 +326,11 @@ export async function getAllPositionsByAuthority(
326
326
  return allPositions;
327
327
  }
328
328
 
329
- export async function positionStateWithPrices({
330
- state,
331
- supplyPrice,
332
- debtPrice,
333
- umi,
334
- protocolAccount,
335
- lendingPlatform,
336
- }: {
337
- state: PositionState;
338
- umi?: Umi;
339
- protocolAccount?: PublicKey;
340
- lendingPlatform?: LendingPlatform;
341
- supplyPrice?: number;
342
- debtPrice?: number;
343
- }): Promise<PositionState | undefined> {
344
- if (currentUnixSeconds() - Number(state.lastUpdated) > 60 * 60 * 24 * 7) {
345
- if (
346
- umi === undefined ||
347
- protocolAccount === undefined ||
348
- lendingPlatform === undefined
349
- ) {
350
- throw new Error("Missing required parameters");
351
- }
352
-
353
- if (lendingPlatform === LendingPlatform.Marginfi) {
354
- return await getMarginfiAccountPositionState(
355
- umi,
356
- protocolAccount,
357
- toWeb3JsPublicKey(state.supply.mint),
358
- toWeb3JsPublicKey(state.debt.mint)
359
- );
360
- } else {
361
- throw new Error("Lending platorm not yet supported");
362
- }
363
- }
364
-
329
+ export async function positionStateWithPrices(
330
+ state: PositionState,
331
+ supplyPrice?: number,
332
+ debtPrice?: number,
333
+ ): Promise<PositionState | undefined> {
365
334
  if (!supplyPrice || !debtPrice) {
366
335
  [supplyPrice, debtPrice] = await getTokenPrices([
367
336
  toWeb3JsPublicKey(state.supply.mint),
@@ -117,8 +117,8 @@ async function getFakePosition(
117
117
  const supplyUsd = 1000;
118
118
  const maxLtvBps = 6400;
119
119
  const liqThresholdBps = 8181;
120
- client.solautoPositionState = await positionStateWithPrices({
121
- state: createFakePositionState(
120
+ client.solautoPositionState = await positionStateWithPrices(
121
+ createFakePositionState(
122
122
  {
123
123
  amountUsedBaseUnit: toBaseUnit(supplyUsd / supplyPrice, 9),
124
124
  decimals: 9,
@@ -139,8 +139,8 @@ async function getFakePosition(
139
139
  },
140
140
  maxLtvBps,
141
141
  liqThresholdBps
142
- ),
143
- });
142
+ )
143
+ );
144
144
 
145
145
  client.solautoPositionData = {
146
146
  positionId: [1],