@scallop-io/sui-scallop-sdk 1.4.3 → 1.4.5
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.
- package/dist/constants/common.d.ts +5 -5
- package/dist/constants/enum.d.ts +2 -2
- package/dist/index.js +126 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +126 -37
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +13 -6
- package/dist/models/scallopUtils.d.ts +2 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +4 -1
- package/dist/queries/coreQuery.d.ts +1 -0
- package/dist/queries/poolAddressesQuery.d.ts +1 -1
- package/dist/queries/portfolioQuery.d.ts +4 -2
- package/dist/queries/priceQuery.d.ts +2 -0
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/package.json +1 -1
- package/src/constants/coinGecko.ts +1 -0
- package/src/constants/common.ts +3 -0
- package/src/constants/enum.ts +8 -0
- package/src/constants/poolAddress.ts +25 -0
- package/src/constants/pyth.ts +1 -0
- package/src/constants/testAddress.ts +21 -0
- package/src/models/scallopQuery.ts +4 -3
- package/src/queries/borrowIncentiveQuery.ts +2 -1
- package/src/queries/coreQuery.ts +51 -17
- package/src/queries/portfolioQuery.ts +15 -10
- package/src/queries/spoolQuery.ts +18 -9
- package/src/utils/query.ts +2 -2
|
@@ -58,24 +58,33 @@ const queryRequiredSpoolObjects = async (
|
|
|
58
58
|
// Map the results back to poolCoinNames
|
|
59
59
|
const mapObjects = (
|
|
60
60
|
tasks: { poolCoinName: string; [key: string]: string | undefined }[],
|
|
61
|
-
fetchedObjects: SuiObjectData[]
|
|
61
|
+
fetchedObjects: SuiObjectData[],
|
|
62
|
+
keyValue: string
|
|
62
63
|
) => {
|
|
63
64
|
const resultMap: Record<string, SuiObjectData> = {};
|
|
64
|
-
|
|
65
|
+
const fetchedObjectMap = fetchedObjects.reduce(
|
|
66
|
+
(acc, obj) => {
|
|
67
|
+
acc[obj.objectId] = obj;
|
|
68
|
+
return acc;
|
|
69
|
+
},
|
|
70
|
+
{} as Record<string, SuiObjectData>
|
|
71
|
+
);
|
|
65
72
|
|
|
66
73
|
for (const task of tasks) {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
resultMap[task.poolCoinName] = fetchedObjects[fetchedIndex];
|
|
70
|
-
fetchedIndex++;
|
|
74
|
+
if (task[keyValue]) {
|
|
75
|
+
resultMap[task.poolCoinName] = fetchedObjectMap[task[keyValue]];
|
|
71
76
|
}
|
|
72
77
|
}
|
|
73
78
|
return resultMap;
|
|
74
79
|
};
|
|
75
80
|
|
|
76
|
-
const spoolMap = mapObjects(tasks, spoolObjects);
|
|
77
|
-
const spoolRewardMap = mapObjects(tasks, spoolRewardObjects);
|
|
78
|
-
const sCoinTreasuryMap = mapObjects(
|
|
81
|
+
const spoolMap = mapObjects(tasks, spoolObjects, 'spool');
|
|
82
|
+
const spoolRewardMap = mapObjects(tasks, spoolRewardObjects, 'spoolReward');
|
|
83
|
+
const sCoinTreasuryMap = mapObjects(
|
|
84
|
+
tasks,
|
|
85
|
+
sCoinTreasuryObjects,
|
|
86
|
+
'sCoinTreasury'
|
|
87
|
+
);
|
|
79
88
|
|
|
80
89
|
// Construct the final requiredObjects result
|
|
81
90
|
return stakePoolCoinNames.reduce(
|
package/src/utils/query.ts
CHANGED
|
@@ -167,10 +167,10 @@ export const calculateMarketPoolData = (
|
|
|
167
167
|
conversionRate: conversionRate.toNumber(),
|
|
168
168
|
isIsolated: parsedMarketPoolData.isIsolated,
|
|
169
169
|
maxSupplyCoin: BigNumber(parsedMarketPoolData.supplyLimit)
|
|
170
|
-
.shiftedBy(coinDecimal)
|
|
170
|
+
.shiftedBy(-coinDecimal)
|
|
171
171
|
.toNumber(),
|
|
172
172
|
maxBorrowCoin: BigNumber(parsedMarketPoolData.borrowLimit)
|
|
173
|
-
.shiftedBy(coinDecimal)
|
|
173
|
+
.shiftedBy(-coinDecimal)
|
|
174
174
|
.toNumber(),
|
|
175
175
|
};
|
|
176
176
|
};
|