@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.
- package/dist/constants/queryKeys.d.ts +2 -2
- package/dist/index.js +255 -48
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +253 -43
- package/dist/index.mjs.map +1 -1
- package/dist/types/query/portfolio.d.ts +4 -0
- package/package.json +1 -1
- package/src/builders/borrowIncentiveBuilder.ts +29 -7
- package/src/builders/coreBuilder.ts +66 -10
- package/src/builders/oracle.ts +44 -4
- package/src/builders/referralBuilder.ts +20 -4
- package/src/builders/spoolBuilder.ts +38 -4
- package/src/builders/vescaBuilder.ts +25 -5
- package/src/constants/queryKeys.ts +2 -2
- package/src/queries/portfolioQuery.ts +16 -5
- package/src/queries/vescaQuery.ts +18 -4
- package/src/types/query/portfolio.ts +4 -0
- package/dist/test.d.ts +0 -1
- package/src/test.ts +0 -17
|
@@ -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,8 @@
|
|
|
1
1
|
import { Transaction } from '@mysten/sui/transactions';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
508
|
+
return txBlock.borrowWithReferral(
|
|
453
509
|
obligationInfo.obligationId,
|
|
454
510
|
obligationInfo.obligationKey as SuiObjectArg,
|
|
455
511
|
borrowReferral,
|
package/src/builders/oracle.ts
CHANGED
|
@@ -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(
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
[
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
856
|
+
supplyValue: supplyLendingValue.plus(supplyCollateralValue).toNumber(),
|
|
857
|
+
supplyLendingValue: supplyLendingValue.toNumber(),
|
|
858
|
+
supplyCollateralValue: supplyCollateralValue.toNumber(),
|
|
851
859
|
borrowValue: borrowValue.toNumber(),
|
|
852
|
-
totalValue:
|
|
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 = [
|
|
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 = [
|
|
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();
|