@scallop-io/sui-scallop-sdk 1.4.18 → 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.
@@ -26,6 +26,7 @@ export const POOL_ADDRESSES: OptionalKeys<
26
26
  spool?: string;
27
27
  spoolReward?: string;
28
28
  spoolName?: string;
29
+ decimals: number;
29
30
  }
30
31
  >
31
32
  > = {
@@ -64,6 +65,7 @@ export const POOL_ADDRESSES: OptionalKeys<
64
65
  sCoinMetadataId:
65
66
  '0x763a21eba338e00bc684aaad80491c89eea5f247b59c47df45b17610c9ad58f2',
66
67
  spoolName: 'susdc',
68
+ decimals: 6,
67
69
  },
68
70
  sbeth: {
69
71
  coinName: 'sbeth',
@@ -96,6 +98,7 @@ export const POOL_ADDRESSES: OptionalKeys<
96
98
  '0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29::eth::ETH',
97
99
  sCoinMetadataId:
98
100
  '0xdfdd14d53ed8c7ace7cac8a0eecdfa4c2345e15d9efcbd4e1828f81a107cbe2d',
101
+ decimals: 8,
99
102
  },
100
103
  sbusdt: {
101
104
  coinName: 'sbusdt',
@@ -128,6 +131,7 @@ export const POOL_ADDRESSES: OptionalKeys<
128
131
  '0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT',
129
132
  sCoinMetadataId:
130
133
  '0x1ce77b036043c8fdcc5cd050ed06433ae60296b194c2abf7ade8b7b7c8386d36',
134
+ decimals: 6,
131
135
  },
132
136
  weth: {
133
137
  coinName: 'weth',
@@ -164,6 +168,7 @@ export const POOL_ADDRESSES: OptionalKeys<
164
168
  sCoinMetadataId:
165
169
  '0x077d0fd835b559e5b4bb52641f7627ddbf8b200f9b2cf4e28b3514da2a32a4dd',
166
170
  spoolName: 'sweth',
171
+ decimals: 8,
167
172
  },
168
173
  wbtc: {
169
174
  coinName: 'wbtc',
@@ -196,6 +201,7 @@ export const POOL_ADDRESSES: OptionalKeys<
196
201
  '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881::coin::COIN',
197
202
  sCoinMetadataId:
198
203
  '0x1ba5904dae41699683da767c7a97785a55c51ec1253498c8fe1980169a96523d',
204
+ decimals: 8,
199
205
  },
200
206
  wusdc: {
201
207
  coinName: 'wusdc',
@@ -232,6 +238,7 @@ export const POOL_ADDRESSES: OptionalKeys<
232
238
  sCoinMetadataId:
233
239
  '0xdc0595d068621d630f3c7c364dd257f7e3f8079e00c31c8d18755a033c15ae93',
234
240
  spoolName: 'swusdc',
241
+ decimals: 6,
235
242
  },
236
243
  wusdt: {
237
244
  coinName: 'wusdt',
@@ -268,6 +275,7 @@ export const POOL_ADDRESSES: OptionalKeys<
268
275
  sCoinMetadataId:
269
276
  '0x171d0f1ca99d5fefb8b2e40b89899bacdc5417a783906ae119b9cb1c113d59ae',
270
277
  spoolName: 'swusdt',
278
+ decimals: 6,
271
279
  },
272
280
  sui: {
273
281
  coinName: 'sui',
@@ -304,6 +312,7 @@ export const POOL_ADDRESSES: OptionalKeys<
304
312
  sCoinMetadataId:
305
313
  '0xac724644f481f4870ecdc29b9549aa8ea5180f10827c0d97b493f9f65a91455d',
306
314
  spoolName: 'ssui',
315
+ decimals: 9,
307
316
  },
308
317
  wapt: {
309
318
  coinName: 'wapt',
@@ -324,6 +333,7 @@ export const POOL_ADDRESSES: OptionalKeys<
324
333
  '0xc969c5251f372c0f34c32759f1d315cf1ea0ee5e4454b52aea08778eacfdd0a8',
325
334
  coinType:
326
335
  '0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37::coin::COIN',
336
+ decimals: 8,
327
337
  },
