@scallop-io/sui-scallop-sdk 0.44.1 → 0.44.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.
@@ -53,6 +53,7 @@ export declare class ScallopQuery {
53
53
  cetus?: import("../types").MarketPool | undefined;
54
54
  afsui?: import("../types").MarketPool | undefined;
55
55
  hasui?: import("../types").MarketPool | undefined;
56
+ vsui?: import("../types").MarketPool | undefined;
56
57
  }>;
57
58
  /**
58
59
  * Get market pool
@@ -82,6 +83,7 @@ export declare class ScallopQuery {
82
83
  cetus?: import("../types").MarketCollateral | undefined;
83
84
  afsui?: import("../types").MarketCollateral | undefined;
84
85
  hasui?: import("../types").MarketCollateral | undefined;
86
+ vsui?: import("../types").MarketCollateral | undefined;
85
87
  }>;
86
88
  /**
87
89
  * Get market collateral
@@ -122,6 +124,7 @@ export declare class ScallopQuery {
122
124
  cetus?: number | undefined;
123
125
  afsui?: number | undefined;
124
126
  hasui?: number | undefined;
127
+ vsui?: number | undefined;
125
128
  }>;
126
129
  /**
127
130
  * Get asset coin amount.
@@ -149,6 +152,7 @@ export declare class ScallopQuery {
149
152
  scetus?: number | undefined;
150
153
  safsui?: number | undefined;
151
154
  shasui?: number | undefined;
155
+ svsui?: number | undefined;
152
156
  }>;
153
157
  /**
154
158
  * Get market coin amount.
@@ -268,6 +272,7 @@ export declare class ScallopQuery {
268
272
  cetus?: import("../types").Lending | undefined;
269
273
  afsui?: import("../types").Lending | undefined;
270
274
  hasui?: import("../types").Lending | undefined;
275
+ vsui?: import("../types").Lending | undefined;
271
276
  }>;
272
277
  /**
273
278
  * Get user lending and spool information for specific pool.
@@ -142,6 +142,7 @@ export declare class ScallopUtils {
142
142
  cetus?: number | undefined;
143
143
  afsui?: number | undefined;
144
144
  hasui?: number | undefined;
145
+ vsui?: number | undefined;
145
146
  }>;
146
147
  /**
147
148
  * Convert apr to apy.
@@ -35,6 +35,7 @@ export declare const getMarketPools: (query: ScallopQuery, poolCoinNames?: Suppo
35
35
  cetus?: MarketPool | undefined;
36
36
  afsui?: MarketPool | undefined;
37
37
  hasui?: MarketPool | undefined;
38
+ vsui?: MarketPool | undefined;
38
39
  }>;
39
40
  /**
40
41
  * Get market pool data.
@@ -68,6 +69,7 @@ export declare const getMarketCollaterals: (query: ScallopQuery, collateralCoinN
68
69
  cetus?: MarketCollateral | undefined;
69
70
  afsui?: MarketCollateral | undefined;
70
71
  hasui?: MarketCollateral | undefined;
72
+ vsui?: MarketCollateral | undefined;
71
73
  }>;
72
74
  /**
73
75
  * Get market collateral data.
@@ -117,6 +119,7 @@ export declare const getCoinAmounts: (query: ScallopQuery, assetCoinNames?: Supp
117
119
  cetus?: number | undefined;
118
120
  afsui?: number | undefined;
119
121
  hasui?: number | undefined;
122
+ vsui?: number | undefined;
120
123
  }>;
121
124
  /**
122
125
  * Query owned coin amount.
@@ -146,6 +149,7 @@ export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames
146
149
  scetus?: number | undefined;
147
150
  safsui?: number | undefined;
148
151
  shasui?: number | undefined;
152
+ svsui?: number | undefined;
149
153
  }>;
150
154
  /**
151
155
  * Query owned market coin (sCoin) amount.
@@ -19,6 +19,7 @@ export declare const getLendings: (query: ScallopQuery, poolCoinNames?: SupportP
19
19
  cetus?: Lending | undefined;
20
20
  afsui?: Lending | undefined;
21
21
  hasui?: Lending | undefined;
22
+ vsui?: Lending | undefined;
22
23
  }>;
23
24
  /**
24
25
  * Get user lending infomation for specific pool.
@@ -1,5 +1,5 @@
1
1
  import { SUPPORT_ORACLES } from '../constants';
2
- import type { SupportCoins, SupportOracleType, SupportPackageType, SupportStakeMarketCoins } from './constant';
2
+ import type { SupportAssetCoins, SupportOracleType, SupportPackageType, SupportStakeMarketCoins } from './constant';
3
3
  export interface AddressesInterface {
4
4
  core: {
5
5
  version: string;
@@ -7,7 +7,7 @@ export interface AddressesInterface {
7
7
  market: string;
8
8
  adminCap: string;
9
9
  coinDecimalsRegistry: string;
10
- coins: Partial<Record<SupportCoins, {
10
+ coins: Partial<Record<SupportAssetCoins, {
11
11
  id: string;
12
12
  treasury: string;
13
13
  metaData: string;
@@ -21,4 +21,7 @@ type PickFromUnion<T, K extends string> = K extends T ? K : never;
21
21
  export type WormholeCoinIds = {
22
22
  [key in PickFromUnion<SupportAssetCoins, 'eth' | 'btc' | 'usdc' | 'usdt' | 'apt' | 'sol'>]: string;
23
23
  };
24
+ export type VoloCoinIds = {
25
+ [key in PickFromUnion<SupportAssetCoins, 'vsui'>]: string;
26
+ };
24
27
  export {};
@@ -1,2 +1,3 @@
1
- import type { SupportCoins, SupportMarketCoins } from '../types';
1
+ import type { SupportAssetCoins, SupportCoins, SupportMarketCoins } from '../types';
2
2
  export declare const isMarketCoin: (coinName: SupportCoins) => coinName is SupportMarketCoins;
3
+ export declare const parseAssetSymbol: (coinName: SupportAssetCoins) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "0.44.1",
3
+ "version": "0.44.2",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -42,24 +42,24 @@
42
42
  "@mysten/sui.js": "^0.44.0",
43
43
  "@noble/curves": "^1.2.0",
44
44
  "@noble/hashes": "^1.3.2",
45
- "@pythnetwork/price-service-client": "^1.8.1",
46
- "@pythnetwork/pyth-sui-js": "^1.2.3",
45
+ "@pythnetwork/price-service-client": "^1.8.2",
46
+ "@pythnetwork/pyth-sui-js": "^1.2.4",
47
47
  "@scallop-io/sui-kit": "^0.44.0",
48
48
  "@scure/bip39": "^1.2.1",
49
- "axios": "^1.5.1",
49
+ "axios": "^1.6.0",
50
50
  "bignumber.js": "^9.1.2",
51
51
  "superstruct": "^1.0.3",
52
52
  "tweetnacl": "^1.0.3"
53
53
  },
54
54
  "devDependencies": {
55
- "@commitlint/cli": "^18.0.0",
56
- "@commitlint/config-conventional": "^18.0.0",
57
- "@commitlint/prompt-cli": "^18.0.0",
58
- "@types/node": "^20.8.7",
59
- "@typescript-eslint/eslint-plugin": "^6.8.0",
60
- "@typescript-eslint/parser": "^6.8.0",
55
+ "@commitlint/cli": "^18.2.0",
56
+ "@commitlint/config-conventional": "^18.1.0",
57
+ "@commitlint/prompt-cli": "^18.2.0",
58
+ "@types/node": "^20.8.10",
59
+ "@typescript-eslint/eslint-plugin": "^6.10.0",
60
+ "@typescript-eslint/parser": "^6.10.0",
61
61
  "dotenv": "^16.3.1",
62
- "eslint": "^8.52.0",
62
+ "eslint": "^8.53.0",
63
63
  "eslint-config-prettier": "^9.0.0",
64
64
  "eslint-plugin-prettier": "^5.0.1",
65
65
  "husky": "^8.0.3",
@@ -68,7 +68,7 @@
68
68
  "standard-version": "^9.5.0",
69
69
  "tsconfig-paths": "^4.2.0",
70
70
  "tsup": "^7.2.0",
71
- "typedoc": "^0.25.2",
71
+ "typedoc": "^0.25.3",
72
72
  "typescript": "^5.2.2",
73
73
  "vitest": "^0.34.6"
74
74
  },
@@ -16,6 +16,7 @@ export const SUPPORT_POOLS = [
16
16
  'cetus',
17
17
  'afsui',
18
18
  'hasui',
19
+ 'vsui',
19
20
  ] as const;
20
21
 
21
22
  export const SUPPORT_COLLATERALS = [
@@ -29,6 +30,7 @@ export const SUPPORT_COLLATERALS = [
29
30
  'cetus',
30
31
  'afsui',
31
32
  'hasui',
33
+ 'vsui',
32
34
  ] as const;
33
35
 
34
36
  export const SUPPORT_SPOOLS = ['ssui', 'susdc', 'susdt'] as const;
@@ -6,6 +6,7 @@ import type {
6
6
  RewardCoins,
7
7
  AssetCoinIds,
8
8
  WormholeCoinIds,
9
+ VoloCoinIds,
9
10
  } from '../types';
10
11
 
11
12
  export const coinDecimals: SupportCoinDecimals = {
@@ -19,6 +20,7 @@ export const coinDecimals: SupportCoinDecimals = {
19
20
  cetus: 9,
20
21
  afsui: 9,
21
22
  hasui: 9,
23
+ vsui: 9,
22
24
  seth: 8,
23
25
  sbtc: 8,
24
26
  susdc: 6,
@@ -29,6 +31,7 @@ export const coinDecimals: SupportCoinDecimals = {
29
31
  scetus: 9,
30
32
  safsui: 9,
31
33
  shasui: 9,
34
+ svsui: 9,
32
35
  };
33
36
 
34
37
  export const assetCoins: AssetCoins = {
@@ -42,6 +45,7 @@ export const assetCoins: AssetCoins = {
42
45
  cetus: 'cetus',
43
46
  afsui: 'afsui',
44
47
  hasui: 'hasui',
48
+ vsui: 'vsui',
45
49
  };
46
50
 
47
51
  export const marketCoins: MarketCoins = {
@@ -55,6 +59,7 @@ export const marketCoins: MarketCoins = {
55
59
  scetus: 'scetus',
56
60
  safsui: 'safsui',
57
61
  shasui: 'shasui',
62
+ svsui: 'svsui',
58
63
  };
59
64
 
60
65
  export const stakeMarketCoins: StakeMarketCoins = {
@@ -80,6 +85,7 @@ export const coinIds: AssetCoinIds = {
80
85
  cetus: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
81
86
  afsui: '0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc',
82
87
  hasui: '0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d',
88
+ vsui: '0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55',
83
89
  };
84
90
 
85
91
  export const wormholeCoinIds: WormholeCoinIds = {
@@ -90,3 +96,7 @@ export const wormholeCoinIds: WormholeCoinIds = {
90
96
  apt: '0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37',
91
97
  sol: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8',
92
98
  };
99
+
100
+ export const voloCoinIds: VoloCoinIds = {
101
+ vsui: '0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55',
102
+ };
@@ -80,6 +80,45 @@ const EMPTY_ADDRESSES: AddressesInterface = {
80
80
  },
81
81
  },
82
82
  },
83
+ afsui: {
84
+ id: '',
85
+ metaData: '',
86
+ treasury: '',
87
+ oracle: {
88
+ supra: '',
89
+ switchboard: '',
90
+ pyth: {
91
+ feed: '',
92
+ feedObject: '',
93
+ },
94
+ },
95
+ },
96
+ hasui: {
97
+ id: '',
98
+ metaData: '',
99
+ treasury: '',
100
+ oracle: {
101
+ supra: '',
102
+ switchboard: '',
103
+ pyth: {
104
+ feed: '',
105
+ feedObject: '',
106
+ },
107
+ },
108
+ },
109
+ vsui: {
110
+ id: '',
111
+ metaData: '',
112
+ treasury: '',
113
+ oracle: {
114
+ supra: '',
115
+ switchboard: '',
116
+ pyth: {
117
+ feed: '',
118
+ feedObject: '',
119
+ },
120
+ },
121
+ },
83
122
  },
84
123
  oracles: {
85
124
  xOracle: '',
@@ -11,10 +11,15 @@ import {
11
11
  rewardCoins,
12
12
  coinDecimals,
13
13
  wormholeCoinIds,
14
+ voloCoinIds,
14
15
  coinIds,
15
16
  } from '../constants';
16
17
  import { queryObligation } from '../queries';
17
- import { parseDataFromPythPriceFeed, isMarketCoin } from '../utils';
18
+ import {
19
+ parseDataFromPythPriceFeed,
20
+ isMarketCoin,
21
+ parseAssetSymbol,
22
+ } from '../utils';
18
23
  import type {
19
24
  ScallopUtilsParams,
20
25
  ScallopInstanceParams,
@@ -91,9 +96,14 @@ export class ScallopUtils {
91
96
  */
