impermax-sdk 2.1.69 → 2.1.71

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.
@@ -69,7 +69,13 @@ class OffchainAccount {
69
69
  if (userData === null)
70
70
  return result;
71
71
  for (const factory in userData) {
72
- result[factory] = Object.keys(userData[factory].collateralPositions);
72
+ result[factory] = [];
73
+ const collateralPositions = userData[factory].collateralPositions;
74
+ // 1-to-many relationship between lending pool and borrow positions
75
+ for (const lendingPool in collateralPositions) {
76
+ const positions = collateralPositions[lendingPool];
77
+ positions.forEach(() => result[factory].push(lendingPool));
78
+ }
73
79
  }
74
80
  return result;
75
81
  });
@@ -601,9 +601,14 @@ function initializeUserData(account) {
601
601
  borrowPositions: {},
602
602
  };
603
603
  const rawUserData = userData[factory];
604
+ // 1 collateral can have one or many positions (1 for v2, many for v3)
604
605
  for (const collateralPosition of rawUserData.collateralPositions) {
605
606
  const resultOfFactory = result[factory];
606
- resultOfFactory.collateralPositions[collateralPosition.collateral.lendingPool.id] = collateralPosition;
607
+ const lendingPoolId = collateralPosition.collateral.lendingPool.id;
608
+ if (!resultOfFactory.collateralPositions[lendingPoolId]) {
609
+ resultOfFactory.collateralPositions[lendingPoolId] = [];
610
+ }
611
+ resultOfFactory.collateralPositions[lendingPoolId].push(collateralPosition);
607
612
  }
608
613
  for (const supplyPositions of rawUserData.supplyPositions) {
609
614
  const uniswapV2PairAddress = supplyPositions.borrowable.lendingPool.id;
@@ -123,7 +123,7 @@ export interface RawUserData {
123
123
  borrowPositions: BorrowPosition[];
124
124
  }
125
125
  export interface UserData {
126
- collateralPositions: AddressIndex<CollateralPosition>;
126
+ collateralPositions: AddressIndex<CollateralPosition[]>;
127
127
  supplyPositions: AddressIndex<{
128
128
  [key in PoolTokenType]?: SupplyPosition;
129
129
  }>;
@@ -21,6 +21,7 @@ type VaultDayData = {
21
21
  timestamp: string;
22
22
  timestampUTC: string;
23
23
  vault: string;
24
+ tvlUSD: string;
24
25
  };
25
26
  export default class OffchainVault extends OffchainPoolToken {
26
27
  private readonly offchain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.69",
3
+ "version": "2.1.71",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",