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] =
|
|
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
|
-
|
|
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
|
}>;
|