@scallop-io/sui-scallop-sdk 1.4.19 → 1.4.20

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.
@@ -105,10 +105,14 @@ export type ObligationBorrowIncentive = {
105
105
  rewards: ObligationBorrowIcentiveReward[];
106
106
  };
107
107
  export type TotalValueLocked = {
108
+ supplyLendingValue: number;
109
+ supplyCollateralValue: number;
108
110
  supplyValue: number;
109
111
  borrowValue: number;
110
112
  totalValue: number;
111
113
  supplyValueChangeRatio?: number;
114
+ supplyLendingValueChangeRatio?: number;
115
+ supplyCollateralValueChangeRatio?: number;
112
116
  borrowValueChangeRatio?: number;
113
117
  totalValueChangeRatio?: number;
114
118
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "1.4.19",
3
+ "version": "1.4.20",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -1,6 +1,8 @@
1
1
  import { Transaction } from '@mysten/sui/transactions';
2
- import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
3
- import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
2
+ import {
3
+ SuiTxBlock as SuiKitTxBlock,
4
+ SUI_CLOCK_OBJECT_ID,
5
+ } from '@scallop-io/sui-kit';
4
6
  import { getObligations, getObligationLocked } from '../queries';
5
7
  import { requireSender } from '../utils';
6
8
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
@@ -108,7 +110,11 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
108
110
  obligationKey,
109
111
  obligationId,
110
112
  borrowIncentiveIds.obligationAccessStore,
111
- SUI_CLOCK_OBJECT_ID,
113
+ txBlock.sharedObjectRef({
114
+ objectId: SUI_CLOCK_OBJECT_ID,
115
+ mutable: false,
116
+ initialSharedVersion: '1',
117
+ }),
112
118
  ]
113
119
  );
114
120
  },
@@ -127,7 +133,11 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
127
133
  veScaIds.treasury,
128
134
  veScaIds.table,
129
135
  veScaKey,
130
- SUI_CLOCK_OBJECT_ID,
136
+ txBlock.sharedObjectRef({
137
+ objectId: SUI_CLOCK_OBJECT_ID,
138
+ mutable: false,
139
+ initialSharedVersion: '1',
140
+ }),
131
141
  ],
132
142
  []
133
143
  );
@@ -142,7 +152,11 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
142
152
  borrowIncentiveIds.incentiveAccounts,
143
153
  obligationKey,
144
154
  obligationId,
145
- SUI_CLOCK_OBJECT_ID,
155
+ txBlock.sharedObjectRef({
156
+ objectId: SUI_CLOCK_OBJECT_ID,
157
+ mutable: false,
158
+ initialSharedVersion: '1',
159
+ }),
146
160
  ]
147
161
  );
148
162
  },
@@ -157,7 +171,11 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
157
171
  borrowIncentiveIds.incentiveAccounts,
158
172
  obligationKey,
159
173
  obligationId,
160
- SUI_CLOCK_OBJECT_ID,
174
+ txBlock.sharedObjectRef({
175
+ objectId: SUI_CLOCK_OBJECT_ID,
176
+ mutable: false,
177
+ initialSharedVersion: '1',
178
+ }),
161
179
  ],
162
180
  [rewardType]
163
181
  );
@@ -172,7 +190,11 @@ const generateBorrowIncentiveNormalMethod: GenerateBorrowIncentiveNormalMethod =
172
190
  borrowIncentiveIds.incentiveAccounts,
173
191
  obligation,
174
192
  veScaKey,
175
- SUI_CLOCK_OBJECT_ID,
193
+ txBlock.sharedObjectRef({
194
+ objectId: SUI_CLOCK_OBJECT_ID,
195
+ mutable: false,
196
+ initialSharedVersion: '1',
197
+ }),
176
198
  ]
177
199
  );
178
200
  },
@@ -126,7 +126,11 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
126
126
  coreIds.coinDecimalsRegistry,
127
127
  txBlock.pure.u64(amount),
128
128
  coreIds.xOracle,
129
- SUI_CLOCK_OBJECT_ID,
129
+ txBlock.sharedObjectRef({
130
+ objectId: SUI_CLOCK_OBJECT_ID,
131
+ mutable: false,
132
+ initialSharedVersion: '1',
133
+ }),
130
134
  ],
131
135
  [coinType]
132
136
  );
