@scallop-io/sui-scallop-sdk 2.2.3-pyth-sponsored-transaction-alpha.1 → 2.3.0-lst-x-oracle-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/address-CW2IpaLn.d.ts +165 -0
- package/dist/chunk-E3URAUAC.js +25 -0
- package/dist/chunk-YA77R5GT.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/index.d.mts +11 -3242
- package/dist/index.d.ts +11 -3242
- package/dist/index.js +0 -47
- package/dist/index.mjs +0 -14
- 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/scallopUtils-BZLZd2z8.d.ts +2404 -0
- 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 +31 -4
- 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/index.ts +2 -12
- package/src/models/index.ts +2 -1
- package/src/models/interface.ts +6 -6
- 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/src/builders/oracles/pyth.ts +0 -52
- package/src/queries/ownerQuery.ts +0 -32
- package/src/types/constant/enum.ts +0 -64
- package/src/types/query/sCoin.ts +0 -1
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
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SuiPriceServiceConnection,
|
|
3
|
-
SuiPythClient,
|
|
4
|
-
} from '@pythnetwork/pyth-sui-js';
|
|
5
|
-
import { ScallopBuilder } from 'src/models';
|
|
6
|
-
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
7
|
-
|
|
8
|
-
export const updatePythPriceFeeds = async (
|
|
9
|
-
builder: ScallopBuilder,
|
|
10
|
-
assetCoinNames: string[],
|
|
11
|
-
txBlock: SuiKitTxBlock,
|
|
12
|
-
isSponsoredTx: boolean = false
|
|
13
|
-
) => {
|
|
14
|
-
const pythClient = new SuiPythClient(
|
|
15
|
-
builder.suiKit.client,
|
|
16
|
-
builder.address.get('core.oracles.pyth.state'),
|
|
17
|
-
builder.address.get('core.oracles.pyth.wormholeState'),
|
|
18
|
-
{
|
|
19
|
-
defaultPackageId:
|
|
20
|
-
'0xa6f9bec2f9748656b6af8aafb5d7bc1a0d5faf25ac9645fc7f447822cd509325',
|
|
21
|
-
gasStationId:
|
|
22
|
-
'0xa8b8dcc9880166edb57b53e05f8df7364d31b5d9b7d107fd27f0b69cf338b687',
|
|
23
|
-
}
|
|
24
|
-
);
|
|
25
|
-
const priceIds = assetCoinNames.map((assetCoinName) =>
|
|
26
|
-
builder.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`)
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
// iterate through the endpoints
|
|
30
|
-
const endpoints = builder.utils.pythEndpoints ?? [
|
|
31
|
-
...builder.constants.whitelist.pythEndpoints,
|
|
32
|
-
];
|
|
33
|
-
for (const endpoint of endpoints) {
|
|
34
|
-
try {
|
|
35
|
-
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
36
|
-
const priceUpdateData =
|
|
37
|
-
await pythConnection.getPriceFeedsUpdateData(priceIds);
|
|
38
|
-
await pythClient.updatePriceFeeds(
|
|
39
|
-
txBlock.txBlock,
|
|
40
|
-
priceUpdateData,
|
|
41
|
-
priceIds,
|
|
42
|
-
isSponsoredTx
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
break;
|
|
46
|
-
} catch (e) {
|
|
47
|
-
console.warn(
|
|
48
|
-
`Failed to update price feeds with endpoint ${endpoint}: ${e}`
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
// import { ObjectOwner, SuiObjectData } from '@mysten/sui/client';
|
|
2
|
-
|
|
3
|
-
// const parseOwnerAddress = (owner: ObjectOwner | null | undefined): string => {
|
|
4
|
-
// const notSupportedOwner =
|
|
5
|
-
// !owner ||
|
|
6
|
-
// typeof owner === 'string' ||
|
|
7
|
-
// (typeof owner === 'object' &&
|
|
8
|
-
// ('Shared' in owner || 'ConsensusV2' in owner));
|
|
9
|
-
// if (notSupportedOwner)
|
|
10
|
-
// throw new Error('Owner not supported (ConsensusV2 or Shared or Immutable)');
|
|
11
|
-
|
|
12
|
-
// if ('AddressOwner' in owner) {
|
|
13
|
-
// return owner.AddressOwner;
|
|
14
|
-
// } else {
|
|
15
|
-
// return owner.ObjectOwner;
|
|
16
|
-
// }
|
|
17
|
-
// };
|
|
18
|
-
|
|
19
|
-
// export const getObjectOwner = async (
|
|
20
|
-
// cache: ScallopCache,
|
|
21
|
-
// object: string | SuiObjectData
|
|
22
|
-
// ) => {
|
|
23
|
-
// if (typeof object === 'object') {
|
|
24
|
-
// return parseOwnerAddress(object.owner);
|
|
25
|
-
// }
|
|
26
|
-
|
|
27
|
-
// const objResponse = await cache.queryGetObject(object, {
|
|
28
|
-
// showOwner: true,
|
|
29
|
-
// });
|
|
30
|
-
|
|
31
|
-
// return parseOwnerAddress(objResponse.data?.owner);
|
|
32
|
-
// };
|
|
@@ -1,64 +0,0 @@
|
|
|
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
|
-
};
|
package/src/types/query/sCoin.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type sCoinBalance = number;
|