@scallop-io/sui-scallop-sdk 0.44.7 → 0.44.9
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/README.md +8 -1
- package/dist/constants/common.d.ts +1 -0
- package/dist/index.js +405 -68
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +403 -68
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.ts +1 -0
- package/dist/models/scallop.d.ts +9 -1
- package/dist/models/scallopAddress.d.ts +1 -1
- package/dist/models/scallopBuilder.d.ts +1 -1
- package/dist/models/scallopIndexer.d.ts +81 -0
- package/dist/models/scallopQuery.d.ts +29 -15
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -1
- package/dist/queries/coreQuery.d.ts +10 -6
- package/dist/queries/portfolioQuery.d.ts +10 -5
- package/dist/queries/spoolQuery.d.ts +6 -3
- package/package.json +1 -1
- package/src/constants/common.ts +1 -0
- package/src/models/index.ts +1 -0
- package/src/models/scallop.ts +14 -1
- package/src/models/scallopAddress.ts +1 -1
- package/src/models/scallopBuilder.ts +1 -1
- package/src/models/scallopIndexer.ts +269 -0
- package/src/models/scallopQuery.ts +71 -28
- package/src/queries/borrowIncentiveQuery.ts +27 -6
- package/src/queries/coreQuery.ts +104 -18
- package/src/queries/portfolioQuery.ts +46 -13
- package/src/queries/spoolQuery.ts +67 -9
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// src/constants/common.ts
|
|
2
2
|
var API_BASE_URL = "https://sui.api.scallop.io";
|
|
3
|
+
var SDK_API_BASE_URL = "https://sdk.api.scallop.io";
|
|
3
4
|
var ADDRESSES_ID = "6462a088a7ace142bb6d7e9b";
|
|
4
5
|
var PROTOCOL_OBJECT_ID = "0xefe8b36d5b2e43728cc323298626b83177803521d195cfb11e15b910e892fddf";
|
|
5
6
|
var BORROW_FEE_PROTOCOL_ID = "0xc38f849e81cfe46d4e4320f508ea7dda42934a329d5a6571bb4c3cb6ea63f5da";
|
|
@@ -1108,7 +1109,7 @@ var parseDataFromPythPriceFeed = (feed, address) => {
|
|
|
1108
1109
|
};
|
|
1109
1110
|
|
|
1110
1111
|
// src/queries/coreQuery.ts
|
|
1111
|
-
var queryMarket = async (query) => {
|
|
1112
|
+
var queryMarket = async (query, indexer = false) => {
|
|
1112
1113
|
const packageId = query.address.get("core.packages.query.id");
|
|
1113
1114
|
const marketId = query.address.get("core.market");
|
|
1114
1115
|
const txBlock = new SuiKitTxBlock();
|
|
@@ -1116,12 +1117,30 @@ var queryMarket = async (query) => {
|
|
|
1116
1117
|
txBlock.moveCall(queryTarget, [marketId]);
|
|
1117
1118
|
const queryResult = await query.suiKit.inspectTxn(txBlock);
|
|
1118
1119
|
const marketData = queryResult.events[0].parsedJson;
|
|
1120
|
+
const coinPrices = await query.utils.getCoinPrices();
|
|
1119
1121
|
const pools = {};
|
|
1120
1122
|
const collaterals = {};
|
|
1123
|
+
if (indexer) {
|
|
1124
|
+
const marketIndexer = await query.indexer.getMarket();
|
|
1125
|
+
for (const pool of Object.values(marketIndexer.pools)) {
|
|
1126
|
+
pool.coinPrice = coinPrices[pool.coinName] || pool.coinPrice;
|
|
1127
|
+
pool.coinWrappedType = query.utils.getCoinWrappedType(pool.coinName);
|
|
1128
|
+
}
|
|
1129
|
+
for (const collateral of Object.values(marketIndexer.collaterals)) {
|
|
1130
|
+
collateral.coinPrice = coinPrices[collateral.coinName] || collateral.coinPrice;
|
|
1131
|
+
collateral.coinWrappedType = query.utils.getCoinWrappedType(
|
|
1132
|
+
collateral.coinName
|
|
1133
|
+
);
|
|
1134
|
+
}
|
|
1135
|
+
return {
|
|
1136
|
+
pools: marketIndexer.pools,
|
|
1137
|
+
collaterals: marketIndexer.collaterals
|
|
1138
|
+
};
|
|
1139
|
+
}
|
|
1121
1140
|
for (const pool of marketData.pools) {
|
|
1122
1141
|
const coinType = normalizeStructTag2(pool.type.name);
|
|
1123
1142
|
const poolCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
1124
|
-
const coinPrice =
|
|
1143
|
+
const coinPrice = coinPrices[poolCoinName] ?? 0;
|
|
1125
1144
|
if (!SUPPORT_POOLS.includes(poolCoinName)) {
|
|
1126
1145
|
continue;
|
|
1127
1146
|
}
|
|
@@ -1171,7 +1190,7 @@ var queryMarket = async (query) => {
|
|
|
1171
1190
|
for (const collateral of marketData.collaterals) {
|
|
1172
1191
|
const coinType = normalizeStructTag2(collateral.type.name);
|
|
1173
1192
|
const collateralCoinName = query.utils.parseCoinNameFromType(coinType);
|
|
1174
|
-
const coinPrice =
|
|
1193
|
+
const coinPrice = coinPrices[collateralCoinName] ?? 0;
|
|
1175
1194
|
if (!SUPPORT_COLLATERALS.includes(collateralCoinName)) {
|
|
1176
1195
|
continue;
|
|
1177
1196
|
}
|
|
@@ -1211,7 +1230,7 @@ var queryMarket = async (query) => {
|
|
|
1211
1230
|
data: marketData
|
|
1212
1231
|
};
|
|
1213
1232
|
};
|
|
1214
|
-
var getMarketPools = async (query, poolCoinNames) => {
|
|
1233
|
+
var getMarketPools = async (query, poolCoinNames, indexer = false) => {
|
|
1215
1234
|
poolCoinNames = poolCoinNames || [...SUPPORT_POOLS];
|
|
1216
1235
|
const marketId = query.address.get("core.market");
|
|
1217
1236
|
const marketObjectResponse = await query.suiKit.client().getObject({
|
|
@@ -1222,10 +1241,24 @@ var getMarketPools = async (query, poolCoinNames) => {
|
|
|
1222
1241
|
});
|
|
1223
1242
|
const coinPrices = await query.utils.getCoinPrices(poolCoinNames ?? []);
|
|
1224
1243
|
const marketPools = {};
|
|
1244
|
+
if (indexer) {
|
|
1245
|
+
const marketPoolsIndexer = await query.indexer.getMarketPools();
|
|
1246
|
+
for (const marketPool of Object.values(marketPoolsIndexer)) {
|
|
1247
|
+
if (!poolCoinNames.includes(marketPool.coinName))
|
|
1248
|
+
continue;
|
|
1249
|
+
marketPool.coinPrice = coinPrices[marketPool.coinName] || marketPool.coinPrice;
|
|
1250
|
+
marketPool.coinWrappedType = query.utils.getCoinWrappedType(
|
|
1251
|
+
marketPool.coinName
|
|
1252
|
+
);
|
|
1253
|
+
marketPools[marketPool.coinName] = marketPool;
|
|
1254
|
+
}
|
|
1255
|
+
return marketPools;
|
|
1256
|
+
}
|
|
1225
1257
|
for (const poolCoinName of poolCoinNames) {
|
|
1226
1258
|
const marketPool = await getMarketPool(
|
|
1227
1259
|
query,
|
|
1228
1260
|
poolCoinName,
|
|
1261
|
+
indexer,
|
|
1229
1262
|
marketObjectResponse.data,
|
|
1230
1263
|
coinPrices?.[poolCoinName]
|
|
1231
1264
|
);
|
|
@@ -1235,7 +1268,7 @@ var getMarketPools = async (query, poolCoinNames) => {
|
|
|
1235
1268
|
}
|
|
1236
1269
|
return marketPools;
|
|
1237
1270
|
};
|
|
1238
|
-
var getMarketPool = async (query, poolCoinName, marketObject, coinPrice) => {
|
|
1271
|
+
var getMarketPool = async (query, poolCoinName, indexer = false, marketObject, coinPrice) => {
|
|
1239
1272
|
const marketId = query.address.get("core.market");
|
|
1240
1273
|
marketObject = marketObject || (await query.suiKit.client().getObject({
|
|
1241
1274
|
id: marketId,
|
|
@@ -1243,11 +1276,20 @@ var getMarketPool = async (query, poolCoinName, marketObject, coinPrice) => {
|
|
|
1243
1276
|
showContent: true
|
|
1244
1277
|
}
|
|
1245
1278
|
})).data;
|
|
1279
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
1246
1280
|
let marketPool;
|
|
1247
1281
|
let balanceSheet;
|
|
1248
1282
|
let borrowIndex;
|
|
1249
1283
|
let interestModel;
|
|
1250
1284
|
let borrowFeeRate;
|
|
1285
|
+
if (indexer) {
|
|
1286
|
+
const marketPoolIndexer = await query.indexer.getMarketPool(poolCoinName);
|
|
1287
|
+
marketPoolIndexer.coinPrice = coinPrice || marketPoolIndexer.coinPrice;
|
|
1288
|
+
marketPoolIndexer.coinWrappedType = query.utils.getCoinWrappedType(
|
|
1289
|
+
marketPoolIndexer.coinName
|
|
1290
|
+
);
|
|
1291
|
+
return marketPoolIndexer;
|
|
1292
|
+
}
|
|
1251
1293
|
if (marketObject) {
|
|
1252
1294
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
1253
1295
|
const fields = marketObject.content.fields;
|
|
@@ -1341,7 +1383,6 @@ var getMarketPool = async (query, poolCoinName, marketObject, coinPrice) => {
|
|
|
1341
1383
|
query.utils,
|
|
1342
1384
|
parsedMarketPoolData
|
|
1343
1385
|
);
|
|
1344
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([poolCoinName]))?.[poolCoinName];
|
|
1345
1386
|
marketPool = {
|
|
1346
1387
|
coinName: poolCoinName,
|
|
1347
1388
|
symbol: query.utils.parseSymbol(poolCoinName),
|
|
@@ -1362,7 +1403,7 @@ var getMarketPool = async (query, poolCoinName, marketObject, coinPrice) => {
|
|
|
1362
1403
|
}
|
|
1363
1404
|
return marketPool;
|
|
1364
1405
|
};
|
|
1365
|
-
var getMarketCollaterals = async (query, collateralCoinNames) => {
|
|
1406
|
+
var getMarketCollaterals = async (query, collateralCoinNames, indexer = false) => {
|
|
1366
1407
|
collateralCoinNames = collateralCoinNames || [...SUPPORT_COLLATERALS];
|
|
1367
1408
|
const marketId = query.address.get("core.market");
|
|
1368
1409
|
const marketObjectResponse = await query.suiKit.client().getObject({
|
|
@@ -1373,10 +1414,24 @@ var getMarketCollaterals = async (query, collateralCoinNames) => {
|
|
|
1373
1414
|
});
|
|
1374
1415
|
const coinPrices = await query.utils.getCoinPrices(collateralCoinNames ?? []);
|
|
1375
1416
|
const marketCollaterals = {};
|
|
1417
|
+
if (indexer) {
|
|
1418
|
+
const marketCollateralsIndexer = await query.indexer.getMarketCollaterals();
|
|
1419
|
+
for (const marketCollateral of Object.values(marketCollateralsIndexer)) {
|
|
1420
|
+
if (!collateralCoinNames.includes(marketCollateral.coinName))
|
|
1421
|
+
continue;
|
|
1422
|
+
marketCollateral.coinPrice = coinPrices[marketCollateral.coinName] || marketCollateral.coinPrice;
|
|
1423
|
+
marketCollateral.coinWrappedType = query.utils.getCoinWrappedType(
|
|
1424
|
+
marketCollateral.coinName
|
|
1425
|
+
);
|
|
1426
|
+
marketCollaterals[marketCollateral.coinName] = marketCollateral;
|
|
1427
|
+
}
|
|
1428
|
+
return marketCollaterals;
|
|
1429
|
+
}
|
|
1376
1430
|
for (const collateralCoinName of collateralCoinNames) {
|
|
1377
1431
|
const marketCollateral = await getMarketCollateral(
|
|
1378
1432
|
query,
|
|
1379
1433
|
collateralCoinName,
|
|
1434
|
+
indexer,
|
|
1380
1435
|
marketObjectResponse.data,
|
|
1381
1436
|
coinPrices?.[collateralCoinName]
|
|
1382
1437
|
);
|
|
@@ -1386,7 +1441,7 @@ var getMarketCollaterals = async (query, collateralCoinNames) => {
|
|
|
1386
1441
|
}
|
|
1387
1442
|
return marketCollaterals;
|
|
1388
1443
|
};
|
|
1389
|
-
var getMarketCollateral = async (query, collateralCoinName, marketObject, coinPrice) => {
|
|
1444
|
+
var getMarketCollateral = async (query, collateralCoinName, indexer = false, marketObject, coinPrice) => {
|
|
1390
1445
|
const marketId = query.address.get("core.market");
|
|
1391
1446
|
marketObject = marketObject || (await query.suiKit.client().getObject({
|
|
1392
1447
|
id: marketId,
|
|
@@ -1394,9 +1449,18 @@ var getMarketCollateral = async (query, collateralCoinName, marketObject, coinPr
|
|
|
1394
1449
|
showContent: true
|
|
1395
1450
|
}
|
|
1396
1451
|
})).data;
|
|
1452
|
+
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
1397
1453
|
let marketCollateral;
|
|
1398
1454
|
let riskModel;
|
|
1399
1455
|
let collateralStat;
|
|
1456
|
+
if (indexer) {
|
|
1457
|
+
const marketCollateralIndexer = await query.indexer.getMarketCollateral(collateralCoinName);
|
|
1458
|
+
marketCollateralIndexer.coinPrice = coinPrice || marketCollateralIndexer.coinPrice;
|
|
1459
|
+
marketCollateralIndexer.coinWrappedType = query.utils.getCoinWrappedType(
|
|
1460
|
+
marketCollateralIndexer.coinName
|
|
1461
|
+
);
|
|
1462
|
+
return marketCollateralIndexer;
|
|
1463
|
+
}
|
|
1400
1464
|
if (marketObject) {
|
|
1401
1465
|
if (marketObject.content && "fields" in marketObject.content) {
|
|
1402
1466
|
const fields = marketObject.content.fields;
|
|
@@ -1448,7 +1512,6 @@ var getMarketCollateral = async (query, collateralCoinName, marketObject, coinPr
|
|
|
1448
1512
|
query.utils,
|
|
1449
1513
|
parsedMarketCollateralData
|
|
1450
1514
|
);
|
|
1451
|
-
coinPrice = coinPrice || (await query.utils.getCoinPrices([collateralCoinName]))?.[collateralCoinName];
|
|
1452
1515
|
marketCollateral = {
|
|
1453
1516
|
coinName: collateralCoinName,
|
|
1454
1517
|
symbol: query.utils.parseSymbol(collateralCoinName),
|
|
@@ -1691,19 +1754,47 @@ var getMarketCoinAmount = async (query, marketCoinName, ownerAddress) => {
|
|
|
1691
1754
|
|
|
1692
1755
|
// src/queries/spoolQuery.ts
|
|
1693
1756
|
import { normalizeStructTag as normalizeStructTag3 } from "@mysten/sui.js/utils";
|
|
1694
|
-
var getSpools = async (query, stakeMarketCoinNames) => {
|
|
1757
|
+
var getSpools = async (query, stakeMarketCoinNames, indexer = false) => {
|
|
1695
1758
|
stakeMarketCoinNames = stakeMarketCoinNames || [...SUPPORT_SPOOLS];
|
|
1696
1759
|
const stakeCoinNames = stakeMarketCoinNames.map(
|
|
1697
1760
|
(stakeMarketCoinName) => query.utils.parseCoinName(stakeMarketCoinName)
|
|
1698
1761
|
);
|
|
1699
|
-
const
|
|
1762
|
+
const rewardCoinNames = stakeMarketCoinNames.map((stakeMarketCoinName) => {
|
|
1763
|
+
const rewardCoinName = query.utils.getSpoolRewardCoinName(stakeMarketCoinName);
|
|
1764
|
+
return rewardCoinName;
|
|
1765
|
+
});
|
|
1766
|
+
const coinPrices = await query.utils.getCoinPrices(
|
|
1767
|
+
[.../* @__PURE__ */ new Set([...stakeCoinNames, ...rewardCoinNames])]
|
|
1768
|
+
);
|
|
1769
|
+
const marketPools = await query.getMarketPools(stakeCoinNames, indexer);
|
|
1700
1770
|
const spools = {};
|
|
1771
|
+
if (indexer) {
|
|
1772
|
+
const spoolsIndexer = await query.indexer.getSpools();
|
|
1773
|
+
for (const spool of Object.values(spoolsIndexer)) {
|
|
1774
|
+
if (!stakeMarketCoinNames.includes(spool.marketCoinName))
|
|
1775
|
+
continue;
|
|
1776
|
+
const coinName = query.utils.parseCoinName(
|
|
1777
|
+
spool.marketCoinName
|
|
1778
|
+
);
|
|
1779
|
+
const rewardCoinName = query.utils.getSpoolRewardCoinName(
|
|
1780
|
+
spool.marketCoinName
|
|
1781
|
+
);
|
|
1782
|
+
const marketPool = marketPools[coinName];
|
|
1783
|
+
spool.coinPrice = coinPrices[coinName] || spool.coinPrice;
|
|
1784
|
+
spool.marketCoinPrice = (coinPrices[coinName] ?? 0) * (marketPool ? marketPool.conversionRate : 0) || spool.marketCoinPrice;
|
|
1785
|
+
spool.rewardCoinPrice = coinPrices[rewardCoinName] || spool.rewardCoinPrice;
|
|
1786
|
+
spools[spool.marketCoinName] = spool;
|
|
1787
|
+
}
|
|
1788
|
+
return spools;
|
|
1789
|
+
}
|
|
1701
1790
|
for (const stakeMarketCoinName of stakeMarketCoinNames) {
|
|
1702
1791
|
const stakeCoinName = query.utils.parseCoinName(stakeMarketCoinName);
|
|
1703
1792
|
const spool = await getSpool(
|
|
1704
1793
|
query,
|
|
1705
1794
|
stakeMarketCoinName,
|
|
1706
|
-
|
|
1795
|
+
indexer,
|
|
1796
|
+
marketPools[stakeCoinName],
|
|
1797
|
+
coinPrices
|
|
1707
1798
|
);
|
|
1708
1799
|
if (spool) {
|
|
1709
1800
|
spools[stakeMarketCoinName] = spool;
|
|
@@ -1711,15 +1802,24 @@ var getSpools = async (query, stakeMarketCoinNames) => {
|
|
|
1711
1802
|
}
|
|
1712
1803
|
return spools;
|
|
1713
1804
|
};
|
|
1714
|
-
var getSpool = async (query, marketCoinName, marketPool) => {
|
|
1805
|
+
var getSpool = async (query, marketCoinName, indexer = false, marketPool, coinPrices) => {
|
|
1715
1806
|
const coinName = query.utils.parseCoinName(marketCoinName);
|
|
1716
|
-
marketPool = marketPool || await query.getMarketPool(coinName);
|
|
1807
|
+
marketPool = marketPool || await query.getMarketPool(coinName, indexer);
|
|
1717
1808
|
const spoolPkgId = query.address.get(`spool.id`);
|
|
1718
1809
|
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
1719
1810
|
const rewardPoolId = query.address.get(
|
|
1720
1811
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
1721
1812
|
);
|
|
1722
1813
|
let spool = void 0;
|
|
1814
|
+
if (indexer) {
|
|
1815
|
+
const spoolIndexer = await query.indexer.getSpool(marketCoinName);
|
|
1816
|
+
const coinName2 = query.utils.parseCoinName(marketCoinName);
|
|
1817
|
+
const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
|
|
1818
|
+
spoolIndexer.coinPrice = coinPrices?.[coinName2] || spoolIndexer.coinPrice;
|
|
1819
|
+
spoolIndexer.marketCoinPrice = (coinPrices?.[coinName2] ?? 0) * (marketPool ? marketPool.conversionRate : 0) || spoolIndexer.marketCoinPrice;
|
|
1820
|
+
spoolIndexer.rewardCoinPrice = coinPrices?.[rewardCoinName] || spoolIndexer.rewardCoinPrice;
|
|
1821
|
+
return spoolIndexer;
|
|
1822
|
+
}
|
|
1723
1823
|
const spoolObjectResponse = await query.suiKit.client().multiGetObjects({
|
|
1724
1824
|
ids: [poolId, rewardPoolId],
|
|
1725
1825
|
options: {
|
|
@@ -1735,10 +1835,7 @@ var getSpool = async (query, marketCoinName, marketPool) => {
|
|
|
1735
1835
|
});
|
|
1736
1836
|
if (marketPool && spoolObjectResponse[0].data && spoolObjectResponse[1].data) {
|
|
1737
1837
|
const rewardCoinName = query.utils.getSpoolRewardCoinName(marketCoinName);
|
|
1738
|
-
|
|
1739
|
-
coinName,
|
|
1740
|
-
rewardCoinName
|
|
1741
|
-
]);
|
|
1838
|
+
coinPrices = coinPrices || await query.utils.getCoinPrices([coinName, rewardCoinName]);
|
|
1742
1839
|
const spoolObject = spoolObjectResponse[0].data;
|
|
1743
1840
|
const rewardPoolObject = spoolObjectResponse[1].data;
|
|
1744
1841
|
const rewardFeeObject = spoolRewardFeeDynamicFieldsResponse.data;
|
|
@@ -1996,7 +2093,7 @@ var getStakeRewardPool = async (query, marketCoinName) => {
|
|
|
1996
2093
|
// src/queries/borrowIncentiveQuery.ts
|
|
1997
2094
|
import { normalizeStructTag as normalizeStructTag4 } from "@mysten/sui.js/utils";
|
|
1998
2095
|
import { SuiTxBlock as SuiKitTxBlock2 } from "@scallop-io/sui-kit";
|
|
1999
|
-
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames) => {
|
|
2096
|
+
var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames, indexer = false) => {
|
|
2000
2097
|
borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
|
|
2001
2098
|
...SUPPORT_BORROW_INCENTIVE_POOLS
|
|
2002
2099
|
];
|
|
@@ -2011,18 +2108,31 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames) => {
|
|
|
2011
2108
|
borrowIncentivePoolsQueryData.reward_pool
|
|
2012
2109
|
);
|
|
2013
2110
|
const rewardCoinType = parsedBorrowIncentiveRewardPoolData.rewardType;
|
|
2111
|
+
const rewardCoinName = query.utils.parseCoinNameFromType(rewardCoinType);
|
|
2112
|
+
const coinPrices = await query.utils.getCoinPrices(
|
|
2113
|
+
[.../* @__PURE__ */ new Set([...borrowIncentiveCoinNames, rewardCoinName])]
|
|
2114
|
+
);
|
|
2014
2115
|
const borrowIncentivePools = {};
|
|
2116
|
+
if (indexer) {
|
|
2117
|
+
const borrowIncentivePoolsIndexer = await query.indexer.getBorrowIncentivePools();
|
|
2118
|
+
for (const borrowIncentivePool of Object.values(
|
|
2119
|
+
borrowIncentivePoolsIndexer
|
|
2120
|
+
)) {
|
|
2121
|
+
if (!borrowIncentiveCoinNames.includes(borrowIncentivePool.coinName))
|
|
2122
|
+
continue;
|
|
2123
|
+
borrowIncentivePool.coinPrice = coinPrices[borrowIncentivePool.coinName] || borrowIncentivePool.coinPrice;
|
|
2124
|
+
borrowIncentivePool.rewardCoinPrice = coinPrices[rewardCoinName] || borrowIncentivePool.rewardCoinPrice;
|
|
2125
|
+
borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
|
|
2126
|
+
}
|
|
2127
|
+
return borrowIncentivePools;
|
|
2128
|
+
}
|
|
2015
2129
|
for (const pool of borrowIncentivePoolsQueryData.incentive_pools) {
|
|
2016
2130
|
const coinType = normalizeStructTag4(pool.pool_type.name);
|
|
2017
2131
|
const coinName = query.utils.parseCoinNameFromType(coinType);
|
|
2018
|
-
const
|
|
2132
|
+
const rewardCoinName2 = query.utils.parseCoinNameFromType(rewardCoinType);
|
|
2019
2133
|
if (!borrowIncentiveCoinNames.includes(coinName)) {
|
|
2020
2134
|
continue;
|
|
2021
2135
|
}
|
|
2022
|
-
const coinPrices = await query.utils.getCoinPrices([
|
|
2023
|
-
coinName,
|
|
2024
|
-
rewardCoinName
|
|
2025
|
-
]);
|
|
2026
2136
|
const parsedBorrowIncentivePoolData = parseOriginBorrowIncentivePoolData(pool);
|
|
2027
2137
|
const coinPrice = coinPrices?.[coinName] ?? 0;
|
|
2028
2138
|
const coinDecimal = query.utils.getCoinDecimal(coinName);
|
|
@@ -2031,8 +2141,8 @@ var queryBorrowIncentivePools = async (query, borrowIncentiveCoinNames) => {
|
|
|
2031
2141
|
coinPrice,
|
|
2032
2142
|
coinDecimal
|
|
2033
2143
|
);
|
|
2034
|
-
const rewardCoinPrice = coinPrices?.[
|
|
2035
|
-
const rewardCoinDecimal = query.utils.getCoinDecimal(
|
|
2144
|
+
const rewardCoinPrice = coinPrices?.[rewardCoinName2] ?? 0;
|
|
2145
|
+
const rewardCoinDecimal = query.utils.getCoinDecimal(rewardCoinName2);
|
|
2036
2146
|
const calculatedBorrowIncentiveRewardPoolData = calculateBorrowIncentiveRewardPoolData(
|
|
2037
2147
|
parsedBorrowIncentivePoolData,
|
|
2038
2148
|
parsedBorrowIncentiveRewardPoolData,
|
|
@@ -2128,7 +2238,7 @@ var getPythPrice = async (query, assetCoinName) => {
|
|
|
2128
2238
|
|
|
2129
2239
|
// src/queries/portfolioQuery.ts
|
|
2130
2240
|
import BigNumber3 from "bignumber.js";
|
|
2131
|
-
var getLendings = async (query, poolCoinNames, ownerAddress) => {
|
|
2241
|
+
var getLendings = async (query, poolCoinNames, ownerAddress, indexer = false) => {
|
|
2132
2242
|
poolCoinNames = poolCoinNames || [...SUPPORT_POOLS];
|
|
2133
2243
|
const marketCoinNames = poolCoinNames.map(
|
|
2134
2244
|
(poolCoinName) => query.utils.parseMarketCoinName(poolCoinName)
|
|
@@ -2136,8 +2246,8 @@ var getLendings = async (query, poolCoinNames, ownerAddress) => {
|
|
|
2136
2246
|
const stakeMarketCoinNames = marketCoinNames.filter(
|
|
2137
2247
|
(marketCoinName) => SUPPORT_SPOOLS.includes(marketCoinName)
|
|
2138
2248
|
);
|
|
2139
|
-
const marketPools = await query.getMarketPools(poolCoinNames);
|
|
2140
|
-
const spools = await query.getSpools(stakeMarketCoinNames);
|
|
2249
|
+
const marketPools = await query.getMarketPools(poolCoinNames, indexer);
|
|
2250
|
+
const spools = await query.getSpools(stakeMarketCoinNames, indexer);
|
|
2141
2251
|
const coinAmounts = await query.getCoinAmounts(poolCoinNames, ownerAddress);
|
|
2142
2252
|
const marketCoinAmounts = await query.getMarketCoinAmounts(
|
|
2143
2253
|
marketCoinNames,
|
|
@@ -2155,6 +2265,7 @@ var getLendings = async (query, poolCoinNames, ownerAddress) => {
|
|
|
2155
2265
|
query,
|
|
2156
2266
|
poolCoinName,
|
|
2157
2267
|
ownerAddress,
|
|
2268
|
+
indexer,
|
|
2158
2269
|
marketPools?.[poolCoinName],
|
|
2159
2270
|
stakeMarketCoinName ? spools[stakeMarketCoinName] : void 0,
|
|
2160
2271
|
stakeMarketCoinName ? allStakeAccounts[stakeMarketCoinName] : void 0,
|
|
@@ -2165,10 +2276,10 @@ var getLendings = async (query, poolCoinNames, ownerAddress) => {
|
|
|
2165
2276
|
}
|
|
2166
2277
|
return lendings;
|
|
2167
2278
|
};
|
|
2168
|
-
var getLending = async (query, poolCoinName, ownerAddress, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice) => {
|
|
2279
|
+
var getLending = async (query, poolCoinName, ownerAddress, indexer = false, marketPool, spool, stakeAccounts, coinAmount, marketCoinAmount, coinPrice) => {
|
|
2169
2280
|
const marketCoinName = query.utils.parseMarketCoinName(poolCoinName);
|
|
2170
|
-
marketPool = marketPool || await query.getMarketPool(poolCoinName);
|
|
2171
|
-
spool = spool || SUPPORT_SPOOLS.includes(marketCoinName) ? await query.getSpool(marketCoinName) : void 0;
|
|
2281
|
+
marketPool = marketPool || await query.getMarketPool(poolCoinName, indexer);
|
|
2282
|
+
spool = spool || SUPPORT_SPOOLS.includes(marketCoinName) ? await query.getSpool(marketCoinName, indexer) : void 0;
|
|
2172
2283
|
stakeAccounts = stakeAccounts || SUPPORT_SPOOLS.includes(marketCoinName) ? await query.getStakeAccounts(
|
|
2173
2284
|
marketCoinName,
|
|
2174
2285
|
ownerAddress
|
|
@@ -2215,7 +2326,7 @@ var getLending = async (query, poolCoinName, ownerAddress, marketPool, spool, st
|
|
|
2215
2326
|
-1 * spool.coinDecimal
|
|
2216
2327
|
);
|
|
2217
2328
|
const baseIndexRate = 1e9;
|
|
2218
|
-
const increasedPointRate = spool
|
|
2329
|
+
const increasedPointRate = spool.currentPointIndex ? BigNumber3(spool.currentPointIndex - stakeAccount.index).dividedBy(
|
|
2219
2330
|
baseIndexRate
|
|
2220
2331
|
) : 1;
|
|
2221
2332
|
availableClaimAmount = availableClaimAmount.plus(
|
|
@@ -2279,8 +2390,8 @@ var getLending = async (query, poolCoinName, ownerAddress, marketPool, spool, st
|
|
|
2279
2390
|
};
|
|
2280
2391
|
return lending;
|
|
2281
2392
|
};
|
|
2282
|
-
var getObligationAccounts = async (query, ownerAddress) => {
|
|
2283
|
-
const market = await query.queryMarket();
|
|
2393
|
+
var getObligationAccounts = async (query, ownerAddress, indexer = false) => {
|
|
2394
|
+
const market = await query.queryMarket(indexer);
|
|
2284
2395
|
const coinPrices = await query.utils.getCoinPrices();
|
|
2285
2396
|
const coinAmounts = await query.getCoinAmounts(void 0, ownerAddress);
|
|
2286
2397
|
const obligations = await query.getObligations(ownerAddress);
|
|
@@ -2290,6 +2401,7 @@ var getObligationAccounts = async (query, ownerAddress) => {
|
|
|
2290
2401
|
query,
|
|
2291
2402
|
obligation.id,
|
|
2292
2403
|
ownerAddress,
|
|
2404
|
+
indexer,
|
|
2293
2405
|
market,
|
|
2294
2406
|
coinPrices,
|
|
2295
2407
|
coinAmounts
|
|
@@ -2297,8 +2409,8 @@ var getObligationAccounts = async (query, ownerAddress) => {
|
|
|
2297
2409
|
}
|
|
2298
2410
|
return obligationAccounts;
|
|
2299
2411
|
};
|
|
2300
|
-
var getObligationAccount = async (query, obligationId, ownerAddress, market, coinPrices, coinAmounts) => {
|
|
2301
|
-
market = market || await query.queryMarket();
|
|
2412
|
+
var getObligationAccount = async (query, obligationId, ownerAddress, indexer = false, market, coinPrices, coinAmounts) => {
|
|
2413
|
+
market = market || await query.queryMarket(indexer);
|
|
2302
2414
|
const assetCoinNames = [
|
|
2303
2415
|
.../* @__PURE__ */ new Set([
|
|
2304
2416
|
...Object.values(market.pools).map((pool) => pool.coinName),
|
|
@@ -2308,7 +2420,10 @@ var getObligationAccount = async (query, obligationId, ownerAddress, market, coi
|
|
|
2308
2420
|
])
|
|
2309
2421
|
];
|
|
2310
2422
|
const obligationQuery = await query.queryObligation(obligationId);
|
|
2311
|
-
const borrowIncentivePools = await query.getBorrowIncentivePools(
|
|
2423
|
+
const borrowIncentivePools = await query.getBorrowIncentivePools(
|
|
2424
|
+
void 0,
|
|
2425
|
+
indexer
|
|
2426
|
+
);
|
|
2312
2427
|
const borrowIncentiveAccounts = await query.getBorrowIncentiveAccounts(obligationId);
|
|
2313
2428
|
coinPrices = coinPrices || await query.utils.getCoinPrices(assetCoinNames);
|
|
2314
2429
|
coinAmounts = coinAmounts || await query.getCoinAmounts(assetCoinNames, ownerAddress);
|
|
@@ -2343,7 +2458,13 @@ var getObligationAccount = async (query, obligationId, ownerAddress, market, coi
|
|
|
2343
2458
|
const requiredCollateralValue2 = depositedValue.multipliedBy(
|
|
2344
2459
|
marketCollateral.liquidationFactor
|
|
2345
2460
|
);
|
|
2346
|
-
const
|
|
2461
|
+
const poolSizeAmount = BigNumber3(marketCollateral.maxDepositAmount).minus(
|
|
2462
|
+
marketCollateral.depositAmount
|
|
2463
|
+
);
|
|
2464
|
+
const availableDepositAmount = minBigNumber(
|
|
2465
|
+
BigNumber3(coinAmount),
|
|
2466
|
+
poolSizeAmount
|
|
2467
|
+
);
|
|
2347
2468
|
const availableDepositCoin = availableDepositAmount.shiftedBy(
|
|
2348
2469
|
-1 * coinDecimal
|
|
2349
2470
|
);
|
|
@@ -2550,10 +2671,18 @@ var getObligationAccount = async (query, obligationId, ownerAddress, market, coi
|
|
|
2550
2671
|
}
|
|
2551
2672
|
return obligationAccount;
|
|
2552
2673
|
};
|
|
2553
|
-
var getTotalValueLocked = async (query) => {
|
|
2554
|
-
const market = await query.queryMarket();
|
|
2674
|
+
var getTotalValueLocked = async (query, indexer = false) => {
|
|
2675
|
+
const market = await query.queryMarket(indexer);
|
|
2555
2676
|
let supplyValue = BigNumber3(0);
|
|
2556
2677
|
let borrowValue = BigNumber3(0);
|
|
2678
|
+
if (indexer) {
|
|
2679
|
+
const tvl2 = await query.indexer.getTotalValueLocked();
|
|
2680
|
+
return {
|
|
2681
|
+
supplyValue: tvl2.supplyValue,
|
|
2682
|
+
borrowValue: tvl2.borrowValue,
|
|
2683
|
+
totalValue: tvl2.totalValue
|
|
2684
|
+
};
|
|
2685
|
+
}
|
|
2557
2686
|
for (const pool of Object.values(market.pools)) {
|
|
2558
2687
|
supplyValue = supplyValue.plus(
|
|
2559
2688
|
BigNumber3(pool.supplyCoin).multipliedBy(pool.coinPrice)
|
|
@@ -2575,6 +2704,183 @@ var getTotalValueLocked = async (query) => {
|
|
|
2575
2704
|
return tvl;
|
|
2576
2705
|
};
|
|
2577
2706
|
|
|
2707
|
+
// src/models/scallopIndexer.ts
|
|
2708
|
+
import axios2 from "axios";
|
|
2709
|
+
var ScallopIndexer = class {
|
|
2710
|
+
constructor() {
|
|
2711
|
+
this._requestClient = axios2.create({
|
|
2712
|
+
baseURL: SDK_API_BASE_URL,
|
|
2713
|
+
headers: {
|
|
2714
|
+
"Content-Type": "application/json",
|
|
2715
|
+
Accept: "application/json"
|
|
2716
|
+
},
|
|
2717
|
+
timeout: 3e4
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
/**
|
|
2721
|
+
* Get market index data.
|
|
2722
|
+
*
|
|
2723
|
+
* @return Market data.
|
|
2724
|
+
*/
|
|
2725
|
+
async getMarket() {
|
|
2726
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/market`);
|
|
2727
|
+
if (response.status === 200) {
|
|
2728
|
+
return {
|
|
2729
|
+
pools: response.data.pools.reduce((marketPools, marketPool) => {
|
|
2730
|
+
marketPools[marketPool.coinName] = marketPool;
|
|
2731
|
+
return marketPools;
|
|
2732
|
+
}, {}),
|
|
2733
|
+
collaterals: response.data.collaterals.reduce(
|
|
2734
|
+
(marketCollaterals, marketCollateral) => {
|
|
2735
|
+
marketCollaterals[marketCollateral.coinName] = marketCollateral;
|
|
2736
|
+
return marketCollaterals;
|
|
2737
|
+
},
|
|
2738
|
+
{}
|
|
2739
|
+
)
|
|
2740
|
+
};
|
|
2741
|
+
} else {
|
|
2742
|
+
throw Error("Failed to getMarket.");
|
|
2743
|
+
}
|
|
2744
|
+
}
|
|
2745
|
+
/**
|
|
2746
|
+
* Get market pools index data.
|
|
2747
|
+
*
|
|
2748
|
+
* @return Market pools data.
|
|
2749
|
+
*/
|
|
2750
|
+
async getMarketPools() {
|
|
2751
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/market/pools`);
|
|
2752
|
+
if (response.status === 200) {
|
|
2753
|
+
return response.data.pools.reduce((marketPools, marketPool) => {
|
|
2754
|
+
marketPools[marketPool.coinName] = marketPool;
|
|
2755
|
+
return marketPools;
|
|
2756
|
+
}, {});
|
|
2757
|
+
} else {
|
|
2758
|
+
throw Error("Failed to getMarketPools.");
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
/**
|
|
2762
|
+
* Get market pool index data.
|
|
2763
|
+
*
|
|
2764
|
+
* @return Market pool data.
|
|
2765
|
+
*/
|
|
2766
|
+
async getMarketPool(poolCoinName) {
|
|
2767
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/market/pool/${poolCoinName}`);
|
|
2768
|
+
if (response.status === 200) {
|
|
2769
|
+
return response.data.pool;
|
|
2770
|
+
} else {
|
|
2771
|
+
throw Error("Failed to getMarketPool.");
|
|
2772
|
+
}
|
|
2773
|
+
}
|
|
2774
|
+
/**
|
|
2775
|
+
* Get market collaterals index data.
|
|
2776
|
+
*
|
|
2777
|
+
* @return Market collaterals data.
|
|
2778
|
+
*/
|
|
2779
|
+
async getMarketCollaterals() {
|
|
2780
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/market/collaterals`);
|
|
2781
|
+
if (response.status === 200) {
|
|
2782
|
+
return response.data.collaterals.reduce(
|
|
2783
|
+
(marketCollaterals, marketCollateral) => {
|
|
2784
|
+
marketCollaterals[marketCollateral.coinName] = marketCollateral;
|
|
2785
|
+
return marketCollaterals;
|
|
2786
|
+
},
|
|
2787
|
+
{}
|
|
2788
|
+
);
|
|
2789
|
+
} else {
|
|
2790
|
+
throw Error("Failed to getMarketCollaterals.");
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
/**
|
|
2794
|
+
* Get market collateral index data.
|
|
2795
|
+
*
|
|
2796
|
+
* @return Market collateral data.
|
|
2797
|
+
*/
|
|
2798
|
+
async getMarketCollateral(collateralCoinName) {
|
|
2799
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/market/collateral/${collateralCoinName}`);
|
|
2800
|
+
if (response.status === 200) {
|
|
2801
|
+
return response.data.collateral;
|
|
2802
|
+
} else {
|
|
2803
|
+
throw Error("Failed to getMarketCollateral.");
|
|
2804
|
+
}
|
|
2805
|
+
}
|
|
2806
|
+
/**
|
|
2807
|
+
* Get spools index data.
|
|
2808
|
+
*
|
|
2809
|
+
* @return Spools data.
|
|
2810
|
+
*/
|
|
2811
|
+
async getSpools() {
|
|
2812
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/spools`);
|
|
2813
|
+
if (response.status === 200) {
|
|
2814
|
+
return response.data.spools.reduce((spools, spool) => {
|
|
2815
|
+
spools[spool.marketCoinName] = spool;
|
|
2816
|
+
return spools;
|
|
2817
|
+
}, {});
|
|
2818
|
+
} else {
|
|
2819
|
+
throw Error("Failed to getSpools.");
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
/**
|
|
2823
|
+
* Get spool index data.
|
|
2824
|
+
*
|
|
2825
|
+
* @return Spool data.
|
|
2826
|
+
*/
|
|
2827
|
+
async getSpool(marketCoinName) {
|
|
2828
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/spool/${marketCoinName}`);
|
|
2829
|
+
if (response.status === 200) {
|
|
2830
|
+
return response.data.spool;
|
|
2831
|
+
} else {
|
|
2832
|
+
throw Error("Failed to getSpool.");
|
|
2833
|
+
}
|
|
2834
|
+
}
|
|
2835
|
+
/**
|
|
2836
|
+
* Get borrow incentive pools index data.
|
|
2837
|
+
*
|
|
2838
|
+
* @return Borrow incentive pools data.
|
|
2839
|
+
*/
|
|
2840
|
+
async getBorrowIncentivePools() {
|
|
2841
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/borrowIncentivePools`);
|
|
2842
|
+
if (response.status === 200) {
|
|
2843
|
+
return response.data.borrowIncentivePools.reduce(
|
|
2844
|
+
(borrowIncentivePools, borrowIncentivePool) => {
|
|
2845
|
+
borrowIncentivePools[borrowIncentivePool.coinName] = borrowIncentivePool;
|
|
2846
|
+
return borrowIncentivePools;
|
|
2847
|
+
},
|
|
2848
|
+
{}
|
|
2849
|
+
);
|
|
2850
|
+
} else {
|
|
2851
|
+
throw Error("Failed to getBorrowIncentivePools.");
|
|
2852
|
+
}
|
|
2853
|
+
}
|
|
2854
|
+
/**
|
|
2855
|
+
* Get borrow incentive pool index data.
|
|
2856
|
+
*
|
|
2857
|
+
* @return Borrow incentive pool data.
|
|
2858
|
+
*/
|
|
2859
|
+
async getBorrowIncentivePool(borrowIncentiveCoinName) {
|
|
2860
|
+
const response = await this._requestClient.get(
|
|
2861
|
+
`${SDK_API_BASE_URL}/api/borrowIncentivePool/${borrowIncentiveCoinName}`
|
|
2862
|
+
);
|
|
2863
|
+
if (response.status === 200) {
|
|
2864
|
+
return response.data.borrowIncentivePool;
|
|
2865
|
+
} else {
|
|
2866
|
+
throw Error("Failed to getSpool.");
|
|
2867
|
+
}
|
|
2868
|
+
}
|
|
2869
|
+
/**
|
|
2870
|
+
* Get total value locked index data.
|
|
2871
|
+
*
|
|
2872
|
+
* @return Total value locked.
|
|
2873
|
+
*/
|
|
2874
|
+
async getTotalValueLocked() {
|
|
2875
|
+
const response = await this._requestClient.get(`${SDK_API_BASE_URL}/api/market/tvl`);
|
|
2876
|
+
if (response.status === 200) {
|
|
2877
|
+
return response.data;
|
|
2878
|
+
} else {
|
|
2879
|
+
throw Error("Failed to getTotalValueLocked.");
|
|
2880
|
+
}
|
|
2881
|
+
}
|
|
2882
|
+
};
|
|
2883
|
+
|
|
2578
2884
|
// src/models/scallopQuery.ts
|
|
2579
2885
|
var ScallopQuery = class {
|
|
2580
2886
|
constructor(params, instance) {
|
|
@@ -2589,6 +2895,7 @@ var ScallopQuery = class {
|
|
|
2589
2895
|
address: this.address,
|
|
2590
2896
|
query: this
|
|
2591
2897
|
});
|
|
2898
|
+
this.indexer = new ScallopIndexer();
|
|
2592
2899
|
}
|
|
2593
2900
|
/**
|
|
2594
2901
|
* Request the scallop API to initialize data.
|
|
@@ -2604,11 +2911,11 @@ var ScallopQuery = class {
|
|
|
2604
2911
|
/* ==================== Core Query Methods ==================== */
|
|
2605
2912
|
/**
|
|
2606
2913
|
* Query market data.
|
|
2607
|
-
*
|
|
2914
|
+
* @param indexer - Whether to use indexer.
|
|
2608
2915
|
* @return Market data.
|
|
2609
2916
|
*/
|
|
2610
|
-
async queryMarket() {
|
|
2611
|
-
return await queryMarket(this);
|
|
2917
|
+
async queryMarket(indexer = false) {
|
|
2918
|
+
return await queryMarket(this, indexer);
|
|
2612
2919
|
}
|
|
2613
2920
|
/**
|
|
2614
2921
|
* Get market pools.
|
|
@@ -2618,19 +2925,21 @@ var ScallopQuery = class {
|
|
|
2618
2925
|
* the `queryMarket` method to reduce time consumption.
|
|
2619
2926
|
*
|
|
2620
2927
|
* @param poolCoinNames - Specific an array of support pool coin name.
|
|
2928
|
+
* @param indexer - Whether to use indexer.
|
|
2621
2929
|
* @return Market pools data.
|
|
2622
2930
|
*/
|
|
2623
|
-
async getMarketPools(poolCoinNames) {
|
|
2624
|
-
return await getMarketPools(this, poolCoinNames);
|
|
2931
|
+
async getMarketPools(poolCoinNames, indexer = false) {
|
|
2932
|
+
return await getMarketPools(this, poolCoinNames, indexer);
|
|
2625
2933
|
}
|
|
2626
2934
|
/**
|
|
2627
2935
|
* Get market pool
|
|
2628
2936
|
*
|
|
2629
2937
|
* @param poolCoinName - Specific support pool coin name.
|
|
2938
|
+
* @param indexer - Whether to use indexer.
|
|
2630
2939
|
* @return Market pool data.
|
|
2631
2940
|
*/
|
|
2632
|
-
async getMarketPool(poolCoinName) {
|
|
2633
|
-
return await getMarketPool(this, poolCoinName);
|
|
2941
|
+
async getMarketPool(poolCoinName, indexer = false) {
|
|
2942
|
+
return await getMarketPool(this, poolCoinName, indexer);
|
|
2634
2943
|
}
|
|
2635
2944
|
/**
|
|
2636
2945
|
* Get market collaterals.
|
|
@@ -2640,19 +2949,21 @@ var ScallopQuery = class {
|
|
|
2640
2949
|
* the `queryMarket` method to reduce time consumption.
|
|
2641
2950
|
*
|
|
2642
2951
|
* @param collateralCoinNames - Specific an array of support collateral coin name.
|
|
2952
|
+
* @param indexer - Whether to use indexer.
|
|
2643
2953
|
* @return Market collaterals data.
|
|
2644
2954
|
*/
|
|
2645
|
-
async getMarketCollaterals(collateralCoinNames) {
|
|
2646
|
-
return await getMarketCollaterals(this, collateralCoinNames);
|
|
2955
|
+
async getMarketCollaterals(collateralCoinNames, indexer = false) {
|
|
2956
|
+
return await getMarketCollaterals(this, collateralCoinNames, indexer);
|
|
2647
2957
|
}
|
|
2648
2958
|
/**
|
|
2649
2959
|
* Get market collateral
|
|
2650
2960
|
*
|
|
2651
2961
|
* @param collateralCoinName - Specific support collateral coin name.
|
|
2962
|
+
* @param indexer - Whether to use indexer.
|
|
2652
2963
|
* @return Market collateral data.
|
|
2653
2964
|
*/
|
|
2654
|
-
async getMarketCollateral(collateralCoinName) {
|
|
2655
|
-
return await getMarketCollateral(this, collateralCoinName);
|
|
2965
|
+
async getMarketCollateral(collateralCoinName, indexer = false) {
|
|
2966
|
+
return await getMarketCollateral(this, collateralCoinName, indexer);
|
|
2656
2967
|
}
|
|
2657
2968
|
/**
|
|
2658
2969
|
* Get obligations data.
|
|
@@ -2726,19 +3037,21 @@ var ScallopQuery = class {
|
|
|
2726
3037
|
* Get spools data.
|
|
2727
3038
|
*
|
|
2728
3039
|
* @param stakeMarketCoinNames - Specific an array of support stake market coin name.
|
|
3040
|
+
* @param indexer - Whether to use indexer.
|
|
2729
3041
|
* @return Spools data.
|
|
2730
3042
|
*/
|
|
2731
|
-
async getSpools(stakeMarketCoinNames) {
|
|
2732
|
-
return await getSpools(this, stakeMarketCoinNames);
|
|
3043
|
+
async getSpools(stakeMarketCoinNames, indexer = false) {
|
|
3044
|
+
return await getSpools(this, stakeMarketCoinNames, indexer);
|
|
2733
3045
|
}
|
|
2734
3046
|
/**
|
|
2735
3047
|
* Get spool data.
|
|
2736
3048
|
*
|
|
2737
3049
|
* @param stakeMarketCoinName - Specific support stake market coin name.
|
|
3050
|
+
* @param indexer - Whether to use indexer.
|
|
2738
3051
|
* @return Spool data.
|
|
2739
3052
|
*/
|
|
2740
|
-
async getSpool(stakeMarketCoinName) {
|
|
2741
|
-
return await getSpool(this, stakeMarketCoinName);
|
|
3053
|
+
async getSpool(stakeMarketCoinName, indexer = false) {
|
|
3054
|
+
return await getSpool(this, stakeMarketCoinName, indexer);
|
|
2742
3055
|
}
|
|
2743
3056
|
/**
|
|
2744
3057
|
* Get stake accounts data for all stake pools (spools).
|
|
@@ -2835,10 +3148,11 @@ var ScallopQuery = class {
|
|
|
2835
3148
|
* Get borrow incentive pools data.
|
|
2836
3149
|
*
|
|
2837
3150
|
* @param coinNames - Specific an array of support borrow incentive coin name.
|
|
3151
|
+
* @param indexer - Whether to use indexer.
|
|
2838
3152
|
* @return Borrow incentive pools data.
|
|
2839
3153
|
*/
|
|
2840
|
-
async getBorrowIncentivePools(coinNames) {
|
|
2841
|
-
return await queryBorrowIncentivePools(this, coinNames);
|
|
3154
|
+
async getBorrowIncentivePools(coinNames, indexer = false) {
|
|
3155
|
+
return await queryBorrowIncentivePools(this, coinNames, indexer);
|
|
2842
3156
|
}
|
|
2843
3157
|
/**
|
|
2844
3158
|
* Get borrow incentive accounts data.
|
|
@@ -2855,20 +3169,22 @@ var ScallopQuery = class {
|
|
|
2855
3169
|
*
|
|
2856
3170
|
* @param poolCoinNames - Specific an array of support pool coin name.
|
|
2857
3171
|
* @param ownerAddress - The owner address.
|
|
3172
|
+
* @param indexer - Whether to use indexer.
|
|
2858
3173
|
* @return All lending and spool infomation.
|
|
2859
3174
|
*/
|
|
2860
|
-
async getLendings(poolCoinNames, ownerAddress) {
|
|
2861
|
-
return await getLendings(this, poolCoinNames, ownerAddress);
|
|
3175
|
+
async getLendings(poolCoinNames, ownerAddress, indexer = false) {
|
|
3176
|
+
return await getLendings(this, poolCoinNames, ownerAddress, indexer);
|
|
2862
3177
|
}
|
|
2863
3178
|
/**
|
|
2864
3179
|
* Get user lending and spool information for specific pool.
|
|
2865
3180
|
*
|
|
2866
3181
|
* @param poolCoinName - Specific support pool coin name.
|
|
2867
3182
|
* @param ownerAddress - The owner address.
|
|
3183
|
+
* @param indexer - Whether to use indexer.
|
|
2868
3184
|
* @return Lending pool data.
|
|
2869
3185
|
*/
|
|
2870
|
-
async getLending(poolCoinName, ownerAddress) {
|
|
2871
|
-
return await getLending(this, poolCoinName, ownerAddress);
|
|
3186
|
+
async getLending(poolCoinName, ownerAddress, indexer = false) {
|
|
3187
|
+
return await getLending(this, poolCoinName, ownerAddress, indexer);
|
|
2872
3188
|
}
|
|
2873
3189
|
/**
|
|
2874
3190
|
* Get user all obligation accounts information.
|
|
@@ -2877,10 +3193,11 @@ var ScallopQuery = class {
|
|
|
2877
3193
|
* All collateral and borrowing information in all obligation accounts owned by the user.
|
|
2878
3194
|
*
|
|
2879
3195
|
* @param ownerAddress - The owner address.
|
|
3196
|
+
* @param indexer - Whether to use indexer.
|
|
2880
3197
|
* @return All obligation accounts information.
|
|
2881
3198
|
*/
|
|
2882
|
-
async getObligationAccounts(ownerAddress) {
|
|
2883
|
-
return await getObligationAccounts(this, ownerAddress);
|
|
3199
|
+
async getObligationAccounts(ownerAddress, indexer = false) {
|
|
3200
|
+
return await getObligationAccounts(this, ownerAddress, indexer);
|
|
2884
3201
|
}
|
|
2885
3202
|
/**
|
|
2886
3203
|
* Get obligation account information for specific id.
|
|
@@ -2890,21 +3207,28 @@ var ScallopQuery = class {
|
|
|
2890
3207
|
*
|
|
2891
3208
|
* @param obligationId - The obligation id.
|
|
2892
3209
|
* @param ownerAddress - The owner address.
|
|
3210
|
+
* @param indexer - Whether to use indexer.
|
|
2893
3211
|
* @return Borrowing and collateral information.
|
|
2894
3212
|
*/
|
|
2895
|
-
async getObligationAccount(obligationId, ownerAddress) {
|
|
2896
|
-
return await getObligationAccount(
|
|
3213
|
+
async getObligationAccount(obligationId, ownerAddress, indexer = false) {
|
|
3214
|
+
return await getObligationAccount(
|
|
3215
|
+
this,
|
|
3216
|
+
obligationId,
|
|
3217
|
+
ownerAddress,
|
|
3218
|
+
indexer
|
|
3219
|
+
);
|
|
2897
3220
|
}
|
|
2898
3221
|
/**
|
|
2899
3222
|
* Get total value locked.
|
|
2900
3223
|
*
|
|
3224
|
+
* @param indexer - Whether to use indexer.
|
|
2901
3225
|
* @description
|
|
2902
3226
|
* Include total supplied value and total borrowed value.
|
|
2903
3227
|
*
|
|
2904
3228
|
* @return Total value locked.
|
|
2905
3229
|
*/
|
|
2906
|
-
async getTvl() {
|
|
2907
|
-
return await getTotalValueLocked(this);
|
|
3230
|
+
async getTvl(indexer = false) {
|
|
3231
|
+
return await getTotalValueLocked(this, indexer);
|
|
2908
3232
|
}
|
|
2909
3233
|
};
|
|
2910
3234
|
|
|
@@ -4724,6 +5048,15 @@ var Scallop = class {
|
|
|
4724
5048
|
});
|
|
4725
5049
|
return scallopQuery;
|
|
4726
5050
|
}
|
|
5051
|
+
/**
|
|
5052
|
+
* Create a scallop indexer instance.
|
|
5053
|
+
*
|
|
5054
|
+
* @return Scallop Indexer.
|
|
5055
|
+
*/
|
|
5056
|
+
async createScallopIndexer() {
|
|
5057
|
+
const scallopIndexer = new ScallopIndexer();
|
|
5058
|
+
return scallopIndexer;
|
|
5059
|
+
}
|
|
4727
5060
|
/**
|
|
4728
5061
|
* Create a scallop utils instance.
|
|
4729
5062
|
*
|
|
@@ -4744,6 +5077,7 @@ export {
|
|
|
4744
5077
|
API_BASE_URL,
|
|
4745
5078
|
BORROW_FEE_PROTOCOL_ID,
|
|
4746
5079
|
PROTOCOL_OBJECT_ID,
|
|
5080
|
+
SDK_API_BASE_URL,
|
|
4747
5081
|
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
4748
5082
|
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
4749
5083
|
SUPPORT_COLLATERALS,
|
|
@@ -4756,6 +5090,7 @@ export {
|
|
|
4756
5090
|
ScallopAddress,
|
|
4757
5091
|
ScallopBuilder,
|
|
4758
5092
|
ScallopClient,
|
|
5093
|
+
ScallopIndexer,
|
|
4759
5094
|
ScallopQuery,
|
|
4760
5095
|
ScallopUtils,
|
|
4761
5096
|
assetCoins,
|