92
97
  public parseSymbol(coinName: SupportCoins) {
93
98
  if (isMarketCoin(coinName)) {
94
- return coinName.slice(0, 1) + coinName.slice(1).toUpperCase();
99
+ const assetCoinName = coinName
100
+ .slice(1)
101
+ .toLowerCase() as SupportAssetCoins;
102
+ return (
103
+ coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName)
104
+ );
95
105
  } else {
96
- return coinName.toUpperCase();
106
+ return parseAssetSymbol(coinName);
97
107
  }
98
108
  }
99
109
 
@@ -111,15 +121,15 @@ export class ScallopUtils {
111
121
  public parseCoinType(coinName: SupportCoins) {
112
122
  coinName = isMarketCoin(coinName) ? this.parseCoinName(coinName) : coinName;
113
123
  const coinPackageId =
114
- this._address.get(`core.coins.${coinName}.id`) ??
115
- coinIds[coinName] ??
124
+ this._address.get(`core.coins.${coinName}.id`) ||
125
+ coinIds[coinName] ||
116
126
  undefined;
117
127
  if (!coinPackageId) {
118
128
  throw Error(`Coin ${coinName} is not supported`);
119
129
  }
120
130
  if (coinName === 'sui')
121
131
  return normalizeStructTag(`${coinPackageId}::sui::SUI`);
122
- const wormHoleCoinIds = [
132
+ const wormHolePckageIds = [
123
133
  this._address.get('core.coins.usdc.id') ?? wormholeCoinIds.usdc,
124
134
  this._address.get('core.coins.usdt.id') ?? wormholeCoinIds.usdt,
125
135
  this._address.get('core.coins.eth.id') ?? wormholeCoinIds.eth,
@@ -127,8 +137,13 @@ export class ScallopUtils {
127
137
  this._address.get('core.coins.sol.id') ?? wormholeCoinIds.sol,
128
138
  this._address.get('core.coins.apt.id') ?? wormholeCoinIds.apt,
129
139
  ];
130
- if (wormHoleCoinIds.includes(coinPackageId)) {
140
+ const voloPckageIds = [
141
+ this._address.get('core.coins.vsui.id') ?? voloCoinIds.vsui,
142
+ ];
143
+ if (wormHolePckageIds.includes(coinPackageId)) {
131
144
  return `${coinPackageId}::coin::COIN`;
145
+ } else if (voloPckageIds.includes(coinPackageId)) {
146
+ return `${coinPackageId}::cert::CERT`;
132
147
  } else {
133
148
  return `${coinPackageId}::${coinName}::${coinName.toUpperCase()}`;
134
149
  }
@@ -192,9 +207,15 @@ export class ScallopUtils {
192
207
  this._address.get('core.coins.apt.id') ?? wormholeCoinIds.apt
193
208
  }::coin::COIN`]: 'apt',
194
209
  };
210
+ const voloCoinTypeMap: Record<string, SupportAssetCoins> = {
211
+ [`${
212
+ this._address.get('core.coins.vsui.id') ?? voloCoinIds.vsui
213
+ }::cert::CERT`]: 'vsui',
214
+ };
195
215
 
196
216
  const assetCoinName =
197
217
  wormHoleCoinTypeMap[coinType] ||
218
+ voloCoinTypeMap[coinType] ||
198
219
  (coinType.split('::')[2].toLowerCase() as SupportAssetCoins);
199
220
 
200
221
  return isMarketCoinType
@@ -363,13 +384,14 @@ export class ScallopUtils {
363
384
  try {
364
385
  const priceFeeds =
365
386
  (await pythConnection.getLatestPriceFeeds(priceIds)) || [];
366
- for (const feed of priceFeeds) {
387
+ for (const [index, feed] of priceFeeds.entries()) {
367
388
  const data = parseDataFromPythPriceFeed(feed, this._address);
368
- this._priceMap.set(data.coinName, {
389
+ const coinName = lackPricesCoinNames[index];
390
+ this._priceMap.set(coinName, {
369
391
  price: data.price,
370
392
  publishTime: data.publishTime,
371
393
  });
372
- coinPrices[data.coinName] = data.price;
394
+ coinPrices[coinName] = data.price;
373
395
  }
374
396
  } catch (_e) {
375
397
  for (const coinName of lackPricesCoinNames) {
@@ -1,6 +1,6 @@
1
1
  import { SUPPORT_ORACLES } from '../constants';
2
2
  import type {
3
- SupportCoins,
3
+ SupportAssetCoins,
4
4
  SupportOracleType,
5
5
  SupportPackageType,
6
6
  SupportStakeMarketCoins,
@@ -15,7 +15,7 @@ export interface AddressesInterface {
15
15
  coinDecimalsRegistry: string;
16
16
  coins: Partial<
17
17
  Record<
18
- SupportCoins,
18
+ SupportAssetCoins,
19
19
  {
20
20
  id: string;
21
21
  treasury: string;
@@ -38,3 +38,7 @@ export type WormholeCoinIds = {
38
38
  'eth' | 'btc' | 'usdc' | 'usdt' | 'apt' | 'sol'
39
39
  >]: string;
40
40
  };
41
+
42
+ export type VoloCoinIds = {
43
+ [key in PickFromUnion<SupportAssetCoins, 'vsui'>]: string;
44
+ };
package/src/utils/util.ts CHANGED
@@ -12,12 +12,28 @@ import type {
12
12
  export const isMarketCoin = (
13
13
  coinName: SupportCoins
14
14
  ): coinName is SupportMarketCoins => {
15
- const assetCoinName = coinName.slice(1) as SupportAssetCoins;
16
- return [
17
- ...new Set([
18
- ...SUPPORT_POOLS,
19
- ...SUPPORT_COLLATERALS,
20
- ...SUPPORT_REWARD_POOLS,
21
- ]),
22
- ].includes(assetCoinName);
15
+ const assetCoinName = coinName.slice(1).toLowerCase() as SupportAssetCoins;
16
+ return (
17
+ coinName.charAt(0).toLowerCase() === 's' &&
18
+ [
19
+ ...new Set([
20
+ ...SUPPORT_POOLS,
21
+ ...SUPPORT_COLLATERALS,
22
+ ...SUPPORT_REWARD_POOLS,
23
+ ]),
24
+ ].includes(assetCoinName)
25
+ );
26
+ };
27
+
28
+ export const parseAssetSymbol = (coinName: SupportAssetCoins): string => {
29
+ switch (coinName) {
30
+ case 'afsui':
31
+ return 'afSUI';
32
+ case 'hasui':
33
+ return 'haSUI';
34
+ case 'vsui':
35
+ return 'vSUI';
36
+ default:
37
+ return coinName.toUpperCase();
38
+ }
23
39
  };