328
338
  wsol: {
329
339
  coinName: 'wsol',
@@ -356,6 +366,7 @@ export const POOL_ADDRESSES: OptionalKeys<
356
366
  '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8::coin::COIN',
357
367
  sCoinMetadataId:
358
368
  '0xee202d2013fc09453d695c640088ee08f14afc8f1ae26284b4ebbc4712ff1ba5',
369
+ decimals: 8,
359
370
  },
360
371
  cetus: {
361
372
  coinName: 'cetus',
@@ -392,6 +403,7 @@ export const POOL_ADDRESSES: OptionalKeys<
392
403
  sCoinMetadataId:
393
404
  '0xf022d041455a038d762a091f7a9e9521211f20501bcf8b6913ef5493a023218f',
394
405
  spoolName: 'scetus',
406
+ decimals: 9,
395
407
  },
396
408
  afsui: {
397
409
  coinName: 'afsui',
@@ -428,6 +440,7 @@ export const POOL_ADDRESSES: OptionalKeys<
428
440
  sCoinMetadataId:
429
441
  '0xfd81c4d1b4d9d1b8c522e91121d22e94759386b29eafe1cc3888ca0ebe369b9e',
430
442
  spoolName: 'safsui',
443
+ decimals: 9,
431
444
  },
432
445
  hasui: {
433
446
  coinName: 'hasui',
@@ -464,6 +477,7 @@ export const POOL_ADDRESSES: OptionalKeys<
464
477
  sCoinMetadataId:
465
478
  '0x0a2a4a25aac50ac79210d710f93cb22db58bc6ee22f213364dda9a709cab2189',
466
479
  spoolName: 'shasui',
480
+ decimals: 9,
467
481
  },
468
482
  vsui: {
469
483
  coinName: 'vsui',
@@ -500,6 +514,7 @@ export const POOL_ADDRESSES: OptionalKeys<
500
514
  sCoinMetadataId:
501
515
  '0xa96cc21ddfb6486be4a96cda0c58734e4ddea2a8c04984f9e6121d8fae997ddf',
502
516
  spoolName: 'svsui',
517
+ decimals: 9,
503
518
  },
504
519
  sca: {
505
520
  coinName: 'sca',
@@ -532,6 +547,7 @@ export const POOL_ADDRESSES: OptionalKeys<
532
547
  '0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6::sca::SCA',
533
548
  sCoinMetadataId:
534
549
  '0x27e3877491b308dfac46fb3d9f7dfa6a1e8b7dc3c374e92ecda7976055746964',
550
+ decimals: 9,
535
551
  },
536
552
  fud: {
537
553
  coinName: 'fud',
@@ -562,36 +578,7 @@ export const POOL_ADDRESSES: OptionalKeys<
562
578
  '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD',
563
579
  sCoinMetadataId:
564
580
  '0x4e03390de36b8c84e0a8297d3d0d08a8a34bed93787e37fcb26bfc26df33226c',
565
- },
566
- deep: {
567
- coinName: 'deep',
568
- symbol: 'DEEP',
569
- lendingPoolAddress:
570
- '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
571
- borrowDynamic:
572
- '0x95e00d7466f97a100e70f08bd37788dc49335796f6f49fab996d40dd0681c6d3',
573
- interestModel:
574
- '0x4143c298506a332d92ea8a995e6f3991ee3215f58f6fc6441752835d275b9a69',
575
- borrowFeeKey:
576
- '0xb14ee43f4ad2a2c40bac8c4406a401690e93c982e289cf3802fedf74a159cab2',
577
- supplyLimitKey:
578
- '0x599528fdfdc253e90dfd0acf4f4a166b391e2aac1ca6528abbff63225b548fee',
579
- borrowLimitKey:
580
- '0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e',
581
- isolatedAssetKey:
582
- '0x208d3a24ba369dcfc8f0387333d1512b98199eb150d2f2a69359ff708cf761e3',
583
- sCoinTreasury:
584
- '0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88',
585
- sCoinType:
586
- '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
587
- sCoinName: 'sdeep',
588
- sCoinSymbol: 'sDEEP',
589
- coinMetadataId:
590
- '0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0',
591
- coinType:
592
- '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
593
- sCoinMetadataId:
594
- '0x2443014594a500a9119e11c6c6a86e865834f496c4614280ce8cace33c0b072e',
581
+ decimals: 5,
595
582
  },
