@scallop-io/sui-scallop-sdk 0.46.33 → 0.46.34
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 +1 -1
- package/dist/index.js +17 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +17 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/models/scallopCache.ts +4 -3
- package/src/queries/borrowIncentiveQuery.ts +12 -15
- package/src/queries/portfolioQuery.ts +4 -4
package/package.json
CHANGED
|
@@ -168,6 +168,9 @@ export class ScallopCache {
|
|
|
168
168
|
JSON.stringify(objectIds),
|
|
169
169
|
this.suiKit.currentAddress(),
|
|
170
170
|
];
|
|
171
|
+
if (options) {
|
|
172
|
+
queryKey.push(JSON.stringify(options));
|
|
173
|
+
}
|
|
171
174
|
return this.queryClient.fetchQuery({
|
|
172
175
|
queryKey,
|
|
173
176
|
queryFn: async () => {
|
|
@@ -213,9 +216,6 @@ export class ScallopCache {
|
|
|
213
216
|
if (input.cursor) {
|
|
214
217
|
queryKey.push(JSON.stringify(input.cursor));
|
|
215
218
|
}
|
|
216
|
-
if (input.cursor) {
|
|
217
|
-
queryKey.push(JSON.stringify(input.cursor));
|
|
218
|
-
}
|
|
219
219
|
if (input.limit) {
|
|
220
220
|
queryKey.push(JSON.stringify(input.limit));
|
|
221
221
|
}
|
|
@@ -234,6 +234,7 @@ export class ScallopCache {
|
|
|
234
234
|
const queryKey = [
|
|
235
235
|
'getDynamicFieldObject',
|
|
236
236
|
input.parentId,
|
|
237
|
+
input.name.type,
|
|
237
238
|
input.name.value,
|
|
238
239
|
];
|
|
239
240
|
return this.queryClient.fetchQuery({
|
|
@@ -215,15 +215,13 @@ export const getBindedObligationId = async (
|
|
|
215
215
|
const incentivePoolsId = query.address.get('borrowIncentive.incentivePools');
|
|
216
216
|
const veScaObjId = query.address.get('vesca.object');
|
|
217
217
|
|
|
218
|
-
const client = query.suiKit.client();
|
|
219
|
-
|
|
220
218
|
// get incentive pools
|
|
221
|
-
const incentivePoolsResponse = await
|
|
222
|
-
|
|
223
|
-
|
|
219
|
+
const incentivePoolsResponse = await query.cache.queryGetObject(
|
|
220
|
+
incentivePoolsId,
|
|
221
|
+
{
|
|
224
222
|
showContent: true,
|
|
225
|
-
}
|
|
226
|
-
|
|
223
|
+
}
|
|
224
|
+
);
|
|
227
225
|
|
|
228
226
|
if (incentivePoolsResponse.data?.content?.dataType !== 'moveObject')
|
|
229
227
|
return null;
|
|
@@ -233,7 +231,7 @@ export const getBindedObligationId = async (
|
|
|
233
231
|
|
|
234
232
|
// check if veSca is inside the bind table
|
|
235
233
|
const keyType = `${borrowIncentiveObjectId}::typed_id::TypedID<${veScaObjId}::ve_sca::VeScaKey>`;
|
|
236
|
-
const veScaBindTableResponse = await
|
|
234
|
+
const veScaBindTableResponse = await query.cache.queryGetDynamicFieldObject({
|
|
237
235
|
parentId: veScaBindTableId,
|
|
238
236
|
name: {
|
|
239
237
|
type: keyType,
|
|
@@ -260,15 +258,14 @@ export const getBindedVeScaKey = async (
|
|
|
260
258
|
'borrowIncentive.incentiveAccounts'
|
|
261
259
|
);
|
|
262
260
|
const corePkg = query.address.get('core.object');
|
|
263
|
-
const client = query.suiKit.client();
|
|
264
261
|
|
|
265
262
|
// get IncentiveAccounts object
|
|
266
|
-
const incentiveAccountsObject = await
|
|
267
|
-
|
|
268
|
-
|
|
263
|
+
const incentiveAccountsObject = await query.cache.queryGetObject(
|
|
264
|
+
incentiveAccountsId,
|
|
265
|
+
{
|
|
269
266
|
showContent: true,
|
|
270
|
-
}
|
|
271
|
-
|
|
267
|
+
}
|
|
268
|
+
);
|
|
272
269
|
if (incentiveAccountsObject.data?.content?.dataType !== 'moveObject')
|
|
273
270
|
return null;
|
|
274
271
|
const incentiveAccountsTableId = (
|
|
@@ -276,7 +273,7 @@ export const getBindedVeScaKey = async (
|
|
|
276
273
|
).accounts.fields.id.id;
|
|
277
274
|
|
|
278
275
|
// Search in the table
|
|
279
|
-
const bindedIncentiveAcc = await
|
|
276
|
+
const bindedIncentiveAcc = await query.cache.queryGetDynamicFieldObject({
|
|
280
277
|
parentId: incentiveAccountsTableId,
|
|
281
278
|
name: {
|
|
282
279
|
type: `${borrowIncentiveObjectId}::typed_id::TypedID<${corePkg}::obligation::Obligation>`,
|
|
@@ -433,12 +433,12 @@ export const getObligationAccount = async (
|
|
|
433
433
|
const increasedRate = debt?.borrowIndex
|
|
434
434
|
? marketPool.borrowIndex / Number(debt.borrowIndex) - 1
|
|
435
435
|
: 0;
|
|
436
|
-
const borrowedAmount = BigNumber(debt?.amount ?? 0)
|
|
437
|
-
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
438
|
-
|
|
439
|
-
const requiredRepayAmount = borrowedAmount.multipliedBy(
|
|
436
|
+
const borrowedAmount = BigNumber(debt?.amount ?? 0).multipliedBy(
|
|
440
437
|
increasedRate + 1
|
|
441
438
|
);
|
|
439
|
+
const borrowedCoin = borrowedAmount.shiftedBy(-1 * coinDecimal);
|
|
440
|
+
|
|
441
|
+
const requiredRepayAmount = borrowedAmount;
|
|
442
442
|
const requiredRepayCoin = requiredRepayAmount.shiftedBy(-1 * coinDecimal);
|
|
443
443
|
|
|
444
444
|
const availableRepayAmount = BigNumber(coinAmount);
|