@scallop-io/sui-scallop-sdk 2.2.3-pyth-sponsored-transaction-alpha.1 → 2.3.0-lst-x-oracle-alpha.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.
Files changed (74) hide show
  1. package/dist/address-CW2IpaLn.d.ts +165 -0
  2. package/dist/chunk-E3URAUAC.js +25 -0
  3. package/dist/chunk-YA77R5GT.mjs +5 -0
  4. package/dist/constants/index.d.mts +262 -0
  5. package/dist/constants/index.d.ts +262 -0
  6. package/dist/constants/index.js +86 -0
  7. package/dist/constants/index.mjs +5 -0
  8. package/dist/index.d.mts +11 -3242
  9. package/dist/index.d.ts +11 -3242
  10. package/dist/index.js +0 -47
  11. package/dist/index.mjs +0 -14
  12. package/dist/models/index.d.mts +393 -0
  13. package/dist/models/index.d.ts +393 -0
  14. package/dist/models/index.js +34 -0
  15. package/dist/models/index.mjs +16 -0
  16. package/dist/queryKeys-AaZqDYle.d.ts +43 -0
  17. package/dist/scallopUtils-BZLZd2z8.d.ts +2404 -0
  18. package/dist/types/index.d.mts +9 -0
  19. package/dist/types/index.d.ts +9 -0
  20. package/dist/types/index.js +2 -0
  21. package/dist/types/index.mjs +1 -0
  22. package/package.json +31 -4
  23. package/src/builders/borrowIncentiveBuilder.ts +2 -2
  24. package/src/builders/coreBuilder.ts +5 -14
  25. package/src/builders/index.ts +2 -2
  26. package/src/builders/oracles/error.ts +29 -0
  27. package/src/builders/oracles/index.ts +114 -365
  28. package/src/builders/oracles/oraclePackageRegistry.ts +323 -0
  29. package/src/builders/oracles/priceFeedUpdater.ts +112 -0
  30. package/src/builders/oracles/priceUpdateRequester.ts +50 -0
  31. package/src/builders/oracles/xOracleUpdateStrategy.ts +178 -0
  32. package/src/builders/oracles/xOracleUpdater.ts +160 -0
  33. package/src/builders/vescaBuilder.ts +2 -2
  34. package/src/constants/api.ts +2 -0
  35. package/src/constants/common.ts +0 -3
  36. package/src/constants/index.ts +2 -1
  37. package/src/constants/package.ts +14 -0
  38. package/src/constants/testAddress.ts +190 -105
  39. package/src/constants/xoracle.ts +8 -2
  40. package/src/index.ts +2 -12
  41. package/src/models/index.ts +2 -1
  42. package/src/models/interface.ts +6 -6
  43. package/src/models/scallopAddress.ts +24 -4
  44. package/src/models/scallopBuilder.ts +4 -4
  45. package/src/models/scallopClient.ts +1 -1
  46. package/src/models/scallopConstants.ts +2 -2
  47. package/src/models/scallopIndexer.ts +3 -2
  48. package/src/models/scallopQuery.ts +52 -36
  49. package/src/models/scallopQueryClient.ts +1 -1
  50. package/src/models/scallopSuiKit.ts +1 -1
  51. package/src/models/scallopUtils.ts +5 -8
  52. package/src/queries/borrowIncentiveQuery.ts +2 -3
  53. package/src/queries/coreQuery.ts +2 -3
  54. package/src/queries/index.ts +4 -3
  55. package/src/queries/loyaltyProgramQuery.ts +1 -1
  56. package/src/queries/portfolioQuery.ts +13 -13
  57. package/src/queries/sCoinQuery.ts +2 -2
  58. package/src/queries/spoolQuery.ts +8 -8
  59. package/src/queries/vescaQuery.ts +2 -2
  60. package/src/queries/xOracleQuery.ts +20 -3
  61. package/src/types/address.ts +85 -47
  62. package/src/types/builder/core.ts +2 -4
  63. package/src/types/constant/index.ts +2 -1
  64. package/src/types/constant/package.ts +3 -0
  65. package/src/types/constant/xOracle.ts +10 -7
  66. package/src/types/query/index.ts +0 -1
  67. package/src/utils/builder.ts +1 -1
  68. package/src/utils/index.ts +2 -2
  69. package/src/utils/query.ts +6 -6
  70. package/src/utils/util.ts +1 -1
  71. package/src/builders/oracles/pyth.ts +0 -52
  72. package/src/queries/ownerQuery.ts +0 -32
  73. package/src/types/constant/enum.ts +0 -64
  74. package/src/types/query/sCoin.ts +0 -1
