@scallop-io/sui-scallop-sdk 4.1.2 → 4.3.0

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 (53) hide show
  1. package/README.md +356 -140
  2. package/dist/builder.cjs +5 -4
  3. package/dist/builder.d.cts +2 -2
  4. package/dist/builder.d.ts +2 -2
  5. package/dist/builder.js +2 -2
  6. package/dist/chunk-FNZDTB3A.js +16 -0
  7. package/dist/chunk-UCRLKWQI.js +11 -0
  8. package/dist/{chunk-VTGQACWU.js → chunk-ZAFUZGSI.js} +2 -2
  9. package/dist/client.cjs +5 -4
  10. package/dist/client.d.cts +1 -1
  11. package/dist/client.d.ts +1 -1
  12. package/dist/client.js +3 -3
  13. package/dist/index.cjs +24 -23
  14. package/dist/index.d.cts +2 -6
  15. package/dist/index.d.ts +2 -6
  16. package/dist/index.js +4 -4
  17. package/dist/{query-DkitepDi.d.ts → query-b84awDFp.d.ts} +80 -9
  18. package/dist/query.cjs +5 -4
  19. package/dist/query.d.cts +1 -1
  20. package/dist/query.d.ts +1 -1
  21. package/dist/query.js +1 -1
  22. package/dist/types.d.cts +1 -1
  23. package/dist/types.d.ts +1 -1
  24. package/package.json +4 -2
  25. package/src/constants/queryKeys.ts +0 -12
  26. package/src/constants/testAddress.ts +9 -1
  27. package/src/datasources/api.ts +3 -3
  28. package/src/models/scallop.ts +0 -1
  29. package/src/models/scallopAddress/const.ts +5 -0
  30. package/src/models/scallopAddress/index.ts +2 -2
  31. package/src/models/scallopAddress/types.ts +5 -0
  32. package/src/models/scallopQuery/index.ts +10 -0
  33. package/src/models/scallopUtils/index.ts +3 -3
  34. package/src/models/scallopUtils/types.ts +1 -1
  35. package/src/repositories/addressApi/types.ts +4 -0
  36. package/src/repositories/obligation/helpers.ts +59 -0
  37. package/src/repositories/obligation/index.ts +5 -0
  38. package/src/repositories/obligation/types.ts +17 -1
  39. package/src/repositories/obligation/utils.ts +22 -0
  40. package/src/repositories/price/helpers.ts +7 -2
  41. package/src/repositories/price/types.ts +2 -2
  42. package/src/repositories/wiring/metadata.ts +1 -0
  43. package/src/txBuilders/index.ts +8 -1
  44. package/src/txBuilders/manifest.ts +8 -1
  45. package/src/txBuilders/modules.ts +6 -0
  46. package/src/txBuilders/obligationNaming/index.ts +46 -0
  47. package/src/txBuilders/obligationNaming/moveCalls.ts +33 -0
  48. package/src/txBuilders/oracles/pyth.ts +1 -5
  49. package/src/types/builder/index.ts +5 -1
  50. package/src/types/builder/modules.ts +3 -0
  51. package/src/types/builder/obligationNaming.ts +18 -0
  52. package/dist/chunk-33AK5RWM.js +0 -15
  53. package/dist/chunk-DIC6P5HB.js +0 -11
package/dist/query.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { f as ScallopQuery, bi as ScallopQueryConstructorParams, bi as ScallopQueryParams } from './query-DkitepDi.js';
1
+ export { f as ScallopQuery, bu as ScallopQueryConstructorParams, bu as ScallopQueryParams } from './query-b84awDFp.js';
2
2
  import '@tanstack/query-core';
3
3
  import './Logger-Cg2iFdpH.js';
4
4
  import '@mysten/sui/client';
package/dist/query.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { f as ScallopQuery, bi as ScallopQueryConstructorParams, bi as ScallopQueryParams } from './query-DkitepDi.js';
1
+ export { f as ScallopQuery, bu as ScallopQueryConstructorParams, bu as ScallopQueryParams } from './query-b84awDFp.js';
2
2
  import '@tanstack/query-core';
3
3
  import './Logger-Cg2iFdpH.js';
4
4
  import '@mysten/sui/client';
package/dist/query.js CHANGED
@@ -1,3 +1,3 @@
1
- export { R as ScallopQuery } from './chunk-33AK5RWM.js';
1
+ export { R as ScallopQuery } from './chunk-FNZDTB3A.js';
2
2
  import './chunk-S34VOEZN.js';
3
3
  import './chunk-6UQ4NWEU.js';
