@haven-fi/solauto-sdk 1.0.13 → 1.0.14

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const numberUtils_1 = require("./numberUtils");
4
- // // TODO delete this file
4
+ // TODO delete this file
5
5
  function check() {
6
6
  let supply = 458948;
7
7
  let debt = 212846;
@@ -1 +1 @@
1
- {"version":3,"file":"marginfiUtils.d.ts","sourceRoot":"","sources":["../../src/utils/marginfiUtils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAa,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,EACL,IAAI,EAOL,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,cAAc,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAG7D,wBAAgB,wBAAwB,CAAC,EACvC,IAAI,EACJ,IAAI,GACL,EAAE;IACD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf,GAAG,qBAAqB,CAWxB;AAED,wBAAsB,wBAAwB,CAC5C,UAAU,EAAE,IAAI,EAChB,QAAQ,EAAE,IAAI,EACd,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAkC3B;AAED,wBAAsB,iCAAiC,CACrD,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,SAAS,EACpB,qBAAqB,CAAC,EAAE,OAAO,GAC9B,OAAO,CAAC,SAAS,EAAE,CAAC,CAwCtB;AAoDD,wBAAsB,+BAA+B,CACnD,GAAG,EAAE,GAAG,EACR,iBAAiB,EAAE,SAAS,EAC5B,UAAU,CAAC,EAAE,SAAS,EACtB,QAA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C,EAAE,SAAS,EACpB,mBAAmB,CAAC,EAAE,mBAAmB,GACxC,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CA4IpC;AA+DD,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CA0B3B"}
@@ -64,11 +64,11 @@ async function getAllMarginfiAccountsByAuthority(umi, authority, compatibleWithS
64
64
  ],
65
65
  });
66
66
  if (compatibleWithSolauto) {
67
- const compatiblePositions = await Promise.all(marginfiAccounts.map((x) => ({
67
+ const positionStates = await Promise.all(marginfiAccounts.map(async (x) => ({
68
68
  publicKey: x.publicKey,
69
- state: getMarginfiAccountPositionState(umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey)),
69
+ state: await getMarginfiAccountPositionState(umi, (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey)),
70
70
  })));
71
- return compatiblePositions
71
+ return positionStates
72
72
  .filter((x) => x.state !== undefined)
73
73
  .map((x) => (0, umi_web3js_adapters_1.toWeb3JsPublicKey)(x.publicKey));
74
74
  }
@@ -207,7 +207,7 @@ async function getAllPositionsByAuthority(umi, user) {
207
207
  protocolAccount: pubkey,
208
208
  })));
209
209
  // TODO support other platforms
210
- return [];
210
+ return allPositions;
211
211
  }
212
212
  exports.getAllPositionsByAuthority = getAllPositionsByAuthority;
213
213
  async function positionStateWithLatestPrices(umi, state, protocolAccount, lendingPlatform) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haven-fi/solauto-sdk",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
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",
@@ -1,6 +1,6 @@
1
1
  import { getDebtAdjustmentUsd, getLiqUtilzationRateBps } from "./numberUtils";
2
2
 
3
- // // TODO delete this file
3
+ // TODO delete this file
4
4
  function check() {
5
5
  let supply = 458948;
6
6
  let debt = 212846;
@@ -37,4 +37,4 @@ function check() {
37
37
  console.log!(liq_utilization_rate);
38
38
  }
39
39
 
40
- check();
40
+ check();
@@ -112,17 +112,16 @@ export async function getAllMarginfiAccountsByAuthority(
112
112
  );
113
113
 
114
114
  if (compatibleWithSolauto) {
115
- const compatiblePositions = await Promise.all(
116
- marginfiAccounts.map((x) => ({
115
+ const positionStates = await Promise.all(
116
+ marginfiAccounts.map(async (x) => ({
117
117
  publicKey: x.publicKey,
118
- state: getMarginfiAccountPositionState(
118
+ state: await getMarginfiAccountPositionState(
119
119
  umi,
120
120
  toWeb3JsPublicKey(x.publicKey)
121
121
  ),
122
122
  }))
123
123
  );
124
-
125
- return compatiblePositions
124
+ return positionStates
126
125
  .filter((x) => x.state !== undefined)
127
126
  .map((x) => toWeb3JsPublicKey(x.publicKey));
128
127
  } else {
@@ -333,7 +333,7 @@ export async function getAllPositionsByAuthority(
333
333
 
334
334
  // TODO support other platforms
335
335
 
336
- return [];
336
+ return allPositions;
337
337
  }
338
338
 
339
339
  async function positionStateWithLatestPrices(