@haven-fi/solauto-sdk 1.0.149 → 1.0.151

Sign up to get free protection for your applications and to get access to all the features.
@@ -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,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"}
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,CAgD5E;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"}
@@ -62,6 +62,7 @@ async function fetchTokenPrices(mints) {
62
62
  }
63
63
  const json = await resp.json();
64
64
  const prices = json.parsed.map((x) => {
65
+ console.log(x);
65
66
  if (x.price.expo > 0) {
66
67
  return Number((0, numberUtils_1.toBaseUnit)(Number(x.price.price), x.price.expo));
67
68
  }
@@ -22,10 +22,10 @@ function getStandardTargetLiqUtilizationRateBps(state, settings) {
22
22
  const adjustedSettings = (0, generalUtils_1.getAdjustedSettingsFromAutomation)(settings, (0, generalUtils_2.currentUnixSeconds)());
23
23
  const repayFrom = settings.repayToBps + settings.repayGap;
24
24
  const boostFrom = adjustedSettings.boostToBps - settings.boostGap;
25
- if (state.liqUtilizationRateBps < boostFrom) {
25
+ if (state.liqUtilizationRateBps <= boostFrom) {
26
26
  return adjustedSettings.boostToBps;
27
27
  }
28
- else if (state.liqUtilizationRateBps > repayFrom) {
28
+ else if (state.liqUtilizationRateBps >= repayFrom) {
29
29
  return adjustedSettings.repayToBps;
30
30
  }
31
31
  else {
@@ -177,7 +177,7 @@ function getJupSwapRebalanceDetails(client, values, targetLiqUtilizationRateBps,
177
177
  BigInt(Math.round(Number(client.solautoPositionState.debt.amountUsed.baseUnit) *
178
178
  // Add this small percentage to account for the APR on the debt between now and the transaction
179
179
  0.0001))
180
- : BigInt(Math.round(Number(inputAmount) * 1.05)),
180
+ : BigInt(Math.round(Number(inputAmount) * 1.01)),
181
181
  exactOut: exactOut,
182
182
  };
183
183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.149",
3
+ "version": "1.0.151",
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",
@@ -75,6 +75,7 @@ export async function fetchTokenPrices(mints: PublicKey[]): Promise<number[]> {
75
75
 
76
76
  const json = await resp.json();
77
77
  const prices = json.parsed.map((x: any) => {
78
+ console.log(x);
78
79
  if (x.price.expo > 0) {
79
80
  return Number(toBaseUnit(Number(x.price.price), x.price.expo));
80
81
  } else if (x.price.expo < 0) {
@@ -58,9 +58,9 @@ function getStandardTargetLiqUtilizationRateBps(
58
58
  const repayFrom = settings.repayToBps + settings.repayGap;
59
59
  const boostFrom = adjustedSettings.boostToBps - settings.boostGap;
60
60
 
61
- if (state.liqUtilizationRateBps < boostFrom) {
61
+ if (state.liqUtilizationRateBps <= boostFrom) {
62
62
  return adjustedSettings.boostToBps;
63
- } else if (state.liqUtilizationRateBps > repayFrom) {
63
+ } else if (state.liqUtilizationRateBps >= repayFrom) {
64
64
  return adjustedSettings.repayToBps;
65
65
  } else {
66
66
  throw new Error("Invalid rebalance condition");
@@ -358,7 +358,7 @@ export function getJupSwapRebalanceDetails(
358
358
  0.0001
359
359
  )
360
360
  )
361
- : BigInt(Math.round(Number(inputAmount) * 1.05)),
361
+ : BigInt(Math.round(Number(inputAmount) * 1.01)),
362
362
  exactOut: exactOut,
363
363
  };
364
364
  }