package/dist/types.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { i as AddressStringPath, A as AddressesInterface, B as BaseScallopTxBlock, j as BorrowIncentiveAccounts, k as BorrowIncentiveIds, l as BorrowIncentiveModule, m as BorrowIncentiveNormalMethods, n as BorrowIncentivePool, o as BorrowIncentivePoolPoints, p as BorrowIncentivePools, q as BorrowIncentiveQuickMethods, r as BorrowIncentiveTxBlock, C as CalculatedSpoolData, s as CalculatedSpoolRewardPoolData, t as CoinBalance, u as CoinPrices, v as CoinWrappedType, w as CoreIds, y as CoreModule, z as CoreNormalMethods, D as CoreQuickMethods, E as CoreTxBlock, F as DevInspectResults, H as DynamicFieldPage, I as EncodeDynamicFieldNameInput, J as GenerateBorrowIncentiveNormalMethod, K as GenerateBorrowIncentiveQuickMethod, L as GenerateCoreNormalMethod, M as GenerateCoreQuickMethod, N as GenerateLoyaltyProgramNormalMethod, O as GenerateLoyaltyProgramQuickMethod, Q as GenerateSCoinNormalMethod, R as GenerateSCoinQuickMethod, T as GenerateSpoolNormalMethod, U as GenerateSpoolQuickMethod, V as GenerateVeScaNormalMethod, X as GenerateVeScaQuickMethod, Y as GetBalanceParams, d as GetDynamicFieldObjectParams, G as GetDynamicFieldsParams, Z as GetOwnedObjectsParams, _ as InspectTxnParsedJson, $ as Lending, a0 as Lendings, a1 as LoyaltyModule, a2 as LoyaltyProgramInfo, a3 as LoyaltyProgramNormalMethods, a4 as LoyaltyProgramQuickMethods, a5 as LoyaltyProgramTxBlock, a6 as Market, a7 as MarketCollateral, a8 as MarketCollaterals, a9 as MarketPool, aa as MarketPools, ab as Markets, ac as NestedResult, ad as ObligationAccount, ae as ObligationAccounts, af as ObligationBorrowIncentive, ag as ObligationBorrowIncentiveReward, ah as ObligationCollateral, ai as ObligationDebt, aj as OptionalKeys, ak as OriginSpoolData, al as OriginSpoolRewardPoolData, am as PaginatedObjectsResponse, an as ParsedBorrowIncentiveAccountData, ao as ParsedBorrowIncentiveAccountPoolData, ap as ParsedSpoolData, aq as ParsedSpoolRewardPoolData, P as PoolAddress, ar as QuickMethodReturnType, as as ReferralModule, at as SCoinActionContext, au as SCoinModule, av as SCoinTxBlock, a as ScallopTxBlock, ax as ScallopTxBlockModules, ay as Spool, az as SpoolActionContext, aA as SpoolData, aB as SpoolIds, aC as SpoolModule, aD as SpoolNormalMethods, aE as SpoolQuickMethods, aF as SpoolRewardPool, aG as SpoolTxBlock, aH as Spools, aI as StakeAccount, aJ as StakeAccounts, aK as StakePool, aL as StakePools, aM as StakeRewardPool, aN as StakeRewardPools, e as SuiObjectData, c as SuiObjectDataOptions, aP as SuiObjectRef, aQ as SuiObjectResponse, aR as SuiParsedData, aS as SuiTxBlockWithBorrowIncentiveNormalMethods, aT as SuiTxBlockWithCoreNormalMethods, aU as SuiTxBlockWithLoyaltyProgramNormalMethods, aV as SuiTxBlockWithSCoin, aW as SuiTxBlockWithSCoinNormalMethods, aX as SuiTxBlockWithSpool, aY as SuiTxBlockWithSpoolNormalMethods, aZ as SuiTxBlockWithVeScaNormalMethods, a_ as SupportOracleType, a$ as TotalValueLocked, b0 as TransactionCommand, b1 as VeSca, b2 as VeScaLoyaltyProgramInfo, b3 as VeScaModule, b4 as VeScaNormalMethods, b5 as VeScaQuickMethods, b6 as VeScaTreasuryInfo, b7 as VeScaTxBlock, b1 as Vesca, W as Whitelist, b8 as _SUPPORT_ORACLES, b9 as sCoinNormalMethods, ba as sCoinPkgIds, bb as sCoinQuickMethods, x as xOracleListType, bc as xOracleRuleType, bd as xOracleRules } from './query-DkitepDi.js';
1
+ export { i as AddressStringPath, A as AddressesInterface, B as BaseScallopTxBlock, j as BorrowIncentiveAccounts, k as BorrowIncentiveIds, l as BorrowIncentiveModule, m as BorrowIncentiveNormalMethods, n as BorrowIncentivePool, o as BorrowIncentivePoolPoints, p as BorrowIncentivePools, q as BorrowIncentiveQuickMethods, r as BorrowIncentiveTxBlock, C as CalculatedSpoolData, s as CalculatedSpoolRewardPoolData, t as CoinBalance, u as CoinPrices, v as CoinWrappedType, w as CoreIds, y as CoreModule, z as CoreNormalMethods, D as CoreQuickMethods, E as CoreTxBlock, F as DevInspectResults, H as DynamicFieldPage, I as EncodeDynamicFieldNameInput, J as GenerateBorrowIncentiveNormalMethod, K as GenerateBorrowIncentiveQuickMethod, L as GenerateCoreNormalMethod, M as GenerateCoreQuickMethod, N as GenerateLoyaltyProgramNormalMethod, O as GenerateLoyaltyProgramQuickMethod, Q as GenerateObligationNamingNormalMethod, R as GenerateReferralNormalMethod, T as GenerateReferralQuickMethod, U as GenerateSCoinNormalMethod, V as GenerateSCoinQuickMethod, X as GenerateSpoolNormalMethod, Y as GenerateSpoolQuickMethod, Z as GenerateVeScaNormalMethod, _ as GenerateVeScaQuickMethod, $ as GetBalanceParams, d as GetDynamicFieldObjectParams, G as GetDynamicFieldsParams, a0 as GetOwnedObjectsParams, a1 as InspectTxnParsedJson, a2 as Lending, a3 as Lendings, a4 as LoyaltyModule, a5 as LoyaltyProgramInfo, a6 as LoyaltyProgramNormalMethods, a7 as LoyaltyProgramQuickMethods, a8 as LoyaltyProgramTxBlock, a9 as Market, aa as MarketCollateral, ab as MarketCollaterals, ac as MarketPool, ad as MarketPools, ae as Markets, af as NestedResult, ag as ObligationAccount, ah as ObligationAccounts, ai as ObligationBorrowIncentive, aj as ObligationBorrowIncentiveReward, ak as ObligationCollateral, al as ObligationDebt, am as ObligationNamingModule, an as ObligationNamingNormalMethods, ao as ObligationNamingTxBlock, ap as OptionalKeys, aq as OriginSpoolData, ar as OriginSpoolRewardPoolData, as as PaginatedObjectsResponse, at as ParsedBorrowIncentiveAccountData, au as ParsedBorrowIncentiveAccountPoolData, av as ParsedSpoolData, aw as ParsedSpoolRewardPoolData, P as PoolAddress, ax as QuickMethodReturnType, ay as ReferralIds, az as ReferralModule, aA as ReferralNormalMethods, aB as ReferralQuickMethods, aC as ReferralTxBlock, aD as SCoinActionContext, aE as SCoinModule, aF as SCoinTxBlock, a as ScallopTxBlock, aH as ScallopTxBlockModules, aI as Spool, aJ as SpoolActionContext, aK as SpoolData, aL as SpoolIds, aM as SpoolModule, aN as SpoolNormalMethods, aO as SpoolQuickMethods, aP as SpoolRewardPool, aQ as SpoolTxBlock, aR as Spools, aS as StakeAccount, aT as StakeAccounts, aU as StakePool, aV as StakePools, aW as StakeRewardPool, aX as StakeRewardPools, e as SuiObjectData, c as SuiObjectDataOptions, aZ as SuiObjectRef, a_ as SuiObjectResponse, a$ as SuiParsedData, b0 as SuiTxBlockWithBorrowIncentiveNormalMethods, b1 as SuiTxBlockWithCoreNormalMethods, b2 as SuiTxBlockWithLoyaltyProgramNormalMethods, b3 as SuiTxBlockWithObligationNamingNormalMethods, b4 as SuiTxBlockWithReferralNormalMethods, b5 as SuiTxBlockWithSCoin, b6 as SuiTxBlockWithSCoinNormalMethods, b7 as SuiTxBlockWithSpool, b8 as SuiTxBlockWithSpoolNormalMethods, b9 as SuiTxBlockWithVeScaNormalMethods, ba as SupportOracleType, bb as TotalValueLocked, bc as TransactionCommand, bd as VeSca, be as VeScaLoyaltyProgramInfo, bf as VeScaModule, bg as VeScaNormalMethods, bh as VeScaQuickMethods, bi as VeScaTreasuryInfo, bj as VeScaTxBlock, bd as Vesca, W as Whitelist, bk as _SUPPORT_ORACLES, bl as sCoinNormalMethods, bm as sCoinPkgIds, bn as sCoinQuickMethods, x as xOracleListType, bo as xOracleRuleType, bp as xOracleRules } from './query-b84awDFp.js';
2
2
  import '@tanstack/query-core';
