@scallop-io/sui-scallop-sdk 0.47.4 → 0.47.5
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/constants/common.d.ts +6 -4
- package/dist/constants/enum.d.ts +1 -0
- package/dist/index.js +120 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +117 -118
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopQuery.d.ts +7 -2
- package/dist/models/scallopUtils.d.ts +4 -2
- package/dist/queries/borrowIncentiveQuery.d.ts +2 -0
- package/dist/queries/coreQuery.d.ts +2 -0
- package/dist/queries/portfolioQuery.d.ts +1 -0
- package/dist/queries/sCoinQuery.d.ts +1 -1
- package/dist/types/constant/common.d.ts +3 -1
- package/dist/types/constant/enum.d.ts +7 -1
- package/dist/utils/util.d.ts +3 -1
- package/package.json +1 -1
- package/src/constants/common.ts +15 -1
- package/src/constants/enum.ts +13 -0
- package/src/models/scallopUtils.ts +52 -22
- package/src/queries/coreQuery.ts +0 -1
- package/src/queries/spoolQuery.ts +40 -103
- package/src/types/constant/common.ts +4 -0
- package/src/types/constant/enum.ts +9 -0
- package/src/utils/util.ts +25 -3
|
@@ -52,6 +52,7 @@ export declare class ScallopQuery {
|
|
|
52
52
|
*/
|
|
53
53
|
getMarketPools(poolCoinNames?: SupportPoolCoins[], indexer?: boolean): Promise<{
|
|
54
54
|
usdc?: import("../types").MarketPool | undefined;
|
|
55
|
+
sbeth?: import("../types").MarketPool | undefined;
|
|
55
56
|
weth?: import("../types").MarketPool | undefined;
|
|
56
57
|
wbtc?: import("../types").MarketPool | undefined;
|
|
57
58
|
wusdc?: import("../types").MarketPool | undefined;
|
|
@@ -86,6 +87,7 @@ export declare class ScallopQuery {
|
|
|
86
87
|
*/
|
|
87
88
|
getMarketCollaterals(collateralCoinNames?: SupportCollateralCoins[], indexer?: boolean): Promise<{
|
|
88
89
|
usdc?: import("../types").MarketCollateral | undefined;
|
|
90
|
+
sbeth?: import("../types").MarketCollateral | undefined;
|
|
89
91
|
weth?: import("../types").MarketCollateral | undefined;
|
|
90
92
|
wbtc?: import("../types").MarketCollateral | undefined;
|
|
91
93
|
wusdc?: import("../types").MarketCollateral | undefined;
|
|
@@ -281,6 +283,7 @@ export declare class ScallopQuery {
|
|
|
281
283
|
*/
|
|
282
284
|
getBorrowIncentivePools(coinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean): Promise<{
|
|
283
285
|
usdc?: import("../types").BorrowIncentivePool | undefined;
|
|
286
|
+
sbeth?: import("../types").BorrowIncentivePool | undefined;
|
|
284
287
|
weth?: import("../types").BorrowIncentivePool | undefined;
|
|
285
288
|
wusdc?: import("../types").BorrowIncentivePool | undefined;
|
|
286
289
|
wusdt?: import("../types").BorrowIncentivePool | undefined;
|
|
@@ -299,6 +302,7 @@ export declare class ScallopQuery {
|
|
|
299
302
|
*/
|
|
300
303
|
getBorrowIncentiveAccounts(obligationId: string, coinNames?: SupportBorrowIncentiveCoins[]): Promise<{
|
|
301
304
|
usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
305
|
+
sbeth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
302
306
|
weth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
303
307
|
wusdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
304
308
|
wusdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
@@ -318,6 +322,7 @@ export declare class ScallopQuery {
|
|
|
318
322
|
*/
|
|
319
323
|
getLendings(poolCoinNames?: SupportPoolCoins[], ownerAddress?: string, indexer?: boolean): Promise<{
|
|
320
324
|
usdc?: import("../types").Lending | undefined;
|
|
325
|
+
sbeth?: import("../types").Lending | undefined;
|
|
321
326
|
weth?: import("../types").Lending | undefined;
|
|
322
327
|
wbtc?: import("../types").Lending | undefined;
|
|
323
328
|
wusdc?: import("../types").Lending | undefined;
|
|
@@ -432,7 +437,7 @@ export declare class ScallopQuery {
|
|
|
432
437
|
* @param ownerAddress - The owner address.
|
|
433
438
|
* @return All market sCoin amounts.
|
|
434
439
|
*/
|
|
435
|
-
getSCoinAmounts(sCoinNames?: SupportSCoin[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<"susdc" | "sweth" | "ssui" | "swusdc" | "swusdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "swsol" | "swbtc", number>>>;
|
|
440
|
+
getSCoinAmounts(sCoinNames?: SupportSCoin[], ownerAddress?: string): Promise<import("../types").OptionalKeys<Record<"susdc" | "sweth" | "ssui" | "swusdc" | "swusdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssbeth" | "ssca" | "swsol" | "swbtc", number>>>;
|
|
436
441
|
/**
|
|
437
442
|
* Get sCoin amount.
|
|
438
443
|
*
|
|
@@ -447,7 +452,7 @@ export declare class ScallopQuery {
|
|
|
447
452
|
* @returns
|
|
448
453
|
*/
|
|
449
454
|
getSCoinSwapRate(fromSCoin: SupportSCoin, toSCoin: SupportSCoin): Promise<number>;
|
|
450
|
-
getFlashLoanFees(assetCoinNames?: SupportAssetCoins[]): Promise<Record<"usdc" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca", number>>;
|
|
455
|
+
getFlashLoanFees(assetCoinNames?: SupportAssetCoins[]): Promise<Record<"usdc" | "sbeth" | "weth" | "wbtc" | "wusdc" | "wusdt" | "sui" | "wapt" | "wsol" | "cetus" | "afsui" | "hasui" | "vsui" | "sca", number>>;
|
|
451
456
|
/**
|
|
452
457
|
* Get supply limit of supply pool
|
|
453
458
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SuiKit } from '@scallop-io/sui-kit';
|
|
2
2
|
import { ScallopAddress } from './scallopAddress';
|
|
3
3
|
import { ScallopCache } from './scallopCache';
|
|
4
|
-
import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams } from '../types';
|
|
4
|
+
import type { ScallopUtilsParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType, SupportSCoin, ScallopUtilsInstanceParams, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
|
|
5
5
|
import type { SuiAddressArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
6
6
|
/**
|
|
7
7
|
* @description
|
|
@@ -24,6 +24,8 @@ export declare class ScallopUtils {
|
|
|
24
24
|
walletAddress: string;
|
|
25
25
|
private _priceMap;
|
|
26
26
|
constructor(params: ScallopUtilsParams, instance?: ScallopUtilsInstanceParams);
|
|
27
|
+
isSuiBridgeAsset(coinName: any): coinName is SupportSuiBridgeCoins;
|
|
28
|
+
isWormholeAsset(coinName: any): coinName is SupportWormholeCoins;
|
|
27
29
|
/**
|
|
28
30
|
* Request the scallop API to initialize data.
|
|
29
31
|
*
|
|
@@ -97,7 +99,7 @@ export declare class ScallopUtils {
|
|
|
97
99
|
parseCoinNameFromType<T extends SupportMarketCoins>(coinType: string): T extends SupportMarketCoins ? T : SupportMarketCoins;
|
|
98
100
|
parseCoinNameFromType<T extends SupportCoins>(coinType: string): T extends SupportCoins ? T : SupportCoins;
|
|
99
101
|
/**
|
|
100
|
-
* Convert
|
|
102
|
+
* Convert market coin name to coin name.
|
|
101
103
|
*
|
|
102
104
|
* @param marketCoinName - Specific support market coin name.
|
|
103
105
|
* @return Coin Name.
|
|
@@ -16,6 +16,7 @@ export declare const queryBorrowIncentivePools: (address: ScallopAddress) => Pro
|
|
|
16
16
|
*/
|
|
17
17
|
export declare const getBorrowIncentivePools: (query: ScallopQuery, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[], indexer?: boolean) => Promise<{
|
|
18
18
|
usdc?: BorrowIncentivePool | undefined;
|
|
19
|
+
sbeth?: BorrowIncentivePool | undefined;
|
|
19
20
|
weth?: BorrowIncentivePool | undefined;
|
|
20
21
|
wusdc?: BorrowIncentivePool | undefined;
|
|
21
22
|
wusdt?: BorrowIncentivePool | undefined;
|
|
@@ -36,6 +37,7 @@ export declare const queryBorrowIncentiveAccounts: ({ utils, }: {
|
|
|
36
37
|
utils: ScallopUtils;
|
|
37
38
|
}, obligationId: string, borrowIncentiveCoinNames?: SupportBorrowIncentiveCoins[]) => Promise<{
|
|
38
39
|
usdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
40
|
+
sbeth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
39
41
|
weth?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
40
42
|
wusdc?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
41
43
|
wusdt?: import("../types").ParsedBorrowIncentiveAccountData | undefined;
|
|
@@ -27,6 +27,7 @@ export declare const queryMarket: (query: ScallopQuery, indexer?: boolean) => Pr
|
|
|
27
27
|
*/
|
|
28
28
|
export declare const getMarketPools: (query: ScallopQuery, poolCoinNames?: SupportPoolCoins[], indexer?: boolean) => Promise<{
|
|
29
29
|
usdc?: MarketPool | undefined;
|
|
30
|
+
sbeth?: MarketPool | undefined;
|
|
30
31
|
weth?: MarketPool | undefined;
|
|
31
32
|
wbtc?: MarketPool | undefined;
|
|
32
33
|
wusdc?: MarketPool | undefined;
|
|
@@ -65,6 +66,7 @@ export declare const getMarketPool: (query: ScallopQuery, poolCoinName: SupportP
|
|
|
65
66
|
*/
|
|
66
67
|
export declare const getMarketCollaterals: (query: ScallopQuery, collateralCoinNames?: SupportCollateralCoins[], indexer?: boolean) => Promise<{
|
|
67
68
|
usdc?: MarketCollateral | undefined;
|
|
69
|
+
sbeth?: MarketCollateral | undefined;
|
|
68
70
|
weth?: MarketCollateral | undefined;
|
|
69
71
|
wbtc?: MarketCollateral | undefined;
|
|
70
72
|
wusdc?: MarketCollateral | undefined;
|
|
@@ -11,6 +11,7 @@ import type { Market, SupportPoolCoins, MarketPool, Spool, StakeAccount, Lending
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const getLendings: (query: ScallopQuery, poolCoinNames?: SupportPoolCoins[], ownerAddress?: string, indexer?: boolean) => Promise<{
|
|
13
13
|
usdc?: Lending | undefined;
|
|
14
|
+
sbeth?: Lending | undefined;
|
|
14
15
|
weth?: Lending | undefined;
|
|
15
16
|
wbtc?: Lending | undefined;
|
|
16
17
|
wusdc?: Lending | undefined;
|
|
@@ -19,7 +19,7 @@ export declare const getSCoinTotalSupply: ({ utils, }: {
|
|
|
19
19
|
*/
|
|
20
20
|
export declare const getSCoinAmounts: ({ utils, }: {
|
|
21
21
|
utils: ScallopUtils;
|
|
22
|
-
}, sCoinNames?: SupportSCoin[], ownerAddress?: string) => Promise<OptionalKeys<Record<"susdc" | "sweth" | "ssui" | "swusdc" | "swusdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssca" | "swsol" | "swbtc", number>>>;
|
|
22
|
+
}, sCoinNames?: SupportSCoin[], ownerAddress?: string) => Promise<OptionalKeys<Record<"susdc" | "sweth" | "ssui" | "swusdc" | "swusdt" | "scetus" | "safsui" | "shasui" | "svsui" | "ssbeth" | "ssca" | "swsol" | "swbtc", number>>>;
|
|
23
23
|
/**
|
|
24
24
|
* Query owned sCoin amount.
|
|
25
25
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SUPPORT_POOLS, SUPPORT_COLLATERALS, SUPPORT_ORACLES, SUPPORT_PACKAGES, SUPPORT_SPOOLS, SUPPORT_SPOOLS_REWARDS, SUPPORT_BORROW_INCENTIVE_POOLS, SUPPORT_BORROW_INCENTIVE_REWARDS, SUPPORT_SCOIN } from '../../constants';
|
|
1
|
+
import { SUPPORT_POOLS, SUPPORT_COLLATERALS, SUPPORT_ORACLES, SUPPORT_PACKAGES, SUPPORT_SPOOLS, SUPPORT_SPOOLS_REWARDS, SUPPORT_BORROW_INCENTIVE_POOLS, SUPPORT_BORROW_INCENTIVE_REWARDS, SUPPORT_SCOIN, SUPPORT_SUI_BRIDGE, SUPPORT_WORMHOLE } from '../../constants';
|
|
2
2
|
type ParseMarketCoins<T extends string> = `s${T}`;
|
|
3
3
|
type ParseCoins<T extends string> = T extends `s${infer R}` ? R : never;
|
|
4
4
|
export type SupportCoins = SupportAssetCoins | SupportMarketCoins | SupportStakeMarketCoins | SupportSCoin;
|
|
@@ -7,6 +7,8 @@ export type SupportPoolCoins = (typeof SUPPORT_POOLS)[number];
|
|
|
7
7
|
export type SupportCollateralCoins = (typeof SUPPORT_COLLATERALS)[number];
|
|
8
8
|
export type SupportMarketCoins = ParseMarketCoins<SupportPoolCoins> | SupportStakeMarketCoins;
|
|
9
9
|
export type SupportStakeMarketCoins = (typeof SUPPORT_SPOOLS)[number];
|
|
10
|
+
export type SupportSuiBridgeCoins = (typeof SUPPORT_SUI_BRIDGE)[number];
|
|
11
|
+
export type SupportWormholeCoins = (typeof SUPPORT_WORMHOLE)[number];
|
|
10
12
|
export type SupportStakeCoins = Extract<SupportPoolCoins, ParseCoins<SupportStakeMarketCoins>>;
|
|
11
13
|
export type SupportStakeRewardCoins = (typeof SUPPORT_SPOOLS_REWARDS)[number];
|
|
12
14
|
export type SupportBorrowIncentiveCoins = (typeof SUPPORT_BORROW_INCENTIVE_POOLS)[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportStakeRewardCoins, SupportBorrowIncentiveCoins, SupportBorrowIncentiveRewardCoins, SupportSCoin } from './common';
|
|
1
|
+
import { SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportStakeRewardCoins, SupportBorrowIncentiveCoins, SupportBorrowIncentiveRewardCoins, SupportSCoin, SupportSuiBridgeCoins } from './common';
|
|
2
2
|
export type Coins = {
|
|
3
3
|
[K in SupportCoins]: K;
|
|
4
4
|
};
|
|
@@ -17,6 +17,9 @@ export type StakeMarketCoins = {
|
|
|
17
17
|
export type StakeRewardCoins = {
|
|
18
18
|
[key in SupportStakeMarketCoins]: SupportStakeRewardCoins;
|
|
19
19
|
};
|
|
20
|
+
export type SuiBridgeCoins = {
|
|
21
|
+
[K in SupportSuiBridgeCoins]: K;
|
|
22
|
+
};
|
|
20
23
|
export type BorrowIncentiveRewardCoins = {
|
|
21
24
|
[key in SupportBorrowIncentiveCoins]: SupportBorrowIncentiveRewardCoins[];
|
|
22
25
|
};
|
|
@@ -39,4 +42,7 @@ export type WormholeCoinIds = {
|
|
|
39
42
|
export type VoloCoinIds = {
|
|
40
43
|
[key in PickFromUnion<SupportAssetCoins, 'vsui'>]: string;
|
|
41
44
|
};
|
|
45
|
+
export type SuiBridgedCoinPackageIds = {
|
|
46
|
+
[key in SupportSuiBridgeCoins]: string;
|
|
47
|
+
};
|
|
42
48
|
export {};
|
package/dist/utils/util.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import type { ScallopAddress } from '../models';
|
|
2
2
|
import type { SupportAssetCoins, SupportCoins, SupportMarketCoins } from '../types';
|
|
3
3
|
export declare const isMarketCoin: (coinName: SupportCoins) => coinName is SupportMarketCoins;
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const isSuiBridgeAsset: (coinName: any) => coinName is "sbeth";
|
|
5
|
+
export declare const isWormholeAsset: (coinName: any) => coinName is "weth" | "wbtc" | "wusdc" | "wusdt" | "wapt" | "wsol";
|
|
6
|
+
export declare const parseAssetSymbol: (coinName: SupportCoins) => string;
|
|
5
7
|
/**
|
|
6
8
|
* Parse price from pyth price feed.
|
|
7
9
|
*
|
package/package.json
CHANGED
package/src/constants/common.ts
CHANGED
|
@@ -32,6 +32,7 @@ export const OLD_BORROW_INCENTIVE_PROTOCOL_ID =
|
|
|
32
32
|
|
|
33
33
|
export const SUPPORT_POOLS = [
|
|
34
34
|
'usdc', // native USDC
|
|
35
|
+
'sbeth', // native ETH
|
|
35
36
|
'weth',
|
|
36
37
|
'wbtc',
|
|
37
38
|
'wusdc',
|
|
@@ -47,7 +48,8 @@ export const SUPPORT_POOLS = [
|
|
|
47
48
|
] as const;
|
|
48
49
|
|
|
49
50
|
export const SUPPORT_COLLATERALS = [
|
|
50
|
-
'usdc',
|
|
51
|
+
'usdc', // native USDC
|
|
52
|
+
'sbeth', // native ETH
|
|
51
53
|
'weth',
|
|
52
54
|
'wbtc',
|
|
53
55
|
'wusdc',
|
|
@@ -76,6 +78,7 @@ export const SUPPORT_SPOOLS = [
|
|
|
76
78
|
|
|
77
79
|
export const SUPPORT_SCOIN = [
|
|
78
80
|
'susdc',
|
|
81
|
+
'ssbeth',
|
|
79
82
|
'ssui',
|
|
80
83
|
'swusdc',
|
|
81
84
|
'swusdt',
|
|
@@ -89,6 +92,16 @@ export const SUPPORT_SCOIN = [
|
|
|
89
92
|
'swbtc',
|
|
90
93
|
] as const;
|
|
91
94
|
|
|
95
|
+
export const SUPPORT_SUI_BRIDGE = ['sbeth'] as const;
|
|
96
|
+
export const SUPPORT_WORMHOLE = [
|
|
97
|
+
'wusdc',
|
|
98
|
+
'wusdt',
|
|
99
|
+
'weth',
|
|
100
|
+
'wbtc',
|
|
101
|
+
'wapt',
|
|
102
|
+
'wsol',
|
|
103
|
+
] as const;
|
|
104
|
+
|
|
92
105
|
export const SUPPORT_SPOOLS_REWARDS = ['sui'] as const;
|
|
93
106
|
|
|
94
107
|
export const SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
@@ -99,6 +112,7 @@ export const SUPPORT_BORROW_INCENTIVE_POOLS = [
|
|
|
99
112
|
'hasui',
|
|
100
113
|
'vsui',
|
|
101
114
|
'weth',
|
|
115
|
+
'sbeth',
|
|
102
116
|
'sca',
|
|
103
117
|
'usdc',
|
|
104
118
|
] as const;
|
package/src/constants/enum.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { IS_VE_SCA_TEST } from './common';
|
|
|
3
3
|
|
|
4
4
|
export const coinDecimals: types.SupportCoinDecimals = {
|
|
5
5
|
usdc: 6,
|
|
6
|
+
sbeth: 8,
|
|
6
7
|
weth: 8,
|
|
7
8
|
wbtc: 8,
|
|
8
9
|
wusdc: 6,
|
|
@@ -17,6 +18,7 @@ export const coinDecimals: types.SupportCoinDecimals = {
|
|
|
17
18
|
sca: 9,
|
|
18
19
|
susdc: 6,
|
|
19
20
|
sweth: 8,
|
|
21
|
+
ssbeth: 8,
|
|
20
22
|
swbtc: 8,
|
|
21
23
|
swusdc: 6,
|
|
22
24
|
swusdt: 6,
|
|
@@ -32,6 +34,7 @@ export const coinDecimals: types.SupportCoinDecimals = {
|
|
|
32
34
|
|
|
33
35
|
export const assetCoins: types.AssetCoins = {
|
|
34
36
|
usdc: 'usdc',
|
|
37
|
+
sbeth: 'sbeth',
|
|
35
38
|
weth: 'weth',
|
|
36
39
|
wbtc: 'wbtc',
|
|
37
40
|
wusdc: 'wusdc',
|
|
@@ -48,6 +51,7 @@ export const assetCoins: types.AssetCoins = {
|
|
|
48
51
|
|
|
49
52
|
export const marketCoins: types.MarketCoins = {
|
|
50
53
|
susdc: 'susdc',
|
|
54
|
+
ssbeth: 'ssbeth',
|
|
51
55
|
sweth: 'sweth',
|
|
52
56
|
swbtc: 'swbtc',
|
|
53
57
|
swusdc: 'swusdc',
|
|
@@ -64,6 +68,7 @@ export const marketCoins: types.MarketCoins = {
|
|
|
64
68
|
|
|
65
69
|
export const sCoins: types.SCoins = {
|
|
66
70
|
susdc: 'susdc',
|
|
71
|
+
ssbeth: 'ssbeth',
|
|
67
72
|
sweth: 'sweth',
|
|
68
73
|
swusdc: 'swusdc',
|
|
69
74
|
swusdt: 'swusdt',
|
|
@@ -101,6 +106,10 @@ export const spoolRewardCoins: types.StakeRewardCoins = {
|
|
|
101
106
|
susdc: 'sui',
|
|
102
107
|
};
|
|
103
108
|
|
|
109
|
+
export const suiBridgeCoins: types.SuiBridgeCoins = {
|
|
110
|
+
sbeth: 'sbeth',
|
|
111
|
+
};
|
|
112
|
+
|
|
104
113
|
export const borrowIncentiveRewardCoins: types.BorrowIncentiveRewardCoins = {
|
|
105
114
|
usdc: ['sui', 'sca'],
|
|
106
115
|
sui: ['sui', 'sca'],
|
|
@@ -111,11 +120,13 @@ export const borrowIncentiveRewardCoins: types.BorrowIncentiveRewardCoins = {
|
|
|
111
120
|
hasui: ['sui'],
|
|
112
121
|
vsui: ['sui'],
|
|
113
122
|
weth: ['sui'],
|
|
123
|
+
sbeth: ['sui'],
|
|
114
124
|
};
|
|
115
125
|
|
|
116
126
|
export const coinIds: types.AssetCoinIds = {
|
|
117
127
|
usdc: '0xdba34672e30cb065b1f93e3ab55318768fd6fef66c15942c9f7cb846e2f900e7',
|
|
118
128
|
sui: '0x0000000000000000000000000000000000000000000000000000000000000002',
|
|
129
|
+
sbeth: '0xd0e89b2af5e4910726fbcd8b8dd37bb79b29e5f83f7491bca830e94f7f226d29',
|
|
119
130
|
weth: '0xaf8cd5edc19c4512f4259f0bee101a40d41ebed738ade5874359610ef8eeced5',
|
|
120
131
|
wbtc: '0x027792d9fed7f9844eb4839566001bb6f6cb4804f66aa2da6fe1ee242d896881',
|
|
121
132
|
wusdc: '0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf',
|
|
@@ -148,6 +159,8 @@ export const voloCoinIds: types.VoloCoinIds = {
|
|
|
148
159
|
export const sCoinIds: types.SCoinIds = {
|
|
149
160
|
susdc:
|
|
150
161
|
'0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
|
|
162
|
+
ssbeth:
|
|
163
|
+
'0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
|
|
151
164
|
ssui: '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
152
165
|
scetus:
|
|
153
166
|
'0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
MAX_LOCK_DURATION,
|
|
18
18
|
SUPPORT_SCOIN,
|
|
19
19
|
sCoinIds,
|
|
20
|
+
suiBridgeCoins,
|
|
20
21
|
} from '../constants';
|
|
21
22
|
import { getPythPrice, queryObligation } from '../queries';
|
|
22
23
|
import {
|
|
@@ -24,6 +25,8 @@ import {
|
|
|
24
25
|
isMarketCoin,
|
|
25
26
|
parseAssetSymbol,
|
|
26
27
|
findClosestUnlockRound,
|
|
28
|
+
isSuiBridgeAsset,
|
|
29
|
+
isWormholeAsset,
|
|
27
30
|
} from '../utils';
|
|
28
31
|
import { PYTH_ENDPOINTS } from 'src/constants/pyth';
|
|
29
32
|
import { ScallopCache } from './scallopCache';
|
|
@@ -40,6 +43,8 @@ import type {
|
|
|
40
43
|
CoinWrappedType,
|
|
41
44
|
SupportSCoin,
|
|
42
45
|
ScallopUtilsInstanceParams,
|
|
46
|
+
SupportSuiBridgeCoins,
|
|
47
|
+
SupportWormholeCoins,
|
|
43
48
|
} from '../types';
|
|
44
49
|
import type { SuiAddressArg, SuiTxArg, SuiTxBlock } from '@scallop-io/sui-kit';
|
|
45
50
|
|
|
@@ -106,6 +111,14 @@ export class ScallopUtils {
|
|
|
106
111
|
? params.networkType === 'testnet'
|
|
107
112
|
: false;
|
|
108
113
|
}
|
|
114
|
+
// -------------- TYPE GUARDS --------------
|
|
115
|
+
public isSuiBridgeAsset(coinName: any): coinName is SupportSuiBridgeCoins {
|
|
116
|
+
return isSuiBridgeAsset(coinName);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
public isWormholeAsset(coinName: any): coinName is SupportWormholeCoins {
|
|
120
|
+
return isWormholeAsset(coinName);
|
|
121
|
+
}
|
|
109
122
|
|
|
110
123
|
/**
|
|
111
124
|
* Request the scallop API to initialize data.
|
|
@@ -128,16 +141,7 @@ export class ScallopUtils {
|
|
|
128
141
|
* @return Symbol string.
|
|
129
142
|
*/
|
|
130
143
|
public parseSymbol(coinName: SupportCoins) {
|
|
131
|
-
|
|
132
|
-
const assetCoinName = coinName
|
|
133
|
-
.slice(1)
|
|
134
|
-
.toLowerCase() as SupportAssetCoins;
|
|
135
|
-
return (
|
|
136
|
-
coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName)
|
|
137
|
-
);
|
|
138
|
-
} else {
|
|
139
|
-
return parseAssetSymbol(coinName);
|
|
140
|
-
}
|
|
144
|
+
return parseAssetSymbol(coinName);
|
|
141
145
|
}
|
|
142
146
|
|
|
143
147
|
/**
|
|
@@ -173,10 +177,23 @@ export class ScallopUtils {
|
|
|
173
177
|
const voloPackageIds = [
|
|
174
178
|
this.address.get('core.coins.vsui.id') ?? voloCoinIds.vsui,
|
|
175
179
|
];
|
|
180
|
+
|
|
181
|
+
const suiBridgePackageIds = Object.values<SupportSuiBridgeCoins>(
|
|
182
|
+
suiBridgeCoins
|
|
183
|
+
).reduce((curr, coinName) => {
|
|
184
|
+
curr.push(
|
|
185
|
+
this.address.get(`core.coins.${coinName}.id`) ?? coinIds[coinName]
|
|
186
|
+
);
|
|
187
|
+
return curr;
|
|
188
|
+
}, [] as string[]);
|
|
176
189
|
if (wormHolePackageIds.includes(coinPackageId)) {
|
|
177
190
|
return `${coinPackageId}::coin::COIN`;
|
|
178
191
|
} else if (voloPackageIds.includes(coinPackageId)) {
|
|
179
192
|
return `${coinPackageId}::cert::CERT`;
|
|
193
|
+
} else if (suiBridgePackageIds.includes(coinPackageId)) {
|
|
194
|
+
// handle sui bridge assets
|
|
195
|
+
const typeCoinName = coinName.slice(2);
|
|
196
|
+
return `${coinPackageId}::${typeCoinName}::${typeCoinName.toUpperCase()}`;
|
|
180
197
|
} else {
|
|
181
198
|
return `${coinPackageId}::${coinName}::${coinName.toUpperCase()}`;
|
|
182
199
|
}
|
|
@@ -299,9 +316,20 @@ export class ScallopUtils {
|
|
|
299
316
|
}::cert::CERT`]: 'vsui',
|
|
300
317
|
};
|
|
301
318
|
|
|
319
|
+
const suiBridgeTypeMap = Object.values<SupportSuiBridgeCoins>(
|
|
320
|
+
suiBridgeCoins
|
|
321
|
+
).reduce(
|
|
322
|
+
(curr, coinName) => {
|
|
323
|
+
curr[this.parseCoinType(coinName)] = coinName;
|
|
324
|
+
return curr;
|
|
325
|
+
},
|
|
326
|
+
{} as Record<string, SupportSuiBridgeCoins>
|
|
327
|
+
);
|
|
328
|
+
|
|
302
329
|
const assetCoinName =
|
|
303
330
|
wormHoleCoinTypeMap[coinType] ||
|
|
304
331
|
voloCoinTypeMap[coinType] ||
|
|
332
|
+
suiBridgeTypeMap[coinType] ||
|
|
305
333
|
(coinType.split('::')[2].toLowerCase() as SupportAssetCoins);
|
|
306
334
|
|
|
307
335
|
return isMarketCoinType
|
|
@@ -310,7 +338,7 @@ export class ScallopUtils {
|
|
|
310
338
|
}
|
|
311
339
|
|
|
312
340
|
/**
|
|
313
|
-
* Convert
|
|
341
|
+
* Convert market coin name to coin name.
|
|
314
342
|
*
|
|
315
343
|
* @param marketCoinName - Specific support market coin name.
|
|
316
344
|
* @return Coin Name.
|
|
@@ -370,17 +398,19 @@ export class ScallopUtils {
|
|
|
370
398
|
* return Coin wrapped type.
|
|
371
399
|
*/
|
|
372
400
|
public getCoinWrappedType(assetCoinName: SupportAssetCoins): CoinWrappedType {
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
401
|
+
if (this.isSuiBridgeAsset(assetCoinName)) {
|
|
402
|
+
return {
|
|
403
|
+
from: 'Sui Bridge',
|
|
404
|
+
type: 'Asset from Sui Bridge',
|
|
405
|
+
};
|
|
406
|
+
} else if (this.isWormholeAsset(assetCoinName)) {
|
|
407
|
+
return {
|
|
408
|
+
from: 'Wormhole',
|
|
409
|
+
type: 'Portal from Ethereum',
|
|
410
|
+
};
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
return undefined;
|
|
384
414
|
}
|
|
385
415
|
|
|
386
416
|
/**
|
package/src/queries/coreQuery.ts
CHANGED
|
@@ -324,7 +324,6 @@ export const getMarketPool = async (
|
|
|
324
324
|
if (marketObject.content && 'fields' in marketObject.content) {
|
|
325
325
|
const fields = marketObject.content.fields as any;
|
|
326
326
|
const coinType = query.utils.parseCoinType(poolCoinName);
|
|
327
|
-
|
|
328
327
|
// Get balance sheet.
|
|
329
328
|
const balanceSheetParentId =
|
|
330
329
|
fields.vault.fields.balance_sheets.fields.table.fields.id.id;
|
|
@@ -272,18 +272,13 @@ export const getStakeAccounts = async (
|
|
|
272
272
|
}
|
|
273
273
|
} while (hasNextPage);
|
|
274
274
|
|
|
275
|
-
const stakeAccounts: StakeAccounts =
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
safsui: [],
|
|
283
|
-
shasui: [],
|
|
284
|
-
svsui: [],
|
|
285
|
-
// ssca: [],
|
|
286
|
-
};
|
|
275
|
+
const stakeAccounts: StakeAccounts = SUPPORT_SPOOLS.reduce(
|
|
276
|
+
(acc, stakeName) => {
|
|
277
|
+
acc[stakeName] = [];
|
|
278
|
+
return acc;
|
|
279
|
+
},
|
|
280
|
+
{} as StakeAccounts
|
|
281
|
+
);
|
|
287
282
|
|
|
288
283
|
const stakeMarketCoinTypes: Record<SupportStakeMarketCoins, string> =
|
|
289
284
|
Object.keys(stakeAccounts).reduce(
|
|
@@ -300,6 +295,16 @@ export const getStakeAccounts = async (
|
|
|
300
295
|
{} as Record<SupportStakeMarketCoins, string>
|
|
301
296
|
);
|
|
302
297
|
|
|
298
|
+
// Reverse the mapping
|
|
299
|
+
const reversedStakeMarketCoinTypes: Record<string, SupportStakeMarketCoins> =
|
|
300
|
+
Object.entries(stakeMarketCoinTypes).reduce(
|
|
301
|
+
(reversedTypes, [key, value]) => {
|
|
302
|
+
reversedTypes[value] = key as SupportStakeMarketCoins;
|
|
303
|
+
return reversedTypes;
|
|
304
|
+
},
|
|
305
|
+
{} as Record<string, SupportStakeMarketCoins>
|
|
306
|
+
);
|
|
307
|
+
|
|
303
308
|
const stakeObjectIds: string[] = stakeObjectsResponse
|
|
304
309
|
.map((ref: any) => ref?.data?.objectId)
|
|
305
310
|
.filter((id: any) => id !== undefined);
|
|
@@ -318,98 +323,30 @@ export const getStakeAccounts = async (
|
|
|
318
323
|
const index = Number(fields.index);
|
|
319
324
|
const points = Number(fields.points);
|
|
320
325
|
const totalPoints = Number(fields.total_points);
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
stakeAccounts.
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.swusdc) {
|
|
344
|
-
stakeAccounts.swusdc.push({
|
|
345
|
-
id,
|
|
346
|
-
type: normalizeStructTag(type),
|
|
347
|
-
stakePoolId,
|
|
348
|
-
stakeType: normalizeStructTag(stakeType),
|
|
349
|
-
staked,
|
|
350
|
-
index,
|
|
351
|
-
points,
|
|
352
|
-
totalPoints,
|
|
353
|
-
});
|
|
354
|
-
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.swusdt) {
|
|
355
|
-
stakeAccounts.swusdt.push({
|
|
356
|
-
id,
|
|
357
|
-
type: normalizeStructTag(type),
|
|
358
|
-
stakePoolId,
|
|
359
|
-
stakeType: normalizeStructTag(stakeType),
|
|
360
|
-
staked,
|
|
361
|
-
index,
|
|
362
|
-
points,
|
|
363
|
-
totalPoints,
|
|
364
|
-
});
|
|
365
|
-
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.scetus) {
|
|
366
|
-
stakeAccounts.scetus.push({
|
|
367
|
-
id,
|
|
368
|
-
type: normalizeStructTag(type),
|
|
369
|
-
stakePoolId,
|
|
370
|
-
stakeType: normalizeStructTag(stakeType),
|
|
371
|
-
staked,
|
|
372
|
-
index,
|
|
373
|
-
points,
|
|
374
|
-
totalPoints,
|
|
375
|
-
});
|
|
376
|
-
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.safsui) {
|
|
377
|
-
stakeAccounts.safsui.push({
|
|
378
|
-
id,
|
|
379
|
-
type: normalizeStructTag(type),
|
|
380
|
-
stakePoolId,
|
|
381
|
-
stakeType: normalizeStructTag(stakeType),
|
|
382
|
-
staked,
|
|
383
|
-
index,
|
|
384
|
-
points,
|
|
385
|
-
totalPoints,
|
|
386
|
-
});
|
|
387
|
-
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.shasui) {
|
|
388
|
-
stakeAccounts.shasui.push({
|
|
389
|
-
id,
|
|
390
|
-
type: normalizeStructTag(type),
|
|
391
|
-
stakePoolId,
|
|
392
|
-
stakeType: normalizeStructTag(stakeType),
|
|
393
|
-
staked,
|
|
394
|
-
index,
|
|
395
|
-
points,
|
|
396
|
-
totalPoints,
|
|
397
|
-
});
|
|
398
|
-
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.svsui) {
|
|
399
|
-
stakeAccounts.svsui.push({
|
|
400
|
-
id,
|
|
401
|
-
type: normalizeStructTag(type),
|
|
402
|
-
stakePoolId,
|
|
403
|
-
stakeType: normalizeStructTag(stakeType),
|
|
404
|
-
staked,
|
|
405
|
-
index,
|
|
406
|
-
points,
|
|
407
|
-
totalPoints,
|
|
408
|
-
});
|
|
409
|
-
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.susdc) {
|
|
410
|
-
stakeAccounts.susdc.push({
|
|
326
|
+
|
|
327
|
+
const stakeMarketCoinTypeMap: Record<
|
|
328
|
+
SupportStakeMarketCoins,
|
|
329
|
+
StakeAccounts[SupportStakeMarketCoins]
|
|
330
|
+
> = {
|
|
331
|
+
sweth: stakeAccounts.sweth,
|
|
332
|
+
ssui: stakeAccounts.ssui,
|
|
333
|
+
swusdc: stakeAccounts.swusdc,
|
|
334
|
+
swusdt: stakeAccounts.swusdt,
|
|
335
|
+
scetus: stakeAccounts.scetus,
|
|
336
|
+
safsui: stakeAccounts.safsui,
|
|
337
|
+
shasui: stakeAccounts.shasui,
|
|
338
|
+
svsui: stakeAccounts.svsui,
|
|
339
|
+
susdc: stakeAccounts.susdc,
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const normalizedType = normalizeStructTag(type);
|
|
343
|
+
const stakeAccountArray =
|
|
344
|
+
stakeMarketCoinTypeMap[reversedStakeMarketCoinTypes[normalizedType]];
|
|
345
|
+
|
|
346
|
+
if (stakeAccountArray) {
|
|
347
|
+
stakeAccountArray.push({
|
|
411
348
|
id,
|
|
412
|
-
type:
|
|
349
|
+
type: normalizedType,
|
|
413
350
|
stakePoolId,
|
|
414
351
|
stakeType: normalizeStructTag(stakeType),
|
|
415
352
|
staked,
|
|
@@ -8,6 +8,8 @@ import {
|
|
|
8
8
|
SUPPORT_BORROW_INCENTIVE_POOLS,
|
|
9
9
|
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
10
10
|
SUPPORT_SCOIN,
|
|
11
|
+
SUPPORT_SUI_BRIDGE,
|
|
12
|
+
SUPPORT_WORMHOLE,
|
|
11
13
|
} from '../../constants';
|
|
12
14
|
|
|
13
15
|
type ParseMarketCoins<T extends string> = `s${T}`;
|
|
@@ -29,6 +31,8 @@ export type SupportMarketCoins =
|
|
|
29
31
|
| ParseMarketCoins<SupportPoolCoins>
|
|
30
32
|
| SupportStakeMarketCoins;
|
|
31
33
|
export type SupportStakeMarketCoins = (typeof SUPPORT_SPOOLS)[number];
|
|
34
|
+
export type SupportSuiBridgeCoins = (typeof SUPPORT_SUI_BRIDGE)[number];
|
|
35
|
+
export type SupportWormholeCoins = (typeof SUPPORT_WORMHOLE)[number];
|
|
32
36
|
export type SupportStakeCoins = Extract<
|
|
33
37
|
SupportPoolCoins,
|
|
34
38
|
ParseCoins<SupportStakeMarketCoins>
|