@scallop-io/sui-scallop-sdk 2.3.0-lst-x-oracle-alpha.5 → 2.3.0-lst-x-oracle-alpha.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.3.0-lst-x-oracle-alpha.5",
3
+ "version": "2.3.0-lst-x-oracle-alpha.7",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -13,7 +13,7 @@ import type {
13
13
  SuiTxBlockWithBorrowIncentiveNormalMethods,
14
14
  BorrowIncentiveTxBlock,
15
15
  ScallopTxBlock,
16
- } from 'src/types';
16
+ } from 'src/types/builder';
17
17
  import { OLD_BORROW_INCENTIVE_PROTOCOL_ID } from 'src/constants/common';
18
18
  import { getObligationLocked, getObligations } from 'src/queries/coreQuery';
19
19
 
@@ -15,7 +15,7 @@ import type {
15
15
  ScallopTxBlock,
16
16
  NestedResult,
17
17
  SuiTxBlockWithSpool,
18
- } from 'src/types';
18
+ } from 'src/types/builder';
19
19
 
20
20
  /**
21
21
  * Check and get Obligation information from transaction block.
@@ -7,7 +7,7 @@ import {
7
7
  LoyaltyProgramTxBlock,
8
8
  ScallopTxBlock,
9
9
  SuiTxBlockWithLoyaltyProgramNormalMethods,
10
- } from 'src/types';
10
+ } from 'src/types/builder';
11
11
  import { requireSender } from './utils';
12
12
 
13
13
  const generateLoyaltyProgramNormalMethod: GenerateLoyaltyProgramNormalMethod =
@@ -10,7 +10,7 @@ import {
10
10
  } from './priceFeedUpdater';
11
11
  import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
12
12
  import type { ScallopBuilder } from 'src/models';
13
- import type { SupportOracleType, xOracleRuleType } from 'src/types';
13
+ import type { SupportOracleType, xOracleRuleType } from 'src/types/constant';
14
14
  import { PriceUpdateRequester } from './priceUpdateRequester';
15
15
  import { UnsupportedOracleError } from './error';
16
16
 
@@ -5,11 +5,10 @@ import {
5
5
  BasePackage,
6
6
  OracleLst,
7
7
  OracleLstConfig,
8
- SupportedOracleSuiLst,
9
8
  SupportOracleLst,
10
- SupportOracleType,
11
- } from 'src/types';
9
+ } from 'src/types/address';
12
10
  import { UnsupportedOracleError } from './error';
11
+ import { SupportedOracleSuiLst, SupportOracleType } from 'src/types/constant';
13
12
 
14
13
  export type XOraclePackages = {
15
14
  xOraclePackageId: string;
@@ -4,7 +4,7 @@ import {
4
4
  } from '@pythnetwork/pyth-sui-js';
5
5
  import { SuiTxBlock } from '@scallop-io/sui-kit';
6
6
  import { ScallopBuilder } from 'src/models';
7
- import { SupportOracleType } from 'src/types';
7
+ import { SupportOracleType } from 'src/types/constant';
8
8
 
9
9
  type PythPriceFeedUpdateOptions = {
10
10
  usePythPullModel: boolean;
@@ -8,7 +8,7 @@ import {
8
8
  SupportedOracleSuiLst,
9
9
  SupportOracleType,
10
10
  xOracleRuleType,
11
- } from 'src/types';
11
+ } from 'src/types/constant';
12
12
  import { UnsupportedLstOracleError } from './error';
13
13
 
14
14
  export interface IXOracleUpdateStrategy<
@@ -1,5 +1,5 @@
1
1
  import { SuiTxBlock, TransactionArgument } from '@scallop-io/sui-kit';
2
- import { SupportOracleType, xOracleRuleType } from 'src/types';
2
+ import { SupportOracleType, xOracleRuleType } from 'src/types/constant';
3
3
  import { SUPPORT_SUI_LST } from 'src/constants/xoracle';
4
4
  import { IOraclePackageRegistry } from './oraclePackageRegistry';
5
5
  import {
@@ -1,5 +1,5 @@
1
1
  import { ScallopBuilder } from 'src/models';
2
- import { ScallopTxBlock } from 'src/types';
2
+ import { ScallopTxBlock } from 'src/types/builder';
3
3
  import {
4
4
  SUI_CLOCK_OBJECT_ID,
5
5
  SuiTxBlock as SuiKitTxBlock,
@@ -8,7 +8,7 @@ import {
8
8
  ScallopTxBlock,
9
9
  SuiTxBlockWithSCoinNormalMethods,
10
10
  sCoinPkgIds,
11
- } from 'src/types';
11
+ } from 'src/types/builder';
12
12
  import { requireSender } from './utils';
13
13
 
14
14
  const generateSCoinNormalMethod: GenerateSCoinNormalMethod = ({
@@ -14,7 +14,7 @@ import type {
14
14
  SpoolTxBlock,
15
15
  ScallopTxBlock,
16
16
  SuiTxBlockWithSCoin,
17
- } from 'src/types';
17
+ } from 'src/types/builder';
18
18
 
19
19
  /**
20
20
  * Check and get stake account id from transaction block.
@@ -20,15 +20,15 @@ import type {
20
20
  SuiObjectArg,
21
21
  } from '@scallop-io/sui-kit';
22
22
  import type {
23
- AddressesInterface,
24
23
  GenerateVeScaNormalMethod,
25
24
  GenerateVeScaQuickMethod,
26
25
  QuickMethodReturnType,
27
26
  ScallopTxBlock,
28
27
  SuiTxBlockWithVeScaNormalMethods,
29
28
  VeScaTxBlock,
30
- } from 'src/types';
29
+ } from 'src/types/builder';
31
30
  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.
package/src/index.ts CHANGED
@@ -10,3 +10,4 @@ export {
10
10
  ScallopIndexer,
11
11
  ScallopUtils,
12
12
  } from './models';
13
+ export * from './types';
@@ -43,7 +43,7 @@ import {
43
43
  ScallopIndexer,
44
44
  ScallopAddress,
45
45
  } from 'src/models';
46
- import { CoinPrices, OptionalKeys } from 'src/types';
46
+ import { CoinPrices, OptionalKeys } from 'src/types/util';
47
47
 
48
48
  /**
49
49
  * Query market data.
@@ -2,7 +2,7 @@ import { SuiObjectData } from '@mysten/sui/client';
2
2
  import BigNumber from 'bignumber.js';
3
3
  import { MAX_LOCK_DURATION } from 'src/constants/vesca';
4
4
  import { ScallopQuery } from 'src/models';
5
- import { LoyaltyProgramInfo, VeScaLoyaltyProgramInfo } from 'src/types';
5
+ import { LoyaltyProgramInfo, VeScaLoyaltyProgramInfo } from 'src/types/query';
6
6
  import { z as zod } from 'zod';
7
7
 
8
8
  const rewardPoolFieldsZod = zod
@@ -1,5 +1,7 @@
1
1
  import { getFullnodeUrl, SuiClient, SuiParsedData } from '@mysten/sui/client';
2
- import { AddressesInterface, OptionalKeys, PoolAddress } from 'src/types';
2
+ import { AddressesInterface } from 'src/types/address';
3
+ import { PoolAddress } from 'src/types/constant';
4
+ import { OptionalKeys } from 'src/types/util';
3
5
 
4
6
  const RPC_PROVIDERS = [
5
7
  getFullnodeUrl('mainnet'),
@@ -1,6 +1,7 @@
1
1
  import { SuiObjectData } from '@mysten/sui/client';
2
2
  import type { ScallopAddress, ScallopQuery, ScallopSuiKit } from 'src/models';
3
- import type { CoinPrices, MarketPools, OptionalKeys } from '../types';
3
+ import type { MarketPools } from 'src/types/query';
4
+ import type { CoinPrices } from 'src/types/util';
4
5
  import BigNumber from 'bignumber.js';
5
6
 
6
7
  /**
@@ -150,7 +151,7 @@ export const getAllCoinPrices = async (
150
151
  throw new Error(`Failed to fetch market pool for getAllCoinPrices`);
151
152
  }
152
153
 
153
- const sCoinPrices: OptionalKeys<Record<string, number>> = {};
154
+ const sCoinPrices: CoinPrices = {};
154
155
  query.constants.whitelist.scoin.forEach((sCoinName) => {
155
156
  const coinName = query.utils.parseCoinName(sCoinName);
156
157
  sCoinPrices[sCoinName] = BigNumber(coinPrices[coinName] ?? 0)
@@ -2,7 +2,7 @@ import { bcs } from '@mysten/sui/bcs';
2
2
  import assert from 'assert';
3
3
  import BigNumber from 'bignumber.js';
4
4
  import { ScallopQuery, ScallopUtils } from 'src/models';
5
- import { OptionalKeys } from 'src/types';
5
+ import { OptionalKeys } from 'src/types/util';
6
6
 
7
7
  /**
8
8
  * Get total supply of sCoin
@@ -8,7 +8,6 @@ import {
8
8
  } from './utils';
9
9
  import type { SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';
10
10
  import type { ScallopQuery, ScallopUtils } from 'src/models';
11
- import { CoinPrices } from 'src/types';
12
11
  import {
13
12
  OriginSpoolData,
14
13
  OriginSpoolRewardPoolData,
@@ -20,6 +19,7 @@ import {
20
19
  StakePool,
21
20
  StakeRewardPool,
22
21
  } from 'src/types/query';
22
+ import { CoinPrices } from 'src/types/util';
23
23
 
24
24
  const queryRequiredSpoolObjects = async (
25
25
  query: ScallopQuery,
@@ -164,11 +164,11 @@ export const getSpools = async (
164
164
  if (!stakeMarketCoinNames.includes(spool.marketCoinName)) return;
165
165
  const coinName = query.utils.parseCoinName(spool.marketCoinName);
166
166
  const rewardCoinName = query.utils.getSpoolRewardCoinName();
167
- spool.coinPrice = coinPrices[coinName] ?? spool.coinPrice;
167
+ spool.coinPrice = coinPrices?.[coinName] ?? spool.coinPrice;
168
168
  spool.marketCoinPrice =
169
- coinPrices[spool.marketCoinName] ?? spool.marketCoinPrice;
169
+ coinPrices?.[spool.marketCoinName] ?? spool.marketCoinPrice;
170
170
  spool.rewardCoinPrice =
171
- coinPrices[rewardCoinName] ?? spool.rewardCoinPrice;
171
+ coinPrices?.[rewardCoinName] ?? spool.rewardCoinPrice;
172
172
  spools[spool.marketCoinName] = spool;
173
173
  };
174
174
  Object.values(spoolsIndexer)
@@ -1,5 +1,5 @@
1
1
  import BigNumber from 'bignumber.js';
2
- import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from 'src/types';
2
+ import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from 'src/types/query';
3
3
  import {
4
4
  type SuiObjectResponse,
5
5
  type SuiObjectData,
@@ -1,6 +1,6 @@
1
1
  import { SuiObjectResponse } from '@mysten/sui/client';
2
2
  import { ScallopAddress, ScallopSuiKit, ScallopUtils } from 'src/models';
3
- import { SupportOracleType, xOracleRuleType } from 'src/types';
3
+ import { SupportOracleType, xOracleRuleType } from 'src/types/constant';
4
4
 
5
5
  /**
6
6
  * Query the price update policy table ids. Usually the value for these table will be constant.
@@ -16,12 +16,16 @@ export type CoreIds = {
16
16
  };
17
17
 
18
18
  export type NestedResult = Extract<Argument, { $kind: 'NestedResult' }>;
19
- type Obligation = NestedResult;
20
- type ObligationKey = NestedResult;
21
- type ObligationHotPotato = NestedResult;
19
+ type ResultAsObligation = NestedResult;
20
+ type ResultAsObligationKey = NestedResult;
21
+ type ResultAsObligationHotPotato = NestedResult;
22
22
 
23
23
  export type CoreNormalMethods = {
24
- openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
24
+ openObligation: () => [
25
+ ResultAsObligation,
26
+ ResultAsObligationKey,
27
+ ResultAsObligationHotPotato,
28
+ ];
25
29
  returnObligation: (
26
30
  obligation: SuiObjectArg,
27
31
  obligationHotPotato: SuiObjectArg
@@ -0,0 +1,5 @@
1
+ export type * from './builder';
2
+ export type * from './constant';
3
+ export type * from './query';
4
+ export type * from './address';
5
+ export type * from './util';