3
3
  import './Logger-Cg2iFdpH.js';
4
4
  import '@mysten/sui/client';
package/dist/types.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { i as AddressStringPath, A as AddressesInterface, B as BaseScallopTxBlock, j as BorrowIncentiveAccounts, k as BorrowIncentiveIds, l as BorrowIncentiveModule, m as BorrowIncentiveNormalMethods, n as BorrowIncentivePool, o as BorrowIncentivePoolPoints, p as BorrowIncentivePools, q as BorrowIncentiveQuickMethods, r as BorrowIncentiveTxBlock, C as CalculatedSpoolData, s as CalculatedSpoolRewardPoolData, t as CoinBalance, u as CoinPrices, v as CoinWrappedType, w as CoreIds, y as CoreModule, z as CoreNormalMethods, D as CoreQuickMethods, E as CoreTxBlock, F as DevInspectResults, H as DynamicFieldPage, I as EncodeDynamicFieldNameInput, J as GenerateBorrowIncentiveNormalMethod, K as GenerateBorrowIncentiveQuickMethod, L as GenerateCoreNormalMethod, M as GenerateCoreQuickMethod, N as GenerateLoyaltyProgramNormalMethod, O as GenerateLoyaltyProgramQuickMethod, Q as GenerateSCoinNormalMethod, R as GenerateSCoinQuickMethod, T as GenerateSpoolNormalMethod, U as GenerateSpoolQuickMethod, V as GenerateVeScaNormalMethod, X as GenerateVeScaQuickMethod, Y as GetBalanceParams, d as GetDynamicFieldObjectParams, G as GetDynamicFieldsParams, Z as GetOwnedObjectsParams, _ as InspectTxnParsedJson, $ as Lending, a0 as Lendings, a1 as LoyaltyModule, a2 as LoyaltyProgramInfo, a3 as LoyaltyProgramNormalMethods, a4 as LoyaltyProgramQuickMethods, a5 as LoyaltyProgramTxBlock, a6 as Market, a7 as MarketCollateral, a8 as MarketCollaterals, a9 as MarketPool, aa as MarketPools, ab as Markets, ac as NestedResult, ad as ObligationAccount, ae as ObligationAccounts, af as ObligationBorrowIncentive, ag as ObligationBorrowIncentiveReward, ah as ObligationCollateral, ai as ObligationDebt, aj as OptionalKeys, ak as OriginSpoolData, al as OriginSpoolRewardPoolData, am as PaginatedObjectsResponse, an as ParsedBorrowIncentiveAccountData, ao as ParsedBorrowIncentiveAccountPoolData, ap as ParsedSpoolData, aq as ParsedSpoolRewardPoolData, P as PoolAddress, ar as QuickMethodReturnType, as as ReferralModule, at as SCoinActionContext, au as SCoinModule, av as SCoinTxBlock, a as ScallopTxBlock, ax as ScallopTxBlockModules, ay as Spool, az as SpoolActionContext, aA as SpoolData, aB as SpoolIds, aC as SpoolModule, aD as SpoolNormalMethods, aE as SpoolQuickMethods, aF as SpoolRewardPool, aG as SpoolTxBlock, aH as Spools, aI as StakeAccount, aJ as StakeAccounts, aK as StakePool, aL as StakePools, aM as StakeRewardPool, aN as StakeRewardPools, e as SuiObjectData, c as SuiObjectDataOptions, aP as SuiObjectRef, aQ as SuiObjectResponse, aR as SuiParsedData, aS as SuiTxBlockWithBorrowIncentiveNormalMethods, aT as SuiTxBlockWithCoreNormalMethods, aU as SuiTxBlockWithLoyaltyProgramNormalMethods, aV as SuiTxBlockWithSCoin, aW as SuiTxBlockWithSCoinNormalMethods, aX as SuiTxBlockWithSpool, aY as SuiTxBlockWithSpoolNormalMethods, aZ as SuiTxBlockWithVeScaNormalMethods, a_ as SupportOracleType, a$ as TotalValueLocked, b0 as TransactionCommand, b1 as VeSca, b2 as VeScaLoyaltyProgramInfo, b3 as VeScaModule, b4 as VeScaNormalMethods, b5 as VeScaQuickMethods, b6 as VeScaTreasuryInfo, b7 as VeScaTxBlock, b1 as Vesca, W as Whitelist, b8 as _SUPPORT_ORACLES, b9 as sCoinNormalMethods, ba as sCoinPkgIds, bb as sCoinQuickMethods, x as xOracleListType, bc as xOracleRuleType, bd as xOracleRules } from './query-DkitepDi.js';
1
+ export { i as AddressStringPath, A as AddressesInterface, B as BaseScallopTxBlock, j as BorrowIncentiveAccounts, k as BorrowIncentiveIds, l as BorrowIncentiveModule, m as BorrowIncentiveNormalMethods, n as BorrowIncentivePool, o as BorrowIncentivePoolPoints, p as BorrowIncentivePools, q as BorrowIncentiveQuickMethods, r as BorrowIncentiveTxBlock, C as CalculatedSpoolData, s as CalculatedSpoolRewardPoolData, t as CoinBalance, u as CoinPrices, v as CoinWrappedType, w as CoreIds, y as CoreModule, z as CoreNormalMethods, D as CoreQuickMethods, E as CoreTxBlock, F as DevInspectResults, H as DynamicFieldPage, I as EncodeDynamicFieldNameInput, J as GenerateBorrowIncentiveNormalMethod, K as GenerateBorrowIncentiveQuickMethod, L as GenerateCoreNormalMethod, M as GenerateCoreQuickMethod, N as GenerateLoyaltyProgramNormalMethod, O as GenerateLoyaltyProgramQuickMethod, Q as GenerateObligationNamingNormalMethod, R as GenerateReferralNormalMethod, T as GenerateReferralQuickMethod, U as GenerateSCoinNormalMethod, V as GenerateSCoinQuickMethod, X as GenerateSpoolNormalMethod, Y as GenerateSpoolQuickMethod, Z as GenerateVeScaNormalMethod, _ as GenerateVeScaQuickMethod, $ as GetBalanceParams, d as GetDynamicFieldObjectParams, G as GetDynamicFieldsParams, a0 as GetOwnedObjectsParams, a1 as InspectTxnParsedJson, a2 as Lending, a3 as Lendings, a4 as LoyaltyModule, a5 as LoyaltyProgramInfo, a6 as LoyaltyProgramNormalMethods, a7 as LoyaltyProgramQuickMethods, a8 as LoyaltyProgramTxBlock, a9 as Market, aa as MarketCollateral, ab as MarketCollaterals, ac as MarketPool, ad as MarketPools, ae as Markets, af as NestedResult, ag as ObligationAccount, ah as ObligationAccounts, ai as ObligationBorrowIncentive, aj as ObligationBorrowIncentiveReward, ak as ObligationCollateral, al as ObligationDebt, am as ObligationNamingModule, an as ObligationNamingNormalMethods, ao as ObligationNamingTxBlock, ap as OptionalKeys, aq as OriginSpoolData, ar as OriginSpoolRewardPoolData, as as PaginatedObjectsResponse, at as ParsedBorrowIncentiveAccountData, au as ParsedBorrowIncentiveAccountPoolData, av as ParsedSpoolData, aw as ParsedSpoolRewardPoolData, P as PoolAddress, ax as QuickMethodReturnType, ay as ReferralIds, az as ReferralModule, aA as ReferralNormalMethods, aB as ReferralQuickMethods, aC as ReferralTxBlock, aD as SCoinActionContext, aE as SCoinModule, aF as SCoinTxBlock, a as ScallopTxBlock, aH as ScallopTxBlockModules, aI as Spool, aJ as SpoolActionContext, aK as SpoolData, aL as SpoolIds, aM as SpoolModule, aN as SpoolNormalMethods, aO as SpoolQuickMethods, aP as SpoolRewardPool, aQ as SpoolTxBlock, aR as Spools, aS as StakeAccount, aT as StakeAccounts, aU as StakePool, aV as StakePools, aW as StakeRewardPool, aX as StakeRewardPools, e as SuiObjectData, c as SuiObjectDataOptions, aZ as SuiObjectRef, a_ as SuiObjectResponse, a$ as SuiParsedData, b0 as SuiTxBlockWithBorrowIncentiveNormalMethods, b1 as SuiTxBlockWithCoreNormalMethods, b2 as SuiTxBlockWithLoyaltyProgramNormalMethods, b3 as SuiTxBlockWithObligationNamingNormalMethods, b4 as SuiTxBlockWithReferralNormalMethods, b5 as SuiTxBlockWithSCoin, b6 as SuiTxBlockWithSCoinNormalMethods, b7 as SuiTxBlockWithSpool, b8 as SuiTxBlockWithSpoolNormalMethods, b9 as SuiTxBlockWithVeScaNormalMethods, ba as SupportOracleType, bb as TotalValueLocked, bc as TransactionCommand, bd as VeSca, be as VeScaLoyaltyProgramInfo, bf as VeScaModule, bg as VeScaNormalMethods, bh as VeScaQuickMethods, bi as VeScaTreasuryInfo, bj as VeScaTxBlock, bd as Vesca, W as Whitelist, bk as _SUPPORT_ORACLES, bl as sCoinNormalMethods, bm as sCoinPkgIds, bn as sCoinQuickMethods, x as xOracleListType, bo as xOracleRuleType, bp as xOracleRules } from './query-b84awDFp.js';
2
2
  import '@tanstack/query-core';
