@scallop-io/sui-scallop-sdk 1.3.0-alpha.4 → 1.3.0-alpha.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/index.d.ts +1 -0
- package/dist/constants/queryKeys.d.ts +61 -0
- package/dist/index.js +119 -128
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -136
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallop.d.ts +2 -1
- package/dist/models/scallopCache.d.ts +2 -3
- package/package.json +2 -2
- package/src/constants/index.ts +1 -0
- package/src/constants/queryKeys.ts +111 -0
- package/src/models/scallop.ts +5 -2
- package/src/models/scallopAddress.ts +2 -1
- package/src/models/scallopCache.ts +31 -129
- package/src/models/scallopIndexer.ts +5 -4
- package/src/models/scallopUtils.ts +2 -1
- package/src/queries/vescaQuery.ts +5 -4
- package/src/utils/indexer.ts +2 -2
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { GetDynamicFieldObjectParams, GetDynamicFieldsParams, GetOwnedObjectsParams, SuiObjectData, SuiObjectDataOptions } from '@mysten/sui/client';
|
|
2
|
+
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
3
|
+
export declare const queryKeys: {
|
|
4
|
+
api: {
|
|
5
|
+
getAddresses: (addressesId?: string) => (string | {
|
|
6
|
+
addressesId: string | undefined;
|
|
7
|
+
})[];
|
|
8
|
+
getMarket: () => string[];
|
|
9
|
+
getSpools: () => string[];
|
|
10
|
+
getBorrowIncentivePool: () => string[];
|
|
11
|
+
getTotalValueLocked: () => string[];
|
|
12
|
+
};
|
|
13
|
+
rpc: {
|
|
14
|
+
getInspectTxn: (queryTarget?: string, args?: SuiObjectArg[], typeArgs?: any[]) => (string | {
|
|
15
|
+
queryTarget: string | undefined;
|
|
16
|
+
args: string;
|
|
17
|
+
typeArgs: string | undefined;
|
|
18
|
+
})[];
|
|
19
|
+
getObject: (objectId?: string, walletAddress?: string, options?: SuiObjectDataOptions) => (string | {
|
|
20
|
+
walletAddress: string | undefined;
|
|
21
|
+
options: SuiObjectDataOptions | undefined;
|
|
22
|
+
objectId: string | undefined;
|
|
23
|
+
})[];
|
|
24
|
+
getObjects: (objectIds?: string[], walletAddress?: string, options?: SuiObjectDataOptions) => (string | {
|
|
25
|
+
walletAddress: string | undefined;
|
|
26
|
+
options: SuiObjectDataOptions | undefined;
|
|
27
|
+
objectIds: string;
|
|
28
|
+
})[];
|
|
29
|
+
getOwnedObjects: (input: Partial<GetOwnedObjectsParams>) => (string | {
|
|
30
|
+
walletAddress: string | undefined;
|
|
31
|
+
cursor: string | undefined;
|
|
32
|
+
options: SuiObjectDataOptions | undefined;
|
|
33
|
+
filter: string;
|
|
34
|
+
limit: number | undefined;
|
|
35
|
+
})[];
|
|
36
|
+
getDynamicFields: (input: Partial<GetDynamicFieldsParams>) => (string | {
|
|
37
|
+
parentId: string | undefined;
|
|
38
|
+
cursor: string | undefined;
|
|
39
|
+
limit: number | undefined;
|
|
40
|
+
})[];
|
|
41
|
+
getDynamicFieldObject: (input: Partial<GetDynamicFieldObjectParams>) => (string | {
|
|
42
|
+
parentId: string | undefined;
|
|
43
|
+
name: {
|
|
44
|
+
type: string | undefined;
|
|
45
|
+
value: unknown;
|
|
46
|
+
};
|
|
47
|
+
})[];
|
|
48
|
+
getTotalVeScaTreasuryAmount: (refreshArgs?: any[], vescaAmountArgs?: (string | SuiObjectData)[]) => (string | {
|
|
49
|
+
refreshArgs: string;
|
|
50
|
+
vescaAmountArgs: string;
|
|
51
|
+
})[];
|
|
52
|
+
getAllCoinBalances: (owner?: string) => (string | {
|
|
53
|
+
owner: string | undefined;
|
|
54
|
+
})[];
|
|
55
|
+
};
|
|
56
|
+
pyth: {
|
|
57
|
+
getPythLatestPriceFeed: (pythPriceId?: string) => (string | {
|
|
58
|
+
pythPriceId: string | undefined;
|
|
59
|
+
})[];
|
|
60
|
+
};
|
|
61
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -69,6 +69,7 @@ __export(src_exports, {
|
|
|
69
69
|
coinDecimals: () => coinDecimals,
|
|
70
70
|
coinIds: () => coinIds,
|
|
71
71
|
marketCoins: () => marketCoins,
|
|
72
|
+
queryKeys: () => queryKeys,
|
|
72
73
|
sCoinIds: () => sCoinIds,
|
|
73
74
|
sCoins: () => sCoins,
|
|
74
75
|
spoolRewardCoins: () => spoolRewardCoins,
|
|
@@ -364,6 +365,93 @@ var FlashLoanFeeObjectMap = {
|
|
|
364
365
|
wsol: "0xe84bdb35b790fc7bdd1645122ac6ac0fc904531d6772c9e25904fece322c5f34"
|
|
365
366
|
};
|
|
366
367
|
|
|
368
|
+
// src/constants/queryKeys.ts
|
|
369
|
+
var queryKeys = {
|
|
370
|
+
api: {
|
|
371
|
+
getAddresses: (addressesId) => [
|
|
372
|
+
"api",
|
|
373
|
+
"getAddresses",
|
|
374
|
+
{ addressesId }
|
|
375
|
+
],
|
|
376
|
+
getMarket: () => ["api", "getMarket"],
|
|
377
|
+
getSpools: () => ["api", "getSpools"],
|
|
378
|
+
getBorrowIncentivePool: () => ["api", "getBorrowIncentivePools"],
|
|
379
|
+
getTotalValueLocked: () => ["api", "getTotalValueLocked"]
|
|
380
|
+
},
|
|
381
|
+
rpc: {
|
|
382
|
+
getInspectTxn: (queryTarget, args, typeArgs) => [
|
|
383
|
+
"rpc",
|
|
384
|
+
"getInspectTxn",
|
|
385
|
+
{
|
|
386
|
+
queryTarget,
|
|
387
|
+
args: JSON.stringify(args),
|
|
388
|
+
typeArgs: !typeArgs ? void 0 : JSON.stringify(typeArgs)
|
|
389
|
+
}
|
|
390
|
+
],
|
|
391
|
+
getObject: (objectId, walletAddress, options) => ["rpc", "getObject", { walletAddress, options, objectId }],
|
|
392
|
+
getObjects: (objectIds, walletAddress, options) => [
|
|
393
|
+
"rpc",
|
|
394
|
+
"getObjects",
|
|
395
|
+
{
|
|
396
|
+
walletAddress,
|
|
397
|
+
options,
|
|
398
|
+
objectIds: JSON.stringify(objectIds ?? [])
|
|
399
|
+
}
|
|
400
|
+
],
|
|
401
|
+
getOwnedObjects: (input) => [
|
|
402
|
+
"rpc",
|
|
403
|
+
"getOwnedObjects",
|
|
404
|
+
{
|
|
405
|
+
walletAddress: input.owner,
|
|
406
|
+
cursor: input.cursor ?? void 0,
|
|
407
|
+
options: input.options ?? void 0,
|
|
408
|
+
filter: JSON.stringify(input.filter ?? void 0),
|
|
409
|
+
limit: input.limit ?? void 0
|
|
410
|
+
}
|
|
411
|
+
],
|
|
412
|
+
getDynamicFields: (input) => [
|
|
413
|
+
"rpc",
|
|
414
|
+
"getDynamicFields",
|
|
415
|
+
{
|
|
416
|
+
parentId: input.parentId,
|
|
417
|
+
cursor: input.cursor ?? void 0,
|
|
418
|
+
limit: input.limit ?? void 0
|
|
419
|
+
}
|
|
420
|
+
],
|
|
421
|
+
getDynamicFieldObject: (input) => [
|
|
422
|
+
"rpc",
|
|
423
|
+
"getDynamicFieldObject",
|
|
424
|
+
{
|
|
425
|
+
parentId: input.parentId,
|
|
426
|
+
name: {
|
|
427
|
+
type: input?.name?.type,
|
|
428
|
+
value: input?.name?.value
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
],
|
|
432
|
+
getTotalVeScaTreasuryAmount: (refreshArgs, vescaAmountArgs) => [
|
|
433
|
+
"rpc",
|
|
434
|
+
"getTotalVeScaTreasuryAmount",
|
|
435
|
+
{
|
|
436
|
+
refreshArgs: JSON.stringify(refreshArgs),
|
|
437
|
+
vescaAmountArgs: JSON.stringify(vescaAmountArgs)
|
|
438
|
+
}
|
|
439
|
+
],
|
|
440
|
+
getAllCoinBalances: (owner) => [
|
|
441
|
+
"rpc",
|
|
442
|
+
"getAllCoinBalances",
|
|
443
|
+
{ owner }
|
|
444
|
+
]
|
|
445
|
+
},
|
|
446
|
+
pyth: {
|
|
447
|
+
getPythLatestPriceFeed: (pythPriceId) => [
|
|
448
|
+
"pyth",
|
|
449
|
+
"getPythPriceId",
|
|
450
|
+
{ pythPriceId }
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
|
|
367
455
|
// src/constants/vesca.ts
|
|
368
456
|
var UNLOCK_ROUND_DURATION = 60 * 60 * 24;
|
|
369
457
|
var MAX_LOCK_ROUNDS = 1460;
|
|
@@ -1019,8 +1107,8 @@ async function callMethodWithIndexerFallback(method, context, ...args) {
|
|
|
1019
1107
|
if (indexer) {
|
|
1020
1108
|
try {
|
|
1021
1109
|
return await method.apply(context, args);
|
|
1022
|
-
} catch (
|
|
1023
|
-
console.warn(
|
|
1110
|
+
} catch (e) {
|
|
1111
|
+
console.warn(`Indexer requests failed: ${e}. Retrying without indexer..`);
|
|
1024
1112
|
return await method.apply(context, [...args.slice(0, -1), false]);
|
|
1025
1113
|
}
|
|
1026
1114
|
}
|
|
@@ -1034,8 +1122,8 @@ function withIndexerFallback(method) {
|
|
|
1034
1122
|
|
|
1035
1123
|
// src/models/scallopCache.ts
|
|
1036
1124
|
var ScallopCache = class {
|
|
1037
|
-
constructor(suiKit, walletAddress, cacheOptions, tokenBucket) {
|
|
1038
|
-
this.queryClient = new import_query_core.QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
|
|
1125
|
+
constructor(suiKit, walletAddress, cacheOptions, tokenBucket, queryClient) {
|
|
1126
|
+
this.queryClient = queryClient ?? new import_query_core.QueryClient(cacheOptions ?? DEFAULT_CACHE_OPTIONS);
|
|
1039
1127
|
this._suiKit = suiKit;
|
|
1040
1128
|
this.tokenBucket = tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS);
|
|
1041
1129
|
this.walletAddress = walletAddress ?? suiKit.currentAddress();
|
|
@@ -1063,41 +1151,6 @@ var ScallopCache = class {
|
|
|
1063
1151
|
refetchType
|
|
1064
1152
|
});
|
|
1065
1153
|
}
|
|
1066
|
-
async resolveArgs(txb, args) {
|
|
1067
|
-
return await Promise.all(
|
|
1068
|
-
args.map(async (arg) => {
|
|
1069
|
-
if (typeof arg === "string") {
|
|
1070
|
-
const objData = (await this.queryGetObject(arg, { showOwner: true }))?.data;
|
|
1071
|
-
if (!objData)
|
|
1072
|
-
return arg;
|
|
1073
|
-
const owner = objData?.owner;
|
|
1074
|
-
if (!owner)
|
|
1075
|
-
return arg;
|
|
1076
|
-
if ("Shared" in owner) {
|
|
1077
|
-
return txb.sharedObjectRef({
|
|
1078
|
-
objectId: objData.objectId,
|
|
1079
|
-
initialSharedVersion: owner.Shared.initial_shared_version,
|
|
1080
|
-
mutable: true
|
|
1081
|
-
});
|
|
1082
|
-
} else {
|
|
1083
|
-
return txb.objectRef({
|
|
1084
|
-
objectId: objData.objectId,
|
|
1085
|
-
version: objData.version,
|
|
1086
|
-
digest: objData.digest
|
|
1087
|
-
});
|
|
1088
|
-
}
|
|
1089
|
-
} else if ("objectId" in arg && "version" in arg && "digest" in arg) {
|
|
1090
|
-
return txb.objectRef({
|
|
1091
|
-
objectId: arg.objectId,
|
|
1092
|
-
version: arg.version,
|
|
1093
|
-
digest: arg.digest
|
|
1094
|
-
});
|
|
1095
|
-
} else {
|
|
1096
|
-
return arg;
|
|
1097
|
-
}
|
|
1098
|
-
})
|
|
1099
|
-
);
|
|
1100
|
-
}
|
|
1101
1154
|
/**
|
|
1102
1155
|
* @description Provides cache for inspectTxn of the SuiKit.
|
|
1103
1156
|
* @param QueryInspectTxnParams
|
|
@@ -1110,15 +1163,9 @@ var ScallopCache = class {
|
|
|
1110
1163
|
typeArgs
|
|
1111
1164
|
}) {
|
|
1112
1165
|
const txBlock = new import_sui_kit.SuiTxBlock();
|
|
1113
|
-
|
|
1114
|
-
txBlock.moveCall(queryTarget, resolvedArgs, typeArgs);
|
|
1166
|
+
txBlock.moveCall(queryTarget, args, typeArgs);
|
|
1115
1167
|
const query = await this.queryClient.fetchQuery({
|
|
1116
|
-
queryKey:
|
|
1117
|
-
"inspectTxn",
|
|
1118
|
-
queryTarget,
|
|
1119
|
-
JSON.stringify(args),
|
|
1120
|
-
JSON.stringify(typeArgs)
|
|
1121
|
-
],
|
|
1168
|
+
queryKey: queryKeys.rpc.getInspectTxn(queryTarget, args, typeArgs),
|
|
1122
1169
|
queryFn: async () => {
|
|
1123
1170
|
return await callWithRateLimit(
|
|
1124
1171
|
this.tokenBucket,
|
|
@@ -1135,12 +1182,8 @@ var ScallopCache = class {
|
|
|
1135
1182
|
* @returns Promise<SuiObjectResponse>
|
|
1136
1183
|
*/
|
|
1137
1184
|
async queryGetObject(objectId, options) {
|
|
1138
|
-
const queryKey = ["getObject", objectId, this.walletAddress];
|
|
1139
|
-
if (options) {
|
|
1140
|
-
queryKey.push(JSON.stringify(options));
|
|
1141
|
-
}
|
|
1142
1185
|
return this.queryClient.fetchQuery({
|
|
1143
|
-
queryKey,
|
|
1186
|
+
queryKey: queryKeys.rpc.getObject(objectId, this.walletAddress, options),
|
|
1144
1187
|
queryFn: async () => {
|
|
1145
1188
|
return await callWithRateLimit(
|
|
1146
1189
|
this.tokenBucket,
|
|
@@ -1162,16 +1205,12 @@ var ScallopCache = class {
|
|
|
1162
1205
|
}) {
|
|
1163
1206
|
if (objectIds.length === 0)
|
|
1164
1207
|
return [];
|
|
1165
|
-
const queryKey = [
|
|
1166
|
-
"getObjects",
|
|
1167
|
-
JSON.stringify(objectIds),
|
|
1168
|
-
this.walletAddress
|
|
1169
|
-
];
|
|
1170
|
-
if (options) {
|
|
1171
|
-
queryKey.push(JSON.stringify(options));
|
|
1172
|
-
}
|
|
1173
1208
|
return this.queryClient.fetchQuery({
|
|
1174
|
-
queryKey
|
|
1209
|
+
queryKey: queryKeys.rpc.getObjects(
|
|
1210
|
+
objectIds,
|
|
1211
|
+
this.walletAddress,
|
|
1212
|
+
options
|
|
1213
|
+
),
|
|
1175
1214
|
queryFn: async () => {
|
|
1176
1215
|
return await callWithRateLimit(
|
|
1177
1216
|
this.tokenBucket,
|
|
@@ -1186,21 +1225,8 @@ var ScallopCache = class {
|
|
|
1186
1225
|
* @returns Promise<PaginatedObjectsResponse>
|
|
1187
1226
|
*/
|
|
1188
1227
|
async queryGetOwnedObjects(input) {
|
|
1189
|
-
const queryKey = ["getOwnedObjects", input.owner];
|
|
1190
|
-
if (input.cursor) {
|
|
1191
|
-
queryKey.push(JSON.stringify(input.cursor));
|
|
1192
|
-
}
|
|
1193
|
-
if (input.options) {
|
|
1194
|
-
queryKey.push(JSON.stringify(input.options));
|
|
1195
|
-
}
|
|
1196
|
-
if (input.filter) {
|
|
1197
|
-
queryKey.push(JSON.stringify(input.filter));
|
|
1198
|
-
}
|
|
1199
|
-
if (input.limit) {
|
|
1200
|
-
queryKey.push(JSON.stringify(input.limit));
|
|
1201
|
-
}
|
|
1202
1228
|
return this.queryClient.fetchQuery({
|
|
1203
|
-
queryKey,
|
|
1229
|
+
queryKey: queryKeys.rpc.getOwnedObjects(input),
|
|
1204
1230
|
queryFn: async () => {
|
|
1205
1231
|
return await callWithRateLimit(
|
|
1206
1232
|
this.tokenBucket,
|
|
@@ -1210,15 +1236,8 @@ var ScallopCache = class {
|
|
|
1210
1236
|
});
|
|
1211
1237
|
}
|
|
1212
1238
|
async queryGetDynamicFields(input) {
|
|
1213
|
-
const queryKey = ["getDynamicFields", input.parentId];
|
|
1214
|
-
if (input.cursor) {
|
|
1215
|
-
queryKey.push(JSON.stringify(input.cursor));
|
|
1216
|
-
}
|
|
1217
|
-
if (input.limit) {
|
|
1218
|
-
queryKey.push(JSON.stringify(input.limit));
|
|
1219
|
-
}
|
|
1220
1239
|
return this.queryClient.fetchQuery({
|
|
1221
|
-
queryKey,
|
|
1240
|
+
queryKey: queryKeys.rpc.getDynamicFields(input),
|
|
1222
1241
|
queryFn: async () => {
|
|
1223
1242
|
return await callWithRateLimit(
|
|
1224
1243
|
this.tokenBucket,
|
|
@@ -1228,14 +1247,8 @@ var ScallopCache = class {
|
|
|
1228
1247
|
});
|
|
1229
1248
|
}
|
|
1230
1249
|
async queryGetDynamicFieldObject(input) {
|
|
1231
|
-
const queryKey = [
|
|
1232
|
-
"getDynamicFieldObject",
|
|
1233
|
-
input.parentId,
|
|
1234
|
-
input.name.type,
|
|
1235
|
-
input.name.value
|
|
1236
|
-
];
|
|
1237
1250
|
return this.queryClient.fetchQuery({
|
|
1238
|
-
queryKey,
|
|
1251
|
+
queryKey: queryKeys.rpc.getDynamicFieldObject(input),
|
|
1239
1252
|
queryFn: async () => {
|
|
1240
1253
|
return await callWithRateLimit(
|
|
1241
1254
|
this.tokenBucket,
|
|
@@ -1245,9 +1258,8 @@ var ScallopCache = class {
|
|
|
1245
1258
|
});
|
|
1246
1259
|
}
|
|
1247
1260
|
async queryGetAllCoinBalances(owner) {
|
|
1248
|
-
const queryKey = ["getAllCoinBalances", owner];
|
|
1249
1261
|
return this.queryClient.fetchQuery({
|
|
1250
|
-
queryKey,
|
|
1262
|
+
queryKey: queryKeys.rpc.getAllCoinBalances(owner),
|
|
1251
1263
|
queryFn: async () => {
|
|
1252
1264
|
const allBalances = await callWithRateLimit(
|
|
1253
1265
|
this.tokenBucket,
|
|
@@ -1264,17 +1276,6 @@ var ScallopCache = class {
|
|
|
1264
1276
|
},
|
|
1265
1277
|
{}
|
|
1266
1278
|
);
|
|
1267
|
-
for (const coinType in balances) {
|
|
1268
|
-
const coinBalanceQueryKey = [
|
|
1269
|
-
"getCoinBalance",
|
|
1270
|
-
(0, import_sui_kit.normalizeSuiAddress)(owner),
|
|
1271
|
-
(0, import_sui_kit.normalizeStructTag)(coinType)
|
|
1272
|
-
];
|
|
1273
|
-
this.queryClient.setQueryData(
|
|
1274
|
-
coinBalanceQueryKey,
|
|
1275
|
-
balances[coinType]
|
|
1276
|
-
);
|
|
1277
|
-
}
|
|
1278
1279
|
return balances;
|
|
1279
1280
|
}
|
|
1280
1281
|
});
|
|
@@ -1282,19 +1283,7 @@ var ScallopCache = class {
|
|
|
1282
1283
|
async queryGetCoinBalance(input) {
|
|
1283
1284
|
if (!input.coinType)
|
|
1284
1285
|
return "0";
|
|
1285
|
-
|
|
1286
|
-
"getCoinBalance",
|
|
1287
|
-
(0, import_sui_kit.normalizeSuiAddress)(input.owner),
|
|
1288
|
-
(0, import_sui_kit.normalizeStructTag)(input.coinType)
|
|
1289
|
-
];
|
|
1290
|
-
return this.queryClient.fetchQuery({
|
|
1291
|
-
queryKey,
|
|
1292
|
-
queryFn: async () => {
|
|
1293
|
-
if (!input.coinType)
|
|
1294
|
-
return "0";
|
|
1295
|
-
return (await this.queryGetAllCoinBalances(input.owner))[(0, import_sui_kit.normalizeStructTag)(input.coinType)] ?? "0";
|
|
1296
|
-
}
|
|
1297
|
-
});
|
|
1286
|
+
return (await this.queryGetAllCoinBalances(input.owner) || {})[(0, import_sui_kit.normalizeStructTag)(input.coinType)] ?? "0";
|
|
1298
1287
|
}
|
|
1299
1288
|
};
|
|
1300
1289
|
|
|
@@ -2228,7 +2217,7 @@ var ScallopAddress = class {
|
|
|
2228
2217
|
const addressesId = id || this._id || void 0;
|
|
2229
2218
|
if (addressesId !== void 0) {
|
|
2230
2219
|
const response = await this.cache.queryClient.fetchQuery({
|
|
2231
|
-
queryKey:
|
|
2220
|
+
queryKey: queryKeys.api.getAddresses(addressesId),
|
|
2232
2221
|
queryFn: async () => {
|
|
2233
2222
|
return await this._requestClient.get(`/addresses/${addressesId}`, {
|
|
2234
2223
|
headers: {
|
|
@@ -4329,10 +4318,10 @@ var getTotalVeScaTreasuryAmount = async (utils, veScaTreasury) => {
|
|
|
4329
4318
|
onlyTransactionKind: true
|
|
4330
4319
|
});
|
|
4331
4320
|
const res = await utils.cache.queryClient.fetchQuery({
|
|
4332
|
-
queryKey:
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4321
|
+
queryKey: queryKeys.rpc.getTotalVeScaTreasuryAmount(
|
|
4322
|
+
refreshArgs,
|
|
4323
|
+
veScaAmountArgs
|
|
4324
|
+
),
|
|
4336
4325
|
queryFn: async () => {
|
|
4337
4326
|
return await utils.suiKit.inspectTxn(txBytes);
|
|
4338
4327
|
}
|
|
@@ -4816,7 +4805,7 @@ var ScallopUtils = class {
|
|
|
4816
4805
|
const pythConnection = new import_pyth_sui_js.SuiPriceServiceConnection(endpoint);
|
|
4817
4806
|
try {
|
|
4818
4807
|
const feed = await this.address.cache.queryClient.fetchQuery({
|
|
4819
|
-
queryKey:
|
|
4808
|
+
queryKey: queryKeys.pyth.getPythLatestPriceFeed(priceId),
|
|
4820
4809
|
queryFn: async () => {
|
|
4821
4810
|
return await pythConnection.getLatestPriceFeeds([priceId]);
|
|
4822
4811
|
}
|
|
@@ -6532,7 +6521,7 @@ var ScallopIndexer = class {
|
|
|
6532
6521
|
*/
|
|
6533
6522
|
async getMarket() {
|
|
6534
6523
|
const response = await this.cache.queryClient.fetchQuery({
|
|
6535
|
-
queryKey:
|
|
6524
|
+
queryKey: queryKeys.api.getMarket(),
|
|
6536
6525
|
queryFn: async () => {
|
|
6537
6526
|
return await this._requestClient.get(`/api/market/migrate`);
|
|
6538
6527
|
}
|
|
@@ -6595,7 +6584,7 @@ var ScallopIndexer = class {
|
|
|
6595
6584
|
*/
|
|
6596
6585
|
async getSpools() {
|
|
6597
6586
|
const response = await this.cache.queryClient.fetchQuery({
|
|
6598
|
-
queryKey:
|
|
6587
|
+
queryKey: queryKeys.api.getSpools(),
|
|
6599
6588
|
queryFn: async () => {
|
|
6600
6589
|
return await this._requestClient.get(`/api/spools/migrate`);
|
|
6601
6590
|
}
|
|
@@ -6624,7 +6613,7 @@ var ScallopIndexer = class {
|
|
|
6624
6613
|
*/
|
|
6625
6614
|
async getBorrowIncentivePools() {
|
|
6626
6615
|
const response = await this.cache.queryClient.fetchQuery({
|
|
6627
|
-
queryKey:
|
|
6616
|
+
queryKey: queryKeys.api.getBorrowIncentivePool(),
|
|
6628
6617
|
queryFn: async () => {
|
|
6629
6618
|
return await this._requestClient.get(`/api/borrowIncentivePools/migrate`);
|
|
6630
6619
|
}
|
|
@@ -6665,7 +6654,7 @@ var ScallopIndexer = class {
|
|
|
6665
6654
|
*/
|
|
6666
6655
|
async getTotalValueLocked() {
|
|
6667
6656
|
const response = await this.cache.queryClient.fetchQuery({
|
|
6668
|
-
queryKey:
|
|
6657
|
+
queryKey: queryKeys.api.getTotalValueLocked(),
|
|
6669
6658
|
queryFn: async () => {
|
|
6670
6659
|
return await this._requestClient.get(`/api/market/tvl`);
|
|
6671
6660
|
}
|
|
@@ -8130,14 +8119,15 @@ var ScallopClient = class {
|
|
|
8130
8119
|
|
|
8131
8120
|
// src/models/scallop.ts
|
|
8132
8121
|
var Scallop = class {
|
|
8133
|
-
constructor(params, cacheOptions, tokenBucket) {
|
|
8122
|
+
constructor(params, cacheOptions, tokenBucket, queryClient) {
|
|
8134
8123
|
this.params = params;
|
|
8135
8124
|
this.suiKit = new import_sui_kit16.SuiKit(params);
|
|
8136
8125
|
this.cache = new ScallopCache(
|
|
8137
8126
|
this.suiKit,
|
|
8138
8127
|
params.walletAddress,
|
|
8139
8128
|
cacheOptions ?? DEFAULT_CACHE_OPTIONS,
|
|
8140
|
-
tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS)
|
|
8129
|
+
tokenBucket ?? new TokenBucket(DEFAULT_TOKENS_PER_INTERVAL, DEFAULT_INTERVAL_IN_MS),
|
|
8130
|
+
queryClient
|
|
8141
8131
|
);
|
|
8142
8132
|
this.address = new ScallopAddress(
|
|
8143
8133
|
{
|
|
@@ -8282,6 +8272,7 @@ var Scallop = class {
|
|
|
8282
8272
|
coinDecimals,
|
|
8283
8273
|
coinIds,
|
|
8284
8274
|
marketCoins,
|
|
8275
|
+
queryKeys,
|
|
8285
8276
|
sCoinIds,
|
|
8286
8277
|
sCoins,
|
|
8287
8278
|
spoolRewardCoins,
|