@scallop-io/sui-scallop-sdk 0.47.0-alpha.5 → 0.47.0

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.
@@ -280,6 +280,7 @@ export declare class ScallopQuery {
280
280
  * @return Borrow incentive pools data.
281
281
  */
282
282
  getBorrowIncentivePools(coinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean): Promise<{
283
+ usdc?: import("../types").BorrowIncentivePool | undefined;
283
284
  weth?: import("../types").BorrowIncentivePool | undefined;
284
285
  wusdc?: import("../types").BorrowIncentivePool | undefined;
285
286
  wusdt?: import("../types").BorrowIncentivePool | undefined;
@@ -297,6 +298,7 @@ export declare class ScallopQuery {
297
298
  * @return Borrow incentive accounts data.
298
299
  */
299
300
  getBorrowIncentiveAccounts(obligationId: string, coinNames?: SupportBorrowIncentiveCoins[]): Promise<{
301
+ usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
300
302
  weth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
301
303
  wusdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
302
304
  wusdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
@@ -1,14 +1,21 @@
1
1
  import type { ScallopAddress, ScallopQuery, ScallopUtils } from '../models';
2
- import type { SupportBorrowIncentiveCoins, BorrowIncentivePool } from '../types';
2
+ import type { BorrowIncentivePoolsQueryInterface, SupportBorrowIncentiveCoins, BorrowIncentivePool } from '../types';
3
3
  /**
4
- * Query borrow incentive pools data.
4
+ * Query borrow incentive pools data using moveCall
5
+ * @param address
6
+ * @returns
7
+ */
8
+ export declare const queryBorrowIncentivePools: (address: ScallopAddress) => Promise<BorrowIncentivePoolsQueryInterface | undefined>;
9
+ /**
10
+ * Get borrow incentive pools data.
5
11
  *
6
12
  * @param query - The Scallop query instance.
7
13
  * @param borrowIncentiveCoinNames - Specific an array of support borrow incentive coin name.
8
14
  * @param indexer - Whether to use indexer.
9
15
  * @return Borrow incentive pools data.
10
16
  */
11
- export declare const queryBorrowIncentivePools: (query: ScallopQuery, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean) => Promise<{
17
+ export declare const getBorrowIncentivePools: (query: ScallopQuery, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean) => Promise<{
18
+ usdc?: BorrowIncentivePool | undefined;
12
19
  weth?: BorrowIncentivePool | undefined;
13
20
  wusdc?: BorrowIncentivePool | undefined;
14
21
  wusdt?: BorrowIncentivePool | undefined;
@@ -28,6 +35,7 @@ export declare const queryBorrowIncentivePools: (query: ScallopQuery, borrowInce
28
35
  export declare const queryBorrowIncentiveAccounts: ({ utils, }: {
29
36
  utils: ScallopUtils;
30
37
  }, obligationId: string, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[]) => Promise<{
38
+ usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
31
39
  weth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
32
40
  wusdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
33
41
  wusdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
@@ -37,6 +37,7 @@ export type OriginBorrowIncentivePoolPointData = {
37
37
  base_weight: string;
38
38
  weighted_amount: string;
39
39
  last_update: string;
40
+ created_at: string;
40
41
  };
41
42
  export type OriginBorrowIncentivePoolData = {
42
43
  pool_type: {
@@ -58,6 +59,7 @@ export type ParsedBorrowIncentivePoolPointData = {
58
59
  baseWeight: number;
59
60
  weightedAmount: number;
60
61
  lastUpdate: number;
62
+ createdAt: number;
61
63
  };
62
64
  export type ParsedBorrowIncentivePoolData = {
63
65
  poolType: string;
@@ -65,7 +67,6 @@ export type ParsedBorrowIncentivePoolData = {
65
67
  minStakes: number;
66
68
  maxStakes: number;
67
69
  staked: number;
68
- createdAt: number;
69
70
  };
70
71
  export type CalculatedBorrowIncentivePoolPointData = {
71
72
  baseWeight: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.47.0-alpha.5",
3
+ "version": "0.47.0",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -5,14 +5,11 @@ export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io';
5
5
  export const IS_VE_SCA_TEST = false;
6
6
  export const USE_TEST_ADDRESS = false;
7
7
 
8
- // export const ADDRESSES_ID = '';
9
8
  export const ADDRESSES_ID =
10
9
  IS_VE_SCA_TEST || USE_TEST_ADDRESS
11
10
  ? ('65fb07c39c845425d71d7b18' as const)
12
11
  : ('66f8e7ed9bb9e07fdfb86bbb' as const);
13
12
  // : ('664dfe22898c36c159e28bc8' as const);
14
- // : ('6601955b8b0024600a917079' as const);
15
- // : ('6462a088a7ace142bb6d7e9b' as const);
16
13
 
17
14
  export const PROTOCOL_OBJECT_ID = IS_VE_SCA_TEST
18
15
  ? ('0xc9f859f98ca352a11b97a038c4b4162bee437b8df8caa047990fe9cb03d4f778' as const)
@@ -103,6 +100,7 @@ export const SUPPORT_BORROW_INCENTIVE_POOLS = [
103
100
  'vsui',
104
101
  'weth',
105
102
  'sca',
103
+ 'usdc',
106
104
  ] as const;
107
105
 
108
106
  export const SUPPORT_BORROW_INCENTIVE_REWARDS = ['sui', 'sca'] as const;
@@ -102,6 +102,7 @@ export const spoolRewardCoins: types.StakeRewardCoins = {
102
102
  };
103
103
 
104
104
  export const borrowIncentiveRewardCoins: types.BorrowIncentiveRewardCoins = {
105
+ usdc: ['sui', 'sca'],
105
106
  sui: ['sui', 'sca'],
106
107
  wusdc: ['sui', 'sca'],
107
108
  wusdt: ['sui', 'sca'],
@@ -145,7 +146,8 @@ export const voloCoinIds: types.VoloCoinIds = {
145
146
 
146
147
  // PROD VERSION
147
148
  export const sCoinIds: types.SCoinIds = {
148
- susdc: '', // TODO: sCoin contract
149
+ susdc:
150
+ '0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
149
151
  ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
150
152
  scetus:
151
153
  '0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
@@ -14,7 +14,6 @@ import {
14
14
  getMarketCollateral,
15
15
  getSpools,
16
16
  getSpool,
17
- queryBorrowIncentivePools,
18
17
  queryBorrowIncentiveAccounts,
19
18
  getCoinAmounts,
20
19
  getCoinAmount,
@@ -34,6 +33,7 @@ import {
34
33
  getLoyaltyProgramInformations,
35
34
  getFlashLoanFees,
36
35
  getVeSca,
36
+ getBorrowIncentivePools,
37
37
  } from '../queries';
38
38
  import {
39
39
  ScallopQueryParams,
@@ -462,7 +462,7 @@ export class ScallopQuery {
462
462
  coinNames?: SupportBorrowIncentiveCoins[],
463
463
  indexer: boolean = false
464
464
  ) {
465
- return await queryBorrowIncentivePools(this, coinNames, indexer);
465
+ return await getBorrowIncentivePools(this, coinNames, indexer);
466
466
  }
467
467
 
468
468
  /**
@@ -475,13 +475,11 @@ export class ScallopUtils {
475
475
  * @param assetCoinNames - Specific an array of support asset coin name.
476
476
  * @return Asset coin price.
477
477
  */
478
- public async getCoinPrices(assetCoinNames?: SupportAssetCoins[]) {
479
- assetCoinNames =
480
- assetCoinNames ||
481
- ([
482
- ...new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS]),
483
- ] as SupportAssetCoins[]);
484
-
478
+ public async getCoinPrices(
479
+ assetCoinNames: SupportAssetCoins[] = [
480
+ ...new Set([...SUPPORT_POOLS, ...SUPPORT_COLLATERALS]),
481
+ ] as SupportAssetCoins[]
482
+ ) {
485
483
  const coinPrices: CoinPrices = {};
486
484
  const existPricesCoinNames: SupportAssetCoins[] = [];
487
485
  const lackPricesCoinNames: SupportAssetCoins[] = [];
@@ -23,14 +23,35 @@ import type {
23
23
  import BigNumber from 'bignumber.js';
24
24
 
25
25
  /**
26
- * Query borrow incentive pools data.
26
+ * Query borrow incentive pools data using moveCall
27
+ * @param address
28
+ * @returns
29
+ */
30
+ export const queryBorrowIncentivePools = async (address: ScallopAddress) => {
31
+ const queryPkgId = address.get('borrowIncentive.query');
32
+ const incentivePoolsId = address.get('borrowIncentive.incentivePools');
33
+
34
+ const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
35
+ const args = [incentivePoolsId];
36
+ const queryResult = await address.cache.queryInspectTxn({
37
+ queryTarget,
38
+ args,
39
+ });
40
+ const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson as
41
+ | BorrowIncentivePoolsQueryInterface
42
+ | undefined;
43
+ return borrowIncentivePoolsQueryData;
44
+ };
45
+
46
+ /**
47
+ * Get borrow incentive pools data.
27
48
  *
28
49
  * @param query - The Scallop query instance.
29
50
  * @param borrowIncentiveCoinNames - Specific an array of support borrow incentive coin name.
30
51
  * @param indexer - Whether to use indexer.
31
52
  * @return Borrow incentive pools data.
32
53
  */
33
- export const queryBorrowIncentivePools = async (
54
+ export const getBorrowIncentivePools = async (
34
55
  query: ScallopQuery,
35
56
  borrowIncentiveCoinNames: SupportBorrowIncentiveCoins[] = [
36
57
  ...SUPPORT_BORROW_INCENTIVE_POOLS,
@@ -64,15 +85,9 @@ export const queryBorrowIncentivePools = async (
64
85
  return borrowIncentivePools;
65
86
  }
66
87
 
67
- const queryPkgId = query.address.get('borrowIncentive.query');
68
- const incentivePoolsId = query.address.get('borrowIncentive.incentivePools');
69
-
70
- const queryTarget = `${queryPkgId}::incentive_pools_query::incentive_pools_data`;
71
- const args = [incentivePoolsId];
72
- const queryResult = await query.cache.queryInspectTxn({ queryTarget, args });
73
- const borrowIncentivePoolsQueryData = queryResult?.events[0].parsedJson as
74
- | BorrowIncentivePoolsQueryInterface
75
- | undefined;
88
+ const borrowIncentivePoolsQueryData = await queryBorrowIncentivePools(
89
+ query.address
90
+ );
76
91
 
77
92
  for (const pool of borrowIncentivePoolsQueryData?.incentive_pools ?? []) {
78
93
  const borrowIncentivePoolPoints: OptionalKeys<
@@ -166,11 +181,10 @@ export const queryBorrowIncentiveAccounts = async (
166
181
  utils: ScallopUtils;
167
182
  },
168
183
  obligationId: string,
169
- borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[]
170
- ) => {
171
- borrowIncentiveCoinNames = borrowIncentiveCoinNames || [
184
+ borrowIncentiveCoinNames: SupportBorrowIncentiveCoins[] = [
172
185
  ...SUPPORT_BORROW_INCENTIVE_POOLS,
173
- ];
186
+ ]
187
+ ) => {
174
188
  const queryPkgId = utils.address.get('borrowIncentive.query');
175
189
  const incentiveAccountsId = utils.address.get(
176
190
  'borrowIncentive.incentiveAccounts'
@@ -208,7 +208,7 @@ export const queryMarket = async (
208
208
  return {
209
209
  pools,
210
210
  collaterals,
211
- data: marketData,
211
+ // data: marketData,
212
212
  } as Market;
213
213
  };
214
214
 
@@ -846,10 +846,9 @@ export const queryObligation = async (
846
846
  */
847
847
  export const getCoinAmounts = async (
848
848
  query: ScallopQuery,
849
- assetCoinNames?: SupportAssetCoins[],
849
+ assetCoinNames: SupportAssetCoins[] = [...SUPPORT_POOLS],
850
850
  ownerAddress?: string
851
851
  ) => {
852
- assetCoinNames = assetCoinNames || [...SUPPORT_POOLS];
853
852
  const owner = ownerAddress || query.suiKit.currentAddress();
854
853
  const assetCoins = {} as OptionalKeys<Record<SupportAssetCoins, number>>;
855
854
 
@@ -60,10 +60,9 @@ export const getSCoinAmounts = async (
60
60
  }: {
61
61
  utils: ScallopUtils;
62
62
  },
63
- sCoinNames?: SupportSCoin[],
63
+ sCoinNames: SupportSCoin[] = [...SUPPORT_SCOIN],
64
64
  ownerAddress?: string
65
65
  ) => {
66
- sCoinNames = sCoinNames || [...SUPPORT_SCOIN];
67
66
  const owner = ownerAddress || utils.suiKit.currentAddress();
68
67
  const sCoins = {} as OptionalKeys<Record<SupportSCoin, number>>;
69
68
 
@@ -56,6 +56,7 @@ export type OriginBorrowIncentivePoolPointData = {
56
56
  base_weight: string;
57
57
  weighted_amount: string;
58
58
  last_update: string;
59
+ created_at: string;
59
60
  };
60
61
 
61
62
  export type OriginBorrowIncentivePoolData = {
@@ -79,6 +80,7 @@ export type ParsedBorrowIncentivePoolPointData = {
79
80
  baseWeight: number;
80
81
  weightedAmount: number;
81
82
  lastUpdate: number;
83
+ createdAt: number;
82
84
  };
83
85
 
84
86
  export type ParsedBorrowIncentivePoolData = {
@@ -92,7 +94,6 @@ export type ParsedBorrowIncentivePoolData = {
92
94
  minStakes: number;
93
95
  maxStakes: number;
94
96
  staked: number;
95
- createdAt: number;
96
97
  };
97
98
 
98
99
  export type CalculatedBorrowIncentivePoolPointData = {
@@ -412,6 +412,7 @@ export const parseOriginBorrowIncentivesPoolPointData = (
412
412
  baseWeight: Number(originBorrowIncentivePoolPointData.base_weight),
413
413
  weightedAmount: Number(originBorrowIncentivePoolPointData.weighted_amount),
414
414
  lastUpdate: Number(originBorrowIncentivePoolPointData.last_update),
415
+ createdAt: Number(originBorrowIncentivePoolPointData.created_at),
415
416
  };
416
417
  };
417
418
 
@@ -429,7 +430,6 @@ export const parseOriginBorrowIncentivePoolData = (
429
430
  minStakes: Number(originBorrowIncentivePoolData.min_stakes),
430
431
  maxStakes: Number(originBorrowIncentivePoolData.max_stakes),
431
432
  staked: Number(originBorrowIncentivePoolData.stakes),
432
- createdAt: Number(originBorrowIncentivePoolData.created_at),
433
433
  poolPoints: originBorrowIncentivePoolData.points.reduce(
434
434
  (acc, point) => {
435
435
  const parsed = parseOriginBorrowIncentivesPoolPointData(point);