@scallop-io/sui-scallop-sdk 1.3.3-alpha.2 → 1.3.4-alpha.1

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.
Files changed (38) hide show
  1. package/dist/constants/coinGecko.d.ts +2 -0
  2. package/dist/constants/index.d.ts +6 -0
  3. package/dist/constants/poolAddress.d.ts +5 -0
  4. package/dist/constants/pyth.d.ts +2 -0
  5. package/dist/index.js +189 -40
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +182 -40
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/models/scallopIndexer.d.ts +6 -0
  10. package/dist/models/scallopQuery.d.ts +10 -4
  11. package/dist/models/scallopUtils.d.ts +6 -1
  12. package/dist/queries/sCoinQuery.d.ts +1 -1
  13. package/dist/queries/spoolQuery.d.ts +1 -1
  14. package/dist/queries/vescaQuery.d.ts +2 -2
  15. package/dist/types/query/portfolio.d.ts +1 -1
  16. package/dist/types/query/spool.d.ts +1 -0
  17. package/dist/types/query/vesca.d.ts +1 -1
  18. package/dist/types/utils.d.ts +12 -0
  19. package/dist/utils/util.d.ts +2 -2
  20. package/package.json +1 -1
  21. package/src/builders/borrowIncentiveBuilder.ts +3 -2
  22. package/src/constants/coinGecko.ts +18 -0
  23. package/src/constants/index.ts +6 -0
  24. package/src/constants/poolAddress.ts +94 -0
  25. package/src/constants/pyth.ts +19 -0
  26. package/src/models/scallopClient.ts +3 -3
  27. package/src/models/scallopIndexer.ts +9 -0
  28. package/src/models/scallopQuery.ts +9 -0
  29. package/src/models/scallopUtils.ts +25 -1
  30. package/src/queries/coreQuery.ts +9 -8
  31. package/src/queries/portfolioQuery.ts +1 -0
  32. package/src/queries/spoolQuery.ts +1 -0
  33. package/src/queries/vescaQuery.ts +4 -6
  34. package/src/types/query/portfolio.ts +1 -0
  35. package/src/types/query/spool.ts +1 -0
  36. package/src/types/query/vesca.ts +1 -1
  37. package/src/types/utils.ts +13 -0
  38. package/src/utils/util.ts +2 -1
@@ -80,4 +80,10 @@ export declare class ScallopIndexer {
80
80
  borrowValueChangeRatio: number;
81
81
  supplyValueChangeRatio: number;
82
82
  }>;
83
+ /**
84
+ * Get coin price index data.
85
+ *
86
+ * @return price data.
87
+ */
88
+ getCoinPrice(poolCoinName: SupportPoolCoins): Promise<number>;
83
89
  }
