@scallop-io/sui-scallop-sdk 2.3.0-lst-x-oracle-alpha.9 → 2.3.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/index.d.mts +1841 -1809
- package/dist/index.d.ts +1841 -1809
- package/dist/index.js +49 -2
- package/dist/index.mjs +15 -2
- package/package.json +8 -7
- package/src/builders/borrowIncentiveBuilder.ts +4 -4
- package/src/builders/coreBuilder.ts +86 -59
- package/src/builders/index.ts +2 -2
- package/src/builders/loyaltyProgramBuilder.ts +2 -2
- package/src/builders/oracles/index.ts +365 -114
- package/src/builders/oracles/pyth.ts +135 -0
- package/src/builders/referralBuilder.ts +4 -10
- package/src/builders/sCoinBuilder.ts +2 -2
- package/src/builders/spoolBuilder.ts +5 -8
- package/src/builders/vescaBuilder.ts +5 -5
- package/src/constants/common.ts +3 -0
- package/src/constants/index.ts +1 -1
- package/src/constants/queryKeys.ts +1 -1
- package/src/constants/rpc.ts +0 -1
- package/src/constants/testAddress.ts +99 -271
- package/src/constants/xoracle.ts +2 -8
- package/src/index.ts +1 -1
- package/src/models/index.ts +1 -2
- package/src/models/interface.ts +7 -7
- package/src/models/rateLimiter.ts +55 -0
- package/src/models/scallop.ts +2 -2
- package/src/models/scallopAddress.ts +7 -35
- package/src/models/scallopBuilder.ts +19 -12
- package/src/models/scallopClient.ts +47 -33
- package/src/models/scallopConstants.ts +3 -3
- package/src/models/scallopIndexer.ts +3 -4
- package/src/models/scallopQuery.ts +113 -57
- package/src/models/scallopQueryClient.ts +1 -1
- package/src/models/scallopSuiKit.ts +1 -1
- package/src/models/scallopUtils.ts +12 -7
- package/src/queries/borrowIncentiveQuery.ts +4 -3
- package/src/queries/coreQuery.ts +114 -186
- package/src/queries/index.ts +3 -4
- package/src/queries/loyaltyProgramQuery.ts +2 -2
- package/src/queries/ownerQuery.ts +32 -0
- package/src/queries/poolAddressesQuery.ts +1 -4
- package/src/queries/portfolioQuery.ts +68 -16
- package/src/queries/priceQuery.ts +2 -3
- package/src/queries/sCoinQuery.ts +2 -2
- package/src/queries/spoolQuery.ts +57 -74
- package/src/queries/vescaQuery.ts +3 -3
- package/src/queries/xOracleQuery.ts +4 -21
- package/src/types/address.ts +47 -98
- package/src/types/builder/core.ts +40 -15
- package/src/types/builder/index.ts +17 -1
- package/src/types/constant/enum.ts +64 -0
- package/src/types/constant/index.ts +1 -2
- package/src/types/constant/xOracle.ts +7 -10
- package/src/types/index.ts +1 -1
- package/src/types/query/core.ts +3 -0
- package/src/types/query/index.ts +1 -0
- package/src/types/query/sCoin.ts +1 -0
- package/src/{builders/utils.ts → utils/builder.ts} +1 -1
- package/src/utils/core.ts +18 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/indexer.ts +47 -0
- package/src/{queries/utils.ts → utils/query.ts} +7 -25
- package/src/utils/util.ts +42 -0
- package/src/builders/oracles/error.ts +0 -18
- package/src/builders/oracles/oraclePackageRegistry.ts +0 -336
- package/src/builders/oracles/priceFeedUpdater.ts +0 -112
- package/src/builders/oracles/priceUpdateRequester.ts +0 -50
- package/src/builders/oracles/xOracleUpdateStrategy.ts +0 -214
- package/src/builders/oracles/xOracleUpdater.ts +0 -153
- package/src/constants/api.ts +0 -2
- package/src/models/utils.ts +0 -97
- package/src/types/builder/type.ts +0 -25
- package/src/types/constant/package.ts +0 -16
- /package/src/types/{util.ts → utils.ts} +0 -0
|
@@ -5,100 +5,83 @@ import {
|
|
|
5
5
|
parseOriginSpoolRewardPoolData,
|
|
6
6
|
calculateSpoolRewardPoolData,
|
|
7
7
|
parseObjectAs,
|
|
8
|
-
|
|
8
|
+
partitionArray,
|
|
9
|
+
} from 'src/utils';
|
|
9
10
|
import type { SuiObjectData, SuiObjectResponse } from '@mysten/sui/client';
|
|
10
11
|
import type { ScallopQuery, ScallopUtils } from 'src/models';
|
|
11
|
-
import {
|
|
12
|
-
OriginSpoolData,
|
|
13
|
-
OriginSpoolRewardPoolData,
|
|
14
|
-
SpoolData,
|
|
15
|
-
MarketPools,
|
|
12
|
+
import type {
|
|
16
13
|
Spools,
|
|
17
14
|
Spool,
|
|
18
|
-
StakeAccounts,
|
|
19
15
|
StakePool,
|
|
20
16
|
StakeRewardPool,
|
|
21
|
-
|
|
22
|
-
|
|
17
|
+
StakeAccounts,
|
|
18
|
+
CoinPrices,
|
|
19
|
+
MarketPools,
|
|
20
|
+
OriginSpoolRewardPoolData,
|
|
21
|
+
SpoolData,
|
|
22
|
+
OriginSpoolData,
|
|
23
|
+
} from '../types';
|
|
23
24
|
|
|
24
25
|
const queryRequiredSpoolObjects = async (
|
|
25
26
|
query: ScallopQuery,
|
|
26
27
|
stakePoolCoinNames: string[]
|
|
27
28
|
) => {
|
|
28
|
-
|
|
29
|
-
type KeyType = {
|
|
30
|
-
spool?: string;
|
|
31
|
-
spoolReward?: string;
|
|
32
|
-
sCoinTreasury?: string;
|
|
33
|
-
};
|
|
29
|
+
const keyTypes = ['spool', 'spoolReward', 'sCoinTreasury'] as const;
|
|
34
30
|
|
|
35
|
-
const
|
|
36
|
-
spool: [],
|
|
37
|
-
spoolReward: [],
|
|
38
|
-
sCoinTreasury: [],
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const taskMap = new Map<string, KeyType>();
|
|
31
|
+
const allObjectIds: string[] = [];
|
|
42
32
|
|
|
43
|
-
// Single iteration to collect all keys
|
|
44
33
|
for (const poolCoinName of stakePoolCoinNames) {
|
|
45
34
|
const poolData = query.constants.poolAddresses[poolCoinName];
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
sCoinTreasury: poolData?.sCoinTreasury,
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Add to key collections
|
|
53
|
-
(Object.entries(task) as [keyof KeyType, string | undefined][]).forEach(
|
|
54
|
-
([key, value]) => {
|
|
55
|
-
if (value) keyCollections[key].push(value);
|
|
35
|
+
for (const keyType of keyTypes) {
|
|
36
|
+
if (poolData?.[keyType] && poolData[keyType] !== '') {
|
|
37
|
+
allObjectIds.push(poolData[keyType]);
|
|
56
38
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
taskMap.set(poolCoinName, task);
|
|
39
|
+
}
|
|
60
40
|
}
|
|
61
41
|
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
await Promise.all([
|
|
65
|
-
query.scallopSuiKit.queryGetObjects(keyCollections.spool),
|
|
66
|
-
query.scallopSuiKit.queryGetObjects(keyCollections.spoolReward),
|
|
67
|
-
query.scallopSuiKit.queryGetObjects(keyCollections.sCoinTreasury),
|
|
68
|
-
]);
|
|
69
|
-
|
|
70
|
-
// Phase 3: Create lookup maps
|
|
71
|
-
const createObjectMap = (objects: SuiObjectData[]) =>
|
|
72
|
-
new Map(objects.map((obj) => [obj.objectId, obj]));
|
|
73
|
-
|
|
74
|
-
const objectMaps = {
|
|
75
|
-
spool: createObjectMap(spoolObjects),
|
|
76
|
-
spoolReward: createObjectMap(spoolRewardObjects),
|
|
77
|
-
sCoinTreasury: createObjectMap(sCoinTreasuryObjects),
|
|
78
|
-
};
|
|
42
|
+
const objectDatas: SuiObjectData[] = [];
|
|
43
|
+
const batches = partitionArray(allObjectIds, 50);
|
|
79
44
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
for (const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
: undefined,
|
|
88
|
-
sCoinTreasury: task.sCoinTreasury
|
|
89
|
-
? objectMaps.sCoinTreasury.get(task.sCoinTreasury)
|
|
90
|
-
: undefined,
|
|
91
|
-
};
|
|
45
|
+
console.log('Fetching spool objects in batches:', batches.length);
|
|
46
|
+
|
|
47
|
+
for (const batch of batches) {
|
|
48
|
+
const responses = await query.scallopSuiKit.queryGetObjects(batch);
|
|
49
|
+
if (responses.length > 0) {
|
|
50
|
+
objectDatas.push(...responses);
|
|
51
|
+
}
|
|
92
52
|
}
|
|
93
53
|
|
|
94
|
-
|
|
54
|
+
// Transform into map
|
|
55
|
+
const objectDataMap = objectDatas.reduce(
|
|
56
|
+
(acc, obj) => {
|
|
57
|
+
acc[obj.objectId] = obj;
|
|
58
|
+
return acc;
|
|
59
|
+
},
|
|
60
|
+
{} as Record<string, SuiObjectData>
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const results: Record<
|
|
95
64
|
string,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
65
|
+
Record<(typeof keyTypes)[number], SuiObjectData>
|
|
66
|
+
> = {};
|
|
67
|
+
|
|
68
|
+
for (const poolCoinName of stakePoolCoinNames) {
|
|
69
|
+
const poolData = query.constants.poolAddresses[poolCoinName];
|
|
70
|
+
for (const keyType of keyTypes) {
|
|
71
|
+
const objectId = poolData?.[keyType];
|
|
72
|
+
if (objectId && objectId !== '') {
|
|
73
|
+
if (!results[poolCoinName]) {
|
|
74
|
+
results[poolCoinName] = {} as Record<
|
|
75
|
+
(typeof keyTypes)[number],
|
|
76
|
+
SuiObjectData
|
|
77
|
+
>;
|
|
78
|
+
}
|
|
79
|
+
results[poolCoinName][keyType] = objectDataMap[objectId];
|
|
80
|
+
}
|
|
100
81
|
}
|
|
101
|
-
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return results;
|
|
102
85
|
};
|
|
103
86
|
|
|
104
87
|
const parseSpoolObjects = ({
|
|
@@ -164,11 +147,11 @@ export const getSpools = async (
|
|
|
164
147
|
if (!stakeMarketCoinNames.includes(spool.marketCoinName)) return;
|
|
165
148
|
const coinName = query.utils.parseCoinName(spool.marketCoinName);
|
|
166
149
|
const rewardCoinName = query.utils.getSpoolRewardCoinName();
|
|
167
|
-
spool.coinPrice = coinPrices
|
|
150
|
+
spool.coinPrice = coinPrices[coinName] ?? spool.coinPrice;
|
|
168
151
|
spool.marketCoinPrice =
|
|
169
|
-
coinPrices
|
|
152
|
+
coinPrices[spool.marketCoinName] ?? spool.marketCoinPrice;
|
|
170
153
|
spool.rewardCoinPrice =
|
|
171
|
-
coinPrices
|
|
154
|
+
coinPrices[rewardCoinName] ?? spool.rewardCoinPrice;
|
|
172
155
|
spools[spool.marketCoinName] = spool;
|
|
173
156
|
};
|
|
174
157
|
Object.values(spoolsIndexer)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from 'src/types
|
|
2
|
+
import { VeScaTreasuryFields, VeScaTreasuryInfo, Vesca } from 'src/types';
|
|
3
3
|
import {
|
|
4
4
|
type SuiObjectResponse,
|
|
5
5
|
type SuiObjectData,
|
|
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';
|
|
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';
|
|
14
14
|
import assert from 'assert';
|
|
15
15
|
/**
|
|
16
16
|
* Query all owned veSca key.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SuiObjectResponse } from '@mysten/sui/client';
|
|
2
2
|
import { ScallopAddress, ScallopSuiKit, ScallopUtils } from 'src/models';
|
|
3
|
-
import { SupportOracleType, xOracleRuleType } from 'src/types
|
|
3
|
+
import { SupportOracleType, xOracleRuleType } from 'src/types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Query the price update policy table ids. Usually the value for these table will be constant.
|
|
@@ -61,28 +61,11 @@ 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
|
-
|
|
79
64
|
const ruleTypeNameToOracleType: Record<string, SupportOracleType> = {
|
|
80
|
-
[
|
|
81
|
-
|
|
82
|
-
[
|
|
83
|
-
[createRuleType(utils.address.get('core.packages.switchboard.object'))]:
|
|
65
|
+
[`${utils.address.get('core.packages.pyth.object')}::rule::Rule`]: 'pyth',
|
|
66
|
+
[`${utils.address.get('core.packages.supra.object')}::rule::Rule`]: 'supra',
|
|
67
|
+
[`${utils.address.get('core.packages.switchboard.object')}::rule::Rule`]:
|
|
84
68
|
'switchboard',
|
|
85
|
-
...pythLstRuleTypeNameToOracleType,
|
|
86
69
|
};
|
|
87
70
|
|
|
88
71
|
const assetOracles = {} as Record<string, SupportOracleType[]>;
|
package/src/types/address.ts
CHANGED
|
@@ -1,67 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SupportOracleType, SupportedOracleSuiLst } from './constant/xOracle';
|
|
3
|
-
import { PackageName } from './constant/package';
|
|
1
|
+
import { _SUPPORT_ORACLES, SupportOracleType } from './constant/xOracle';
|
|
4
2
|
|
|
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
|
-
type PythOracleLstConfigItem<T extends SupportedOracleSuiLst, U> = Record<
|
|
32
|
-
T,
|
|
33
|
-
{ configId: string } & U
|
|
34
|
-
>;
|
|
35
|
-
|
|
36
|
-
export type PythOracleLstConfig<
|
|
37
|
-
T extends SupportedOracleSuiLst = SupportedOracleSuiLst,
|
|
38
|
-
> = T extends 'afsui'
|
|
39
|
-
? PythOracleLstConfigItem<
|
|
40
|
-
'afsui',
|
|
41
|
-
{
|
|
42
|
-
stakedSuiVaultId: string;
|
|
43
|
-
safeId: string;
|
|
44
|
-
configId: string;
|
|
45
|
-
}
|
|
46
|
-
>
|
|
47
|
-
: T extends 'hasui'
|
|
48
|
-
? PythOracleLstConfigItem<
|
|
49
|
-
'hasui',
|
|
50
|
-
{
|
|
51
|
-
staking: string;
|
|
52
|
-
}
|
|
53
|
-
>
|
|
54
|
-
: never;
|
|
55
|
-
|
|
56
|
-
export type OracleLst<T extends SupportOracleLst> = T extends 'pyth'
|
|
57
|
-
? PythOracleLstConfig
|
|
58
|
-
: never;
|
|
59
|
-
|
|
60
|
-
type MaybeWithOracleLst<T, U> = T extends SupportOracleLst
|
|
61
|
-
? U & {
|
|
62
|
-
lst: OracleLst<T>;
|
|
63
|
-
}
|
|
64
|
-
: U;
|
|
65
3
|
export interface AddressesInterface {
|
|
66
4
|
id?: string;
|
|
67
5
|
core: {
|
|
@@ -83,11 +21,11 @@ export interface AddressesInterface {
|
|
|
83
21
|
symbol: string;
|
|
84
22
|
decimals: number;
|
|
85
23
|
oracle: {
|
|
86
|
-
[K in SupportOracleType]: K extends (typeof
|
|
24
|
+
[K in SupportOracleType]: K extends (typeof _SUPPORT_ORACLES)[0]
|
|
87
25
|
? string
|
|
88
|
-
: K extends (typeof
|
|
26
|
+
: K extends (typeof _SUPPORT_ORACLES)[1]
|
|
89
27
|
? string
|
|
90
|
-
: K extends (typeof
|
|
28
|
+
: K extends (typeof _SUPPORT_ORACLES)[2]
|
|
91
29
|
? {
|
|
92
30
|
feed: string;
|
|
93
31
|
feedObject: string;
|
|
@@ -98,36 +36,27 @@ export interface AddressesInterface {
|
|
|
98
36
|
>
|
|
99
37
|
>;
|
|
100
38
|
oracles: {
|
|
101
|
-
[K in SupportOracleType]: K extends (typeof
|
|
102
|
-
?
|
|
103
|
-
|
|
104
|
-
|
|
39
|
+
[K in SupportOracleType]: K extends (typeof _SUPPORT_ORACLES)[0]
|
|
40
|
+
? {
|
|
41
|
+
registry: string;
|
|
42
|
+
registryCap: string;
|
|
43
|
+
holder: string;
|
|
44
|
+
}
|
|
45
|
+
: K extends (typeof _SUPPORT_ORACLES)[1]
|
|
46
|
+
? {
|
|
105
47
|
registry: string;
|
|
106
48
|
registryCap: string;
|
|
107
|
-
|
|
49
|
+
registryTableId: string;
|
|
50
|
+
state: string;
|
|
108
51
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
? MaybeWithOracleLst<
|
|
112
|
-
K,
|
|
113
|
-
{
|
|
52
|
+
: K extends (typeof _SUPPORT_ORACLES)[2]
|
|
53
|
+
? {
|
|
114
54
|
registry: string;
|
|
115
55
|
registryCap: string;
|
|
116
|
-
registryTableId: string;
|
|
117
56
|
state: string;
|
|
57
|
+
wormhole: string;
|
|
58
|
+
wormholeState: string;
|
|
118
59
|
}
|
|
119
|
-
>
|
|
120
|
-
: K extends (typeof SUPPORT_ORACLES)[2]
|
|
121
|
-
? MaybeWithOracleLst<
|
|
122
|
-
K,
|
|
123
|
-
{
|
|
124
|
-
registry: string;
|
|
125
|
-
registryCap: string;
|
|
126
|
-
state: string;
|
|
127
|
-
wormhole: string;
|
|
128
|
-
wormholeState: string;
|
|
129
|
-
}
|
|
130
|
-
>
|
|
131
60
|
: never;
|
|
132
61
|
} & {
|
|
133
62
|
xOracle: string;
|
|
@@ -137,7 +66,16 @@ export interface AddressesInterface {
|
|
|
137
66
|
primaryPriceUpdatePolicyVecsetId: string;
|
|
138
67
|
secondaryPriceUpdatePolicyVecsetId: string;
|
|
139
68
|
};
|
|
140
|
-
packages:
|
|
69
|
+
packages: Partial<
|
|
70
|
+
Record<
|
|
71
|
+
string,
|
|
72
|
+
{
|
|
73
|
+
id: string;
|
|
74
|
+
object?: string;
|
|
75
|
+
upgradeCap: string;
|
|
76
|
+
}
|
|
77
|
+
>
|
|
78
|
+
>;
|
|
141
79
|
};
|
|
142
80
|
spool: {
|
|
143
81
|
id: string;
|
|
@@ -218,12 +156,23 @@ export interface AddressesInterface {
|
|
|
218
156
|
};
|
|
219
157
|
}
|
|
220
158
|
|
|
221
|
-
type
|
|
222
|
-
?
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
}[Extract<keyof T, string>]
|
|
227
|
-
: never;
|
|
159
|
+
type AddressPathsProps<T> = T extends string
|
|
160
|
+
? []
|
|
161
|
+
: {
|
|
162
|
+
[K in Extract<keyof T, string>]: [K, ...AddressPathsProps<T[K]>];
|
|
163
|
+
}[Extract<keyof T, string>];
|
|
228
164
|
|
|
229
|
-
|
|
165
|
+
type Join<T extends string[], D extends string> = T extends []
|
|
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;
|
|
174
|
+
|
|
175
|
+
export type AddressStringPath = Join<
|
|
176
|
+
AddressPathsProps<AddressesInterface>,
|
|
177
|
+
'.'
|
|
178
|
+
>;
|
|
@@ -16,16 +16,12 @@ export type CoreIds = {
|
|
|
16
16
|
};
|
|
17
17
|
|
|
18
18
|
export type NestedResult = Extract<Argument, { $kind: 'NestedResult' }>;
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
type
|
|
19
|
+
type Obligation = NestedResult;
|
|
20
|
+
type ObligationKey = NestedResult;
|
|
21
|
+
type ObligationHotPotato = NestedResult;
|
|
22
22
|
|
|
23
23
|
export type CoreNormalMethods = {
|
|
24
|
-
openObligation: () => [
|
|
25
|
-
ResultAsObligation,
|
|
26
|
-
ResultAsObligationKey,
|
|
27
|
-
ResultAsObligationHotPotato,
|
|
28
|
-
];
|
|
24
|
+
openObligation: () => [Obligation, ObligationKey, ObligationHotPotato];
|
|
29
25
|
returnObligation: (
|
|
30
26
|
obligation: SuiObjectArg,
|
|
31
27
|
obligationHotPotato: SuiObjectArg
|
|
@@ -91,31 +87,51 @@ export type CoreQuickMethods = {
|
|
|
91
87
|
addCollateralQuick: (
|
|
92
88
|
amount: number,
|
|
93
89
|
collateralCoinName: string,
|
|
94
|
-
obligationId?: SuiObjectArg
|
|
90
|
+
obligationId?: SuiObjectArg,
|
|
91
|
+
isSponsoredTx?: boolean
|
|
95
92
|
) => Promise<void>;
|
|
96
93
|
takeCollateralQuick: (
|
|
97
94
|
amount: number,
|
|
98
95
|
collateralCoinName: string,
|
|
99
96
|
obligationId?: SuiObjectArg,
|
|
100
|
-
obligationKey?: SuiObjectArg
|
|
97
|
+
obligationKey?: SuiObjectArg,
|
|
98
|
+
updateOracleOptions?: {
|
|
99
|
+
usePythPullModel?: boolean;
|
|
100
|
+
useOnChainXOracleList?: boolean;
|
|
101
|
+
sponsoredFeeds?: string[];
|
|
102
|
+
isSponsoredTx?: boolean;
|
|
103
|
+
}
|
|
101
104
|
) => Promise<TransactionResult>;
|
|
102
105
|
borrowQuick: (
|
|
103
106
|
amount: number,
|
|
104
107
|
poolCoinName: string,
|
|
105
108
|
obligationId?: SuiObjectArg,
|
|
106
|
-
obligationKey?: SuiObjectArg
|
|
109
|
+
obligationKey?: SuiObjectArg,
|
|
110
|
+
updateOracleOptions?: {
|
|
111
|
+
usePythPullModel?: boolean;
|
|
112
|
+
useOnChainXOracleList?: boolean;
|
|
113
|
+
sponsoredFeeds?: string[];
|
|
114
|
+
isSponsoredTx?: boolean;
|
|
115
|
+
}
|
|
107
116
|
) => Promise<TransactionResult>;
|
|
108
117
|
borrowWithReferralQuick: (
|
|
109
118
|
amount: number,
|
|
110
119
|
poolCoinName: string,
|
|
111
120
|
borrowReferral: SuiObjectArg,
|
|
112
121
|
obligationId?: SuiObjectArg,
|
|
113
|
-
obligationKey?: SuiObjectArg
|
|
122
|
+
obligationKey?: SuiObjectArg,
|
|
123
|
+
updateOracleOptions?: {
|
|
124
|
+
usePythPullModel?: boolean;
|
|
125
|
+
useOnChainXOracleList?: boolean;
|
|
126
|
+
sponsoredFeeds?: string[];
|
|
127
|
+
isSponsoredTx?: boolean;
|
|
128
|
+
}
|
|
114
129
|
) => Promise<TransactionResult>;
|
|
115
130
|
depositQuick: (
|
|
116
131
|
amount: number,
|
|
117
132
|
poolCoinName: string,
|
|
118
|
-
returnSCoin?: boolean
|
|
133
|
+
returnSCoin?: boolean,
|
|
134
|
+
isSponsoredTx?: boolean
|
|
119
135
|
) => Promise<TransactionResult>;
|
|
120
136
|
withdrawQuick: (
|
|
121
137
|
amount: number,
|
|
@@ -124,9 +140,18 @@ export type CoreQuickMethods = {
|
|
|
124
140
|
repayQuick: (
|
|
125
141
|
amount: number,
|
|
126
142
|
poolCoinName: string,
|
|
127
|
-
obligationId?: SuiObjectArg
|
|
143
|
+
obligationId?: SuiObjectArg,
|
|
144
|
+
isSponsoredTx?: boolean
|
|
145
|
+
) => Promise<void>;
|
|
146
|
+
updateAssetPricesQuick: (
|
|
147
|
+
assetCoinNames?: string[],
|
|
148
|
+
updateOracleOptions?: {
|
|
149
|
+
usePythPullModel?: boolean;
|
|
150
|
+
useOnChainXOracleList?: boolean;
|
|
151
|
+
sponsoredFeeds?: string[];
|
|
152
|
+
isSponsoredTx?: boolean;
|
|
153
|
+
}
|
|
128
154
|
) => Promise<void>;
|
|
129
|
-
updateAssetPricesQuick: (assetCoinNames?: string[]) => Promise<void>;
|
|
130
155
|
};
|
|
131
156
|
|
|
132
157
|
export type SuiTxBlockWithCoreNormalMethods = SuiKitTxBlock &
|
|
@@ -1,7 +1,23 @@
|
|
|
1
|
+
import type { CoreTxBlock } from './core';
|
|
2
|
+
import type { SpoolTxBlock } from './spool';
|
|
3
|
+
import type { BorrowIncentiveTxBlock } from './borrowIncentive';
|
|
4
|
+
import type { VeScaTxBlock } from './vesca';
|
|
5
|
+
import type { ReferralTxBlock } from './referral';
|
|
6
|
+
import { LoyaltyProgramTxBlock } from './loyaltyProgram';
|
|
7
|
+
import { SCoinTxBlock } from './sCoin';
|
|
8
|
+
|
|
1
9
|
export type * from './core';
|
|
2
10
|
export type * from './spool';
|
|
3
11
|
export type * from './borrowIncentive';
|
|
4
12
|
export type * from './vesca';
|
|
5
13
|
export type * from './loyaltyProgram';
|
|
6
14
|
export type * from './sCoin';
|
|
7
|
-
|
|
15
|
+
|
|
16
|
+
export type BaseScallopTxBlock = ReferralTxBlock &
|
|
17
|
+
LoyaltyProgramTxBlock &
|
|
18
|
+
BorrowIncentiveTxBlock &
|
|
19
|
+
VeScaTxBlock;
|
|
20
|
+
|
|
21
|
+
export type SuiTxBlockWithSCoin = BaseScallopTxBlock & SCoinTxBlock;
|
|
22
|
+
export type SuiTxBlockWithSpool = SuiTxBlockWithSCoin & SpoolTxBlock;
|
|
23
|
+
export type ScallopTxBlock = SuiTxBlockWithSpool & CoreTxBlock;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type Coins = {
|
|
2
|
+
[K in string]: K;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export type AssetCoins = {
|
|
6
|
+
[K in string]: K;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export type MarketCoins = {
|
|
10
|
+
[K in string]: K;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type SCoins = {
|
|
14
|
+
[K in string]: K;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export type StakeMarketCoins = {
|
|
18
|
+
[K in string]: K;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type StakeRewardCoins = {
|
|
22
|
+
[key in string]: string;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export type SuiBridgeCoins = {
|
|
26
|
+
[K in string]: K;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type BorrowIncentiveRewardCoins = {
|
|
30
|
+
[key in string]: string[];
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export type AssetCoinIds = {
|
|
34
|
+
[key in string]: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export type SCoinIds = {
|
|
38
|
+
[key in string]: string;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type SCoinTreasuryCaps = {
|
|
42
|
+
[key in string]: string;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export type SCoinConverterTreasury = {
|
|
46
|
+
[key in string]: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
type PickFromUnion<T, K extends string> = K extends T ? K : never;
|
|
50
|
+
|
|
51
|
+
export type WormholeCoinIds = {
|
|
52
|
+
[key in PickFromUnion<
|
|
53
|
+
string,
|
|
54
|
+
'weth' | 'wbtc' | 'wusdc' | 'wusdt' | 'wapt' | 'wsol'
|
|
55
|
+
>]: string;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export type VoloCoinIds = {
|
|
59
|
+
[key in PickFromUnion<string, 'vsui'>]: string;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type SuiBridgedCoinPackageIds = {
|
|
63
|
+
[key in string]: string;
|
|
64
|
+
};
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
X_ORACLE_RULES,
|
|
4
|
-
SUPPORT_SUI_LST,
|
|
5
|
-
} from 'src/constants/xoracle';
|
|
1
|
+
export const _SUPPORT_ORACLES = ['supra', 'switchboard', 'pyth'] as const;
|
|
2
|
+
export type SupportOracleType = (typeof _SUPPORT_ORACLES)[number];
|
|
6
3
|
|
|
7
|
-
export type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
export type xOracleRules = {
|
|
5
|
+
primary: SupportOracleType[];
|
|
6
|
+
secondary: SupportOracleType[];
|
|
7
|
+
};
|
|
8
|
+
export type xOracleRuleType = keyof xOracleRules;
|
|
11
9
|
|
|
12
10
|
export type xOracleListType = {
|
|
13
11
|
[key in string]: xOracleRules;
|
|
14
12
|
};
|
|
15
|
-
export type SupportedOracleSuiLst = (typeof SUPPORT_SUI_LST)[number];
|
package/src/types/index.ts
CHANGED
package/src/types/query/core.ts
CHANGED
package/src/types/query/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type sCoinBalance = number;
|