@scallop-io/sui-scallop-sdk 2.2.3-pyth-sponsored-transaction-alpha.1 → 2.3.0-lst-x-oracle-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/address-Bp_gAUMw.d.ts +165 -0
- package/dist/chunk-4GSK5DO7.js +25 -0
- package/dist/chunk-B4M6FI47.mjs +5 -0
- package/dist/constants/index.d.mts +262 -0
- package/dist/constants/index.d.ts +262 -0
- package/dist/constants/index.js +86 -0
- package/dist/constants/index.mjs +5 -0
- package/dist/models/index.d.mts +393 -0
- package/dist/models/index.d.ts +393 -0
- package/dist/models/index.js +34 -0
- package/dist/models/index.mjs +16 -0
- package/dist/queryKeys-AaZqDYle.d.ts +43 -0
- package/dist/{index.d.mts → scallopUtils-Cxm9zldY.d.ts} +1748 -2586
- package/dist/types/index.d.mts +9 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +23 -11
- package/src/builders/borrowIncentiveBuilder.ts +2 -2
- package/src/builders/coreBuilder.ts +5 -14
- package/src/builders/index.ts +2 -2
- package/src/builders/oracles/error.ts +29 -0
- package/src/builders/oracles/index.ts +114 -365
- package/src/builders/oracles/oraclePackageRegistry.ts +323 -0
- package/src/builders/oracles/priceFeedUpdater.ts +112 -0
- package/src/builders/oracles/priceUpdateRequester.ts +50 -0
- package/src/builders/oracles/xOracleUpdateStrategy.ts +178 -0
- package/src/builders/oracles/xOracleUpdater.ts +160 -0
- package/src/builders/vescaBuilder.ts +2 -2
- package/src/constants/api.ts +2 -0
- package/src/constants/common.ts +0 -3
- package/src/constants/index.ts +2 -1
- package/src/constants/package.ts +14 -0
- package/src/constants/testAddress.ts +190 -105
- package/src/constants/xoracle.ts +8 -2
- package/src/models/scallopAddress.ts +24 -4
- package/src/models/scallopBuilder.ts +4 -4
- package/src/models/scallopClient.ts +1 -1
- package/src/models/scallopConstants.ts +2 -2
- package/src/models/scallopIndexer.ts +3 -2
- package/src/models/scallopQuery.ts +52 -36
- package/src/models/scallopQueryClient.ts +1 -1
- package/src/models/scallopSuiKit.ts +1 -1
- package/src/models/scallopUtils.ts +5 -8
- package/src/queries/borrowIncentiveQuery.ts +2 -3
- package/src/queries/coreQuery.ts +2 -3
- package/src/queries/index.ts +4 -3
- package/src/queries/loyaltyProgramQuery.ts +1 -1
- package/src/queries/portfolioQuery.ts +13 -13
- package/src/queries/sCoinQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +8 -8
- package/src/queries/vescaQuery.ts +2 -2
- package/src/queries/xOracleQuery.ts +20 -3
- package/src/types/address.ts +85 -47
- package/src/types/builder/core.ts +2 -4
- package/src/types/constant/index.ts +2 -1
- package/src/types/constant/package.ts +3 -0
- package/src/types/constant/xOracle.ts +10 -7
- package/src/types/query/index.ts +0 -1
- package/src/utils/builder.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/query.ts +6 -6
- package/src/utils/util.ts +1 -1
- package/dist/index.d.ts +0 -3242
- package/dist/index.js +0 -49
- package/dist/index.mjs +0 -15
- package/src/builders/oracles/pyth.ts +0 -52
- package/src/index.ts +0 -13
- package/src/queries/ownerQuery.ts +0 -32
- package/src/types/constant/enum.ts +0 -64
- package/src/types/query/sCoin.ts +0 -1
|
@@ -2,65 +2,82 @@ import ScallopUtils, { ScallopUtilsParams } from './scallopUtils';
|
|
|
2
2
|
import ScallopIndexer, { ScallopIndexerParams } from './scallopIndexer';
|
|
3
3
|
import { withIndexerFallback } from 'src/utils';
|
|
4
4
|
import {
|
|
5
|
-
CoinPrices,
|
|
6
5
|
MarketCollaterals,
|
|
7
6
|
MarketPool,
|
|
8
7
|
MarketPools,
|
|
9
8
|
StakePools,
|
|
10
9
|
StakeRewardPools,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
} from '
|
|
10
|
+
} from 'src/types/query';
|
|
11
|
+
import { SuiObjectRef, SuiObjectData } from '@mysten/sui/dist/cjs/client';
|
|
12
|
+
import { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
13
|
+
import { ScallopQueryInterface } from './interface';
|
|
14
14
|
import {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
getBorrowIncentivePools,
|
|
16
|
+
queryBorrowIncentiveAccounts,
|
|
17
17
|
getBindedObligationId,
|
|
18
18
|
getBindedVeScaKey,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
} from 'src/queries/borrowIncentiveQuery';
|
|
20
|
+
import { getBorrowLimit } from 'src/queries/borrowLimitQuery';
|
|
21
|
+
import {
|
|
22
|
+
queryMarket,
|
|
23
|
+
getMarketPools,
|
|
24
|
+
getMarketCollaterals,
|
|
25
|
+
getMarketCollateral,
|
|
26
|
+
getObligations,
|
|
27
|
+
queryObligation,
|
|
22
28
|
getCoinAmounts,
|
|
29
|
+
getCoinAmount,
|
|
30
|
+
getMarketCoinAmounts,
|
|
31
|
+
getMarketCoinAmount,
|
|
23
32
|
getFlashLoanFees,
|
|
33
|
+
} from 'src/queries/coreQuery';
|
|
34
|
+
import {
|
|
24
35
|
getIsolatedAssets,
|
|
25
|
-
|
|
26
|
-
|
|
36
|
+
isIsolatedAsset,
|
|
37
|
+
} from 'src/queries/isolatedAssetQuery';
|
|
38
|
+
import {
|
|
27
39
|
getLoyaltyProgramInformations,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
40
|
+
getVeScaLoyaltyProgramInformations,
|
|
41
|
+
} from 'src/queries/loyaltyProgramQuery';
|
|
42
|
+
import { getPoolAddresses } from 'src/queries/poolAddressesQuery';
|
|
43
|
+
import {
|
|
44
|
+
getLendings,
|
|
45
|
+
getLending,
|
|
33
46
|
getObligationAccounts,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
getTotalValueLocked,
|
|
48
|
+
getUserPortfolio,
|
|
49
|
+
} from 'src/queries/portfolioQuery';
|
|
50
|
+
import {
|
|
38
51
|
getPythPrice,
|
|
39
52
|
getPythPrices,
|
|
40
|
-
|
|
53
|
+
getAllCoinPrices,
|
|
54
|
+
} from 'src/queries/priceQuery';
|
|
55
|
+
import { queryVeScaKeyIdFromReferralBindings } from 'src/queries/referralQuery';
|
|
56
|
+
import {
|
|
57
|
+
getSCoinTotalSupply,
|
|
41
58
|
getSCoinAmounts,
|
|
59
|
+
getSCoinAmount,
|
|
42
60
|
getSCoinSwapRate,
|
|
43
|
-
|
|
61
|
+
} from 'src/queries/sCoinQuery';
|
|
62
|
+
import {
|
|
44
63
|
getSpools,
|
|
45
64
|
getStakeAccounts,
|
|
46
65
|
getStakePool,
|
|
47
66
|
getStakeRewardPool,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
67
|
+
} from 'src/queries/spoolQuery';
|
|
68
|
+
import { getSupplyLimit } from 'src/queries/supplyLimitQuery';
|
|
69
|
+
import { getOnDemandAggObjectIds } from 'src/queries/switchboardQuery';
|
|
70
|
+
import {
|
|
51
71
|
getVeSca,
|
|
52
|
-
getVeScaLoyaltyProgramInformations,
|
|
53
72
|
getVeScas,
|
|
54
73
|
getVeScaTreasuryInfo,
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
} from 'src/
|
|
61
|
-
import {
|
|
62
|
-
import { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
63
|
-
import { ScallopQueryInterface } from './interface';
|
|
74
|
+
} from 'src/queries/vescaQuery';
|
|
75
|
+
import {
|
|
76
|
+
getPriceUpdatePolicies,
|
|
77
|
+
getAssetOracles,
|
|
78
|
+
} from 'src/queries/xOracleQuery';
|
|
79
|
+
import { CoinPrices } from 'src/types/utils';
|
|
80
|
+
import { SupportOracleType, xOracleRules } from 'src/types/constant';
|
|
64
81
|
|
|
65
82
|
export type ScallopQueryParams = {
|
|
66
83
|
indexer?: ScallopIndexer;
|
|
@@ -851,7 +868,6 @@ class ScallopQuery implements ScallopQueryInterface {
|
|
|
851
868
|
|
|
852
869
|
/**
|
|
853
870
|
* Return the supported primary and secondary oracles for all supported pool assets
|
|
854
|
-
* @returns
|
|
855
871
|
*/
|
|
856
872
|
async getAssetOracles() {
|
|
857
873
|
const [primary, secondary] = await Promise.all([
|
|
@@ -7,18 +7,16 @@ import {
|
|
|
7
7
|
Transaction,
|
|
8
8
|
} from '@scallop-io/sui-kit';
|
|
9
9
|
import ScallopConstants, { ScallopConstantsParams } from './scallopConstants';
|
|
10
|
-
import { CoinPrices, CoinWrappedType, PoolAddress } from 'src/types';
|
|
11
10
|
import { findClosestUnlockRound } from 'src/utils';
|
|
12
|
-
import {
|
|
13
|
-
MAX_LOCK_DURATION,
|
|
14
|
-
queryKeys,
|
|
15
|
-
UNLOCK_ROUND_DURATION,
|
|
16
|
-
} from 'src/constants';
|
|
17
11
|
import { PriceFeed, SuiPriceServiceConnection } from '@pythnetwork/pyth-sui-js';
|
|
18
12
|
import ScallopSuiKit, { ScallopSuiKitParams } from './scallopSuiKit';
|
|
19
13
|
import { SuiObjectData } from '@mysten/sui/dist/cjs/client';
|
|
20
|
-
import { queryObligation } from 'src/queries';
|
|
14
|
+
import { queryObligation } from 'src/queries/coreQuery';
|
|
21
15
|
import { ScallopUtilsInterface } from './interface';
|
|
16
|
+
import { MAX_LOCK_DURATION, UNLOCK_ROUND_DURATION } from 'src/constants/vesca';
|
|
17
|
+
import { queryKeys } from 'src/constants/queryKeys';
|
|
18
|
+
import { CoinWrappedType, PoolAddress } from 'src/types/constant';
|
|
19
|
+
import { CoinPrices } from 'src/types/utils';
|
|
22
20
|
|
|
23
21
|
export type ScallopUtilsParams = {
|
|
24
22
|
pythEndpoints?: string[];
|
|
@@ -43,7 +41,6 @@ class ScallopUtils implements ScallopUtilsInterface {
|
|
|
43
41
|
|
|
44
42
|
this.pythEndpoints = params.pythEndpoints ?? [
|
|
45
43
|
'https://hermes.pyth.network',
|
|
46
|
-
'https://scallop.rpc.p2p.world',
|
|
47
44
|
];
|
|
48
45
|
}
|
|
49
46
|
|
|
@@ -16,12 +16,11 @@ import type {
|
|
|
16
16
|
BorrowIncentiveAccountsQueryInterface,
|
|
17
17
|
BorrowIncentiveAccounts,
|
|
18
18
|
BorrowIncentivePoolPoints,
|
|
19
|
-
OptionalKeys,
|
|
20
|
-
CoinPrices,
|
|
21
19
|
MarketPools,
|
|
22
|
-
} from 'src/types';
|
|
20
|
+
} from 'src/types/query';
|
|
23
21
|
import BigNumber from 'bignumber.js';
|
|
24
22
|
import { SuiObjectRef } from '@mysten/sui/client';
|
|
23
|
+
import { CoinPrices, OptionalKeys } from 'src/types/utils';
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* Query borrow incentive pools data using moveCall
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -26,13 +26,11 @@ import {
|
|
|
26
26
|
BalanceSheet,
|
|
27
27
|
RiskModel,
|
|
28
28
|
CollateralStat,
|
|
29
|
-
OptionalKeys,
|
|
30
|
-
CoinPrices,
|
|
31
29
|
OriginMarketPoolData,
|
|
32
30
|
BorrowFee,
|
|
33
31
|
BorrowDynamic,
|
|
34
32
|
OriginMarketCollateralData,
|
|
35
|
-
} from 'src/types';
|
|
33
|
+
} from 'src/types/query';
|
|
36
34
|
import BigNumber from 'bignumber.js';
|
|
37
35
|
import { getSupplyLimit } from './supplyLimitQuery';
|
|
38
36
|
import { isIsolatedAsset } from './isolatedAssetQuery';
|
|
@@ -45,6 +43,7 @@ import {
|
|
|
45
43
|
ScallopIndexer,
|
|
46
44
|
ScallopAddress,
|
|
47
45
|
} from 'src/models';
|
|
46
|
+
import { CoinPrices, OptionalKeys } from 'src/types';
|
|
48
47
|
|
|
49
48
|
/**
|
|
50
49
|
* Query market data.
|
package/src/queries/index.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
export * from './borrowIncentiveQuery';
|
|
2
|
+
export * from './borrowLimitQuery';
|
|
2
3
|
export * from './coreQuery';
|
|
4
|
+
export * from './flashloanFeeQuery';
|
|
3
5
|
export * from './isolatedAssetQuery';
|
|
4
6
|
export * from './loyaltyProgramQuery';
|
|
7
|
+
export * from './poolAddressesQuery';
|
|
5
8
|
export * from './portfolioQuery';
|
|
6
9
|
export * from './priceQuery';
|
|
7
10
|
export * from './referralQuery';
|
|
8
11
|
export * from './sCoinQuery';
|
|
9
12
|
export * from './spoolQuery';
|
|
10
13
|
export * from './supplyLimitQuery';
|
|
11
|
-
export * from './vescaQuery';
|
|
12
|
-
export * from './borrowLimitQuery';
|
|
13
|
-
export * from './poolAddressesQuery';
|
|
14
14
|
export * from './switchboardQuery';
|
|
15
|
+
export * from './vescaQuery';
|
|
15
16
|
export * from './xOracleQuery';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SuiObjectData } from '@mysten/sui/client';
|
|
2
2
|
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { MAX_LOCK_DURATION } from 'src/constants';
|
|
3
|
+
import { MAX_LOCK_DURATION } from 'src/constants/vesca';
|
|
4
4
|
import { ScallopQuery } from 'src/models';
|
|
5
5
|
import { LoyaltyProgramInfo, VeScaLoyaltyProgramInfo } from 'src/types';
|
|
6
6
|
import { z as zod } from 'zod';
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { minBigNumber, estimatedFactor } from 'src/utils';
|
|
3
3
|
import type { ScallopQuery } from 'src/models';
|
|
4
|
-
import
|
|
4
|
+
import { SuiObjectRef } from '@mysten/sui/client';
|
|
5
|
+
import { normalizeStructTag, SUI_TYPE_ARG } from '@scallop-io/sui-kit';
|
|
6
|
+
import {
|
|
7
|
+
CoinAmounts,
|
|
8
|
+
Lending,
|
|
9
|
+
Lendings,
|
|
5
10
|
Market,
|
|
11
|
+
MarketCollaterals,
|
|
6
12
|
MarketPool,
|
|
13
|
+
MarketPools,
|
|
14
|
+
ObligationAccount,
|
|
15
|
+
ObligationAccounts,
|
|
16
|
+
ObligationBorrowIncentiveReward,
|
|
7
17
|
Spool,
|
|
8
18
|
StakeAccount,
|
|
9
|
-
Lendings,
|
|
10
|
-
Lending,
|
|
11
|
-
ObligationAccounts,
|
|
12
|
-
ObligationAccount,
|
|
13
|
-
CoinAmounts,
|
|
14
|
-
CoinPrices,
|
|
15
19
|
TotalValueLocked,
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
MarketCollaterals,
|
|
19
|
-
} from 'src/types';
|
|
20
|
-
import { SuiObjectRef } from '@mysten/sui/client';
|
|
21
|
-
import { normalizeStructTag, SUI_TYPE_ARG } from '@scallop-io/sui-kit';
|
|
20
|
+
} from 'src/types/query';
|
|
21
|
+
import { CoinPrices } from 'src/types/utils';
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Get user lending infomation for specific pools.
|
|
@@ -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
|
|
5
|
+
import { OptionalKeys } from 'src/types';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Get total supply of sCoin
|
|
@@ -17,7 +17,7 @@ export const getSCoinTotalSupply = async (
|
|
|
17
17
|
utils: ScallopUtils;
|
|
18
18
|
},
|
|
19
19
|
sCoinName: string
|
|
20
|
-
): Promise<
|
|
20
|
+
): Promise<number> => {
|
|
21
21
|
const sCoinPkgId = utils.address.get('scoin.id');
|
|
22
22
|
// get treasury
|
|
23
23
|
const args = [utils.getSCoinTreasury(sCoinName)];
|
|
@@ -8,18 +8,18 @@ import {
|
|
|
8
8
|
} from 'src/utils';
|
|
9
9
|
import type { SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';
|
|
10
10
|
import type { ScallopQuery, ScallopUtils } from 'src/models';
|
|
11
|
-
import
|
|
11
|
+
import { CoinPrices } from 'src/types';
|
|
12
|
+
import {
|
|
13
|
+
OriginSpoolData,
|
|
14
|
+
OriginSpoolRewardPoolData,
|
|
15
|
+
SpoolData,
|
|
16
|
+
MarketPools,
|
|
12
17
|
Spools,
|
|
13
18
|
Spool,
|
|
19
|
+
StakeAccounts,
|
|
14
20
|
StakePool,
|
|
15
21
|
StakeRewardPool,
|
|
16
|
-
|
|
17
|
-
CoinPrices,
|
|
18
|
-
MarketPools,
|
|
19
|
-
OriginSpoolRewardPoolData,
|
|
20
|
-
SpoolData,
|
|
21
|
-
OriginSpoolData,
|
|
22
|
-
} from '../types';
|
|
22
|
+
} from 'src/types/query';
|
|
23
23
|
|
|
24
24
|
const queryRequiredSpoolObjects = async (
|
|
25
25
|
query: ScallopQuery,
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
DevInspectResults,
|
|
7
7
|
} from '@mysten/sui/client';
|
|
8
8
|
import type { ScallopUtils } from 'src/models';
|
|
9
|
-
import { MAX_LOCK_DURATION } from 'src/constants';
|
|
9
|
+
import { MAX_LOCK_DURATION } from 'src/constants/vesca';
|
|
10
10
|
import { SUI_CLOCK_OBJECT_ID, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
11
11
|
import { bcs } from '@mysten/sui/bcs';
|
|
12
12
|
import { z as zod } from 'zod';
|
|
13
|
-
import { queryKeys } from 'src/constants';
|
|
13
|
+
import { queryKeys } from 'src/constants/queryKeys';
|
|
14
14
|
import assert from 'assert';
|
|
15
15
|
/**
|
|
16
16
|
* Query all owned veSca key.
|
|
@@ -61,11 +61,28 @@ export const getAssetOracles = async (
|
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
const createRuleType = (objectId: string): string => {
|
|
65
|
+
return `${objectId}::rule::Rule`;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const pythLstRuleTypeNameToOracleType: Record<string, SupportOracleType> =
|
|
69
|
+
Object.values<{
|
|
70
|
+
object: string;
|
|
71
|
+
}>(utils.address.get('core.packages.pyth.lst') ?? {}).reduce(
|
|
72
|
+
(acc, curr) => {
|
|
73
|
+
acc[createRuleType(curr.object)] = 'pyth';
|
|
74
|
+
return acc;
|
|
75
|
+
},
|
|
76
|
+
{} as Record<string, SupportOracleType>
|
|
77
|
+
);
|
|
78
|
+
|
|
64
79
|
const ruleTypeNameToOracleType: Record<string, SupportOracleType> = {
|
|
65
|
-
[
|
|
66
|
-
|
|
67
|
-
[
|
|
80
|
+
[createRuleType(utils.address.get('core.packages.pyth.object'))]: 'pyth',
|
|
81
|
+
// include the pyth lst type
|
|
82
|
+
[createRuleType(utils.address.get('core.packages.supra.object'))]: 'supra',
|
|
83
|
+
[createRuleType(utils.address.get('core.packages.switchboard.object'))]:
|
|
68
84
|
'switchboard',
|
|
85
|
+
...pythLstRuleTypeNameToOracleType,
|
|
69
86
|
};
|
|
70
87
|
|
|
71
88
|
const assetOracles = {} as Record<string, SupportOracleType[]>;
|
package/src/types/address.ts
CHANGED
|
@@ -1,5 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SUPPORT_ORACLE_LST, SUPPORT_ORACLES } from 'src/constants/xoracle';
|
|
2
|
+
import { SupportOracleType, SupportedOracleSuiLst } from './constant/xOracle';
|
|
3
|
+
import { PackageName } from './constant/package';
|
|
2
4
|
|
|
5
|
+
export type BasePackage = {
|
|
6
|
+
id: string;
|
|
7
|
+
object?: string;
|
|
8
|
+
upgradeCap?: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type OracleLstPackage = {
|
|
12
|
+
[K in SupportedOracleSuiLst]: BasePackage;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
type OraclePackage<T> = BasePackage & T extends SupportOracleLst
|
|
16
|
+
? BasePackage & {
|
|
17
|
+
lst: OracleLstPackage;
|
|
18
|
+
}
|
|
19
|
+
: BasePackage;
|
|
20
|
+
|
|
21
|
+
type Packages<
|
|
22
|
+
T extends SupportOracleType | PackageName = SupportOracleType | PackageName,
|
|
23
|
+
> = T extends SupportOracleType
|
|
24
|
+
? Record<T, OraclePackage<T>>
|
|
25
|
+
: T extends PackageName
|
|
26
|
+
? Record<T, BasePackage>
|
|
27
|
+
: never;
|
|
28
|
+
|
|
29
|
+
export type SupportOracleLst = (typeof SUPPORT_ORACLE_LST)[number];
|
|
30
|
+
|
|
31
|
+
export type OracleLstConfig<T extends SupportedOracleSuiLst> = T extends 'afsui'
|
|
32
|
+
? Record<
|
|
33
|
+
T,
|
|
34
|
+
{
|
|
35
|
+
stakedSuiVaultId: string;
|
|
36
|
+
safeId: string;
|
|
37
|
+
configId: string;
|
|
38
|
+
}
|
|
39
|
+
>
|
|
40
|
+
: never;
|
|
41
|
+
|
|
42
|
+
export type OracleLst<
|
|
43
|
+
T extends SupportOracleLst,
|
|
44
|
+
U extends SupportedOracleSuiLst = SupportedOracleSuiLst,
|
|
45
|
+
> = T extends 'pyth' ? OracleLstConfig<U> : undefined;
|
|
46
|
+
|
|
47
|
+
type MaybeWithOracleLst<T, U> = T extends SupportOracleLst
|
|
48
|
+
? U & {
|
|
49
|
+
lst: OracleLst<T>;
|
|
50
|
+
}
|
|
51
|
+
: U;
|
|
3
52
|
export interface AddressesInterface {
|
|
4
53
|
id?: string;
|
|
5
54
|
core: {
|
|
@@ -21,11 +70,11 @@ export interface AddressesInterface {
|
|
|
21
70
|
symbol: string;
|
|
22
71
|
decimals: number;
|
|
23
72
|
oracle: {
|
|
24
|
-
[K in SupportOracleType]: K extends (typeof
|
|
73
|
+
[K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
|
|
25
74
|
? string
|
|
26
|
-
: K extends (typeof
|
|
75
|
+
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
27
76
|
? string
|
|
28
|
-
: K extends (typeof
|
|
77
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
29
78
|
? {
|
|
30
79
|
feed: string;
|
|
31
80
|
feedObject: string;
|
|
@@ -36,27 +85,36 @@ export interface AddressesInterface {
|
|
|
36
85
|
>
|
|
37
86
|
>;
|
|
38
87
|
oracles: {
|
|
39
|
-
[K in SupportOracleType]: K extends (typeof
|
|
40
|
-
?
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
holder: string;
|
|
44
|
-
}
|
|
45
|
-
: K extends (typeof _SUPPORT_ORACLES)[1]
|
|
46
|
-
? {
|
|
88
|
+
[K in SupportOracleType]: K extends (typeof SUPPORT_ORACLES)[0]
|
|
89
|
+
? MaybeWithOracleLst<
|
|
90
|
+
K,
|
|
91
|
+
{
|
|
47
92
|
registry: string;
|
|
48
93
|
registryCap: string;
|
|
49
|
-
|
|
50
|
-
state: string;
|
|
94
|
+
holder: string;
|
|
51
95
|
}
|
|
52
|
-
|
|
53
|
-
|
|
96
|
+
>
|
|
97
|
+
: K extends (typeof SUPPORT_ORACLES)[1]
|
|
98
|
+
? MaybeWithOracleLst<
|
|
99
|
+
K,
|
|
100
|
+
{
|
|
54
101
|
registry: string;
|
|
55
102
|
registryCap: string;
|
|
103
|
+
registryTableId: string;
|
|
56
104
|
state: string;
|
|
57
|
-
wormhole: string;
|
|
58
|
-
wormholeState: string;
|
|
59
105
|
}
|
|
106
|
+
>
|
|
107
|
+
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
108
|
+
? MaybeWithOracleLst<
|
|
109
|
+
K,
|
|
110
|
+
{
|
|
111
|
+
registry: string;
|
|
112
|
+
registryCap: string;
|
|
113
|
+
state: string;
|
|
114
|
+
wormhole: string;
|
|
115
|
+
wormholeState: string;
|
|
116
|
+
}
|
|
117
|
+
>
|
|
60
118
|
: never;
|
|
61
119
|
} & {
|
|
62
120
|
xOracle: string;
|
|
@@ -66,16 +124,7 @@ export interface AddressesInterface {
|
|
|
66
124
|
primaryPriceUpdatePolicyVecsetId: string;
|
|
67
125
|
secondaryPriceUpdatePolicyVecsetId: string;
|
|
68
126
|
};
|
|
69
|
-
packages:
|
|
70
|
-
Record<
|
|
71
|
-
string,
|
|
72
|
-
{
|
|
73
|
-
id: string;
|
|
74
|
-
object?: string;
|
|
75
|
-
upgradeCap: string;
|
|
76
|
-
}
|
|
77
|
-
>
|
|
78
|
-
>;
|
|
127
|
+
packages: Packages;
|
|
79
128
|
};
|
|
80
129
|
spool: {
|
|
81
130
|
id: string;
|
|
@@ -156,23 +205,12 @@ export interface AddressesInterface {
|
|
|
156
205
|
};
|
|
157
206
|
}
|
|
158
207
|
|
|
159
|
-
type
|
|
160
|
-
?
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
? never
|
|
167
|
-
: T extends [infer F]
|
|
168
|
-
? F
|
|
169
|
-
: T extends [infer F, ...infer R]
|
|
170
|
-
? F extends string
|
|
171
|
-
? `${F}${D}${Join<Extract<R, string[]>, D>}`
|
|
172
|
-
: never
|
|
173
|
-
: string;
|
|
208
|
+
type Paths<T> = T extends object
|
|
209
|
+
? {
|
|
210
|
+
[K in Extract<keyof T, string>]: T[K] extends object // if T[K] is itself an object, emit K *and* K.<deep>
|
|
211
|
+
? K | `${K}.${Paths<T[K]>}`
|
|
212
|
+
: K;
|
|
213
|
+
}[Extract<keyof T, string>]
|
|
214
|
+
: never;
|
|
174
215
|
|
|
175
|
-
export type AddressStringPath =
|
|
176
|
-
AddressPathsProps<AddressesInterface>,
|
|
177
|
-
'.'
|
|
178
|
-
>;
|
|
216
|
+
export type AddressStringPath = Paths<AddressesInterface>;
|
|
@@ -99,16 +99,14 @@ export type CoreQuickMethods = {
|
|
|
99
99
|
amount: number,
|
|
100
100
|
poolCoinName: string,
|
|
101
101
|
obligationId?: SuiObjectArg,
|
|
102
|
-
obligationKey?: SuiObjectArg
|
|
103
|
-
isSponsoredTx?: boolean
|
|
102
|
+
obligationKey?: SuiObjectArg
|
|
104
103
|
) => Promise<TransactionResult>;
|
|
105
104
|
borrowWithReferralQuick: (
|
|
106
105
|
amount: number,
|
|
107
106
|
poolCoinName: string,
|
|
108
107
|
borrowReferral: SuiObjectArg,
|
|
109
108
|
obligationId?: SuiObjectArg,
|
|
110
|
-
obligationKey?: SuiObjectArg
|
|
111
|
-
isSponsoredTx?: boolean
|
|
109
|
+
obligationKey?: SuiObjectArg
|
|
112
110
|
) => Promise<TransactionResult>;
|
|
113
111
|
depositQuick: (
|
|
114
112
|
amount: number,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
SUPPORT_ORACLES,
|
|
3
|
+
X_ORACLE_RULES,
|
|
4
|
+
SUPPORT_SUI_LST,
|
|
5
|
+
} from 'src/constants/xoracle';
|
|
3
6
|
|
|
4
|
-
export type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export type xOracleRuleType = keyof xOracleRules;
|
|
7
|
+
export type SupportOracleType = (typeof SUPPORT_ORACLES)[number];
|
|
8
|
+
export type xOracleRuleType = (typeof X_ORACLE_RULES)[number];
|
|
9
|
+
|
|
10
|
+
export type xOracleRules = Record<xOracleRuleType, SupportOracleType[]>;
|
|
9
11
|
|
|
10
12
|
export type xOracleListType = {
|
|
11
13
|
[key in string]: xOracleRules;
|
|
12
14
|
};
|
|
15
|
+
export type SupportedOracleSuiLst = (typeof SUPPORT_SUI_LST)[number];
|
package/src/types/query/index.ts
CHANGED
package/src/utils/builder.ts
CHANGED
package/src/utils/index.ts
CHANGED
package/src/utils/query.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
2
|
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
3
3
|
import type { ScallopUtils } from '../models';
|
|
4
|
-
import
|
|
4
|
+
import {
|
|
5
5
|
OriginMarketPoolData,
|
|
6
6
|
ParsedMarketPoolData,
|
|
7
7
|
CalculatedMarketPoolData,
|
|
@@ -14,16 +14,16 @@ import type {
|
|
|
14
14
|
OriginSpoolRewardPoolData,
|
|
15
15
|
ParsedSpoolRewardPoolData,
|
|
16
16
|
CalculatedSpoolRewardPoolData,
|
|
17
|
-
OriginBorrowIncentivePoolData,
|
|
18
|
-
ParsedBorrowIncentivePoolData,
|
|
19
|
-
OriginBorrowIncentiveAccountData,
|
|
20
|
-
ParsedBorrowIncentiveAccountData,
|
|
21
17
|
OriginBorrowIncentivePoolPointData,
|
|
22
18
|
ParsedBorrowIncentivePoolPointData,
|
|
19
|
+
OriginBorrowIncentivePoolData,
|
|
20
|
+
ParsedBorrowIncentivePoolData,
|
|
23
21
|
CalculatedBorrowIncentivePoolPointData,
|
|
24
22
|
OriginBorrowIncentiveAccountPoolData,
|
|
25
23
|
ParsedBorrowIncentiveAccountPoolData,
|
|
26
|
-
|
|
24
|
+
OriginBorrowIncentiveAccountData,
|
|
25
|
+
ParsedBorrowIncentiveAccountData,
|
|
26
|
+
} from 'src/types/query';
|
|
27
27
|
|
|
28
28
|
/**
|
|
29
29
|
* Parse origin market pool data to a more readable format.
|
package/src/utils/util.ts
CHANGED