@@ -179,9 +179,9 @@ export declare class ScallopQuery {
179
179
  getSpools(stakeMarketCoinNames?: SupportStakeMarketCoins[], indexer?: boolean): Promise<{
180
180
  susdc?: import("../types").Spool | undefined;
181
181
  sweth?: import("../types").Spool | undefined;
182
- ssui?: import("../types").Spool | undefined;
183
182
  swusdc?: import("../types").Spool | undefined;
184
183
  swusdt?: import("../types").Spool | undefined;
184
+ ssui?: import("../types").Spool | undefined;
185
185
  scetus?: import("../types").Spool | undefined;
186
186
  safsui?: import("../types").Spool | undefined;
187
187
  shasui?: import("../types").Spool | undefined;
@@ -223,9 +223,9 @@ export declare class ScallopQuery {
223
223
  getStakePools(stakeMarketCoinNames?: SupportStakeMarketCoins[]): Promise<{
224
224
  susdc?: import("../types").StakePool | undefined;
225
225
  sweth?: import("../types").StakePool | undefined;
226
- ssui?: import("../types").StakePool | undefined;
227
226
  swusdc?: import("../types").StakePool | undefined;
228
227
  swusdt?: import("../types").StakePool | undefined;
228
+ ssui?: import("../types").StakePool | undefined;
229
229
  scetus?: import("../types").StakePool | undefined;
230
230
  safsui?: import("../types").StakePool | undefined;
231
231
  shasui?: import("../types").StakePool | undefined;
@@ -255,9 +255,9 @@ export declare class ScallopQuery {
255
255
  getStakeRewardPools(stakeMarketCoinNames?: SupportStakeMarketCoins[]): Promise<{
256
256
  susdc?: import("../types").StakeRewardPool | undefined;
257
257
  sweth?: import("../types").StakeRewardPool | undefined;
258
- ssui?: import("../types").StakeRewardPool | undefined;
259
258
  swusdc?: import("../types").StakeRewardPool | undefined;
260
259
  swusdt?: import("../types").StakeRewardPool | undefined;
260
+ ssui?: import("../types").StakeRewardPool | undefined;
261
261
  scetus?: import("../types").StakeRewardPool | undefined;
262
262
  safsui?: import("../types").StakeRewardPool | undefined;
263
263
  shasui?: import("../types").StakeRewardPool | undefined;
@@ -437,7 +437,7 @@ export declare class ScallopQuery {
437
437
  * @param ownerAddress - The owner address.
438
438
  * @return All market sCoin amounts.
439
439
  */
440
- getSCoinAmounts(sCoinNames?: SupportSCoin[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<"susdc" | "sweth" | "ssui" | "swusdc" | "swusdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssbeth" | "ssca" | "swsol" | "swbtc", number>>>;
440
+ getSCoinAmounts(sCoinNames?: SupportSCoin[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<"susdc" | "ssbeth" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca", number>>>;
441
441
  /**
442
442
  * Get sCoin amount.
443
443
  *
@@ -465,4 +465,10 @@ export declare class ScallopQuery {
465
465
  * Check if asset is an isolated asset
466
466
  */
467
467
  isIsolatedAsset(assetCoinName: SupportAssetCoins): Promise<boolean>;
468
+ /**
469
+ * Get pool coin price from indexer
470
+ * @param coinName
471
+ * @returns price data
472
+ */
473
+ getCoinPriceByIndexer(poolName: SupportPoolCoins): Promise<number>;
468
474
  }
@@ -1,7 +1,7 @@
1
1
  import { SuiKit } from '@scallop-io/sui-kit';
2
2
  import { ScallopAddress } from './scallopAddress';
3
3
  import { ScallopCache } from './scallopCache';
4
- import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
4
+ import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams, SupportSuiBridgeCoins, SupportWormholeCoins, PoolAddressInfo } from '../types';
5
5
  import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
6
6
  /**
7
7
  * @description
@@ -214,4 +214,9 @@ export declare class ScallopUtils {
214
214
  * @return New unlock at in seconds timestamp.
215
215
  */
216
216
  getUnlockAt(extendLockPeriodInDay?: number, unlockAtInMillisTimestamp?: number): number;
217
+ /**
218
+ * Get detailed contract address and price id information for supported pool in Scallop
219
+ * @returns Supported pool informations
220
+ */
221
+ getSupportedPoolAddresses(): PoolAddressInfo[];
217
222
  }
@@ -19,7 +19,7 @@ export declare const getSCoinTotalSupply: ({ utils, }: {
19
19
  */
20
20
  export declare const getSCoinAmounts: ({ utils, }: {
21
21
  utils: ScallopUtils;
22
- }, sCoinNames?: SupportSCoin[], ownerAddress?: string) => Promise<OptionalKeys<Record<"susdc" | "sweth" | "ssui" | "swusdc" | "swusdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssbeth" | "ssca" | "swsol" | "swbtc", number>>>;
22
+ }, sCoinNames?: SupportSCoin[], ownerAddress?: string) => Promise<OptionalKeys<Record<"susdc" | "ssbeth" | "sweth" | "swbtc" | "swusdc" | "swusdt" | "ssui" | "swsol" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca", number>>>;
23
23
  /**
24
24
  * Query owned sCoin amount.
25
25
  *
@@ -11,9 +11,9 @@ import type { MarketPool, Spool, StakePool, StakeRewardPool, StakeAccounts, Supp
11
11
  export declare const getSpools: (query: ScallopQuery, stakeMarketCoinNames?: SupportStakeMarketCoins[], indexer?: boolean) => Promise<{
12
12
  susdc?: Spool | undefined;
13
13
  sweth?: Spool | undefined;
14
- ssui?: Spool | undefined;
15
14
  swusdc?: Spool | undefined;
16
15
  swusdt?: Spool | undefined;
16
+ ssui?: Spool | undefined;
17
17
  scetus?: Spool | undefined;
18
18
  safsui?: Spool | undefined;
19
19
  shasui?: Spool | undefined;
@@ -18,7 +18,7 @@ export declare const getVescaKeys: (utils: ScallopUtils, ownerAddress?: string)
18
18
  */
19
19
  export declare const getVeScas: ({ utils, }: {
20
20
  utils: ScallopUtils;
21
- }, ownerAddress?: string, excludeEmpty?: boolean) => Promise<Vesca[]>;
21
+ }, ownerAddress: string, excludeEmpty?: boolean) => Promise<Vesca[]>;
22
22
  /**
23
23
  * Get veSca data.
24
24
  *
@@ -27,7 +27,7 @@ export declare const getVeScas: ({ utils, }: {
27
27
  * @param ownerAddress - The owner address.
28
28
  * @returns Vesca data.
29
29
  */
30
- export declare const getVeSca: (utils: ScallopUtils, veScaKey?: string | SuiObjectData, ownerAddress?: string) => Promise<Vesca | undefined>;
30
+ export declare const getVeSca: (utils: ScallopUtils, veScaKey: string | SuiObjectData) => Promise<Vesca | undefined>;
31
31
  /**
32
32
  * Get veSCA treasury informations
33
33
  * @param query
@@ -6,7 +6,7 @@ type OptionalKeys<T> = {
6
6
  };
7
7
  export type Lendings = OptionalKeys<Record<SupportPoolCoins, Lending>>;
8
8
  export type ObligationAccounts = OptionalKeys<Record<string, ObligationAccount>>;
9
- export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'coinDecimal' | 'coinPrice' | 'conversionRate' | 'isIsolated'> & Pick<Spool, 'marketCoinPrice'>> & {
9
+ export type Lending = Required<Pick<MarketPool, 'coinName' | 'symbol' | 'coinType' | 'marketCoinType' | 'sCoinType' | 'coinDecimal' | 'coinPrice' | 'conversionRate' | 'isIsolated'> & Pick<Spool, 'marketCoinPrice'>> & {
10
10
  supplyApr: number;
11
11
  supplyApy: number;
12
12
  rewardApr: number;
@@ -9,6 +9,7 @@ export type Spool = {
9
9
  coinType: string;
10
10
  marketCoinType: string;
11
11
  rewardCoinType: string;
12
+ sCoinType: string;
12
13
  coinDecimal: number;
13
14
  rewardCoinDecimal: number;
14
15
  coinPrice: number;
@@ -3,7 +3,7 @@ export type Vesca = {
3
3
  id: string;
4
4
  keyId: string;
5
5
  keyObject?: SuiObjectRef;
6
- object?: SuiObjectRef;
6
+ object: SuiObjectRef;
7
7
  lockedScaAmount: string;
8
8
  lockedScaCoin: number;
9
9
  currentVeScaBalance: number;
@@ -7,3 +7,15 @@ export type PriceMap = Map<SupportAssetCoins, {
7
7
  price: number;
8
8
  publishTime: number;
9
9
  }>;
10
+ export type PoolAddressInfo = {
11
+ name: string;
12
+ coingeckoId: string;
13
+ decimal: number;
14
+ pythFeedId: string;
15
+ lendingPoolAddress: string;
16
+ collateralPoolAddress: string;
17
+ sCoinAddress: string | undefined;
18
+ marketCoinAddress: string;
19
+ coinAddress: string;
20
+ sCoinName: string | undefined;
21
+ };
@@ -1,7 +1,7 @@
1
1
  import type { PriceFeed } from '@pythnetwork/pyth-sui-js';
2
2
  import type { ScallopAddress } from '../models';
3
- import type { SupportAssetCoins, SupportCoins, SupportMarketCoins, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
4
- export declare const isMarketCoin: (coinName: SupportCoins) => coinName is SupportMarketCoins;
3
+ import type { SupportAssetCoins, SupportCoins, SupportMarketCoins, SupportSCoin, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
4
+ export declare const isMarketCoin: (coinName: SupportCoins) => coinName is SupportMarketCoins | SupportSCoin;
5
5
  export declare const isSuiBridgeAsset: (coinName: any) => coinName is SupportSuiBridgeCoins;
6
6
  export declare const isWormholeAsset: (coinName: any) => coinName is SupportWormholeCoins;
7
7
  export declare const parseAssetSymbol: (coinName: SupportCoins) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "1.3.3-alpha.2",
3
+ "version": "1.3.4-alpha.1",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -255,13 +255,14 @@ const generateBorrowIncentiveQuickMethod: GenerateBorrowIncentiveQuickMethod =
255
255
  const bindedVeScaKey =
256
256
  await builder.query.getBindedVeScaKey(obligationArg);
257
257
 
258
- if ((veScaKey && veScaKey !== bindedVeScaKey) || !bindedVeScaKey) {
258
+ const _veScaKey = bindedVeScaKey ?? veScaKey;
259
+ if (!_veScaKey) {
259
260
  txBlock.stakeObligation(obligationArg, obligationKeyArg);
260
261
  } else {
261
262
  txBlock.stakeObligationWithVesca(
262
263
  obligationArg,
263
264
  obligationKeyArg,
264
- bindedVeScaKey
265
+ _veScaKey
265
266
  );
266
267
  }
267
268
  }
@@ -0,0 +1,18 @@
1
+ import { SupportPoolCoins } from 'src/types/constant/common';
2
+
3
+ export const COIN_GECKGO_IDS: Record<SupportPoolCoins, string> = {
4
+ usdc: 'usdc-coin',
5
+ sbeth: 'ethereum',
6
+ weth: 'ethereum',
7
+ wbtc: 'bitcoin',
8
+ wusdc: 'usdc-coin',
9
+ wusdt: 'tether',
10
+ sui: 'sui',
11
+ wapt: 'aptos',
12
+ wsol: 'solana',
13
+ cetus: 'cetus-protocol',
14
+ afsui: 'sui',
15
+ hasui: 'sui',
16
+ vsui: 'sui',
17
+ sca: 'scallop-2',
18
+ };
@@ -1,6 +1,12 @@
1
+ export * from './cache';
2
+ export * from './coinGecko';
1
3
  export * from './common';
2
4
  export * from './enum';
3
5
  export * from './flashloan';
6
+ export * from './poolAddress';
7
+ export * from './pyth';
4
8
  export * from './queryKeys';
9
+ export * from './testAddress';
10
+ export * from './tokenBucket';
5
11
  export * from './vesca';
6
12
  export * from './testAddress';
@@ -0,0 +1,94 @@
1
+ import { SupportPoolCoins } from 'src/types';
2
+
3
+ export const POOL_ADDRESSES: Record<
4
+ SupportPoolCoins,
5
+ {
6
+ lendingPoolAddress: string;
7
+ collateralPoolAddress: string;
8
+ }
9
+ > = {
10
+ usdc: {
11
+ lendingPoolAddress:
12
+ '0xd3be98bf540f7603eeb550c0c0a19dbfc78822f25158b5fa84ebd9609def415f',
13
+ collateralPoolAddress:
14
+ '0x8f0d529ba179c5b3d508213003eab813aaae31f78226099639b9a69d1aec17af',
15
+ },
16
+ sbeth: {
17
+ lendingPoolAddress:
18
+ '0x5f08c4f71d56dd3342c452cc70ffc47f2f4180146d821941b0b9c04761bb42e7',
19
+ collateralPoolAddress:
20
+ '0xce0549a1cbe952e734f56646988e6b02bbae14667889a60e24d0d03540a6119f',
21
+ },
22
+ weth: {
23
+ lendingPoolAddress:
24
+ '0xc8fcdff48efc265740ae0b74aae3faccae9ec00034039a113f3339798035108c',
25
+ collateralPoolAddress:
26
+ '0xad7ced91ed6e7f2b81805561eee27fa6f3e72fdae561077334c7248583db4dbf',
27
+ },
28
+ wbtc: {
29
+ lendingPoolAddress:
30
+ '0x65cc08a5aca0a0b8d72e1993ded8d145f06dd102fd0d8f285b92934faed564ab',
31
+ collateralPoolAddress:
32
+ '0x1aa4e5cf743cd797b4eb8bf1e614f80ae2cf556ced426cddaaf190ffcd0e59c3',
33
+ },
34
+ wusdc: {
35
+ lendingPoolAddress:
36
+ '0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8',
37
+ collateralPoolAddress:
38
+ '0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb',
39
+ },
40
+ wusdt: {
41
+ lendingPoolAddress:
42
+ '0xfbc056f126dd35adc1f8fe985e2cedc8010e687e8e851e1c5b99fdf63cd1c879',
43
+ collateralPoolAddress:
44
+ '0x2260cb5b24929dd20a1742f37a61ff3ce4fde5cdb023e2d3ce2e0ce2d90719e3',
45
+ },
46
+ sui: {
47
+ lendingPoolAddress:
48
+ '0x9c9077abf7a29eebce41e33addbcd6f5246a5221dd733e56ea0f00ae1b25c9e8',
49
+ collateralPoolAddress:
50
+ '0x75aacfb7dcbf92ee0111fc1bf975b12569e4ba632e81ed7ae5ac090d40cd3acb',
51
+ },
52
+ wapt: {
53
+ lendingPoolAddress:
54
+ '0xca8c14a24e0c32b198eaf479a3317461e3cc339097ce88eaf296a15df8dcfdf5',
55
+ collateralPoolAddress:
56
+ '0xde33f9ac5bb0ed34598da4e64b4983832716ced65f172fbf267bcfe859c4ad9c',
57
+ },
58
+ wsol: {
59
+ lendingPoolAddress:
60
+ '0x985682c42984cdfb03f9ff7d8923344c2fe096b1ae4b82ea17721af19d22a21f',
61
+ collateralPoolAddress:
62
+ '0xdc1cc2c371a043ae8e3c3fe2d013c35f1346960b7dbb4c072982c5b794ed144f',
63
+ },
64
+ cetus: {
65
+ lendingPoolAddress:
66
+ '0xc09858f60e74a1b671635bec4e8a2c84a0ff313eb87f525fba3258e88c6b6282',
67
+ collateralPoolAddress:
68
+ '0xe363967e29b7b9c1245d6d46d63e719de8f90b37e3358c545b55d945ea0b676a',
69
+ },
70
+ afsui: {
71
+ lendingPoolAddress:
72
+ '0x9b942a24ce390b7f5016d34a0217057bf9487b92aa6d7cc9894271dbbe62471a',
73
+ collateralPoolAddress:
74
+ '0xe5e56f5c0e3072760b21f9d49a5cc793f37d736c412a9065c16e1265c74e6341',
75
+ },
76
+ hasui: {
77
+ lendingPoolAddress:
78
+ '0x7ebc607f6bdeb659fb6506cb91c5cc1d47bb365cfd5d2e637ea765346ec84ed4',
79
+ collateralPoolAddress:
80
+ '0xad9ed40d6486e4c26cec7370dffce8dc4821eb79178250b5938a34ccafd61e6d',
81
+ },
82
+ vsui: {
83
+ lendingPoolAddress:
84
+ '0xda9257c0731d8822e8a438ebced13415850d705b779c79958dcf2aeb21fcb43d',
85
+ collateralPoolAddress:
86
+ '0x4435e8b8ec2a04094d863aa52deb6ab6f8f47ed8778f4d9f1b27afc4a6e85f1e',
87
+ },
88
+ sca: {
89
+ lendingPoolAddress:
90
+ '0x6fc7d4211fc7018b6c75e7b908b88f2e0536443239804a3d32af547637bd28d7',
91
+ collateralPoolAddress:
92
+ '0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31',
93
+ },
94
+ };
@@ -1,6 +1,25 @@
1
+ import { SupportPoolCoins } from 'src/types';
2
+
1
3
  export const PYTH_ENDPOINTS: {
2
4
  [k in 'mainnet' | 'testnet']: string[];
3
5
  } = {
4
6
  testnet: ['https://hermes-beta.pyth.network'],
5
7
  mainnet: ['https://hermes.pyth.network', 'https://scallop.rpc.p2p.world'],
6
8
  };
9
+
10
+ export const PYTH_FEED_IDS: Record<SupportPoolCoins, string> = {
11
+ usdc: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
12
+ sbeth: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
13
+ weth: 'ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace',
14
+ wbtc: 'e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43',
15
+ wusdc: 'eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a',
16
+ wusdt: '2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b',
17
+ sui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
18
+ wapt: '03ae4db29ed4ae33d323568895aa00337e658e348b37509f5372ae51f0af00d5',
19
+ wsol: 'ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d',
20
+ cetus: 'e5b274b2611143df055d6e7cd8d93fe1961716bcd4dca1cad87a83bc1e78c1ef',
21
+ afsui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
22
+ hasui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
23
+ vsui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
24
+ sca: '7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc',
25
+ };
@@ -518,7 +518,7 @@ export class ScallopClient {
518
518
  );
519
519
  txBlock.transferObjects([coin], sender);
520
520
  if (sign && availableStake) {
521
- await txBlock.stakeObligationQuick(obligationId, obligationKey);
521
+ await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKey);
522
522
  }
523
523
 
524
524
  if (sign) {
@@ -560,7 +560,7 @@ export class ScallopClient {
560
560
  }
561
561
  await txBlock.repayQuick(amount, poolCoinName, obligationId);
562
562
  if (sign && availableStake) {
563
- await txBlock.stakeObligationQuick(obligationId, obligationKey);
563
+ await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKey);
564
564
  }
565
565
 
566
566
  if (sign) {
@@ -902,7 +902,7 @@ export class ScallopClient {
902
902
  const sender = walletAddress || this.walletAddress;
903
903
  txBlock.setSender(sender);
904
904
 
905
- await txBlock.stakeObligationQuick(obligationId, obligationKeyId);
905
+ await txBlock.stakeObligationWithVeScaQuick(obligationId, obligationKeyId);
906
906
 
907
907
  if (sign) {
908
908
  return (await this.suiKit.signAndSendTxn(
@@ -264,4 +264,13 @@ export class ScallopIndexer {
264
264
  throw Error('Failed to getTotalValueLocked.');
265
265
  }
266
266
  }
267
+
268
+ /**
269
+ * Get coin price index data.
270
+ *
271
+ * @return price data.
272
+ */
273
+ public async getCoinPrice(poolCoinName: SupportPoolCoins): Promise<number> {
274
+ return (await this.getMarketPool(poolCoinName))?.coinPrice ?? 0;
275
+ }
267
276
  }
@@ -755,4 +755,13 @@ export class ScallopQuery {
755
755
  public async isIsolatedAsset(assetCoinName: SupportAssetCoins) {
756
756
  return isIsolatedAsset(this.utils, assetCoinName);
757
757
  }
758
+
759
+ /**
760
+ * Get pool coin price from indexer
761
+ * @param coinName
762
+ * @returns price data
763
+ */
764
+ public async getCoinPriceByIndexer(poolName: SupportPoolCoins) {
765
+ return this.indexer.getCoinPrice(poolName);
766
+ }
758
767
  }
@@ -18,6 +18,8 @@ import {
18
18
  SUPPORT_SCOIN,
19
19
  sCoinIds,
20
20
  suiBridgeCoins,
21
+ COIN_GECKGO_IDS,
22
+ POOL_ADDRESSES,
21
23
  } from '../constants';
22
24
  import { getPythPrice, queryObligation } from '../queries';
23
25
  import {
@@ -28,7 +30,7 @@ import {
28
30
  isSuiBridgeAsset,
29
31
  isWormholeAsset,
30
32
  } from '../utils';
31
- import { PYTH_ENDPOINTS } from 'src/constants/pyth';
33
+ import { PYTH_ENDPOINTS, PYTH_FEED_IDS } from 'src/constants/pyth';
32
34
  import { ScallopCache } from './scallopCache';
33
35
  import { DEFAULT_CACHE_OPTIONS } from 'src/constants/cache';
34
36
  import type {
@@ -45,6 +47,7 @@ import type {
45
47
  ScallopUtilsInstanceParams,
46
48
  SupportSuiBridgeCoins,
47
49
  SupportWormholeCoins,
50
+ PoolAddressInfo,
48
51
  } from '../types';
49
52
  import { queryKeys } from 'src/constants';
50
53
  import type { SuiObjectArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
@@ -681,4 +684,25 @@ export class ScallopUtils {
681
684
  }
682
685
  return findClosestUnlockRound(newUnlockAtInSecondTimestamp);
683
686
  }
687
+
688
+ /**
689
+ * Get detailed contract address and price id information for supported pool in Scallop
690
+ * @returns Supported pool informations
691
+ */
692
+ public getSupportedPoolAddresses(): PoolAddressInfo[] {
693
+ return SUPPORT_POOLS.map((poolName) => {
694
+ const sCoinName = this.parseSCoinName(poolName)!;
695
+ return {
696
+ name: this.parseSymbol(poolName),
697
+ coingeckoId: COIN_GECKGO_IDS[poolName],
698
+ decimal: coinDecimals[poolName],
699
+ pythFeedId: PYTH_FEED_IDS[poolName],
700
+ ...POOL_ADDRESSES[poolName],
701
+ sCoinAddress: sCoinIds[sCoinName],
702
+ marketCoinAddress: this.parseMarketCoinType(poolName),
703
+ coinAddress: this.parseCoinType(poolName),
704
+ sCoinName: sCoinName ? this.parseSymbol(sCoinName) : undefined,
705
+ };
706
+ });
707
+ }
684
708
  }
@@ -741,6 +741,9 @@ export const getObligations = async (
741
741
  filter: {
742
742
  StructType: `${protocolObjectId}::obligation::ObligationKey`,
743
743
  },
744
+ options: {
745
+ showContent: true,
746
+ },
744
747
  cursor: nextCursor,
745
748
  limit: 10,
746
749
  });
@@ -759,17 +762,15 @@ export const getObligations = async (
759
762
  }
760
763
  } while (hasNextPage);
761
764
 
762
- const keyObjectIds: string[] = keyObjectsResponse
763
- .map((ref: any) => ref?.data?.objectId)
764
- .filter((id: any) => id !== undefined);
765
- const keyObjects = await address.cache.queryGetObjects(keyObjectIds);
765
+ const keyObjects = keyObjectsResponse.filter((ref) => !!ref.data);
766
766
 
767
767
  const obligations: Obligation[] = [];
768
768
  await Promise.allSettled(
769
- keyObjects.map(async (keyObject) => {
770
- const keyId = keyObject.objectId;
771
- if (keyObject.content && 'fields' in keyObject.content) {
772
- const fields = keyObject.content.fields as any;
769
+ keyObjects.map(async ({ data }) => {
770
+ const keyId = data?.objectId;
771
+ const content = data?.content;
772
+ if (keyId && content && 'fields' in content) {
773
+ const fields = content.fields as any;
773
774
  const obligationId = String(fields.ownership.fields.of);
774
775
  const locked = await getObligationLocked(address.cache, obligationId);
775
776
  obligations.push({ id: obligationId, keyId, locked });
@@ -239,6 +239,7 @@ export const getLending = async (
239
239
  symbol: query.utils.parseSymbol(poolCoinName),
240
240
  coinType: query.utils.parseCoinType(poolCoinName),
241
241
  marketCoinType: query.utils.parseMarketCoinType(poolCoinName),
242
+ sCoinType: marketPool?.sCoinType ?? '',
242
243
  coinDecimal: coinDecimal,
243
244
  coinPrice: coinPrice ?? 0,
244
245
  conversionRate: marketPool?.conversionRate ?? 1,
@@ -210,6 +210,7 @@ export const getSpool = async (
210
210
  rewardCoinType: isMarketCoin(rewardCoinName)
211
211
  ? query.utils.parseMarketCoinType(rewardCoinName)
212
212
  : query.utils.parseCoinType(rewardCoinName),
213
+ sCoinType: marketPool.sCoinType,
213
214
  coinDecimal: query.utils.getCoinDecimal(coinName),
214
215
  rewardCoinDecimal: query.utils.getCoinDecimal(rewardCoinName),
215
216
  coinPrice: coinPrices?.[coinName] ?? 0,
@@ -72,7 +72,7 @@ export const getVeScas = async (
72
72
  }: {
73
73
  utils: ScallopUtils;
74
74
  },
75
- ownerAddress?: string,
75
+ ownerAddress: string,
76
76
  excludeEmpty?: boolean
77
77
  ) => {
78
78
  const keyObjectDatas = await getVescaKeys(utils, ownerAddress);
@@ -88,7 +88,7 @@ export const getVeScas = async (
88
88
 
89
89
  const result = veScas
90
90
  .filter(Boolean)
91
- .sort((a, b) => b!.currentVeScaBalance - a!.currentVeScaBalance);
91
+ .sort((a, b) => b.currentVeScaBalance - a.currentVeScaBalance);
92
92
 
93
93
  if (excludeEmpty) {
94
94
  return result.filter((v) => v.lockedScaAmount !== '0');
@@ -113,11 +113,9 @@ type SuiObjectRefType = zod.infer<typeof SuiObjectRefZod>;
113
113
  */
114
114
  export const getVeSca = async (
115
115
  utils: ScallopUtils,
116
- veScaKey?: string | SuiObjectData,
117
- ownerAddress?: string
116
+ veScaKey: string | SuiObjectData
118
117
  ) => {
119
118
  const tableId = utils.address.get(`vesca.tableId`);
120
- veScaKey = veScaKey || (await getVescaKeys(utils, ownerAddress))[0];
121
119
 
122
120
  if (!veScaKey) return undefined;
123
121
  if (typeof veScaKey === 'object') {
@@ -168,7 +166,7 @@ export const getVeSca = async (
168
166
  lockedScaCoin,
169
167
  currentVeScaBalance,
170
168
  unlockAt: BigNumber(dynamicFields.unlock_at * 1000).toNumber(),
171
- } as Vesca;
169
+ };
172
170
  }
173
171
 
174
172
  return vesca;
@@ -22,6 +22,7 @@ export type Lending = Required<
22
22
  | 'symbol'
23
23
  | 'coinType'
24
24
  | 'marketCoinType'
25
+ | 'sCoinType'
25
26
  | 'coinDecimal'
26
27
  | 'coinPrice'
27
28
  | 'conversionRate'
@@ -12,6 +12,7 @@ export type Spool = {
12
12
  coinType: string;
13
13
  marketCoinType: string;
14
14
  rewardCoinType: string;
15
+ sCoinType: string;
15
16
  coinDecimal: number;
16
17
  rewardCoinDecimal: number;
17
18
  coinPrice: number;
@@ -4,7 +4,7 @@ export type Vesca = {
4
4
  id: string;
5
5
  keyId: string;
6
6
  keyObject?: SuiObjectRef;
7
- object?: SuiObjectRef;
7
+ object: SuiObjectRef;
8
8
  lockedScaAmount: string;
9
9
  lockedScaCoin: number;
10
10
  currentVeScaBalance: number;
@@ -13,3 +13,16 @@ export type PriceMap = Map<
13
13
  publishTime: number;
14
14
  }
15
15
  >;
16
+
17
+ export type PoolAddressInfo = {
18
+ name: string;
19
+ coingeckoId: string;
20
+ decimal: number;
21
+ pythFeedId: string;
22
+ lendingPoolAddress: string;
23
+ collateralPoolAddress: string;
24
+ sCoinAddress: string | undefined;
25
+ marketCoinAddress: string;
26
+ coinAddress: string;
27
+ sCoinName: string | undefined;
28
+ };
package/src/utils/util.ts CHANGED
@@ -14,6 +14,7 @@ import type {
14
14
  SupportAssetCoins,
15
15
  SupportCoins,
16
16
  SupportMarketCoins,
17
+ SupportSCoin,
17
18
  SupportSuiBridgeCoins,
18
19
  SupportWormholeCoins,
19
20
  } from '../types';
@@ -30,7 +31,7 @@ const COIN_SET = Array.from(
30
31
 
31
32
  export const isMarketCoin = (
32
33
  coinName: SupportCoins
33
- ): coinName is SupportMarketCoins => {
34
+ ): coinName is SupportMarketCoins | SupportSCoin => {
34
35
  const assetCoinName = coinName.slice(1).toLowerCase() as SupportAssetCoins;
35
36
  return (
36
37
  coinName.charAt(0).toLowerCase() === 's' && COIN_SET.includes(assetCoinName)