3
3
  import './Logger-Cg2iFdpH.js';
4
4
  import '@mysten/sui/client';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scallop-io/sui-scallop-sdk",
3
- "version": "4.1.2",
3
+ "version": "4.3.0",
4
4
  "description": "Typescript sdk for interacting with Scallop contract on SUI",
5
5
  "keywords": [
6
6
  "sui",
@@ -94,7 +94,8 @@
94
94
  "doc": "typedoc --out docs src/index.ts"
95
95
  },
96
96
  "dependencies": {
97
- "@pythnetwork/pyth-sui-js": "2.2.0",
97
+ "@noble/hashes": "^2.2.0",
98
+ "@pythnetwork/pyth-sui-js": "3.0.0",
98
99
  "@scallop-io/sui-kit": "2.0.1",
99
100
  "@tanstack/query-core": "5.59.16",
100
101
  "axios": "1.13.6",
@@ -113,6 +114,7 @@
113
114
  "@mysten/utils": "0.0.0",
114
115
  "@protobuf-ts/grpcweb-transport": "2.11.1",
115
116
  "@protobuf-ts/runtime-rpc": "2.11.1",
117
+ "@pythnetwork/hermes-client": "3.1.0",
116
118
  "@pythnetwork/price-service-client": "1.11.0",
117
119
  "@pythnetwork/price-service-sdk": "1.9.0",
118
120
  "@types/node": "20.19.37",
@@ -11,7 +11,6 @@ export const queryKeys = {
11
11
  getPoolAddresses: () => ['api', 'getPoolAddresses'],
12
12
  getMarkets: () => ['api', 'getMarkets'],
13
13
  getSpools: () => ['api', 'getSpools'],
14
- getBorrowIncentivePools: () => ['api', 'getBorrowIncentivePools'],
15
14
  getTotalValueLocked: () => ['api', 'getTotalValueLocked'],
16
15
  },
17
16
 
@@ -73,12 +72,6 @@ export const queryKeys = {
73
72
  'getAllCoinBalances',
74
73
  props,
75
74
  ],
76
-
77
- getNormalizedMoveFunction: (
78
- props?: QueryKeys.RPC.GetNormalizedMoveFunction
79
- ) => {
80
- return ['rpc', 'getNormalizedMoveCall', props];
81
- },
82
75
  },
