@haven-fi/solauto-sdk 1.0.167 → 1.0.168

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"solautoMarginfiClient.d.ts","sourceRoot":"","sources":["../../src/clients/solautoMarginfiClient.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,MAAM,EACN,kBAAkB,EAMnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,SAAS,EAA8B,MAAM,iBAAiB,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAM1D,OAAO,EACL,kBAAkB,EAElB,aAAa,EAEb,iBAAiB,EACjB,wBAAwB,EACxB,gCAAgC,EAKjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EAUhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAUnE,MAAM,WAAW,yBAA0B,SAAQ,iBAAiB;IAClE,eAAe,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IACrC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,SAAS,CAAC;CAC3B;AAED,qBAAa,qBAAsB,SAAQ,aAAa;IACtD,OAAO,CAAC,WAAW,CAAkB;IAE9B,eAAe,EAAG,SAAS,CAAC;IAE5B,sBAAsB,EAAE,MAAM,CAAa;IAC3C,eAAe,EAAG,SAAS,GAAG,MAAM,CAAC;IACrC,iBAAiB,EAAG,SAAS,CAAC;IAC9B,aAAa,EAAG,SAAS,CAAC;IAE1B,sBAAsB,EAAG,qBAAqB,CAAC;IAC/C,oBAAoB,EAAG,qBAAqB,CAAC;IAE7C,iBAAiB,EAAG,SAAS,CAAC;IAC9B,eAAe,EAAG,SAAS,CAAC;IAG5B,iCAAiC,CAAC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IAUzB,qBAAqB,IAAI,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IA4BpE,yBAAyB,IAAI,kBAAkB;IAS/C,YAAY,CACV,aAAa,CAAC,EAAE,gCAAgC,EAChD,GAAG,CAAC,EAAE,kBAAkB,GACvB,kBAAkB;IAMrB,OAAO,CAAC,sBAAsB;IA+C9B,OAAO,IAAI,kBAAkB;IAc7B,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,kBAAkB;IAUhE,OAAO,CAAC,6BAA6B;IAmErC,OAAO,CAAC,oCAAoC;IA0D5C,SAAS,CACP,aAAa,EAAE,GAAG,GAAG,GAAG,EACxB,WAAW,EAAE,cAAc,EAC3B,aAAa,EAAE,wBAAwB,EACvC,SAAS,CAAC,EAAE,gBAAgB,EAC5B,2BAA2B,CAAC,EAAE,MAAM,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,kBAAkB;IAoErB,WAAW,CACT,gBAAgB,EAAE,gBAAgB,EAClC,uBAAuB,EAAE,SAAS,GACjC,kBAAkB;IA2BrB,UAAU,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,kBAAkB;IAoFlE,iCAAiC,IAAI,kBAAkB;IASjD,qBAAqB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;CAwClE"}
@@ -54,7 +54,7 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
54
54
  this.debtPriceOracle = new web3_js_1.PublicKey(this.marginfiDebtAccounts.priceOracle);
55
55
  if (!this.solautoPositionState) {
56
56
  const result = await this.maxLtvAndLiqThreshold();
57
- this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, result ? (0, numberUtils_1.toBps)(result[0]) : 0, result ? (0, numberUtils_1.toBps)(result[1]) : 0);
57
+ this.solautoPositionState = (0, utils_1.createFakePositionState)({ mint: this.supplyMint }, { mint: this.debtMint }, result ? result[0] : 0, result ? result[1] : 0);
58
58
  }
59
59
  if (!this.initialized) {
60
60
  await this.setIntermediaryMarginfiDetails();
@@ -99,23 +99,24 @@ class SolautoMarginfiClient extends solautoClient_1.SolautoClient {
99
99
  async maxLtvAndLiqThreshold() {
100
100
  const result = super.maxLtvAndLiqThreshold();
101
101
  if (result) {
102
+ console.log("OH NO", result);
102
103
  return result;
103
104
  }
105
+ else if (this.supplyMint.equals(web3_js_1.PublicKey.default) ||
106
+ this.debtMint.equals(web3_js_1.PublicKey.default)) {
107
+ console.log("EMPTY");
108
+ return [0, 0];
109
+ }
104
110
  else {
105
- if (this.supplyMint.equals(web3_js_1.PublicKey.default) ||
106
- this.debtMint.equals(web3_js_1.PublicKey.default)) {
107
- return [0, 0];
108
- }
109
- else {
110
- const [maxLtv, liqThreshold] = await (0, marginfiUtils_1.getMaxLtvAndLiqThreshold)(this.umi, {
111
- mint: this.supplyMint,
112
- }, {
113
- mint: this.debtMint,
114
- });
115
- this.maxLtvBps = maxLtv;
116
- this.liqThresholdBps = liqThreshold;
117
- return [this.maxLtvBps, this.liqThresholdBps];
118
- }
111
+ const [maxLtv, liqThreshold] = await (0, marginfiUtils_1.getMaxLtvAndLiqThreshold)(this.umi, {
112
+ mint: this.supplyMint,
113
+ }, {
114
+ mint: this.debtMint,
115
+ });
116
+ console.log("FETCHED", maxLtv, liqThreshold);
117
+ this.maxLtvBps = maxLtv;
118
+ this.liqThresholdBps = liqThreshold;
119
+ return [maxLtv, liqThreshold];
119
120
  }
120
121
  }
121
122
  marginfiAccountInitialize() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.167",
3
+ "version": "1.0.168",
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",
@@ -137,8 +137,8 @@ export class SolautoMarginfiClient extends SolautoClient {
137
137
  this.solautoPositionState = createFakePositionState(
138
138
  { mint: this.supplyMint },
139
139
  { mint: this.debtMint },
140
- result ? toBps(result[0]) : 0,
141
- result ? toBps(result[1]) : 0
140
+ result ? result[0] : 0,
141
+ result ? result[1] : 0
142
142
  );
143
143
  }
144
144
 
@@ -211,27 +211,28 @@ export class SolautoMarginfiClient extends SolautoClient {
211
211
  async maxLtvAndLiqThreshold(): Promise<[number, number] | undefined> {
212
212
  const result = super.maxLtvAndLiqThreshold();
213
213
  if (result) {
214
+ console.log("OH NO", result);
214
215
  return result;
216
+ } else if (
217
+ this.supplyMint.equals(PublicKey.default) ||
218
+ this.debtMint.equals(PublicKey.default)
219
+ ) {
220
+ console.log("EMPTY");
221
+ return [0, 0];
215
222
  } else {
216
- if (
217
- this.supplyMint.equals(PublicKey.default) ||
218
- this.debtMint.equals(PublicKey.default)
219
- ) {
220
- return [0, 0];
221
- } else {
222
- const [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
223
- this.umi,
224
- {
225
- mint: this.supplyMint,
226
- },
227
- {
228
- mint: this.debtMint,
229
- }
230
- );
231
- this.maxLtvBps = maxLtv;
232
- this.liqThresholdBps = liqThreshold;
233
- return [this.maxLtvBps, this.liqThresholdBps];
234
- }
223
+ const [maxLtv, liqThreshold] = await getMaxLtvAndLiqThreshold(
224
+ this.umi,
225
+ {
226
+ mint: this.supplyMint,
227
+ },
228
+ {
229
+ mint: this.debtMint,
230
+ }
231
+ );
232
+ console.log("FETCHED", maxLtv, liqThreshold);
233
+ this.maxLtvBps = maxLtv;
234
+ this.liqThresholdBps = liqThreshold;
235
+ return [maxLtv, liqThreshold];
235
236
  }
236
237
  }
237
238