@scallop-io/sui-scallop-sdk 1.5.0 → 1.5.2

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.
@@ -25,6 +25,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
25
25
  id: '',
26
26
  metaData: '',
27
27
  treasury: '',
28
+ symbol: '',
29
+ coinType: '',
30
+ decimals: 0,
28
31
  oracle: {
29
32
  supra: '',
30
33
  switchboard: '',
@@ -38,6 +41,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
38
41
  id: '',
39
42
  metaData: '',
40
43
  treasury: '',
44
+ symbol: '',
45
+ coinType: '',
46
+ decimals: 0,
41
47
  oracle: {
42
48
  supra: '',
43
49
  switchboard: '',
@@ -51,6 +57,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
51
57
  id: '',
52
58
  metaData: '',
53
59
  treasury: '',
60
+ symbol: '',
61
+ coinType: '',
62
+ decimals: 0,
54
63
  oracle: {
55
64
  supra: '',
56
65
  switchboard: '',
@@ -64,6 +73,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
64
73
  id: '',
65
74
  metaData: '',
66
75
  treasury: '',
76
+ symbol: '',
77
+ coinType: '',
78
+ decimals: 0,
67
79
  oracle: {
68
80
  supra: '',
69
81
  switchboard: '',
@@ -77,6 +89,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
77
89
  id: '',
78
90
  metaData: '',
79
91
  treasury: '',
92
+ symbol: '',
93
+ coinType: '',
94
+ decimals: 0,
80
95
  oracle: {
81
96
  supra: '',
82
97
  switchboard: '',
@@ -90,6 +105,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
90
105
  id: '',
91
106
  metaData: '',
92
107
  treasury: '',
108
+ symbol: '',
109
+ coinType: '',
110
+ decimals: 0,
93
111
  oracle: {
94
112
  supra: '',
95
113
  switchboard: '',
@@ -103,6 +121,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
103
121
  id: '',
104
122
  metaData: '',
105
123
  treasury: '',
124
+ symbol: '',
125
+ coinType: '',
126
+ decimals: 0,
106
127
  oracle: {
107
128
  supra: '',
108
129
  switchboard: '',
@@ -116,6 +137,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
116
137
  id: '',
117
138
  metaData: '',
118
139
  treasury: '',
140
+ symbol: '',
141
+ coinType: '',
142
+ decimals: 0,
119
143
  oracle: {
120
144
  supra: '',
121
145
  switchboard: '',
@@ -129,6 +153,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
129
153
  id: '',
130
154
  metaData: '',
131
155
  treasury: '',
156
+ symbol: '',
157
+ coinType: '',
158
+ decimals: 0,
132
159
  oracle: {
133
160
  supra: '',
134
161
  switchboard: '',
@@ -142,6 +169,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
142
169
  id: '',
143
170
  metaData: '',
144
171
  treasury: '',
172
+ symbol: '',
173
+ coinType: '',
174
+ decimals: 0,
145
175
  oracle: {
146
176
  supra: '',
147
177
  switchboard: '',
@@ -155,6 +185,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
155
185
  id: '',
156
186
  metaData: '',
157
187
  treasury: '',
188
+ symbol: '',
189
+ coinType: '',
190
+ decimals: 0,
158
191
  oracle: {
159
192
  supra: '',
160
193
  switchboard: '',
@@ -168,6 +201,9 @@ const EMPTY_ADDRESSES: AddressesInterface = {
168
201
  id: '',
169
202
  metaData: '',
170
203
  treasury: '',
204
+ symbol: '',
205
+ coinType: '',
206
+ decimals: 0,
171
207
  oracle: {
172
208
  supra: '',
173
209
  switchboard: '',
@@ -317,46 +353,55 @@ const EMPTY_ADDRESSES: AddressesInterface = {
317
353
  coinType: '',
318
354
  treasury: '',
319
355
  metaData: '',
356
+ symbol: '',
320
357
  },
321
358
  scetus: {
322
359
  coinType: '',
323
360
  treasury: '',
324
361
  metaData: '',
362
+ symbol: '',
325
363
  },
326
364
  ssca: {
327
365
  coinType: '',
328
366
  treasury: '',
329
367
  metaData: '',
368
+ symbol: '',
330
369
  },
331
370
  swusdc: {
332
371
  coinType: '',
333
372
  treasury: '',
334
373
  metaData: '',
374
+ symbol: '',
335
375
  },
336
376
  swusdt: {
337
377
  coinType: '',
338
378
  treasury: '',
339
379
  metaData: '',
380
+ symbol: '',
340
381
  },
341
382
  sweth: {
342
383
  coinType: '',
343
384
  treasury: '',
344
385
  metaData: '',
386
+ symbol: '',
345
387
  },
346
388
  safsui: {
347
389
  coinType: '',
348
390
  treasury: '',
349
391
  metaData: '',
392
+ symbol: '',
350
393
  },
351
394
  shasui: {
352
395
  coinType: '',
353
396
  treasury: '',
354
397
  metaData: '',
398
+ symbol: '',
355
399
  },
356
400
  svsui: {
357
401
  coinType: '',
358
402
  treasury: '',
359
403
  metaData: '',
404
+ symbol: '',
360
405
  },
361
406
  },
362
407
  },
@@ -297,14 +297,8 @@ export class ScallopQuery {
297
297
  * @param obligationId - The obligation id.
298
298
  * @return Obligation data.
299
299
  */
300
- public async queryObligation(
301
- obligationId: SuiObjectArg,
302
- args?: {
303
- version: SuiObjectArg;
304
- market: SuiObjectArg;
305
- }
306
- ) {
307
- return queryObligation(this, obligationId, args?.version, args?.market);
300
+ public async queryObligation(obligationId: SuiObjectArg) {
301
+ return queryObligation(this, obligationId);
308
302
  }
309
303
 
310
304
  /**
@@ -924,8 +918,8 @@ export class ScallopQuery {
924
918
  return SUPPORT_POOLS.reduce(
925
919
  (acc, pool) => {
926
920
  acc[pool] = {
927
- primary: primary[pool] ?? [],
928
- secondary: secondary[pool] ?? [],
921
+ primary: primary?.[pool] ?? [],
922
+ secondary: secondary?.[pool] ?? [],
929
923
  };
930
924
  return acc;
931
925
  },
@@ -1007,11 +1007,11 @@ export const queryObligation = async (
1007
1007
  }: {
1008
1008
  address: ScallopAddress;
1009
1009
  },
1010
- obligationId: SuiObjectArg,
1011
- version: SuiObjectArg = address.get('core.version'),
1012
- market: SuiObjectArg = address.get('core.market')
1010
+ obligationId: SuiObjectArg
1013
1011
  ) => {
1014
1012
  const packageId = address.get('core.packages.query.id');
1013
+ const version = address.get('core.version');
1014
+ const market = address.get('core.market');
1015
1015
  const queryTarget = `${packageId}::obligation_query::obligation_data`;
1016
1016
 
1017
1017
  const args = [
@@ -1023,7 +1023,7 @@ export const queryObligation = async (
1023
1023
  mutable: false,
1024
1024
  initialSharedVersion: '1',
1025
1025
  },
1026
- ]; // @TODO: recheck and confirm on production, need to re-deploy the query package (remind Nathan)
1026
+ ];
1027
1027
 
1028
1028
  const queryResult = await address.cache.queryInspectTxn(
1029
1029
  { queryTarget, args }
@@ -7,14 +7,14 @@ import {
7
7
  } from 'src/types';
8
8
 
9
9
  const PRIMARY_PRICE_UPDATE_POLICY =
10
- '0xbcd908d0ee6d63d726e61676f3feeec3d19817f4849bbecf372dd3399f247f6b'; // @TODO: move this constant to api address
10
+ '0x56e48a141f20a3a6a6d3fc43e58b01fc63f756c08224870e7890c80ec9d2afee';
11
11
  const SECONDARY_PRICE_UPDDATE_POLICY =
12
- '0x624a6f120777bb30e718b86e836c205ef4229448052377dc3d78272a6662b2c0'; // @TODO: move this constant to api address
12
+ '0xef4d9430ae42c1b24199ac55e87ddd7262622447ee3c7de8868efe839b3d8705';
13
13
 
14
14
  /**
15
15
  * Query the price update policy table ids. Usually the value for these table will be constant.
16
16
  * @param query
17
- * @returns
17
+ * @returns Primary and Secondary price update policy table object
18
18
  */
19
19
  export const getPriceUpdatePolicies = async (
20
20
  address: ScallopAddress
@@ -23,7 +23,6 @@ export const getPriceUpdatePolicies = async (
23
23
  secondary: SuiObjectResponse | null;
24
24
  }> => {
25
25
  const priceUpdatePolicyRulesKeyType = `${address.get('core.packages.xOracle.object')}::price_update_policy::PriceUpdatePolicyRulesKey`;
26
-
27
26
  const [primaryPriceUpdatePolicyTable, secondaryPriceUpdatePolicyTable] =
28
27
  await Promise.all([
29
28
  address.cache.queryGetDynamicFieldObject({
@@ -53,14 +52,23 @@ export const getPriceUpdatePolicies = async (
53
52
  // const SECONDARY_PRICE_UPDATE_POLICY_KEY =
54
53
  // '0x304d226734fa5e376423c9ff0f1d49aeb1e2572d4b617d31e11e2f69865b73ed';
55
54
  const PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID =
56
- '0xfb1330aa028ed6a159b742c71b5a79b3b6824cf71efa40ea82b52486ad209264';
55
+ '0xc22c9d691ee4c780de09db91d8b487d863211ebf08720772144bcf716318826c';
57
56
  const SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID =
58
- '0x4b827acc73f3f53f808dd73a7ee0a60ae61e84322176bece72b26467030b467c';
57
+ '0x3b184ff859f5de30eeaf186898e5224925be6bb6d2baa74347ef471a8cd1c0d3';
59
58
 
60
59
  export const getAssetOracles = async (
61
60
  utils: ScallopUtils,
62
61
  ruleType: xOracleRuleType
63
- ): Promise<Record<SupportAssetCoins, SupportOracleType[]>> => {
62
+ ): Promise<Record<SupportAssetCoins, SupportOracleType[]> | null> => {
63
+ if (ruleType === 'primary' && !PRIMARY_PRICE_UPDATE_POLICY_VECSET_ID) {
64
+ console.error('Primary price update policy vecset id is not set');
65
+ return null;
66
+ }
67
+ if (ruleType === 'secondary' && !SECONDARY_PRICE_UPDATE_POLICY_VECSET_ID) {
68
+ console.error('Secondary price update policy vecset id is not set');
69
+ return null;
70
+ }
71
+
64
72
  const ruleTypeNameToOracleType: Record<string, SupportOracleType> = {
65
73
  [`${utils.address.get('core.packages.pyth.object')}::rule::Rule`]: 'pyth',
66
74
  [`${utils.address.get('core.packages.supra.object')}::rule::Rule`]: 'supra',
@@ -23,6 +23,9 @@ export interface AddressesInterface {
23
23
  id: string;
24
24
  treasury: string;
25
25
  metaData: string;
26
+ coinType: string;
27
+ symbol: string;
28
+ decimals: number;
26
29
  oracle: {
27
30
  [K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
28
31
  ? string
@@ -130,6 +133,7 @@ export interface AddressesInterface {
130
133
  SupportSCoin,
131
134
  {
132
135
  coinType: string;
136
+ symbol: string;
133
137
  treasury: string;
134
138
  metaData: string;
135
139
  }
@@ -78,6 +78,7 @@ export type ScallopClientParams = ScallopParams &
78
78
  export type ScallopBuilderParams = ScallopParams & {
79
79
  pythEndpoints?: string[];
80
80
  usePythPullModel?: boolean;
81
+ useOnChainXOracleList?: boolean;
81
82
  } & ScallopQueryParams;
82
83
 
83
84
  export type ScallopQueryParams = ScallopParams & ScallopUtilsParams;