@scallop-io/sui-scallop-sdk 2.3.0-lst-x-oracle-alpha.9 → 2.3.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 (74) hide show
  1. package/dist/index.d.mts +1841 -1809
  2. package/dist/index.d.ts +1841 -1809
  3. package/dist/index.js +49 -2
  4. package/dist/index.mjs +15 -2
  5. package/package.json +8 -7
  6. package/src/builders/borrowIncentiveBuilder.ts +4 -4
  7. package/src/builders/coreBuilder.ts +86 -59
  8. package/src/builders/index.ts +2 -2
  9. package/src/builders/loyaltyProgramBuilder.ts +2 -2
  10. package/src/builders/oracles/index.ts +365 -114
  11. package/src/builders/oracles/pyth.ts +135 -0
  12. package/src/builders/referralBuilder.ts +4 -10
  13. package/src/builders/sCoinBuilder.ts +2 -2
  14. package/src/builders/spoolBuilder.ts +5 -8
  15. package/src/builders/vescaBuilder.ts +5 -5
  16. package/src/constants/common.ts +3 -0
  17. package/src/constants/index.ts +1 -1
  18. package/src/constants/queryKeys.ts +1 -1
  19. package/src/constants/rpc.ts +0 -1
  20. package/src/constants/testAddress.ts +99 -271
  21. package/src/constants/xoracle.ts +2 -8
  22. package/src/index.ts +1 -1
  23. package/src/models/index.ts +1 -2
  24. package/src/models/interface.ts +7 -7
  25. package/src/models/rateLimiter.ts +55 -0
  26. package/src/models/scallop.ts +2 -2
  27. package/src/models/scallopAddress.ts +7 -35
  28. package/src/models/scallopBuilder.ts +19 -12
  29. package/src/models/scallopClient.ts +47 -33
  30. package/src/models/scallopConstants.ts +3 -3
  31. package/src/models/scallopIndexer.ts +3 -4
  32. package/src/models/scallopQuery.ts +113 -57
  33. package/src/models/scallopQueryClient.ts +1 -1
  34. package/src/models/scallopSuiKit.ts +1 -1
  35. package/src/models/scallopUtils.ts +12 -7
  36. package/src/queries/borrowIncentiveQuery.ts +4 -3
  37. package/src/queries/coreQuery.ts +114 -186
  38. package/src/queries/index.ts +3 -4
  39. package/src/queries/loyaltyProgramQuery.ts +2 -2
  40. package/src/queries/ownerQuery.ts +32 -0
  41. package/src/queries/poolAddressesQuery.ts +1 -4
  42. package/src/queries/portfolioQuery.ts +68 -16
  43. package/src/queries/priceQuery.ts +2 -3
  44. package/src/queries/sCoinQuery.ts +2 -2
  45. package/src/queries/spoolQuery.ts +57 -74
  46. package/src/queries/vescaQuery.ts +3 -3
  47. package/src/queries/xOracleQuery.ts +4 -21
  48. package/src/types/address.ts +47 -98
  49. package/src/types/builder/core.ts +40 -15
  50. package/src/types/builder/index.ts +17 -1
  51. package/src/types/constant/enum.ts +64 -0
  52. package/src/types/constant/index.ts +1 -2
  53. package/src/types/constant/xOracle.ts +7 -10
  54. package/src/types/index.ts +1 -1
  55. package/src/types/query/core.ts +3 -0
  56. package/src/types/query/index.ts +1 -0
  57. package/src/types/query/sCoin.ts +1 -0
  58. package/src/{builders/utils.ts → utils/builder.ts} +1 -1
  59. package/src/utils/core.ts +18 -0
  60. package/src/utils/index.ts +5 -0
  61. package/src/utils/indexer.ts +47 -0
  62. package/src/{queries/utils.ts → utils/query.ts} +7 -25
  63. package/src/utils/util.ts +42 -0
  64. package/src/builders/oracles/error.ts +0 -18
  65. package/src/builders/oracles/oraclePackageRegistry.ts +0 -336
  66. package/src/builders/oracles/priceFeedUpdater.ts +0 -112
  67. package/src/builders/oracles/priceUpdateRequester.ts +0 -50
  68. package/src/builders/oracles/xOracleUpdateStrategy.ts +0 -214
  69. package/src/builders/oracles/xOracleUpdater.ts +0 -153
  70. package/src/constants/api.ts +0 -2
  71. package/src/models/utils.ts +0 -97
  72. package/src/types/builder/type.ts +0 -25
  73. package/src/types/constant/package.ts +0 -16
  74. /package/src/types/{util.ts → utils.ts} +0 -0
@@ -2,7 +2,7 @@ import { Transaction } from '@mysten/sui/transactions';
2
2
  import { SUI_CLOCK_OBJECT_ID } from '@mysten/sui/utils';
3
3
  import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
4
4
  import { getStakeAccounts } from '../queries/spoolQuery';
5
- import { requireSender } from './utils';
5
+ import { requireSender } from '../utils';
6
6
  import type { SuiAddressArg } from '@scallop-io/sui-kit';
7
7
  import type { TransactionResult } from '@mysten/sui/transactions';
8
8
  import type { ScallopBuilder } from 'src/models';
