impermax-sdk 2.1.70 → 2.1.72

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
  });
@@ -128,6 +128,8 @@ class OffchainLendingPool {
128
128
  const rewards = [];
129
129
  const stakedTotalSupply = parseFloat(lendingPoolData.pair.stakedTotalSupply);
130
130
  const underlyingLPPrice = yield this.getUnderlyingLPPrice(true);
131
+ if (!lendingPoolData.pair.rewards)
132
+ return rewards;
131
133
  for (const reward of lendingPoolData.pair.rewards) {
132
134
  const multiplier = farm === farms_1.Farms.traderJoeV2 ? 0.5 : 1;
133
135
  const periodFinish = parseInt(reward.periodFinish);
@@ -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;
@@ -164,8 +164,10 @@ class OffchainPriceHelper {
164
164
  const lendingPool = lendingPoolsData[factory][id];
165
165
  this.addPriceIfMissing(offchainTokenPrice, lendingPool.borrowable0.underlying);
166
166
  this.addPriceIfMissing(offchainTokenPrice, lendingPool.borrowable1.underlying);
167
- for (const reward of lendingPool.pair.rewards) {
168
- this.addPriceIfMissing(offchainTokenPrice, reward.rewardsToken);
167
+ if (lendingPool.pair.rewards) {
168
+ for (const reward of lendingPool.pair.rewards) {
169
+ this.addPriceIfMissing(offchainTokenPrice, reward.rewardsToken);
170
+ }
169
171
  }
170
172
  }
171
173
  }
@@ -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
  }>;
@@ -34,17 +34,6 @@ class PonderQueryBuilder {
34
34
  name
35
35
  decimals
36
36
  derivedUSD
37
- }`;
38
- const distributorStr = `{
39
- id
40
- }`;
41
- const farmingPoolStr = `{
42
- epochAmount
43
- epochBegin
44
- segmentLength
45
- vestingBegin
46
- sharePercentage
47
- distributor ${distributorStr}
48
37
  }`;
49
38
  const borrowableStr = `{
50
39
  id
@@ -60,7 +49,6 @@ class PonderQueryBuilder {
60
49
  accrualTimestamp
61
50
  exchangeRate
62
51
  borrowTracker
63
- farmingPool ${farmingPoolStr}
64
52
  }`;
65
53
  const collateralStr = `{
66
54
  id
@@ -74,14 +62,6 @@ class PonderQueryBuilder {
74
62
  dexFactory
75
63
  token1Price
76
64
  token0Price
77
- rewards {
78
- items {
79
- id
80
- rewardRate
81
- rewardsToken ${tokenStr}
82
- periodFinish
83
- }
84
- }
85
65
  }`;
86
66
  const id_in_string = (addressesFilter === null || addressesFilter === void 0 ? void 0 : addressesFilter.length) > 0 ? `id_in: ["${addressesFilter.join('","').toLowerCase()}"]` : "";
87
67
  return (0, graphql_tag_1.default) `{
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "impermax-sdk",
3
- "version": "2.1.70",
3
+ "version": "2.1.72",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib/index.js",