@haven-fi/solauto-sdk 1.0.698 → 1.0.699

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"rebalanceSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAkB,UAAU,EAAa,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAiC,MAAM,iBAAiB,CAAC;AAS3E,qBAAa,oBAAoB;IAQ7B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,2BAA2B,CAAC;IACpC,OAAO,CAAC,SAAS,CAAC;IAXb,UAAU,EAAG,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,cAAc,CAAkB;gBAG9B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,cAAc,CAAC,EAAE,qBAAqB,YAAA,EACtC,2BAA2B,CAAC,EAAE,MAAM,YAAA,EACpC,SAAS,CAAC,EAAE,SAAS,YAAA;IAK/B,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;IA2BnB,OAAO,CAAC,kCAAkC;YA4B5B,mBAAmB;IAoCjC,OAAO,CAAC,mBAAmB;IAIrB,aAAa,CAAC,UAAU,EAAE,MAAM;IAyEhC,aAAa;;;;;;CAWpB"}
1
+ {"version":3,"file":"rebalanceSwapManager.d.ts","sourceRoot":"","sources":["../../../src/services/rebalance/rebalanceSwapManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EAAkB,UAAU,EAAa,MAAM,SAAS,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,SAAS,EAAiC,MAAM,iBAAiB,CAAC;AAU3E,qBAAa,oBAAoB;IAQ7B,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,cAAc,CAAC;IACvB,OAAO,CAAC,2BAA2B,CAAC;IACpC,OAAO,CAAC,SAAS,CAAC;IAXb,UAAU,EAAG,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,cAAc,CAAkB;gBAG9B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,eAAe,EACvB,cAAc,CAAC,EAAE,qBAAqB,YAAA,EACtC,2BAA2B,CAAC,EAAE,MAAM,YAAA,EACpC,SAAS,CAAC,EAAE,SAAS,YAAA;IAK/B,OAAO,CAAC,OAAO;IAIf,OAAO,CAAC,SAAS;IAIjB,OAAO,CAAC,WAAW;IA6BnB,OAAO,CAAC,kCAAkC;YA4B5B,mBAAmB;IAoCjC,OAAO,CAAC,mBAAmB;IAIrB,aAAa,CAAC,UAAU,EAAE,MAAM;IAyEhC,aAAa;;;;;;CAWpB"}
@@ -27,10 +27,12 @@ class RebalanceSwapManager {
27
27
  const output = this.isBoost()
28
28
  ? this.client.pos.state.supply
29
29
  : this.client.pos.state.debt;
30
- const supplyPrice = this.client.pos.supplyPrice(this.priceType);
31
- const debtPrice = this.client.pos.debtPrice(this.priceType);
32
- const inputPrice = this.isBoost() ? debtPrice : supplyPrice;
33
- const outputPrice = this.isBoost() ? supplyPrice : debtPrice;
30
+ // const supplyPrice = this.client.pos.supplyPrice(this.priceType)!;
31
+ // const debtPrice = this.client.pos.debtPrice(this.priceType)!;
32
+ // const inputPrice = this.isBoost() ? debtPrice : supplyPrice;
33
+ // const outputPrice = this.isBoost() ? supplyPrice : debtPrice;
34
+ const inputPrice = (0, utils_1.safeGetPrice)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(input.mint), this.priceType);
35
+ const outputPrice = (0, utils_1.safeGetPrice)((0, umi_web3js_adapters_1.toWeb3JsPublicKey)(output.mint), this.priceType);
34
36
  let inputAmount = (0, utils_1.toBaseUnit)(this.usdToSwap() / inputPrice, input.decimals);
35
37
  return {
36
38
  inputAmount,
@@ -1 +1 @@
1
- {"version":3,"file":"priceUtils.d.ts","sourceRoot":"","sources":["../../src/utils/priceUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,IAAI,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAerE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,UAAU,WAAW;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,SAAS,EAAE,EAClB,SAAS,GAAE,SAA8B,EACzC,SAAS,CAAC,EAAE,SAAS,GACpB,OAAO,CAAC,MAAM,EAAE,CAAC,CA0CnB;AAED,wBAAsB,aAAa,CACjC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,C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,MAAM,EAAE,WAAW,CAAC,CAAC,CA+CtC;AAED,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAiBtC;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,GAAG,YAAY,GAAG,MAAM,GAAG,SAAS,EACnD,SAAS,GAAE,SAA8B,EACzC,SAAS,CAAC,EAAE,SAAS,GACpB,MAAM,GAAG,SAAS,CAyBpB"}
@@ -167,14 +167,12 @@ function safeGetPrice(mint, priceType = generated_1.PriceType.Realtime, priceBia
167
167
  ? priceData.emaConfInterval
168
168
  : priceData.confInterval;
169
169
  const conf = Math.min(confInterval, price * 0.05);
170
- (0, generalUtils_1.consoleLog)("before", price, conf);
171
170
  if (priceBias === marginfi_sdk_1.PriceBias.Low) {
172
171
  price -= conf;
173
172
  }
174
173
  else {
175
174
  price += conf;
176
175
  }
177
- (0, generalUtils_1.consoleLog)("after", price);
178
176
  }
179
177
  return price;
180
178
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.698",
3
+ "version": "1.0.699",
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",
@@ -9,6 +9,7 @@ import {
9
9
  consoleLog,
10
10
  fromBaseUnit,
11
11
  getLiqUtilzationRateBps,
12
+ safeGetPrice,
12
13
  toBaseUnit,
13
14
  tokenInfo,
14
15
  } from "../../utils";
@@ -46,10 +47,12 @@ export class RebalanceSwapManager {
46
47
  ? this.client.pos.state.supply
47
48
  : this.client.pos.state.debt;
48
49
 
49
- const supplyPrice = this.client.pos.supplyPrice(this.priceType)!;
50
- const debtPrice = this.client.pos.debtPrice(this.priceType)!;
51
- const inputPrice = this.isBoost() ? debtPrice : supplyPrice;
52
- const outputPrice = this.isBoost() ? supplyPrice : debtPrice;
50
+ // const supplyPrice = this.client.pos.supplyPrice(this.priceType)!;
51
+ // const debtPrice = this.client.pos.debtPrice(this.priceType)!;
52
+ // const inputPrice = this.isBoost() ? debtPrice : supplyPrice;
53
+ // const outputPrice = this.isBoost() ? supplyPrice : debtPrice;
54
+ const inputPrice = safeGetPrice(toWeb3JsPublicKey(input.mint), this.priceType)!;
55
+ const outputPrice = safeGetPrice(toWeb3JsPublicKey(output.mint), this.priceType)!;
53
56
 
54
57
  let inputAmount = toBaseUnit(
55
58
  this.usdToSwap() / inputPrice!,
@@ -236,13 +236,11 @@ export function safeGetPrice(
236
236
  : priceData.confInterval;
237
237
  const conf = Math.min(confInterval, price * 0.05);
238
238
 
239
- consoleLog("before", price, conf);
240
239
  if (priceBias === PriceBias.Low) {
241
240
  price -= conf;
242
241
  } else {
243
242
  price += conf;
244
243
  }
245
- consoleLog("after", price);
246
244
  }
247
245
 
248
246
  return price;