83
76
  oracle: {
84
77
  getPythLatestPriceFeeds: (endpoint?: string, priceIds?: string[]) => [
@@ -87,10 +80,5 @@ export const queryKeys = {
87
80
  priceIds,
88
81
  endpoint,
89
82
  ],
90
- getCoinPrices: (priceIds: string[]) => [
91
- 'oracle',
92
- 'getCoinPrices',
93
- priceIds,
94
- ],
95
83
  },
96
84
  };
@@ -270,7 +270,8 @@ export const TEST_ADDRESSES: AddressesInterface = {
270
270
  '0xb06657692f7f4d9eb0d7b7d6ac24db30e6fdaed64b09dee49664b496f687de46',
271
271
  incentiveAccounts:
272
272
  '0x0bf8168d983c18edcc6b2c2b2e85d2bdac84764babfecf1b567f98801fbf4942',
273
- incentiveAccountsTableId: '0x0',
273
+ incentiveAccountsTableId:
274
+ '0x654d17f0727366911aa3c6bb9f01dca757b677471032835839d17a77b26f7a99',
274
275
  query: '0xdbc22fe051d384691634cd3b9fe473b09723084a1e4c128728c42e2de3b2228f',
275
276
  adminCap:
276
277
  '0xc486afa253646f4d381e81d7f1df8aa4723b845a6bb356f69bad635ffefffe2c',
@@ -338,6 +339,13 @@ export const TEST_ADDRESSES: AddressesInterface = {
338
339
  veScaRewardTableId:
339
340
  '0x85d3e557d9bbed617b9cbc09982a0c9a6f6f4fc9ecce49b59124206c409c4774',
340
341
  },
342
+ obligationNaming: {
343
+ id: '0x9d16020b034d14ccb622f450bbd449dae3bf235a7fc57b21689645fc1066ab74',
344
+ namingRegistry:
345
+ '0xe948aeff7fa931cb94e70b1bfc15581f34e459fb3747cf927a62697f9cab3671',
346
+ registryTableId:
347
+ '0x684f623918d58ce932dc45e2fc7e68d52738b48da7e08d87a5bfb4e2114c493f',
348
+ },
341
349
  scoin: {
342
350
  id: '0xde8fe7f73fcaff729de640b1a67afff5028019aefa67c151250a8d47db37aa1c',
343
351
  coins: {
@@ -2,16 +2,16 @@ import axios, { type AxiosInstance } from 'axios';
2
2
 
3
3
  export type ApiDataSourceParams = {
4
4
  url?: string;
5
- client?: AxiosInstance;
5
+ httpClient?: AxiosInstance;
6
6
  timeout?: number;
7
7
  };
8
8
 
9
9
  export class ApiDataSource {
10
10
  private readonly client: AxiosInstance;
11
11
 
12
- constructor({ url, client, timeout = 8000 }: ApiDataSourceParams = {}) {
12
+ constructor({ url, httpClient, timeout = 8000 }: ApiDataSourceParams = {}) {
13
13
  this.client =
14
- client ??
14
+ httpClient ??
15
15
  axios.create({
16
16
  baseURL: url,
17
17
  headers: {
@@ -13,7 +13,6 @@ import { ScallopClientConstructorParams } from './scallopClient/types.js';
13
13
  * const scallopConstants = await sdk.getScallopConstants();
14
14
  * const scallopBuilder = await sdk.createScallopBuilder();
15
15
  * const scallopClient = await sdk.createScallopClient();
16
- * const scallopIndexer = await sdk.createScallopIndexer();
17
16
  * const scallopUtils = await sdk.createScallopUtils();
18
17
  * ```
19
18
  */
@@ -354,6 +354,11 @@ export const EMPTY_ADDRESSES: AddressesInterface = {
354
354
  veScaRewardPool: '',
355
355
  veScaRewardTableId: '',
356
356
  },
357
+ obligationNaming: {
358
+ id: '',
359
+ namingRegistry: '',
360
+ registryTableId: '',
361
+ },
357
362
  scoin: {
358
363
  id: '',
359
364
  coins: {
@@ -26,7 +26,7 @@ class ScallopAddress {
26
26
  addressId,
27
27
  url = API_BASE_URL,
28
28
  timeout,
29
- client,
29
+ httpClient,
30
30
  network = 'mainnet',
31
31
  logger = noopLogger,
32
32
  forceAddressesInterface,
@@ -36,7 +36,7 @@ class ScallopAddress {
36
36
  this.network = network;
37
37
  this.logger = logger;
38
38
  this.addressApiRepo = new AddressApiRepository({
39
- api: new ApiDataSource({ url, timeout, client }),
39
+ api: new ApiDataSource({ url, timeout, httpClient }),
40
40
  });
41
41
 
42
42
  if (forceAddressesInterface) {
@@ -174,6 +174,11 @@ export interface AddressesInterface {
174
174
  veScaRewardPool: string;
175
175
  veScaRewardTableId: string;
176
176
  };
177
+ obligationNaming: {
178
+ id: string;
179
+ namingRegistry: string;
180
+ registryTableId: string;
181
+ };
177
182
  scoin: {
178
183
  id: string;
179
184
  coins: Partial<
@@ -213,6 +213,16 @@ class ScallopQuery implements ScallopQueryInterface {
213
213
  return this.repos.obligation.getObligations(ownerAddress);
214
214
  }
215
215
 
216
+ /**
217
+ * Get the on-chain names for an address's obligations.
218
+ *
219
+ * @param ownerAddress - The owner address.
220
+ * @return A map of obligation id to its registered name (unnamed obligations are omitted).
221
+ */
222
+ async getObligationNames(ownerAddress: string = this.walletAddress) {
223
+ return this.repos.obligation.getObligationNames(ownerAddress);
224
+ }
225
+
216
226
  /**
217
227
  * Query obligation data.
218
228
  *
@@ -30,13 +30,13 @@ class ScallopUtils implements ScallopUtilsInterface {
30
30
 
31
31
  constructor(params: ScallopUtilsConstructorParams) {
32
32
  this.constants = params.scallopConstants ?? new ScallopConstants(params);
33
- if (params.client) {
33
+ if (params.suiClient) {
34
34
  const {
35
- client,
35
+ suiClient,
36
36
  fullnodeUrl,
37
37
  tokensPerSecond = DEFAULT_TOKENS_PER_SECOND,
38
38
  } = params;
39
- this.onchain = createOnChainDataSource(client, fullnodeUrl, {
39
+ this.onchain = createOnChainDataSource(suiClient, fullnodeUrl, {
40
40
  tokensPerSecond,
41
41
  });
42
42
  } else {
@@ -10,7 +10,7 @@ export type ScallopUtilsConstructorParams = {
10
10
  walletAddress: string;
11
11
  scallopConstants?: ScallopConstants;
12
12
  logger?: Logger;
13
- client?: ClientWithCoreApi;
13
+ suiClient?: ClientWithCoreApi;
14
14
  tokensPerSecond?: number;
15
15
  } & {
16
16
  network: SuiClientTypes.Network;
@@ -160,6 +160,10 @@ export interface AddressesInterface {
160
160
  veScaRewardPool: string;
161
161
  veScaRewardTableId: string;
162
162
  };
163
+ obligationNaming: {
164
+ id: string;
165
+ namingRegistry: string;
166
+ };
163
167
  scoin: {
164
168
  id: string;
165
169
  coins: Partial<
@@ -2,11 +2,13 @@ import { SuiClientTypes } from '@mysten/sui/client';
2
2
  import {
3
3
  Obligation,
4
4
  ObligationDataContext,
5
+ ObligationNamingContext,
5
6
  ObligationQueryInterface,
6
7
  ObligationsContext,
7
8
  } from './types.js';
8
9
  import { queryKeys } from 'src/constants/queryKeys.js';
9
10
  import {
11
+ computeNamingKey,
10
12
  getObligationFromObligationKey,
11
13
  mapObligationEventToObligationData,
12
14
  } from './utils.js';
@@ -15,6 +17,8 @@ import { logError, type OnChainReadContext } from '../utils.js';
15
17
  import { ScallopRpcError } from 'src/errors/index.js';
16
18
  import { SuiTxBlock } from '@scallop-io/sui-kit';
17
19
  import type { SuiObjectData } from 'src/types/index.js';
20
+ import { encodeDynamicFieldNameForV2 } from 'src/utils/dynamicField.js';
21
+ import { bcs } from '@mysten/sui/bcs';
18
22
 
19
23
  const queryObligationKeys = async (
20
24
  ctx: ObligationsContext,
@@ -226,3 +230,58 @@ export const getObligationObjectsFromOnChain = async (
226
230
  });
227
231
  return objects.map((object) => (object instanceof Error ? null : object));
228
232
  };
233
+
234
+ export const getObligationNamesFromOnChain = async (
235
+ ctx: ObligationNamingContext,
236
+ address: string
237
+ ) => {
238
+ const {
239
+ metadata: { addresses },
240
+ fetchWithCache,
241
+ onchain,
242
+ } = ctx;
243
+
244
+ const registryTableId = addresses.obligationNaming.registryTableId;
245
+
246
+ // Fetch all obligation keys for the given address
247
+ const keys = await queryObligationKeys(ctx, { address });
248
+
249
+ const results = await Promise.all(
250
+ keys.map(async (key) => {
251
+ const computedKey = computeNamingKey(key.objectId, address);
252
+ const options: SuiClientTypes.GetDynamicObjectFieldOptions<{
253
+ json: true;
254
+ }> = {
255
+ parentId: registryTableId,
256
+ name: encodeDynamicFieldNameForV2({
257
+ type: '0x2::object::ID',
258
+ value: computedKey,
259
+ }),
260
+ include: { json: true },
261
+ };
262
+
263
+ try {
264
+ const { dynamicField } = await fetchWithCache({
265
+ queryKey: queryKeys.rpc.getDynamicFieldObject({
266
+ ...options,
267
+ node: onchain.url,
268
+ }),
269
+ queryFn: () => onchain.client.getDynamicField(options),
270
+ });
271
+
272
+ return [
273
+ key.objectId,
274
+ bcs.string().parse(dynamicField.value.bcs),
275
+ ] as const;
276
+ } catch {
277
+ // Obligation has no name set (missing dynamic field) or the fetch
278
+ // failed — skip it instead of failing the whole batch.
279
+ return null;
280
+ }
281
+ })
282
+ );
283
+
284
+ return Object.fromEntries(
285
+ results.filter((r): r is readonly [string, string] => r !== null)
286
+ );
287
+ };
@@ -8,6 +8,7 @@ import { BaseRepository } from '../base.js';
8
8
  import { OnChainDataSource } from 'src/datasources/onchain.js';
9
9
  import {
10
10
  getObligationLockedFromOnChain,
11
+ getObligationNamesFromOnChain,
11
12
  getObligationObjectsFromOnChain,
12
13
  getObligationsFromOnChain,
13
14
  queryObligationData,
@@ -48,4 +49,8 @@ export class ObligationRepository extends BaseRepository<
48
49
  getObligationObjects(ids: string[]) {
49
50
  return getObligationObjectsFromOnChain(this.context, ids);
50
51
  }
52
+
53
+ getObligationNames(address: string) {
54
+ return getObligationNamesFromOnChain(this.context, address);
55
+ }
51
56
  }
@@ -6,11 +6,18 @@ type ObligationKeys =
6
6
  | 'queryPackageId'
7
7
  | 'version'
8
8
  | 'market';
9
+
10
+ type ObligationNamingAddresses = {
11
+ obligationNaming: {
12
+ registryTableId: string;
13
+ };
14
+ };
15
+
9
16
  export type ObligationAddresses<T extends ObligationKeys = ObligationKeys> =
10
17
  Record<T, string>;
11
18
 
12
19
  export type ObligationRepoMetadata = {
13
- addresses: ObligationAddresses;
20
+ addresses: ObligationAddresses & ObligationNamingAddresses;
14
21
  };
15
22
  export type ObligationRepoContext = BaseContext & {
16
23
  onchain: OnChainDataSource;
@@ -30,6 +37,15 @@ export type ObligationDataContext = BaseContext & {
30
37
  };
31
38
  };
32
39
 
40
+ /** Minimal context for `getObligationNameByObligationId`. */
41
+ export type ObligationNamingContext = BaseContext & {
42
+ onchain: OnChainDataSource;
43
+ metadata: {
44
+ addresses: ObligationNamingAddresses &
45
+ Pick<ObligationAddresses, 'protocolObjectId'>;
46
+ };
47
+ };
48
+
33
49
  /** Minimal context for listing obligations owned by an address. */
34
50
  export type ObligationsContext = BaseContext & {
35
51
  onchain: OnChainDataSource;
@@ -6,6 +6,8 @@ import {
6
6
  } from './types.js';
7
7
  import { mapTypeNameField } from 'src/mappers/moveTypeMapper.js';
8
8
  import { ScallopParseError } from 'src/errors/index.js';
9
+ import { bcs } from '@mysten/sui/bcs';
10
+ import { sha3_256 } from '@noble/hashes/sha3.js';
9
11
 
10
12
  export const getObligationFromObligationKey = (
11
13
  obligationKey: SuiClientTypes.Object<{ json: true }>
@@ -55,3 +57,23 @@ export const mapObligationEventToObligationData = (
55
57
  })),
56
58
  };
57
59
  };
60
+
61
+ /**
62
+ * Compute the naming key used by the obligation_naming contract.
63
+ * key = sha3_256(bcs(obligation_key_id) + bcs(sender))
64
+ */
65
+ export const computeNamingKey = (
66
+ obligationKeyId: string,
67
+ owner: string
68
+ ): string => {
69
+ const keyBytes = bcs.Address.serialize(obligationKeyId).toBytes();
70
+ const ownerBytes = bcs.Address.serialize(owner).toBytes();
71
+ const combined = new Uint8Array(keyBytes.length + ownerBytes.length);
72
+ combined.set(keyBytes, 0);
73
+ combined.set(ownerBytes, keyBytes.length);
74
+ const hashBytes = sha3_256(combined);
75
+ const hash = Array.from(hashBytes)
76
+ .map((b) => b.toString(16).padStart(2, '0'))
77
+ .join('');
78
+ return `0x${hash}`;
79
+ };
@@ -17,6 +17,7 @@ import { SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
17
17
  import type { SuiObjectData } from 'src/types/index.js';
18
18
  import { MarketCollateral, MarketPool } from '../market/types.js';
19
19
  import { partitionArray } from 'src/utils/array.js';
20
+ import { BigNumber } from 'bignumber.js';
20
21
 
21
22
  export const getPythPricesFromApi = async (
22
23
  ctx: PriceApiContext,
@@ -41,7 +42,11 @@ export const getPythPricesFromApi = async (
41
42
  );
42
43
 
43
44
  const client = new SuiPriceServiceConnection(endpoint, config);
44
- const feeds = await client.getLatestPriceFeeds(priceFeedIds);
45
+ const { parsed: feeds } = await client.getLatestPriceUpdates(priceFeedIds, {
46
+ parsed: true,
47
+ ignoreInvalidPriceIds: true,
48
+ });
49
+
45
50
  if (!feeds) {
46
51
  throw logError(
47
52
  ctx.logger,
@@ -59,7 +64,7 @@ export const getPythPricesFromApi = async (
59
64
  for (const feed of feeds) {
60
65
  priceByFeedId.set(
61
66
  feed.id,
62
- feed.getPriceUnchecked().getPriceAsNumberUnchecked()
67
+ BigNumber(feed.price.price).shiftedBy(feed.price.expo).toNumber()
63
68
  );
64
69
  }
65
70
 
@@ -1,8 +1,8 @@
1
1
  import { AddressesInterface } from 'src/types/address.js';
2
2
  import { BaseContext, BaseRepoParams } from '../types.js';
3
- import { PriceServiceConnectionConfig } from '@pythnetwork/pyth-sui-js';
4
3
  import { IndexerDataSource } from 'src/datasources/indexer.js';
5
4
  import { OnChainDataSource } from 'src/datasources/onchain.js';
5
+ import { HermesClientConfig } from '@pythnetwork/pyth-sui-js';
6
6
 
7
7
  // Derived from the canonical `core.coins` value shape (single source of truth for
8
8
  // the per-coin oracle/treasury config). Kept as a dense `Record` (the schema's is
@@ -20,7 +20,7 @@ export type PriceRepositoryMetadata = {
20
20
 
21
21
  export type PriceApiConfig = {
22
22
  endpoint: string;
23
- config: PriceServiceConnectionConfig;
23
+ config: HermesClientConfig;
24
24
  };
25
25
 
26
26
  export type PriceRepositoryContext = BaseContext & {
@@ -103,6 +103,7 @@ export const buildObligationMetadata = (
103
103
  queryPackageId: utils.address.get('core.packages.query.id'),
104
104
  version: utils.address.get('core.version'),
105
105
  market: utils.address.get('core.market'),
106
+ obligationNaming: utils.address.get('obligationNaming.registryTableId'),
106
107
  },
107
108
  });
108
109
 
@@ -9,6 +9,7 @@ import type { ScallopTxBlock, ScallopTxBlockModules } from 'src/types/index.js';
9
9
  import { newReferralTxBlock } from './referral/index.js';
10
10
  import { newLoyaltyProgramTxBlock } from './loyaltyProgram/index.js';
11
11
  import { newSCoinTxBlock } from './sCoin/index.js';
12
+ import { newObligationNamingTxBlock } from './obligationNaming/index.js';
12
13
  import { buildTxBlockModules, TX_BLOCK_MODULE_KEYS } from './modules.js';
13
14
 
14
15
  /**
@@ -29,7 +30,11 @@ export const newScallopTxBlock = (
29
30
  builder: ScallopBuilder,
30
31
  initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
31
32
  ): ScallopTxBlock => {
32
- const vescaTxBlock = newVeScaTxBlock(builder, initTxBlock);
33
+ const obligationNamingTxBlock = newObligationNamingTxBlock(
34
+ builder,
35
+ initTxBlock
36
+ );
37
+ const vescaTxBlock = newVeScaTxBlock(builder, obligationNamingTxBlock);
33
38
  const loyaltyTxBlock = newLoyaltyProgramTxBlock(builder, vescaTxBlock);
34
39
  const borrowIncentiveTxBlock = newBorrowIncentiveTxBlock(
35
40
  builder,
@@ -54,6 +59,8 @@ export const newScallopTxBlock = (
54
59
  return Reflect.get(loyaltyTxBlock, prop);
55
60
  } else if (prop in sCoinTxBlock) {
56
61
  return Reflect.get(sCoinTxBlock, prop);
62
+ } else if (prop in obligationNamingTxBlock) {
63
+ return Reflect.get(obligationNamingTxBlock, prop);
57
64
  }
58
65
  return Reflect.get(target, prop);
59
66
  },
@@ -102,6 +102,11 @@ export const SCOIN_METHODS = [
102
102
  'burnSCoinQuick',
103
103
  ] as const;
104
104
 
105
+ export const OBLIGATION_NAMING_METHODS = [
106
+ 'setObligationName',
107
+ 'removeObligationName',
108
+ ] as const;
109
+
105
110
  export type TxBlockModuleName =
106
111
  | 'core.normal'
107
112
  | 'core.quick'
@@ -110,7 +115,8 @@ export type TxBlockModuleName =
110
115
  | 'vesca'
111
116
  | 'referral'
112
117
  | 'loyalty'
113
- | 'sCoin';
118
+ | 'sCoin'
119
+ | 'obligationNaming';
114
120
 
115
121
  export type TxBlockManifest = Record<TxBlockModuleName, readonly string[]>;
116
122
 
@@ -123,6 +129,7 @@ export const TX_BLOCK_MANIFEST: TxBlockManifest = {
123
129
  referral: REFERRAL_METHODS,
124
130
  loyalty: LOYALTY_METHODS,
125
131
  sCoin: SCOIN_METHODS,
132
+ obligationNaming: OBLIGATION_NAMING_METHODS,
126
133
  };
127
134
 
128
135
  /**
@@ -7,6 +7,7 @@ import {
7
7
  REFERRAL_METHODS,
8
8
  LOYALTY_METHODS,
9
9
  SCOIN_METHODS,
10
+ OBLIGATION_NAMING_METHODS,
10
11
  } from './manifest.js';
11
12
  import type { ScallopTxBlockModules } from 'src/types/index.js';
12
13
 
@@ -56,6 +57,10 @@ export const buildTxBlockModules = (
56
57
  LOYALTY_METHODS
57
58
  ),
58
59
  sCoin: pickMethods<ScallopTxBlockModules['sCoin']>(src, SCOIN_METHODS),
60
+ obligationNaming: pickMethods<ScallopTxBlockModules['obligationNaming']>(
61
+ src,
62
+ OBLIGATION_NAMING_METHODS
63
+ ),
59
64
  });
60
65
  };
61
66
 
@@ -67,4 +72,5 @@ export const TX_BLOCK_MODULE_KEYS = [
67
72
  'referral',
68
73
  'loyalty',
69
74
  'sCoin',
75
+ 'obligationNaming',
70
76
  ] as const satisfies readonly (keyof ScallopTxBlockModules)[];
@@ -0,0 +1,46 @@
1
+ import { Transaction } from '@mysten/sui/transactions';
2
+ import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
3
+ import { ScallopBuilder } from 'src/models/index.js';
4
+ import { ObligationNamingTxBlock, ScallopTxBlock } from 'src/types/index.js';
5
+ import { generateObligationNamingNormalMethod } from './moveCalls.js';
6
+ import type { MoveCallContext } from '../context.js';
7
+
8
+ /**
9
+ * Create an enhanced transaction block instance for interaction with obligation naming modules of the Scallop contract.
10
+ *
11
+ * @param builder - Scallop builder instance.
12
+ * @param initTxBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
13
+ * @return Scallop obligation naming txBlock.
14
+ */
15
+ export const newObligationNamingTxBlock = (
16
+ builder: ScallopBuilder,
17
+ initTxBlock?: ScallopTxBlock | SuiKitTxBlock | Transaction
18
+ ) => {
19
+ const txBlock =
20
+ initTxBlock instanceof Transaction
21
+ ? new SuiKitTxBlock(initTxBlock)
22
+ : initTxBlock
23
+ ? initTxBlock
24
+ : new SuiKitTxBlock();
25
+
26
+ // Build the narrow contexts once from `builder`, binding the closures.
27
+ const moveCallContext: MoveCallContext = {
28
+ address: builder.address,
29
+ moveCall: builder.moveCall.bind(builder),
30
+ utils: builder.utils,
31
+ };
32
+
33
+ const normalMethod = generateObligationNamingNormalMethod({
34
+ ctx: moveCallContext,
35
+ txBlock,
36
+ });
37
+
38
+ return new Proxy(txBlock, {
39
+ get: (target, prop) => {
40
+ if (prop in normalMethod) {
41
+ return Reflect.get(normalMethod, prop);
42
+ }
43
+ return Reflect.get(target, prop);
44
+ },
45
+ }) as ObligationNamingTxBlock;
46
+ };