@@ -137,7 +141,16 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
137
141
  return builder.moveCall(
138
142
  txBlock,
139
143
  `${coreIds.protocolPkg}::mint::mint`,
140
- [coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID],
144
+ [
145
+ coreIds.version,
146
+ coreIds.market,
147
+ coin,
148
+ txBlock.sharedObjectRef({
149
+ objectId: SUI_CLOCK_OBJECT_ID,
150
+ mutable: false,
151
+ initialSharedVersion: '1',
152
+ }),
153
+ ],
141
154
  [coinType]
142
155
  );
143
156
  },
@@ -147,7 +160,16 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
147
160
  return builder.moveCall(
148
161
  txBlock,
149
162
  `${coreIds.protocolPkg}::mint::mint_entry`,
150
- [coreIds.version, coreIds.market, coin, SUI_CLOCK_OBJECT_ID],
163
+ [
164
+ coreIds.version,
165
+ coreIds.market,
166
+ coin,
167
+ txBlock.sharedObjectRef({
168
+ objectId: SUI_CLOCK_OBJECT_ID,
169
+ mutable: false,
170
+ initialSharedVersion: '1',
171
+ }),
172
+ ],
151
173
  [coinType]
152
174
  );
153
175
  },
@@ -157,7 +179,16 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
157
179
  return builder.moveCall(
158
180
  txBlock,
159
181
  `${coreIds.protocolPkg}::redeem::redeem`,
160
- [coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID],
182
+ [
183
+ coreIds.version,
184
+ coreIds.market,
185
+ marketCoin,
186
+ txBlock.sharedObjectRef({
187
+ objectId: SUI_CLOCK_OBJECT_ID,
188
+ mutable: false,
189
+ initialSharedVersion: '1',
190
+ }),
191
+ ],
161
192
  [coinType]
162
193
  );
163
194
  },
@@ -167,7 +198,16 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
167
198
  return builder.moveCall(
168
199
  txBlock,
169
200
  `${coreIds.protocolPkg}::redeem::redeem_entry`,
170
- [coreIds.version, coreIds.market, marketCoin, SUI_CLOCK_OBJECT_ID],
201
+ [
202
+ coreIds.version,
203
+ coreIds.market,
204
+ marketCoin,
205
+ txBlock.sharedObjectRef({
206
+ objectId: SUI_CLOCK_OBJECT_ID,
207
+ mutable: false,
208
+ initialSharedVersion: '1',
209
+ }),
210
+ ],
171
211
  [coinType]
172
212
  );
173
213
  },
@@ -185,7 +225,11 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
185
225
  coreIds.coinDecimalsRegistry,
186
226
  amount,
187
227
  coreIds.xOracle,
188
- SUI_CLOCK_OBJECT_ID,
228
+ txBlock.sharedObjectRef({
229
+ objectId: SUI_CLOCK_OBJECT_ID,
230
+ mutable: false,
231
+ initialSharedVersion: '1',
232
+ }),
189
233
  ],
190
234
  [coinType]
191
235
  );
@@ -211,7 +255,11 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
211
255
  borrowReferral,
212
256
  typeof amount === 'number' ? txBlock.pure.u64(amount) : amount,
213
257
  coreIds.xOracle,
214
- SUI_CLOCK_OBJECT_ID,
258
+ txBlock.sharedObjectRef({
259
+ objectId: SUI_CLOCK_OBJECT_ID,
260
+ mutable: false,
261
+ initialSharedVersion: '1',
262
+ }),
215
263
  ],
216
264
  [coinType, referralWitnessType]
217
265
  );
@@ -230,7 +278,11 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
230
278
  coreIds.coinDecimalsRegistry,
231
279
  txBlock.pure.u64(amount),
232
280
  coreIds.xOracle,
233
- SUI_CLOCK_OBJECT_ID,
281
+ txBlock.sharedObjectRef({
282
+ objectId: SUI_CLOCK_OBJECT_ID,
283
+ mutable: false,
284
+ initialSharedVersion: '1',
285
+ }),
234
286
  ],
235
287
  [coinType]
236
288
  );
@@ -245,7 +297,11 @@ const generateCoreNormalMethod: GenerateCoreNormalMethod = ({
245
297
  obligation,
246
298
  coreIds.market,
247
299
  coin,
248
- SUI_CLOCK_OBJECT_ID,
300
+ txBlock.sharedObjectRef({
301
+ objectId: SUI_CLOCK_OBJECT_ID,
302
+ mutable: false,
303
+ initialSharedVersion: '1',
304
+ }),
249
305
  ],
250
306
  [coinType]
251
307
  );
