@scallop-io/sui-scallop-sdk 0.44.0 → 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.
@@ -51,6 +51,9 @@ export declare class ScallopQuery {
51
51
  apt?: import("../types").MarketPool | undefined;
52
52
  sol?: import("../types").MarketPool | undefined;
53
53
  cetus?: import("../types").MarketPool | undefined;
54
+ afsui?: import("../types").MarketPool | undefined;
55
+ hasui?: import("../types").MarketPool | undefined;
56
+ vsui?: import("../types").MarketPool | undefined;
54
57
  }>;
55
58
  /**
56
59
  * Get market pool
@@ -78,6 +81,9 @@ export declare class ScallopQuery {
78
81
  apt?: import("../types").MarketCollateral | undefined;
79
82
  sol?: import("../types").MarketCollateral | undefined;
80
83
  cetus?: import("../types").MarketCollateral | undefined;
84
+ afsui?: import("../types").MarketCollateral | undefined;
85
+ hasui?: import("../types").MarketCollateral | undefined;
86
+ vsui?: import("../types").MarketCollateral | undefined;
81
87
  }>;
82
88
  /**
83
89
  * Get market collateral
@@ -116,6 +122,9 @@ export declare class ScallopQuery {
116
122
  apt?: number | undefined;
117
123
  sol?: number | undefined;
118
124
  cetus?: number | undefined;
125
+ afsui?: number | undefined;
126
+ hasui?: number | undefined;
127
+ vsui?: number | undefined;
119
128
  }>;
120
129
  /**
121
130
  * Get asset coin amount.
@@ -141,6 +150,9 @@ export declare class ScallopQuery {
141
150
  sapt?: number | undefined;
142
151
  ssol?: number | undefined;
143
152
  scetus?: number | undefined;
153
+ safsui?: number | undefined;
154
+ shasui?: number | undefined;
155
+ svsui?: number | undefined;
144
156
  }>;
145
157
  /**
146
158
  * Get market coin amount.
@@ -258,6 +270,9 @@ export declare class ScallopQuery {
258
270
  apt?: import("../types").Lending | undefined;
259
271
  sol?: import("../types").Lending | undefined;
260
272
  cetus?: import("../types").Lending | undefined;
273
+ afsui?: import("../types").Lending | undefined;
274
+ hasui?: import("../types").Lending | undefined;
275
+ vsui?: import("../types").Lending | undefined;
261
276
  }>;
262
277
  /**
263
278
  * Get user lending and spool information for specific pool.
@@ -140,6 +140,9 @@ export declare class ScallopUtils {
140
140
  apt?: number | undefined;
141
141
  sol?: number | undefined;
142
142
  cetus?: number | undefined;
143
+ afsui?: number | undefined;
144
+ hasui?: number | undefined;
145
+ vsui?: number | undefined;
143
146
  }>;
144
147
  /**
145
148
  * Convert apr to apy.
@@ -33,6 +33,9 @@ export declare const getMarketPools: (query: ScallopQuery, poolCoinNames?: Suppo
33
33
  apt?: MarketPool | undefined;
34
34
  sol?: MarketPool | undefined;
35
35
  cetus?: MarketPool | undefined;
36
+ afsui?: MarketPool | undefined;
37
+ hasui?: MarketPool | undefined;
38
+ vsui?: MarketPool | undefined;
36
39
  }>;
37
40
  /**
38
41
  * Get market pool data.
@@ -64,6 +67,9 @@ export declare const getMarketCollaterals: (query: ScallopQuery, collateralCoinN
64
67
  apt?: MarketCollateral | undefined;
65
68
  sol?: MarketCollateral | undefined;
66
69
  cetus?: MarketCollateral | undefined;
70
+ afsui?: MarketCollateral | undefined;
71
+ hasui?: MarketCollateral | undefined;
72
+ vsui?: MarketCollateral | undefined;
67
73
  }>;
68
74
  /**
69
75
  * Get market collateral data.
@@ -111,6 +117,9 @@ export declare const getCoinAmounts: (query: ScallopQuery, assetCoinNames?: Supp
111
117
  apt?: number | undefined;
112
118
  sol?: number | undefined;
113
119
  cetus?: number | undefined;
120
+ afsui?: number | undefined;
121
+ hasui?: number | undefined;
122
+ vsui?: number | undefined;
114
123
  }>;
115
124
  /**
116
125
  * Query owned coin amount.
@@ -138,6 +147,9 @@ export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames
138
147
  sapt?: number | undefined;
139
148
  ssol?: number | undefined;
140
149
  scetus?: number | undefined;
150
+ safsui?: number | undefined;
151
+ shasui?: number | undefined;
152
+ svsui?: number | undefined;
141
153
  }>;
142
154
  /**
143
155
  * Query owned market coin (sCoin) amount.
@@ -17,6 +17,9 @@ export declare const getLendings: (query: ScallopQuery, poolCoinNames?: SupportP
17
17
  apt?: Lending | undefined;
18
18
  sol?: Lending | undefined;
19
19
  cetus?: Lending | undefined;
20
+ afsui?: Lending | undefined;
21
+ hasui?: Lending | undefined;
22
+ vsui?: Lending | undefined;
20
23
  }>;
21
24
  /**
22
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.0",
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
  },
@@ -14,6 +14,9 @@ export const SUPPORT_POOLS = [
14
14
  'apt',
15
15
  'sol',
16
16
  'cetus',
17
+ 'afsui',
18
+ 'hasui',
19
+ 'vsui',
17
20
  ] as const;
18
21
 
19
22
  export const SUPPORT_COLLATERALS = [
@@ -25,6 +28,9 @@ export const SUPPORT_COLLATERALS = [
25
28
  'apt',
26
29
  'sol',
27
30
  'cetus',
31
+ 'afsui',
32
+ 'hasui',
33
+ 'vsui',
28
34
  ] as const;
29
35
 
30
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 = {
@@ -17,6 +18,9 @@ export const coinDecimals: SupportCoinDecimals = {
17
18
  apt: 8,
18
19
  sol: 8,
19
20
  cetus: 9,
21
+ afsui: 9,
22
+ hasui: 9,
23
+ vsui: 9,
20
24
  seth: 8,
21
25
  sbtc: 8,
22
26
  susdc: 6,
@@ -25,6 +29,9 @@ export const coinDecimals: SupportCoinDecimals = {
25
29
  sapt: 8,
26
30
  ssol: 8,
27
31
  scetus: 9,
32
+ safsui: 9,
33
+ shasui: 9,
34
+ svsui: 9,
28
35
  };
29
36
 
30
37
  export const assetCoins: AssetCoins = {
@@ -36,6 +43,9 @@ export const assetCoins: AssetCoins = {
36
43
  apt: 'apt',
37
44
  sol: 'sol',
38
45
  cetus: 'cetus',
46
+ afsui: 'afsui',
47
+ hasui: 'hasui',
48
+ vsui: 'vsui',
39
49
  };
40
50
 
41
51
  export const marketCoins: MarketCoins = {
@@ -47,6 +57,9 @@ export const marketCoins: MarketCoins = {
47
57
  sapt: 'sapt',
48
58
  ssol: 'ssol',
49
59
  scetus: 'scetus',
60
+ safsui: 'safsui',
61
+ shasui: 'shasui',
62
+ svsui: 'svsui',
50
63
  };
51
64
 
52
65
  export const stakeMarketCoins: StakeMarketCoins = {
@@ -70,6 +83,9 @@ export const coinIds: AssetCoinIds = {
70
83
  apt: '0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37',
71
84
  sol: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8',
72
85
  cetus: '0x06864a6f921804860930db6ddbe2e16acdf8504495ea7481637a1c8b9a8fe54b',
86
+ afsui: '0xf325ce1300e8dac124071d3152c5c5ee6174914f8bc2161e88329cf579246efc',
87
+ hasui: '0xbde4ba4c2e274a60ce15c1cfff9e5c42e41654ac8b6d906a57efa4bd3c29f47d',
88
+ vsui: '0x549e8b69270defbfafd4f94e17ec44cdbdd99820b33bda2278dea3b9a32d3f55',
73
89
  };
74
90
 
75
91
  export const wormholeCoinIds: WormholeCoinIds = {
@@ -80,3 +96,7 @@ export const wormholeCoinIds: WormholeCoinIds = {
80
96
  apt: '0x3a5143bb1196e3bcdfab6203d1683ae29edd26294fc8bfeafe4aaa9d2704df37',
81
97
  sol: '0xb7844e289a8410e50fb3ca48d69eb9cf29e27d223ef90353fe1bd8e27ff8f3f8',
82
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
  };