@@ -0,0 +1,9 @@
1
+ export { aq as BalanceSheet, B as BaseScallopTxBlock, ar as BorrowDynamic, as as BorrowFee, a5 as BorrowIncentiveAccountKey, ae as BorrowIncentiveAccounts, ak as BorrowIncentiveAccountsQueryInterface, y as BorrowIncentiveIds, z as BorrowIncentiveNormalMethods, a8 as BorrowIncentivePool, a7 as BorrowIncentivePoolPoints, a6 as BorrowIncentivePools, aj as BorrowIncentivePoolsQueryInterface, A as BorrowIncentiveQuickMethods, E as BorrowIncentiveTxBlock, ad as CalculatedBorrowIncentivePoolPointData, aD as CalculatedMarketCollateralData, aA as CalculatedMarketPoolData, aY as CalculatedSpoolData, b0 as CalculatedSpoolRewardPoolData, an as CoinAmounts, bb as CoinPrices, a4 as CoinWrappedType, av as CollateralStat, C as CoreIds, m as CoreNormalMethods, n as CoreQuickMethods, p as CoreTxBlock, F as GenerateBorrowIncentiveNormalMethod, H as GenerateBorrowIncentiveQuickMethod, G as GenerateCoreNormalMethod, q as GenerateCoreQuickMethod, U as GenerateLoyaltyProgramNormalMethod, W as GenerateLoyaltyProgramQuickMethod, a0 as GenerateSCoinNormalMethod, a1 as GenerateSCoinQuickMethod, w as GenerateSpoolNormalMethod, x as GenerateSpoolQuickMethod, L as GenerateVeScaNormalMethod, M as GenerateVeScaQuickMethod, at as InterestModel, aM as Lending, aK as Lendings, aI as LoyaltyProgramInfo, O as LoyaltyProgramNormalMethods, P as LoyaltyProgramQuickMethods, T as LoyaltyProgramTxBlock, aE as Market, ao as MarketCoinAmounts, ax as MarketCollateral, am as MarketCollaterals, aw as MarketPool, al as MarketPools, aG as MarketQueryInterface, N as NestedResult, aF as Obligation, aN as ObligationAccount, aL as ObligationAccounts, aR as ObligationBorrowIncentive, aQ as ObligationBorrowIncentiveReward, aO as ObligationCollateral, aP as ObligationDebt, aH as ObligationQueryInterface, ba as OptionalKeys, ag as OriginBorrowIncentiveAccountData, af as OriginBorrowIncentiveAccountPoolData, aa as OriginBorrowIncentivePoolData, a9 as OriginBorrowIncentivePoolPointData, aB as OriginMarketCollateralData, ay as OriginMarketPoolData, aV as OriginSpoolData, a_ as OriginSpoolRewardPoolData, ai as ParsedBorrowIncentiveAccountData, ah as ParsedBorrowIncentiveAccountPoolData, ac as ParsedBorrowIncentivePoolData, ab as ParsedBorrowIncentivePoolPointData, aC as ParsedMarketCollateralData, az as ParsedMarketPoolData, aX as ParsedSpoolData, a$ as ParsedSpoolRewardPoolData, a2 as PoolAddress, Q as QuickMethodReturnType, au as RiskModel, ap as SCoinAmounts, $ as SCoinTxBlock, k as ScallopTxBlock, l as SelectCoinReturnType, aU as Spool, aW as SpoolData, r as SpoolIds, s as SpoolNormalMethods, t as SpoolQuickMethods, aZ as SpoolRewardPool, v as SpoolTxBlock, aT as Spools, b4 as StakeAccount, b3 as StakeAccounts, b5 as StakePool, b1 as StakePools, b6 as StakeRewardPool, b2 as StakeRewardPools, D as SuiTxBlockWithBorrowIncentiveNormalMethods, o as SuiTxBlockWithCoreNormalMethods, R as SuiTxBlockWithLoyaltyProgramNormalMethods, i as SuiTxBlockWithSCoin, _ as SuiTxBlockWithSCoinNormalMethods, j as SuiTxBlockWithSpool, u as SuiTxBlockWithSpoolNormalMethods, J as SuiTxBlockWithVeScaNormalMethods, aS as TotalValueLocked, aJ as VeScaLoyaltyProgramInfo, V as VeScaNormalMethods, I as VeScaQuickMethods, b8 as VeScaTreasuryFields, b9 as VeScaTreasuryInfo, K as VeScaTxBlock, b7 as Vesca, a3 as Whitelist, Y as sCoinNormalMethods, X as sCoinPkgIds, Z as sCoinQuickMethods } from '../scallopUtils-BZLZd2z8.js';
2
+ export { Q as QueryKeys } from '../queryKeys-AaZqDYle.js';
3
+ export { l as AddressStringPath, A as AddressesInterface, B as BasePackage, k as OracleLst, j as OracleLstConfig, O as OracleLstPackage, h as PackageName, i as SupportOracleLst, d as SupportOracleType, g as SupportedOracleSuiLst, f as xOracleListType, x as xOracleRuleType, e as xOracleRules } from '../address-CW2IpaLn.js';
4
+ import '@tanstack/query-core';
5
+ import '@scallop-io/sui-kit';
6
+ import 'axios';
7
+ import '@mysten/sui/dist/cjs/client';
8
+ import '@mysten/sui/client';
9
+ import '@mysten/sui/transactions';
@@ -0,0 +1,9 @@
1
+ export { aq as BalanceSheet, B as BaseScallopTxBlock, ar as BorrowDynamic, as as BorrowFee, a5 as BorrowIncentiveAccountKey, ae as BorrowIncentiveAccounts, ak as BorrowIncentiveAccountsQueryInterface, y as BorrowIncentiveIds, z as BorrowIncentiveNormalMethods, a8 as BorrowIncentivePool, a7 as BorrowIncentivePoolPoints, a6 as BorrowIncentivePools, aj as BorrowIncentivePoolsQueryInterface, A as BorrowIncentiveQuickMethods, E as BorrowIncentiveTxBlock, ad as CalculatedBorrowIncentivePoolPointData, aD as CalculatedMarketCollateralData, aA as CalculatedMarketPoolData, aY as CalculatedSpoolData, b0 as CalculatedSpoolRewardPoolData, an as CoinAmounts, bb as CoinPrices, a4 as CoinWrappedType, av as CollateralStat, C as CoreIds, m as CoreNormalMethods, n as CoreQuickMethods, p as CoreTxBlock, F as GenerateBorrowIncentiveNormalMethod, H as GenerateBorrowIncentiveQuickMethod, G as GenerateCoreNormalMethod, q as GenerateCoreQuickMethod, U as GenerateLoyaltyProgramNormalMethod, W as GenerateLoyaltyProgramQuickMethod, a0 as GenerateSCoinNormalMethod, a1 as GenerateSCoinQuickMethod, w as GenerateSpoolNormalMethod, x as GenerateSpoolQuickMethod, L as GenerateVeScaNormalMethod, M as GenerateVeScaQuickMethod, at as InterestModel, aM as Lending, aK as Lendings, aI as LoyaltyProgramInfo, O as LoyaltyProgramNormalMethods, P as LoyaltyProgramQuickMethods, T as LoyaltyProgramTxBlock, aE as Market, ao as MarketCoinAmounts, ax as MarketCollateral, am as MarketCollaterals, aw as MarketPool, al as MarketPools, aG as MarketQueryInterface, N as NestedResult, aF as Obligation, aN as ObligationAccount, aL as ObligationAccounts, aR as ObligationBorrowIncentive, aQ as ObligationBorrowIncentiveReward, aO as ObligationCollateral, aP as ObligationDebt, aH as ObligationQueryInterface, ba as OptionalKeys, ag as OriginBorrowIncentiveAccountData, af as OriginBorrowIncentiveAccountPoolData, aa as OriginBorrowIncentivePoolData, a9 as OriginBorrowIncentivePoolPointData, aB as OriginMarketCollateralData, ay as OriginMarketPoolData, aV as OriginSpoolData, a_ as OriginSpoolRewardPoolData, ai as ParsedBorrowIncentiveAccountData, ah as ParsedBorrowIncentiveAccountPoolData, ac as ParsedBorrowIncentivePoolData, ab as ParsedBorrowIncentivePoolPointData, aC as ParsedMarketCollateralData, az as ParsedMarketPoolData, aX as ParsedSpoolData, a$ as ParsedSpoolRewardPoolData, a2 as PoolAddress, Q as QuickMethodReturnType, au as RiskModel, ap as SCoinAmounts, $ as SCoinTxBlock, k as ScallopTxBlock, l as SelectCoinReturnType, aU as Spool, aW as SpoolData, r as SpoolIds, s as SpoolNormalMethods, t as SpoolQuickMethods, aZ as SpoolRewardPool, v as SpoolTxBlock, aT as Spools, b4 as StakeAccount, b3 as StakeAccounts, b5 as StakePool, b1 as StakePools, b6 as StakeRewardPool, b2 as StakeRewardPools, D as SuiTxBlockWithBorrowIncentiveNormalMethods, o as SuiTxBlockWithCoreNormalMethods, R as SuiTxBlockWithLoyaltyProgramNormalMethods, i as SuiTxBlockWithSCoin, _ as SuiTxBlockWithSCoinNormalMethods, j as SuiTxBlockWithSpool, u as SuiTxBlockWithSpoolNormalMethods, J as SuiTxBlockWithVeScaNormalMethods, aS as TotalValueLocked, aJ as VeScaLoyaltyProgramInfo, V as VeScaNormalMethods, I as VeScaQuickMethods, b8 as VeScaTreasuryFields, b9 as VeScaTreasuryInfo, K as VeScaTxBlock, b7 as Vesca, a3 as Whitelist, Y as sCoinNormalMethods, X as sCoinPkgIds, Z as sCoinQuickMethods } from '../scallopUtils-BZLZd2z8.js';
2
+ export { Q as QueryKeys } from '../queryKeys-AaZqDYle.js';
3
+ export { l as AddressStringPath, A as AddressesInterface, B as BasePackage, k as OracleLst, j as OracleLstConfig, O as OracleLstPackage, h as PackageName, i as SupportOracleLst, d as SupportOracleType, g as SupportedOracleSuiLst, f as xOracleListType, x as xOracleRuleType, e as xOracleRules } from '../address-CW2IpaLn.js';
4
+ import '@tanstack/query-core';
5
+ import '@scallop-io/sui-kit';
6
+ import 'axios';
7
+ import '@mysten/sui/dist/cjs/client';
8
+ import '@mysten/sui/client';
9
+ import '@mysten/sui/transactions';
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1 @@
1
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "2.2.3-pyth-sponsored-transaction-alpha.1",
3
+ "version": "2.3.0-lst-x-oracle-alpha.2",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -27,10 +27,37 @@
27
27
  "types": "./dist/index.d.ts",