@@ -449,7 +505,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
449
505
  )) ?? [];
450
506
  const updateCoinNames = [...obligationCoinNames, poolCoinName];
451
507
  await updateOracles(builder, txBlock, updateCoinNames);
452
- return await txBlock.borrowWithReferral(
508
+ return txBlock.borrowWithReferral(
453
509
  obligationInfo.obligationId,
454
510
  obligationInfo.obligationKey as SuiObjectArg,
455
511
  borrowReferral,
@@ -231,7 +231,19 @@ const confirmPriceUpdateRequest = (
231
231
  ) => {
232
232
  const target = `${packageId}::x_oracle::confirm_price_update_request`;
233
233
  const typeArgs = [coinType];
234
- txBlock.moveCall(target, [xOracleId, request, SUI_CLOCK_OBJECT_ID], typeArgs);
234
+ txBlock.moveCall(
235
+ target,
236
+ [
237
+ xOracleId,
238
+ request,
239
+ txBlock.sharedObjectRef({
240
+ objectId: SUI_CLOCK_OBJECT_ID,
241
+ mutable: false,
242
+ initialSharedVersion: '1',
243
+ }),
244
+ ],
245
+ typeArgs
246
+ );
235
247
  return txBlock;
236
248
  };
237
249
 
@@ -257,7 +269,16 @@ const updateSupraPrice = (
257
269
  ) => {
258
270
  txBlock.moveCall(
259
271
  `${packageId}::rule::set_price`,
260
- [request, holderId, registryId, SUI_CLOCK_OBJECT_ID],
272
+ [
273
+ request,
274
+ holderId,
275
+ registryId,
276
+ txBlock.sharedObjectRef({
277
+ objectId: SUI_CLOCK_OBJECT_ID,
278
+ mutable: false,
279
+ initialSharedVersion: '1',
280
+ }),
281
+ ],
261
282
  [coinType]
262
283
  );
263
284
  };
@@ -284,7 +305,16 @@ const updateSwitchboardPrice = (
284
305
  ) => {
285
306
  txBlock.moveCall(
286
307
  `${packageId}::rule::set_price`,
287
- [request, aggregatorId, registryId, SUI_CLOCK_OBJECT_ID],
308
+ [
309
+ request,
310
+ aggregatorId,
311
+ registryId,
312
+ txBlock.sharedObjectRef({
313
+ objectId: SUI_CLOCK_OBJECT_ID,
314
+ mutable: false,
315
+ initialSharedVersion: '1',
316
+ }),
317
+ ],
288
318
  [coinType]
289
319
  );
290
320
  };
@@ -315,7 +345,17 @@ const updatePythPrice = (
315
345
  ) => {
316
346
  txBlock.moveCall(
317
347
  `${packageId}::rule::set_price`,
318
- [request, stateId, feedObjectId, registryId, SUI_CLOCK_OBJECT_ID],
348
+ [
349
+ request,
350
+ stateId,
351
+ feedObjectId,
352
+ registryId,
353
+ txBlock.sharedObjectRef({
354
+ objectId: SUI_CLOCK_OBJECT_ID,
355
+ mutable: false,
356
+ initialSharedVersion: '1',
357
+ }),
358
+ ],
319
359
  [coinType]
320
360
  );
321
361
  };
@@ -42,7 +42,11 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
42
42
  referralIds.referralBindings,
43
43
  txBlock.pure.id(veScaKeyId),
44
44
  veScaTable,
45
- SUI_CLOCK_OBJECT_ID,
45
+ txBlock.sharedObjectRef({
46
+ objectId: SUI_CLOCK_OBJECT_ID,
47
+ mutable: false,
48
+ initialSharedVersion: '1',
49
+ }),
46
50
  ],
47
51
  []
48
52
  );
@@ -58,7 +62,11 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
58
62
  referralIds.referralBindings,
59
63
  referralIds.authorizedWitnessList,
60
64
  referralIds.referralTiers,
61
- SUI_CLOCK_OBJECT_ID,
65
+ txBlock.sharedObjectRef({
66
+ objectId: SUI_CLOCK_OBJECT_ID,
67
+ mutable: false,
68
+ initialSharedVersion: '1',
69
+ }),
62
70
  ],