596
583
  fdusd: {
597
584
  coinName: 'fdusd',
@@ -622,5 +609,37 @@ export const POOL_ADDRESSES: OptionalKeys<
622
609
  '0xf16e6b723f242ec745dfd7634ad072c42d5c1d9ac9d62a39c381303eaa57693a::fdusd::FDUSD',
623
610
  sCoinMetadataId:
624
611
  '0xb1529a3b5e5831d19a722493eec19785f613945d3dc984602d44a418f990d73f',
612
+ decimals: 6,
613
+ },
614
+ deep: {
615
+ coinName: 'deep',
616
+ symbol: 'DEEP',
617
+ lendingPoolAddress:
618
+ '0xf4a67ffb43da1e1c61c049f188f19463ea8dbbf2d5ef4722d6df854ff1b1cc03',
619
+ borrowDynamic:
620
+ '0x95e00d7466f97a100e70f08bd37788dc49335796f6f49fab996d40dd0681c6d3',
621
+ interestModel:
622
+ '0x4143c298506a332d92ea8a995e6f3991ee3215f58f6fc6441752835d275b9a69',
623
+ borrowFeeKey:
624
+ '0xb14ee43f4ad2a2c40bac8c4406a401690e93c982e289cf3802fedf74a159cab2',
625
+ supplyLimitKey:
626
+ '0x599528fdfdc253e90dfd0acf4f4a166b391e2aac1ca6528abbff63225b548fee',
627
+ borrowLimitKey:
628
+ '0xf4217e8ef9d9c32e8992092e910a77535a8124c19b8a762a673f227f5f765a4e',
629
+ isolatedAssetKey:
630
+ '0x208d3a24ba369dcfc8f0387333d1512b98199eb150d2f2a69359ff708cf761e3',
631
+ sCoinTreasury:
632
+ '0xc63838fabe37b25ad897392d89876d920f5e0c6a406bf3abcb84753d2829bc88',
633
+ sCoinType:
634
+ '0xeb7a05a3224837c5e5503575aed0be73c091d1ce5e43aa3c3e716e0ae614608f::scallop_deep::SCALLOP_DEEP',
635
+ sCoinName: 'sdeep',
636
+ sCoinSymbol: 'sDEEP',
637
+ coinMetadataId:
638
+ '0x6e60b051a08fa836f5a7acd7c464c8d9825bc29c44657fe170fe9b8e1e4770c0',
639
+ coinType:
640
+ '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
641
+ sCoinMetadataId:
642
+ '0x2443014594a500a9119e11c6c6a86e865834f496c4614280ce8cace33c0b072e',
643
+ decimals: 6,
625
644
  },
626
645
  };
@@ -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',
@@ -29,6 +29,7 @@ export const getAllAddresses = async (query: ScallopQuery) => {
29
29
  coinType?: string;
30
30
  sCoinMetadataId?: string;
31
31
  spoolName?: string;
32
+ decimals: number;
32
33
  }
33
34
  >
34
35
  > = {};
@@ -139,6 +140,8 @@ export const getAllAddresses = async (query: ScallopQuery) => {
139
140
  // @ts-ignore
140
141
  `scoin.coins.s${coinName}.metaData`
141
142
  );
143
+
144
+ const decimals = query.utils.getCoinDecimal(coinName);
142
145
  const spoolName = spool ? `s${coinName}` : undefined;
143
146
  results[coinName as SupportPoolCoins] = {
144
147
  coinName,
@@ -162,6 +165,7 @@ export const getAllAddresses = async (query: ScallopQuery) => {
162
165
  coinType: `0x${coinType}`,
163
166
  sCoinMetadataId,
164
167
  spoolName,
168
+ decimals,
165
169
  };
166
170
 
167
171
  await new Promise((resolve) => setTimeout(resolve, 500));
@@ -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();