@haven-fi/solauto-sdk 1.0.58 → 1.0.59

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"solautoClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoClient.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAC;AACxC,OAAO,EAEL,UAAU,EACV,SAAS,EACV,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,MAAM,EACN,kBAAkB,EAClB,GAAG,EAQJ,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,aAAa,EAEd,MAAM,iDAAiD,CAAC;AACzD,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,aAAa,EACb,aAAa,EACb,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,yBAAyB,EACzB,gCAAgC,EAChC,sBAAsB,EASvB,MAAM,cAAc,CAAC;AAUtB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAOvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAOnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAGpE,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,aAAa,CAAC;IAEvB,UAAU,CAAC,EAAE,SAAS,CAAC;IACvB,QAAQ,CAAC,EAAE,SAAS,CAAC;IAErB,oBAAoB,CAAC,EAAE,SAAS,CAAC;IACjC,mBAAmB,CAAC,EAAE,SAAS,CAAC;CACjC;AAED,8BAAsB,aAAa;IAyCxB,SAAS,CAAC,EAAE,OAAO;IAxCrB,GAAG,EAAG,GAAG,CAAC;IACV,UAAU,EAAG,UAAU,CAAC;IACxB,eAAe,EAAG,eAAe,CAAC;IAElC,SAAS,EAAG,SAAS,CAAC;IACtB,MAAM,EAAG,MAAM,CAAC;IA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AA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CAgHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
1
+ {"version":3,"file":"transactionUtils.d.ts","sourceRoot":"","sources":["../../src/transactions/transactionUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,kBAAkB,EAClB,GAAG,EAGJ,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAGL,OAAO,IAAI,eAAe,EAC3B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAEL,aAAa,EASd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAsMzD,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,EACtB,sBAAsB,EAAE,MAAM,EAAE,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CA8G7B;AAkLD,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,aAAa,EACrB,EAAE,EAAE,kBAAkB,GACrB,OAAO,CAAC,CAAC,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CA4BnD;AAGD,wBAAsB,gCAAgC,CACpD,MAAM,EAAE,aAAa,EACrB,2BAA2B,CAAC,EAAE,MAAM,EACpC,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CACN;IACE,EAAE,EAAE,kBAAkB,CAAC;IACvB,oBAAoB,EAAE,MAAM,EAAE,CAAC;CAChC,GACD,SAAS,CACZ,CAiHA;AAED,wBAAsB,gCAAgC,CACpD,GAAG,EAAE,GAAG,EACR,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,eAAe,GAC5B,OAAO,CAAC,CAAC,kBAAkB,EAAE,MAAM,EAAE,CAAC,CAAC,CA8BzC"}
@@ -324,7 +324,7 @@ async function buildSolautoRebalanceTransaction(client, targetLiqUtilizationRate
324
324
  (targetLiqUtilizationRateBps === undefined &&
325
325
  !(0, generalUtils_2.eligibleForRebalance)(client.solautoPositionState, client.livePositionUpdates.settings ??
326
326
  client.solautoPositionData?.position.settingParams, client.livePositionUpdates.activeDca ??
327
- client.solautoPositionData?.position.dca))) {
327
+ client.solautoPositionData?.position.dca, (0, generalUtils_1.currentUnixSeconds)()))) {
328
328
  client.log("Not eligible for a rebalance");
329
329
  return undefined;
330
330
  }
@@ -3,16 +3,16 @@ import { Umi } from "@metaplex-foundation/umi";
3
3
  import { AutomationSettings, DCASettings, DCASettingsInpArgs, FeeType, LendingPlatform, PositionState, SolautoSettingsParameters, SolautoSettingsParametersInpArgs } from "../../generated";
4
4
  import { RebalanceAction, SolautoPositionDetails } from "../../types/solauto";
5
5
  export declare function nextAutomationPeriodTimestamp(automation: AutomationSettings): number;