63
71
  [coinType]
64
72
  );
@@ -72,7 +80,11 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
72
80
  referralIds.version,
73
81
  ticket,
74
82
  referralIds.referralRevenuePool,
75
- SUI_CLOCK_OBJECT_ID,
83
+ txBlock.sharedObjectRef({
84
+ objectId: SUI_CLOCK_OBJECT_ID,
85
+ mutable: false,
86
+ initialSharedVersion: '1',
87
+ }),
76
88
  ],
77
89
  [coinType]
78
90
  );
@@ -89,7 +101,11 @@ const generateReferralNormalMethod: GenerateReferralNormalMethod = ({
89
101
  referralIds.version,
90
102
  referralIds.referralRevenuePool,
91
103
  veScaKey,
92
- SUI_CLOCK_OBJECT_ID,
104
+ txBlock.sharedObjectRef({
105
+ objectId: SUI_CLOCK_OBJECT_ID,
106
+ mutable: false,
107
+ initialSharedVersion: '1',
108
+ }),
93
109
  ],
94
110
  [coinType]
95
111
  );
@@ -136,7 +136,14 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
136
136
  return builder.moveCall(
137
137
  txBlock,
138
138
  `${spoolIds.spoolPkg}::user::new_spool_account`,
139
- [stakePoolId, SUI_CLOCK_OBJECT_ID],
139
+ [
140
+ stakePoolId,
141
+ txBlock.sharedObjectRef({
142
+ objectId: SUI_CLOCK_OBJECT_ID,
143
+ mutable: false,
144
+ initialSharedVersion: '1',
145
+ }),
146
+ ],
140
147
  [marketCoinType]
141
148
  );
142
149
  },
@@ -149,7 +156,16 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
149
156
  builder.moveCall(
150
157
  txBlock,
151
158
  `${spoolIds.spoolPkg}::user::stake`,
152
- [stakePoolId, stakeAccount, coin, SUI_CLOCK_OBJECT_ID],
159
+ [
160
+ stakePoolId,
161
+ stakeAccount,
162
+ coin,
163
+ txBlock.sharedObjectRef({
164
+ objectId: SUI_CLOCK_OBJECT_ID,
165
+ mutable: false,
166
+ initialSharedVersion: '1',
167
+ }),
168
+ ],
153
169
  [marketCoinType]
154
170
  );
155
171
  },
@@ -162,7 +178,16 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
162
178
  return builder.moveCall(
163
179
  txBlock,
164
180
  `${spoolIds.spoolPkg}::user::unstake`,
165
- [stakePoolId, stakeAccount, amount, SUI_CLOCK_OBJECT_ID],
181
+ [
182
+ stakePoolId,
183
+ stakeAccount,
184
+ amount,
185
+ txBlock.sharedObjectRef({
186
+ objectId: SUI_CLOCK_OBJECT_ID,
187
+ mutable: false,
188
+ initialSharedVersion: '1',
189
+ }),
190
+ ],
166
191
  [marketCoinType]
167
192
  );
168
193
  },
@@ -180,7 +205,16 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
180
205
  return builder.moveCall(
181
206
  txBlock,
182
207
  `${spoolIds.spoolPkg}::user::redeem_rewards`,
183
- [stakePoolId, rewardPoolId, stakeAccount, SUI_CLOCK_OBJECT_ID],
208
+ [
209
+ stakePoolId,
210
+ rewardPoolId,
211
+ stakeAccount,
212
+ txBlock.sharedObjectRef({
213
+ objectId: SUI_CLOCK_OBJECT_ID,
214
+ mutable: false,
215
+ initialSharedVersion: '1',
216
+ }),
217
+ ],
184
218
  [marketCoinType, rewardCoinType]
185
219
  );
186
220
  },
@@ -99,7 +99,11 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
99
99
  veScaIds.treasury,
100
100
  scaCoin,
101
101
  unlockAtInSecondTimestamp,
102
- SUI_CLOCK_OBJECT_ID,
102
+ txBlock.sharedObjectRef({
103
+ objectId: SUI_CLOCK_OBJECT_ID,
104
+ mutable: false,
105
+ initialSharedVersion: '1',
106
+ }),
103
107
  ],
104
108
  []
105
109
  );
@@ -114,7 +118,11 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
114
118
  veScaIds.table,
