@haven-fi/solauto-sdk 1.0.290 → 1.0.291

Sign up to get free protection for your applications and to get access to all the features.
@@ -100,7 +100,7 @@ function getSolautoFeesBps(isReferred, targetLiqUtilizationRateBps, positionNetW
100
100
  let referrer = 0;
101
101
  if (isReferred) {
102
102
  feeBps *= 0.9;
103
- referrer = Math.floor(feeBps / 5);
103
+ referrer = Math.floor(feeBps * 0.15);
104
104
  }
105
105
  return {
106
106
  solauto: feeBps - referrer,
@@ -7,7 +7,7 @@ export declare function nextAutomationPeriodTimestamp(automation: AutomationSett
7
7
  export declare function eligibleForNextAutomationPeriod(automation: AutomationSettings, currentUnixTime: number): boolean;
8
8
  export declare function getUpdatedValueFromAutomation(currValue: number, targetValue: number, automation: AutomationSettings, currentUnixTimestamp: number): number;
9
9
  export declare function getAdjustedSettingsFromAutomation(settings: SolautoSettingsParameters, currentUnixTime: number): SolautoSettingsParameters;
10
- export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters, positionDca: DCASettings | undefined, currentUnixTime: number, bpsDistanceThreshold?: number): RebalanceAction | undefined;
10
+ export declare function eligibleForRebalance(positionState: PositionState, positionSettings: SolautoSettingsParameters | undefined, positionDca: DCASettings | undefined, currentUnixTime: number, bpsDistanceThreshold?: number): RebalanceAction | undefined;
11
11
  export declare function eligibleForRefresh(positionState: PositionState, positionSettings: SolautoSettingsParameters, currentUnixTime: number): boolean;
12
12
  export declare function getSolautoManagedPositions(umi: Umi, authority?: PublicKey, positionTypeFilter?: PositionType): Promise<SolautoPositionDetails[]>;
13
13
  export declare function getAllReferralStates(umi: Umi): 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,EAGL,OAAO,EAEP,GAAG,EACJ,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,kBAAk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a,CA8Df;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,gCAAgC,GACzC,yBAAyB,CA8B3B;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,UAAU,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,GAC1C;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAA;KAAE,CAAA;CAAE,GACzE;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,SAAS,CAAA;CAAE,CAAC;AAEhD,qBAAa,mBAAmB;IACvB,gBAAgB,SAAa;IAC7B,cAAc,SAAa;IAC3B,QAAQ,EAAE,yBAAyB,GAAG,SAAS,CAAa;IAC5D,SAAS,EAAE,WAAW,GAAG,SAAS,CAAa;IAC/C,YAAY,CAAC,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,SAAS,CAAA;KAAE,CAAa;IACpE,aAAa,EAAE,SAAS,GAAG,SAAS,CAAa;IAExD,GAAG,CAAC,MAAM,EAAE,kBAAkB;IA6B9B,KAAK;IASL,UAAU,IAAI,OAAO;CAStB"}
@@ -72,6 +72,9 @@ function getAdjustedSettingsFromAutomation(settings, currentUnixTime) {
72
72
  };
73
73
  }
74
74
  function eligibleForRebalance(positionState, positionSettings, positionDca, currentUnixTime, bpsDistanceThreshold = 0) {
75
+ if (!positionSettings) {
76
+ return undefined;
77
+ }
75
78
  if (positionDca &&
76
79
  positionDca.automation.targetPeriods > 0 &&
77
80
  eligibleForNextAutomationPeriod(positionDca.automation, currentUnixTime)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.290",
3
+ "version": "1.0.291",
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",
@@ -647,8 +647,8 @@ export async function buildSolautoRebalanceTransaction(
647
647
  (targetLiqUtilizationRateBps === undefined &&
648
648
  !eligibleForRebalance(
649
649
  client.solautoPositionState!,
650
- client.solautoPositionSettings()!,
651
- client.solautoPositionActiveDca()!,
650
+ client.solautoPositionSettings(),
651
+ client.solautoPositionActiveDca(),
652
652
  currentUnixSeconds()
653
653
  ))
654
654
  ) {
@@ -137,7 +137,7 @@ export function getSolautoFeesBps(
137
137
  let referrer = 0;
138
138
  if (isReferred) {
139
139
  feeBps *= 0.9;
140
- referrer = Math.floor(feeBps / 5);
140
+ referrer = Math.floor(feeBps * 0.15);
141
141
  }
142
142
 
143
143
  return {
@@ -128,11 +128,15 @@ export function getAdjustedSettingsFromAutomation(
128
128
 
129
129
  export function eligibleForRebalance(
130
130
  positionState: PositionState,
131
- positionSettings: SolautoSettingsParameters,
131
+ positionSettings: SolautoSettingsParameters | undefined,
132
132
  positionDca: DCASettings | undefined,
133
133
  currentUnixTime: number,
134
134
  bpsDistanceThreshold = 0
135
135
  ): RebalanceAction | undefined {
136
+ if (!positionSettings) {
137
+ return undefined;
138
+ }
139
+
136
140
  if (
137
141
  positionDca &&
138
142
  positionDca.automation.targetPeriods > 0 &&
@@ -17,11 +17,14 @@ import { NATIVE_MINT } from "@solana/spl-token";
17
17
  import { consoleLog, fetchTokenPrices } from "../../src/utils/generalUtils";
18
18
  import {
19
19
  TransactionItem,
20
- TransactionManagerStatuses,
21
20
  TransactionsManager,
22
21
  } from "../../src/transactions/transactionsManager";
23
22
  import { PublicKey } from "@solana/web3.js";
24
- import { USDC } from "../../src/constants";
23
+ import {
24
+ SOLAUTO_PROD_PROGRAM,
25
+ SOLAUTO_TEST_PROGRAM,
26
+ USDC,
27
+ } from "../../src/constants";
25
28
  import { buildHeliusApiUrl } from "../../src/utils";
26
29
  import { PriorityFeeSetting } from "../../src/types";
27
30
 
@@ -30,12 +33,14 @@ describe("Solauto Marginfi tests", async () => {
30
33
  // const signer = setupTest("solauto-manager");
31
34
 
32
35
  const payForTransactions = false;
36
+ const testProgram = true;
33
37
  const positionId = 1;
34
38
 
35
39
  it("open - deposit - borrow - rebalance to 0 - withdraw - close", async () => {
36
40
  const client = new SolautoMarginfiClient(
37
41
  buildHeliusApiUrl(process.env.HELIUS_API_KEY!),
38
- true
42
+ true,
43
+ testProgram ? SOLAUTO_TEST_PROGRAM : SOLAUTO_PROD_PROGRAM
39
44
  );
40
45
 
41
46
  const supply = NATIVE_MINT;
@@ -54,14 +59,14 @@ describe("Solauto Marginfi tests", async () => {
54
59
  });
55
60
 
56
61
  const transactionItems: TransactionItem[] = [];
57
- // const settingParams: SolautoSettingsParametersInpArgs = {
58
- // boostToBps: 6950,
59
- // boostGap: 100,
60
- // repayToBps: 7000,
61
- // repayGap: 100,
62
- // automation: none(),
63
- // targetBoostToBps: none(),
64
- // };
62
+ const settingParams: SolautoSettingsParametersInpArgs = {
63
+ boostToBps: 6950,
64
+ boostGap: 50,
65
+ repayToBps: 7000,
66
+ repayGap: 50,
67
+ automation: none(),
68
+ targetBoostToBps: none(),
69
+ };
65
70
 
66
71
  // if (client.solautoPositionData === null) {
67
72
  // transactionItems.push(
@@ -73,16 +78,16 @@ describe("Solauto Marginfi tests", async () => {
73
78
  // );
74
79
 
75
80
  // // const initialSupplyUsd = 150;
76
- // transactionItems.push(
77
- // new TransactionItem(async () => {
78
- // // const [supplyPrice] = await fetchTokenPrices([supply]);
79
- // return {
80
- // tx: client.protocolInteraction(
81
- // solautoAction("Deposit", [toBaseUnit(0.5, supplyDecimals)])
82
- // ),
83
- // };
84
- // }, "deposit")
85
- // );
81
+ // transactionItems.push(
82
+ // new TransactionItem(async () => {
83
+ // // const [supplyPrice] = await fetchTokenPrices([supply]);
84
+ // return {
85
+ // tx: client.protocolInteraction(
86
+ // solautoAction("Deposit", [toBaseUnit(9.5, supplyDecimals)])
87
+ // ),
88
+ // };
89
+ // }, "deposit")
90
+ // );
86
91
  // }
87
92
 
88
93
  // const maxLtvBps = client.solautoPositionState!.maxLtvBps;
@@ -120,7 +125,7 @@ describe("Solauto Marginfi tests", async () => {
120
125
  // transactionItems.push(
121
126
  // new TransactionItem(
122
127
  // async (attemptNum) =>
123
- // await buildSolautoRebalanceTransaction(client, 0, attemptNum),
128
+ // await buildSolautoRebalanceTransaction(client, settingParams.boostToBps, attemptNum),
124
129
  // "rebalance"
125
130
  // )
126
131
  // );
@@ -147,13 +152,12 @@ describe("Solauto Marginfi tests", async () => {
147
152
 
148
153
  const statuses = await new TransactionsManager(
149
154
  client,
150
- (statuses: TransactionManagerStatuses) => {
151
- console.log(statuses);
152
- },
155
+ undefined,
153
156
  !payForTransactions ? "only-simulate" : "normal",
154
157
  PriorityFeeSetting.Low
155
158
  ).clientSend(transactionItems);
156
159
 
157
- // console.log(statuses);
160
+ console.log(statuses);
161
+
158
162
  });
159
163
  });