@@ -14,7 +14,7 @@ import type {
14
14
  SpoolTxBlock,
15
15
  ScallopTxBlock,
16
16
  SuiTxBlockWithSCoin,
17
- } from 'src/types/builder';
17
+ } from 'src/types';
18
18
 
19
19
  /**
20
20
  * Check and get stake account id from transaction block.
@@ -196,7 +196,7 @@ const generateSpoolNormalMethod: GenerateSpoolNormalMethod = ({
196
196
  *
197
197
  * @description
198
198
  * The quick methods are the same as the normal methods, but they will automatically
199
- * help users organize transaction blocks, include get stake account info, and transfer
199
+ * help users organize transaction blocks, including getting stake account info, and transferring
200
200
  * coins to the sender. So, they are all asynchronous methods.
201
201
  *
202
202
  * @param builder - Scallop builder instance.
@@ -273,7 +273,7 @@ const generateSpoolQuickMethod: GenerateSpoolQuickMethod = ({
273
273
  for (const account of stakeAccounts) {
274
274
  if (account.staked === 0) continue;
275
275
  const amountToUnstake = Math.min(amount, account.staked);
276
- const marketCoin = await txBlock.unstake(
276
+ const marketCoin = txBlock.unstake(
277
277
  account.id,
278
278
  amountToUnstake,
279
279
  stakeMarketCoinName
@@ -281,10 +281,7 @@ const generateSpoolQuickMethod: GenerateSpoolQuickMethod = ({
281
281
 
282
282
  // convert to new sCoin
283
283
  if (returnSCoin) {
284
- const sCoin = await txBlock.mintSCoin(
285
- stakeMarketCoinName,
286
- marketCoin
287
- );
284
+ const sCoin = txBlock.mintSCoin(stakeMarketCoinName, marketCoin);
288
285
  toTransfer.push(sCoin);
289
286
  } else {
290
287
  toTransfer.push(marketCoin);
@@ -4,9 +4,9 @@ import {
4
4
  Transaction,
5
5
  SuiTxBlock as SuiKitTxBlock,
6
6
  } from '@scallop-io/sui-kit';
7
- import { SCA_COIN_TYPE } from 'src/constants/common';
7
+ import { SCA_COIN_TYPE } from 'src/constants';
8
8
  import { ScallopBuilder } from 'src/models';
9
- import { getVeSca, getVeScas } from 'src/queries/vescaQuery';
9
+ import { getVeSca, getVeScas } from 'src/queries';
10
10
  import {
11
11
  requireSender,
12
12
  checkLockSca,
@@ -14,21 +14,21 @@ import {
14
14
  checkExtendLockAmount,
15
15
  checkRenewExpiredVeSca,
16
16
  checkVesca,
17
- } from './utils';
17
+ } from 'src/utils';
18
18
  import type {
19
19
  TransactionObjectArgument,
20
20
  SuiObjectArg,
21
21
  } from '@scallop-io/sui-kit';
22
22
  import type {
23
+ AddressesInterface,
23
24
  GenerateVeScaNormalMethod,
24
25
  GenerateVeScaQuickMethod,
25
26
  QuickMethodReturnType,
26
27
  ScallopTxBlock,
27
28
  SuiTxBlockWithVeScaNormalMethods,
28
29
  VeScaTxBlock,
29
- } from 'src/types/builder';
30
+ } from 'src/types';
30
31
  import { SuiObjectData } from '@mysten/sui/client';
31
- import { AddressesInterface } from 'src/types/address';
32
32
 
33
33
  /**
34
34
  * Check and get veSCA data from transaction block.
@@ -1,3 +1,6 @@
1
+ export const API_BASE_URL = 'https://sui.apis.scallop.io' as const;
2
+ export const SDK_API_BASE_URL = 'https://sdk.api.scallop.io' as const;
3
+
1
4
  export const IS_VE_SCA_TEST: boolean = false;
2
5
  export const USE_TEST_ADDRESS: boolean = false;
3
6
 
@@ -1,8 +1,8 @@
1
- export * from './api';
2
1
  export * from './cache';
3
2
  export * from './common';
4
3
  export * from './queryKeys';
5
4
  export * from './rpc';
6
5
  export * from './testAddress';
7
6
  export * from './vesca';
7
+ export * from './testAddress';
8
8
  export * from './xoracle';
@@ -11,7 +11,7 @@ export const queryKeys = {
11
11
  getPoolAddresses: () => ['api', 'getPoolAddresses'],
12
12
  getMarket: () => ['api', 'getMarket'],
13
13
  getSpools: () => ['api', 'getSpools'],
14
- getBorrowIncentivePool: () => ['api', 'getBorrowIncentivePools'],
14
+ getBorrowIncentivePools: () => ['api', 'getBorrowIncentivePools'],
15
15
  getTotalValueLocked: () => ['api', 'getTotalValueLocked'],
16
16
  },
17
17
 
@@ -2,7 +2,6 @@ import { getFullnodeUrl } from '@mysten/sui/client';
2
2
 
3
3
  export const RPC_PROVIDERS = [
4
4
  getFullnodeUrl('mainnet'),
5
- 'https://sui-mainnet.public.blastapi.io',
6
5
  'https://sui-mainnet-ca-2.cosmostation.io',
7
6
  'https://sui-mainnet-eu-4.cosmostation.io',
8
7
  'https://sui-mainnet-endpoint.blockvision.org',