115
119
  veScaIds.treasury,
116
120
  newUnlockAtInSecondTimestamp,
117
- SUI_CLOCK_OBJECT_ID,
121
+ txBlock.sharedObjectRef({
122
+ objectId: SUI_CLOCK_OBJECT_ID,
123
+ mutable: false,
124
+ initialSharedVersion: '1',
125
+ }),
118
126
  ],
119
127
  []
120
128
  );
@@ -129,7 +137,11 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
129
137
  veScaIds.table,
130
138
  veScaIds.treasury,
131
139
  scaCoin,
132
- SUI_CLOCK_OBJECT_ID,
140
+ txBlock.sharedObjectRef({
141
+ objectId: SUI_CLOCK_OBJECT_ID,
142
+ mutable: false,
143
+ initialSharedVersion: '1',
144
+ }),
133
145
  ],
134
146
  []
135
147
  );
@@ -145,7 +157,11 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
145
157
  veScaIds.treasury,
146
158
  scaCoin,
147
159
  newUnlockAtInSecondTimestamp,
148
- SUI_CLOCK_OBJECT_ID,
160
+ txBlock.sharedObjectRef({
161
+ objectId: SUI_CLOCK_OBJECT_ID,
162
+ mutable: false,
163
+ initialSharedVersion: '1',
164
+ }),
149
165
  ],
150
166
  []
151
167
  );
@@ -159,7 +175,11 @@ const generateNormalVeScaMethod: GenerateVeScaNormalMethod = ({
159
175
  veScaKey,
160
176
  veScaIds.table,
161
177
  veScaIds.treasury,
162
- SUI_CLOCK_OBJECT_ID,
178
+ txBlock.sharedObjectRef({
179
+ objectId: SUI_CLOCK_OBJECT_ID,
180
+ mutable: false,
181
+ initialSharedVersion: '1',
182
+ }),
163
183
  ],
164
184
  []
165
185
  );
@@ -5,7 +5,7 @@ import type {
5
5
  SuiObjectData,
6
6
  SuiObjectDataOptions,
7
7
  } from '@mysten/sui/client';
8
- import type { SuiObjectArg } from '@scallop-io/sui-kit';
8
+ import type { SuiObjectArg, SuiTxArg } from '@scallop-io/sui-kit';
9
9
 