28
28
  "exports": {
29
29
  ".": {
30
- "source": "./src/index.ts",
31
30
  "import": "./dist/index.mjs",
32
31
  "require": "./dist/index.js",
33
- "default": "./dist/index.js"
32
+ "types": "./dist/index.d.ts"
33
+ },
34
+ "./constants": {
35
+ "import": "./dist/constants/index.mjs",
36
+ "require": "./dist/constants/index.js",
37
+ "types": "./dist/constants/index.d.ts"
38
+ },
39
+ "./models": {
40
+ "import": "./dist/models/index.mjs",
41
+ "require": "./dist/models/index.js",
42
+ "types": "./dist/models/index.d.ts"
43
+ },
44
+ "./types": {
45
+ "import": "./dist/types/index.mjs",
46
+ "require": "./dist/types/index.js",
47
+ "types": "./dist/types/index.d.ts"
48
+ }
49
+ },
50
+ "typesVersions": {
51
+ "*": {
52
+ "constants": [
53
+ "dist/constants/index.d.ts"
54
+ ],
55
+ "models": [
56
+ "dist/models/index.d.ts"
57
+ ],
58
+ "types": [
59
+ "dist/types/index.d.ts"
60
+ ]
34
61
  }
35
62
  },
36
63
  "files": [
@@ -146,7 +173,7 @@
146
173
  "scripts": {
147
174
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
148
175
  "build": "pnpm run build:tsup",
149
- "build:tsup": "tsup ./src/index.ts --format esm,cjs --splitting --minify --treeshake --dts",
176
+ "build:tsup": "tsup src/index.ts src/constants/index.ts src/models/index.ts src/types/index.ts --format esm,cjs --clean --splitting --minify --treeshake --dts",
150
177
  "watch:tsup": "tsup ./src/index.ts --format esm,cjs --clean --splitting --watch",
151
178
  "watch:types": "tsc --watch",
152
179
  "watch": "pnpm run clean & pnpm run watch:types & pnpm run watch:tsup",
@@ -3,7 +3,6 @@ import {
3
3
  SuiTxBlock as SuiKitTxBlock,
4
4
  SUI_CLOCK_OBJECT_ID,
5
5
  } from '@scallop-io/sui-kit';
6
- import { getObligations, getObligationLocked } from 'src/queries';
7
6
  import { requireSender } from 'src/utils';
8
7
  import type { SuiObjectArg } from '@scallop-io/sui-kit';
9
8
  import type { ScallopBuilder } from 'src/models';
@@ -15,7 +14,8 @@ import type {
15
14
  BorrowIncentiveTxBlock,
16
15
  ScallopTxBlock,
17
16
  } from 'src/types';
18
- import { OLD_BORROW_INCENTIVE_PROTOCOL_ID } from 'src/constants';
17
+ import { OLD_BORROW_INCENTIVE_PROTOCOL_ID } from 'src/constants/common';
18
+ import { getObligationLocked, getObligations } from 'src/queries/coreQuery';
19
19
 
20
20
  /**
21
21
  * Check and get Obligation information from transaction block.
@@ -1,7 +1,7 @@
1
1
  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
- import { getObligations } from '../queries';
4
+ import { getObligations } from 'src/queries/coreQuery';
5
5
  import { updateOracles } from './oracles';
6
6
  import { requireSender } from '../utils';
7
7
  import type { SuiObjectArg, TransactionResult } from '@scallop-io/sui-kit';
@@ -382,13 +382,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
382
382
  if (!marketCoin) throw new Error(`No market coin for ${poolCoinName}`);
383
383
  return txBlock.withdraw(marketCoin, poolCoinName);
384
384
  },
385
- borrowQuick: async (
386
- amount,
387
- poolCoinName,
388
- obligationId,
389
- obligationKey,
390
- isSponsoredTx = false
391
- ) => {
385
+ borrowQuick: async (amount, poolCoinName, obligationId, obligationKey) => {
392
386
  const obligationInfo = await requireObligationInfo(
393
387
  builder,
394
388
  txBlock,
@@ -400,7 +394,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
400
394
  obligationInfo.obligationId
401
395
  )) ?? [];
402
396
  const updateCoinNames = [...obligationCoinNames, poolCoinName];
403
- await updateOracles(builder, txBlock, updateCoinNames, { isSponsoredTx });
397
+ await updateOracles(builder, txBlock, updateCoinNames);
404
398
  return txBlock.borrow(
405
399
  obligationInfo.obligationId,
406
400
  obligationInfo.obligationKey as SuiObjectArg,
@@ -413,8 +407,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
413
407
  poolCoinName,
414
408
  borrowReferral,
415
409
  obligationId,
416
- obligationKey,
417
- isSponsoredTx = false
410
+ obligationKey
418
411
  ) => {
419
412
  const obligationInfo = await requireObligationInfo(
420
413
  builder,
@@ -427,9 +420,7 @@ const generateCoreQuickMethod: GenerateCoreQuickMethod = ({
427
420
  obligationInfo.obligationId
428
421
  )) ?? [];
429
422
  const updateCoinNames = [...obligationCoinNames, poolCoinName];
430
- await updateOracles(builder, txBlock, updateCoinNames, {
431
- isSponsoredTx,
432
- });
423
+ await updateOracles(builder, txBlock, updateCoinNames);
433
424
  return txBlock.borrowWithReferral(
434
425
  obligationInfo.obligationId,
435
426
  obligationInfo.obligationKey as SuiObjectArg,
@@ -4,11 +4,11 @@ import { newCoreTxBlock } from './coreBuilder';
4
4
  import { newSpoolTxBlock } from './spoolBuilder';
5
5
  import { newBorrowIncentiveTxBlock } from './borrowIncentiveBuilder';
6
6
  import { newVeScaTxBlock } from './vescaBuilder';
7
- import type { ScallopBuilder } from 'src/models';
8
- import type { ScallopTxBlock } from 'src/types';
9
7
  import { newReferralTxBlock } from './referralBuilder';
10
8
  import { newLoyaltyProgramTxBlock } from './loyaltyProgramBuilder';
11
9
  import { newSCoinTxBlock } from './sCoinBuilder';
10
+ import { ScallopTxBlock } from 'src/types/builder';
11
+ import type { ScallopBuilder } from 'src/models';
12
12
 
13
13
  /**
14
14
  * Create a new ScallopTxBlock instance.
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Thrown when someone asks for an oracle type we haven’t onboarded yet.
3
+ */
4
+ class UnsupportedOracleError extends Error {
5
+ constructor(oracle: string) {
6
+ super(`Unsupported oracle type: ${oracle}`);
7
+ this.name = 'UnsupportedOracleError';
8
+ }
9
+ }
10
+
11
+ class UnsupportedLstUpdateError extends Error {
12
+ constructor(lst: string) {
13
+ super(`Unsupported LST update for: ${lst}`);
14
+ this.name = 'UnsupportedLstUpdateError';
15
+ }
16
+ }
17
+
18
+ class UnsupportedLstOracleError extends Error {
19
+ constructor(lst: string, oracle: string) {
20
+ super(`Unsupported LST oracle update for: ${lst} with oracle: ${oracle}`);
21
+ this.name = 'UnsupportedLstOracleError';
22
+ }
23
+ }
24
+
25
+ export {
26
+ UnsupportedOracleError,
27
+ UnsupportedLstUpdateError,
28
+ UnsupportedLstOracleError,
29
+ };