@scallop-io/sui-scallop-sdk 4.2.0 → 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.
- package/README.md +356 -139
- package/dist/builder.cjs +5 -4
- package/dist/builder.d.cts +2 -2
- package/dist/builder.d.ts +2 -2
- package/dist/builder.js +2 -2
- package/dist/chunk-FNZDTB3A.js +16 -0
- package/dist/chunk-UCRLKWQI.js +11 -0
- package/dist/{chunk-4IC4UXW5.js → chunk-ZAFUZGSI.js} +2 -2
- package/dist/client.cjs +5 -4
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.js +3 -3
- package/dist/index.cjs +21 -20
- package/dist/index.d.cts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +4 -4
- package/dist/{query-CXvcpnYj.d.ts → query-b84awDFp.d.ts} +25 -7
- package/dist/query.cjs +5 -4
- package/dist/query.d.cts +1 -1
- package/dist/query.d.ts +1 -1
- package/dist/query.js +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +4 -2
- package/src/constants/queryKeys.ts +0 -12
- package/src/constants/testAddress.ts +2 -0
- package/src/datasources/api.ts +3 -3
- package/src/models/scallopAddress/const.ts +1 -0
- package/src/models/scallopAddress/index.ts +2 -2
- package/src/models/scallopAddress/types.ts +1 -0
- package/src/models/scallopQuery/index.ts +10 -0
- package/src/models/scallopUtils/index.ts +3 -3
- package/src/models/scallopUtils/types.ts +1 -1
- package/src/repositories/obligation/helpers.ts +59 -0
- package/src/repositories/obligation/index.ts +5 -0
- package/src/repositories/obligation/types.ts +17 -1
- package/src/repositories/obligation/utils.ts +22 -0
- package/src/repositories/price/helpers.ts +7 -2
- package/src/repositories/price/types.ts +2 -2
- package/src/repositories/wiring/metadata.ts +1 -0
- package/src/txBuilders/oracles/pyth.ts +1 -5
- package/dist/chunk-3T4T4AON.js +0 -15
- package/dist/chunk-6YLMI74S.js +0 -11
package/dist/query.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { f as ScallopQuery, bu as ScallopQueryConstructorParams, bu as ScallopQueryParams } from './query-
|
|
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, bu as ScallopQueryConstructorParams, bu as ScallopQueryParams } from './query-
|
|
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
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 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-
|
|
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 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-
|
|
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.
|
|
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
|
-
"@
|
|
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
|
};
|
|
@@ -343,6 +343,8 @@ export const TEST_ADDRESSES: AddressesInterface = {
|
|
|
343
343
|
id: '0x9d16020b034d14ccb622f450bbd449dae3bf235a7fc57b21689645fc1066ab74',
|
|
344
344
|
namingRegistry:
|
|
345
345
|
'0xe948aeff7fa931cb94e70b1bfc15581f34e459fb3747cf927a62697f9cab3671',
|
|
346
|
+
registryTableId:
|
|
347
|
+
'0x684f623918d58ce932dc45e2fc7e68d52738b48da7e08d87a5bfb4e2114c493f',
|
|
346
348
|
},
|
|
347
349
|
scoin: {
|
|
348
350
|
id: '0xde8fe7f73fcaff729de640b1a67afff5028019aefa67c151250a8d47db37aa1c',
|
package/src/datasources/api.ts
CHANGED
|
@@ -2,16 +2,16 @@ import axios, { type AxiosInstance } from 'axios';
|
|
|
2
2
|
|
|
3
3
|
export type ApiDataSourceParams = {
|
|
4
4
|
url?: string;
|
|
5
|
-
|
|
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,
|
|
12
|
+
constructor({ url, httpClient, timeout = 8000 }: ApiDataSourceParams = {}) {
|
|
13
13
|
this.client =
|
|
14
|
-
|
|
14
|
+
httpClient ??
|
|
15
15
|
axios.create({
|
|
16
16
|
baseURL: url,
|
|
17
17
|
headers: {
|
|
@@ -26,7 +26,7 @@ class ScallopAddress {
|
|
|
26
26
|
addressId,
|
|
27
27
|
url = API_BASE_URL,
|
|
28
28
|
timeout,
|
|
29
|
-
|
|
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,
|
|
39
|
+
api: new ApiDataSource({ url, timeout, httpClient }),
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
if (forceAddressesInterface) {
|
|
@@ -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.
|
|
33
|
+
if (params.suiClient) {
|
|
34
34
|
const {
|
|
35
|
-
|
|
35
|
+
suiClient,
|
|
36
36
|
fullnodeUrl,
|
|
37
37
|
tokensPerSecond = DEFAULT_TOKENS_PER_SECOND,
|
|
38
38
|
} = params;
|
|
39
|
-
this.onchain = createOnChainDataSource(
|
|
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
|
-
|
|
13
|
+
suiClient?: ClientWithCoreApi;
|
|
14
14
|
tokensPerSecond?: number;
|
|
15
15
|
} & {
|
|
16
16
|
network: SuiClientTypes.Network;
|
|
@@ -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.
|
|
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.
|
|
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:
|
|
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
|
|
|
@@ -125,11 +125,7 @@ export const updatePythPriceFeeds = async (
|
|
|
125
125
|
// iterate through the endpoints
|
|
126
126
|
for (const endpoint of endpoints) {
|
|
127
127
|
try {
|
|
128
|
-
const pythConnection = new SuiPriceServiceConnection(endpoint
|
|
129
|
-
priceFeedRequestConfig: {
|
|
130
|
-
binary: true,
|
|
131
|
-
},
|
|
132
|
-
});
|
|
128
|
+
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
133
129
|
const priceUpdateData =
|
|
134
130
|
await pythConnection.getPriceFeedsUpdateData(priceIds);
|
|
135
131
|
|