10
10
  export const queryKeys = {
11
11
  api: {
@@ -76,7 +76,7 @@ export const queryKeys = {
76
76
  ],
77
77
  getTotalVeScaTreasuryAmount: (
78
78
  refreshArgs?: any[],
79
- vescaAmountArgs?: (string | SuiObjectData)[]
79
+ vescaAmountArgs?: (string | SuiObjectData | SuiTxArg)[]
80
80
  ) => [
81
81
  'rpc',
82
82
  'getTotalVeScaTreasuryAmount',
@@ -814,7 +814,8 @@ export const getTotalValueLocked = async (
814
814
  ) => {
815
815
  const market = await query.getMarketPools(undefined, { indexer });
816
816
 
817
- let supplyValue = BigNumber(0);
817
+ let supplyLendingValue = BigNumber(0);
818
+ let supplyCollateralValue = BigNumber(0);
818
819
  let borrowValue = BigNumber(0);
819
820
 
820
821
  if (indexer) {
@@ -826,12 +827,17 @@ export const getTotalValueLocked = async (
826
827
  borrowValueChangeRatio: tvlIndexer.borrowValueChangeRatio,
827
828
  totalValue: tvlIndexer.totalValue,
828
829
  totalValueChangeRatio: tvlIndexer.totalValueChangeRatio,
830
+ supplyLendingValue: tvlIndexer.supplyLendingValue,
831
+ supplyLendingValueChangeRatio: tvlIndexer.supplyLendingValueChangeRatio,
832
+ supplyCollateralValue: tvlIndexer.supplyCollateralValue,
833
+ supplyCollateralValueChangeRatio:
834
+ tvlIndexer.supplyCollateralValueChangeRatio,
829
835
  };
830
836
  return tvl;
831
837
  }
832
838
 
833
839
  for (const pool of Object.values(market.pools)) {
834
- supplyValue = supplyValue.plus(
840
+ supplyLendingValue = supplyLendingValue.plus(
835
841
  BigNumber(pool.supplyCoin).multipliedBy(pool.coinPrice)
836
842
  );
837
843
  borrowValue = borrowValue.plus(
@@ -841,15 +847,20 @@ export const getTotalValueLocked = async (
841
847
 
842
848
  // console.dir(market.collaterals, { depth: null });
843
849
  for (const collateral of Object.values(market.collaterals)) {
844
- supplyValue = supplyValue.plus(
850
+ supplyCollateralValue = supplyCollateralValue.plus(
845
851
  BigNumber(collateral.depositCoin).multipliedBy(collateral.coinPrice)
846
852
  );
847
853
  }
848
854
 
849
855
  const tvl: TotalValueLocked = {
850
- supplyValue: supplyValue.toNumber(),
856
+ supplyValue: supplyLendingValue.plus(supplyCollateralValue).toNumber(),
857
+ supplyLendingValue: supplyLendingValue.toNumber(),
858
+ supplyCollateralValue: supplyCollateralValue.toNumber(),
851
859
  borrowValue: borrowValue.toNumber(),
852
- totalValue: supplyValue.minus(borrowValue).toNumber(),
860
+ totalValue: supplyLendingValue
861
+ .plus(supplyCollateralValue)
862
+ .minus(borrowValue)
863
+ .toNumber(),
853
864
  };
854
865
 
855
866
  return tvl;
@@ -183,13 +183,29 @@ const getTotalVeScaTreasuryAmount = async (
183
183
  const veScaConfig = utils.address.get('vesca.config');
184
184
  veScaTreasury = veScaTreasury ?? utils.address.get('vesca.treasury');
185
185
 
186
+ const txb = new SuiTxBlock();
186
187
  // refresh query
187
188
  const refreshQueryTarget = `${veScaPkgId}::treasury::refresh`;
188
- const refreshArgs = [veScaConfig, veScaTreasury, SUI_CLOCK_OBJECT_ID];
189
+ const refreshArgs = [
190
+ veScaConfig,
191
+ veScaTreasury,
192
+ txb.sharedObjectRef({
193
+ objectId: SUI_CLOCK_OBJECT_ID,
194
+ mutable: false,
195
+ initialSharedVersion: '1',
196
+ }),
197
+ ];
189
198
 
190
199
  // query total veSca amount
191
200
  const veScaAmountQueryTarget = `${veScaPkgId}::treasury::total_ve_sca_amount`;
192
- const veScaAmountArgs = [veScaTreasury, SUI_CLOCK_OBJECT_ID];
201
+ const veScaAmountArgs = [
202
+ veScaTreasury,
203
+ txb.sharedObjectRef({
204
+ objectId: SUI_CLOCK_OBJECT_ID,
205
+ mutable: false,
206
+ initialSharedVersion: '1',
207
+ }),
208
+ ];
193
209
 
194
210
  // resolve each args
195
211
  const resolvedRefreshArgs = await Promise.all(
@@ -210,8 +226,6 @@ const getTotalVeScaTreasuryAmount = async (
210
226
  })
211
227
  );
212
228
 
213
- const txb = new SuiTxBlock();
214
-
215
229
  // refresh first
216
230
  txb.moveCall(refreshQueryTarget, resolvedRefreshArgs);
217
231
  txb.moveCall(veScaAmountQueryTarget, resolvedVeScaAmountArgs);
@@ -138,10 +138,14 @@ export type ObligationBorrowIncentive = {
138
138
  };
139
139
 
140
140
  export type TotalValueLocked = {
141
+ supplyLendingValue: number;
142
+ supplyCollateralValue: number;
141
143
  supplyValue: number;
142
144
  borrowValue: number;
143
145
  totalValue: number;
144
146
  supplyValueChangeRatio?: number;
147
+ supplyLendingValueChangeRatio?: number;
148
+ supplyCollateralValueChangeRatio?: number;
145
149
  borrowValueChangeRatio?: number;
146
150
  totalValueChangeRatio?: number;
147
151
  };
package/dist/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/src/test.ts DELETED
@@ -1,17 +0,0 @@
1
- import { ScallopQuery } from './models';
2
-
3
- const main = async () => {
4
- try {
5
- const query = new ScallopQuery({});
6
- await query.init();
7
-
8
- const res = await query.getSpool('ssui');
9
- console.dir(res, { depth: null });
10
- } catch (e) {
11
- console.error(e);
12
- } finally {
13
- process.exit(0);
14
- }
15
- };
16
-
17
- main();