6
- export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings): boolean;
6
+ export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixSecs?: number): boolean;
7
7
  export declare function getUpdatedValueFromAutomation(currValue: number, targetValue: number, automation: AutomationSettings, currentUnixTimestamp: number): number;
8
- export declare function getAdjustedSettingsFromAutomation(settings: SolautoSettingsParameters, currentUnixSeconds: number): SolautoSettingsParameters;
8
+ export declare function getAdjustedSettingsFromAutomation(settings: SolautoSettingsParameters, currentUnixSecs?: number): SolautoSettingsParameters;
9
9
  export declare function getSolautoFeesBps(isReferred: boolean, feeType: FeeType): {
10
10
  solauto: number;
11
11
  referrer: number;
12
12
  total: number;
13
13
  };
14
- export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings): RebalanceAction | undefined;
15
- export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters): boolean;
14
+ export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings, currentUnixSecs: number): RebalanceAction | undefined;
15
+ export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters, currentUnixSecs?: 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[]>;
@@ -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,EAAoB,GAAG,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,aAAa,EAEb,yBAAyB,EACzB,gCAAgC,EAIjC,MAAM,iBAAiB,CAAC;AAczB,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAgB9E,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,kBAAkB,GAC7B,MAAM,CAKR;AAED,wBAAgB,+BAA+B,CAC7C,UAAU,EAAE,kBAAkB,GAC7B,OAAO,CAET;AAED,wBAAgB,6BAA6B,CAC3C,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,kBAAkB,EAC9B,oBAAoB,EAAE,MAAM,UAY7B;AAED,wBAAgB,iCAAiC,CAC/C,QAAQ,EAAE,yBAAyB,EACnC,kBAAkB,EAAE,MAAM,GACzB,yBAAyB,CAgB3B;AAED,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,OAAO,EACnB,OAAO,EAAE,OAAO,GACf;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AA;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"}
@@ -33,8 +33,8 @@ function nextAutomationPeriodTimestamp(automation) {
33
33
  : Number(automation.unixStartDate) +
34
34
  automation.periodsPassed * Number(automation.intervalSeconds);
35
35
  }
36
- function eligibleForNextAutomationPeriod(automation) {
37
- return (0, generalUtils_1.currentUnixSeconds)() >= nextAutomationPeriodTimestamp(automation);
36
+ function eligibleForNextAutomationPeriod(automation, currentUnixSecs) {
37
+ return (currentUnixSecs ?? (0, generalUtils_1.currentUnixSeconds)()) >= nextAutomationPeriodTimestamp(automation);
38
38
  }
39
39
  function getUpdatedValueFromAutomation(currValue, targetValue, automation, currentUnixTimestamp) {
40
40
  const currRateDiff = currValue - targetValue;
@@ -44,10 +44,10 @@ function getUpdatedValueFromAutomation(currValue, targetValue, automation, curre
44
44
  const newValue = currValue - currRateDiff * progressPct;
45
45
  return newValue;
46
46
  }
47
- function getAdjustedSettingsFromAutomation(settings, currentUnixSeconds) {
47
+ function getAdjustedSettingsFromAutomation(settings, currentUnixSecs) {
48
48
  const boostToBps = settings.automation.targetPeriods > 0 &&
49
- eligibleForNextAutomationPeriod(settings.automation)
50
- ? getUpdatedValueFromAutomation(settings.boostToBps, settings.targetBoostToBps, settings.automation, currentUnixSeconds)
49
+ eligibleForNextAutomationPeriod(settings.automation, currentUnixSecs)
50
+ ? getUpdatedValueFromAutomation(settings.boostToBps, settings.targetBoostToBps, settings.automation, currentUnixSecs ?? (0, generalUtils_1.currentUnixSeconds)())
51
51
  : settings.boostToBps;
52
52
  return {
53
53
  ...settings,
@@ -66,17 +66,17 @@ function getSolautoFeesBps(isReferred, feeType) {
66
66
  total: fees,
67
67
  };
68
68
  }
69
- function eligibleForRebalance(positionState, positionSettings, positionDca) {
69
+ function eligibleForRebalance(positionState, positionSettings, positionDca, currentUnixSecs) {
70
70
  if (positionDca.automation.targetPeriods > 0 &&
71
- eligibleForNextAutomationPeriod(positionDca.automation)) {
71
+ eligibleForNextAutomationPeriod(positionDca.automation, currentUnixSecs)) {
72
72
  return "dca";
73
73
  }
74
74
  if (positionState.supply.amountUsed.baseUnit === BigInt(0)) {
75
75
  return undefined;
76
76
  }
77
- const boostToBps = eligibleForRefresh(positionState, positionSettings) &&
77
+ const boostToBps = eligibleForRefresh(positionState, positionSettings, currentUnixSecs) &&
78
78
  positionSettings.automation.targetPeriods > 0
79
- ? getUpdatedValueFromAutomation(positionSettings.boostToBps, positionSettings.targetBoostToBps, positionSettings.automation, (0, generalUtils_1.currentUnixSeconds)())
79
+ ? getUpdatedValueFromAutomation(positionSettings.boostToBps, positionSettings.targetBoostToBps, positionSettings.automation, currentUnixSecs)
80
80
  : positionSettings.boostToBps;
81
81
  const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
82
82
  const boostFrom = boostToBps - positionSettings.boostGap;
@@ -88,9 +88,9 @@ function eligibleForRebalance(positionState, positionSettings, positionDca) {
88
88
  }
89
89
  return undefined;
90
90
  }
91
- function eligibleForRefresh(positionState, positionSettings) {
91
+ function eligibleForRefresh(positionState, positionSettings, currentUnixSecs) {
92
92
  if (positionSettings.automation.targetPeriods > 0) {
93
- return eligibleForNextAutomationPeriod(positionSettings.automation);
93
+ return eligibleForNextAutomationPeriod(positionSettings.automation, currentUnixSecs);
94
94
  }
95
95
  else {
96
96
  return ((0, generalUtils_1.currentUnixSeconds)() - Number(positionState.lastUpdated) >
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.58",
3
+ "version": "1.0.59",
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",
@@ -49,14 +49,12 @@ import {
49
49
  } from "../utils/accountUtils";
50
50
  import {
51
51
  SOLAUTO_FEES_WALLET,
52
- SOLAUTO_MANAGER,
53
52
  } from "../constants/generalAccounts";
54
53
  import { JupSwapDetails } from "../utils/jupiterUtils";
55
54
  import {
56
55
  getSolanaRpcConnection,
57
56
  getWrappedInstruction,
58
57
  splTokenTransferUmiIx,
59
- systemTransferUmiIx,
60
58
  } from "../utils/solanaUtils";
61
59
  import { FlashLoanDetails } from "../utils/solauto/rebalanceUtils";
62
60
  import { NATIVE_MINT } from "@solana/spl-token";
@@ -66,7 +64,6 @@ import {
66
64
  } from "../constants/solautoConstants";
67
65
  import { currentUnixSeconds } from "../utils/generalUtils";
68
66
  import { LivePositionUpdates } from "../utils/solauto/generalUtils";
69
- import { toBaseUnit } from "../utils";
70
67
 
71
68
  export interface SolautoClientArgs {
72
69
  authority?: PublicKey;
@@ -38,6 +38,7 @@ import {
38
38
  getRebalanceValues,
39
39
  } from "../utils/solauto/rebalanceUtils";
40
40
  import {
41
+ currentUnixSeconds,
41
42
  getSolanaAccountCreated,
42
43
  rpcAccountCreated,
43
44
  } from "../utils/generalUtils";
@@ -568,7 +569,8 @@ export async function buildSolautoRebalanceTransaction(
568
569
  client.livePositionUpdates.settings ??
569
570
  client.solautoPositionData?.position.settingParams!,
570
571
  client.livePositionUpdates.activeDca ??
571
- client.solautoPositionData?.position.dca!
572
+ client.solautoPositionData?.position.dca!,
573
+ currentUnixSeconds()
572
574
  ))
573
575
  ) {
574
576
  client.log("Not eligible for a rebalance");
@@ -53,9 +53,10 @@ export function nextAutomationPeriodTimestamp(
53
53
  }
54
54
 
55
55
  export function eligibleForNextAutomationPeriod(
56
- automation: AutomationSettings
56
+ automation: AutomationSettings,
57
+ currentUnixSecs?: number
57
58
  ): boolean {
58
- return currentUnixSeconds() >= nextAutomationPeriodTimestamp(automation);
59
+ return (currentUnixSecs ?? currentUnixSeconds()) >= nextAutomationPeriodTimestamp(automation);
59
60
  }
60
61
 
61
62
  export function getUpdatedValueFromAutomation(
@@ -78,16 +79,16 @@ export function getUpdatedValueFromAutomation(
78
79
 
79
80
  export function getAdjustedSettingsFromAutomation(
80
81
  settings: SolautoSettingsParameters,
81
- currentUnixSeconds: number
82
+ currentUnixSecs?: number
82
83
  ): SolautoSettingsParameters {
83
84
  const boostToBps =
84
85
  settings.automation.targetPeriods > 0 &&
85
- eligibleForNextAutomationPeriod(settings.automation)
86
+ eligibleForNextAutomationPeriod(settings.automation, currentUnixSecs)
86
87
  ? getUpdatedValueFromAutomation(
87
88
  settings.boostToBps,
88
89
  settings.targetBoostToBps,
89
90
  settings.automation,
90
- currentUnixSeconds
91
+ currentUnixSecs ?? currentUnixSeconds()
91
92
  )
92
93
  : settings.boostToBps;
93
94
 
@@ -121,11 +122,12 @@ export function getSolautoFeesBps(
121
122
  export function eligibleForRebalance(
122
123
  positionState: PositionState,
123
124
  positionSettings: SolautoSettingsParameters,
124
- positionDca: DCASettings
125
+ positionDca: DCASettings,
126
+ currentUnixSecs: number
125
127
  ): RebalanceAction | undefined {
126
128
  if (
127
129
  positionDca.automation.targetPeriods > 0 &&
128
- eligibleForNextAutomationPeriod(positionDca.automation)
130
+ eligibleForNextAutomationPeriod(positionDca.automation, currentUnixSecs)
129
131
  ) {
130
132
  return "dca";
131
133
  }
@@ -135,13 +137,13 @@ export function eligibleForRebalance(
135
137
  }
136
138
 
137
139
  const boostToBps =
138
- eligibleForRefresh(positionState, positionSettings) &&
140
+ eligibleForRefresh(positionState, positionSettings, currentUnixSecs) &&
139
141
  positionSettings.automation.targetPeriods > 0
140
142
  ? getUpdatedValueFromAutomation(
141
143
  positionSettings.boostToBps,
142
144
  positionSettings.targetBoostToBps,
143
145
  positionSettings.automation,
144
- currentUnixSeconds()
146
+ currentUnixSecs
145
147
  )
146
148
  : positionSettings.boostToBps;
147
149
  const repayFrom = positionSettings.repayToBps + positionSettings.repayGap;
@@ -158,10 +160,11 @@ export function eligibleForRebalance(
158
160
 
159
161
  export function eligibleForRefresh(
160
162
  positionState: PositionState,
161
- positionSettings: SolautoSettingsParameters
163
+ positionSettings: SolautoSettingsParameters,
164
+ currentUnixSecs?: number
162
165
  ): boolean {
163
166
  if (positionSettings.automation.targetPeriods > 0) {
164
- return eligibleForNextAutomationPeriod(positionSettings.automation);
167
+ return eligibleForNextAutomationPeriod(positionSettings.automation, currentUnixSecs);
165
168
  } else {
166
169
  return (
167
170
  currentUnixSeconds() - Number(positionState.lastUpdated) >