@scallop-io/sui-scallop-sdk 1.5.3 → 2.0.0-alpha.10
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 +509 -602
- package/dist/index.d.ts +509 -602
- package/dist/index.js +28 -59
- package/dist/index.mjs +7 -7
- package/package.json +1 -1
- package/src/builders/coreBuilder.ts +33 -33
- package/src/builders/loyaltyProgramBuilder.ts +5 -3
- package/src/builders/{oracle.ts → oracles/index.ts} +48 -60
- package/src/builders/oracles/pyth.ts +44 -0
- package/src/builders/oracles/switchboard.ts +270 -0
- package/src/builders/referralBuilder.ts +5 -9
- package/src/builders/sCoinBuilder.ts +9 -8
- package/src/builders/spoolBuilder.ts +4 -6
- package/src/constants/common.ts +114 -126
- package/src/constants/index.ts +0 -5
- package/src/constants/pyth.ts +25 -34
- package/src/constants/queryKeys.ts +2 -0
- package/src/constants/testAddress.ts +36 -487
- package/src/models/index.ts +1 -0
- package/src/models/scallop.ts +23 -19
- package/src/models/scallopAddress.ts +17 -5
- package/src/models/scallopBuilder.ts +36 -41
- package/src/models/scallopCache.ts +3 -3
- package/src/models/scallopClient.ts +93 -98
- package/src/models/scallopConstants.ts +399 -0
- package/src/models/scallopIndexer.ts +11 -24
- package/src/models/scallopQuery.ts +76 -79
- package/src/models/scallopUtils.ts +126 -250
- package/src/queries/borrowIncentiveQuery.ts +25 -58
- package/src/queries/borrowLimitQuery.ts +3 -6
- package/src/queries/coreQuery.ts +98 -114
- package/src/queries/flashloanFeeQuery.ts +86 -0
- package/src/queries/index.ts +1 -0
- package/src/queries/isolatedAssetQuery.ts +12 -11
- package/src/queries/poolAddressesQuery.ts +211 -117
- package/src/queries/portfolioQuery.ts +60 -70
- package/src/queries/priceQuery.ts +16 -22
- package/src/queries/sCoinQuery.ts +15 -16
- package/src/queries/spoolQuery.ts +49 -59
- package/src/queries/supplyLimitQuery.ts +2 -6
- package/src/queries/switchboardQuery.ts +64 -0
- package/src/queries/xOracleQuery.ts +29 -32
- package/src/types/address.ts +21 -19
- package/src/types/builder/borrowIncentive.ts +2 -3
- package/src/types/builder/core.ts +20 -27
- package/src/types/builder/index.ts +1 -2
- package/src/types/builder/referral.ts +4 -8
- package/src/types/builder/sCoin.ts +4 -8
- package/src/types/builder/spool.ts +7 -10
- package/src/types/constant/common.ts +44 -49
- package/src/types/constant/enum.ts +15 -27
- package/src/types/constant/xOracle.ts +3 -2
- package/src/types/model.ts +49 -28
- package/src/types/query/borrowIncentive.ts +7 -24
- package/src/types/query/core.ts +8 -18
- package/src/types/query/portfolio.ts +9 -17
- package/src/types/query/spool.ts +5 -11
- package/src/types/utils.ts +1 -21
- package/src/utils/core.ts +1 -1
- package/src/utils/query.ts +15 -23
- package/src/utils/util.ts +6 -84
- package/src/constants/coinGecko.ts +0 -34
- package/src/constants/enum.ts +0 -268
- package/src/constants/flashloan.ts +0 -18
- package/src/constants/poolAddress.ts +0 -898
- package/src/models/scallopPrice.ts +0 -0
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SupportBorrowIncentiveCoins,
|
|
3
|
-
SupportBorrowIncentiveRewardCoins,
|
|
4
|
-
} from '../constant';
|
|
5
|
-
|
|
6
1
|
export interface BorrowIncentiveAccountKey {
|
|
7
2
|
id: string;
|
|
8
3
|
onwerId: string;
|
|
@@ -13,12 +8,12 @@ type OptionalKeys<T> = {
|
|
|
13
8
|
};
|
|
14
9
|
|
|
15
10
|
export type BorrowIncentivePools = OptionalKeys<
|
|
16
|
-
Record<
|
|
11
|
+
Record<string, BorrowIncentivePool>
|
|
17
12
|
>;
|
|
18
13
|
|
|
19
14
|
export type BorrowIncentivePoolPoints = {
|
|
20
15
|
symbol: string;
|
|
21
|
-
coinName:
|
|
16
|
+
coinName: string;
|
|
22
17
|
coinType: string;
|
|
23
18
|
coinDecimal: number;
|
|
24
19
|
coinPrice: number;
|
|
@@ -31,7 +26,7 @@ export type BorrowIncentivePoolPoints = {
|
|
|
31
26
|
CalculatedBorrowIncentivePoolPointData;
|
|
32
27
|
|
|
33
28
|
export type BorrowIncentivePool = {
|
|
34
|
-
coinName:
|
|
29
|
+
coinName: string;
|
|
35
30
|
symbol: string;
|
|
36
31
|
coinType: string;
|
|
37
32
|
coinDecimal: number;
|
|
@@ -39,9 +34,7 @@ export type BorrowIncentivePool = {
|
|
|
39
34
|
stakedAmount: number;
|
|
40
35
|
stakedCoin: number;
|
|
41
36
|
stakedValue: number;
|
|
42
|
-
points: OptionalKeys<
|
|
43
|
-
Record<SupportBorrowIncentiveRewardCoins, BorrowIncentivePoolPoints>
|
|
44
|
-
>;
|
|
37
|
+
points: OptionalKeys<Record<string, BorrowIncentivePoolPoints>>;
|
|
45
38
|
};
|
|
46
39
|
|
|
47
40
|
export type OriginBorrowIncentivePoolPointData = {
|
|
@@ -85,12 +78,7 @@ export type ParsedBorrowIncentivePoolPointData = {
|
|
|
85
78
|
|
|
86
79
|
export type ParsedBorrowIncentivePoolData = {
|
|
87
80
|
poolType: string;
|
|
88
|
-
poolPoints: OptionalKeys<
|
|
89
|
-
Record<
|
|
90
|
-
SupportBorrowIncentiveRewardCoins,
|
|
91
|
-
ParsedBorrowIncentivePoolPointData
|
|
92
|
-
>
|
|
93
|
-
>;
|
|
81
|
+
poolPoints: OptionalKeys<Record<string, ParsedBorrowIncentivePoolPointData>>;
|
|
94
82
|
minStakes: number;
|
|
95
83
|
maxStakes: number;
|
|
96
84
|
staked: number;
|
|
@@ -110,7 +98,7 @@ export type CalculatedBorrowIncentivePoolPointData = {
|
|
|
110
98
|
};
|
|
111
99
|
|
|
112
100
|
export type BorrowIncentiveAccounts = OptionalKeys<
|
|
113
|
-
Record<
|
|
101
|
+
Record<string, ParsedBorrowIncentiveAccountData>
|
|
114
102
|
>;
|
|
115
103
|
|
|
116
104
|
export type OriginBorrowIncentiveAccountPoolData = {
|
|
@@ -140,12 +128,7 @@ export type ParsedBorrowIncentiveAccountPoolData = {
|
|
|
140
128
|
};
|
|
141
129
|
|
|
142
130
|
export type ParsedBorrowIncentiveAccountData = {
|
|
143
|
-
pointList: OptionalKeys<
|
|
144
|
-
Record<
|
|
145
|
-
SupportBorrowIncentiveRewardCoins,
|
|
146
|
-
ParsedBorrowIncentiveAccountPoolData
|
|
147
|
-
>
|
|
148
|
-
>;
|
|
131
|
+
pointList: OptionalKeys<Record<string, ParsedBorrowIncentiveAccountPoolData>>;
|
|
149
132
|
poolType: string;
|
|
150
133
|
debtAmount: number;
|
|
151
134
|
};
|
package/src/types/query/core.ts
CHANGED
|
@@ -1,25 +1,15 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
SupportPoolCoins,
|
|
3
|
-
SupportCollateralCoins,
|
|
4
|
-
SupportMarketCoins,
|
|
5
|
-
CoinWrappedType,
|
|
6
|
-
SupportSCoin,
|
|
7
|
-
} from '../constant';
|
|
1
|
+
import type { CoinWrappedType } from '../constant';
|
|
8
2
|
|
|
9
3
|
type OptionalKeys<T> = {
|
|
10
4
|
[K in keyof T]?: T[K];
|
|
11
5
|
};
|
|
12
6
|
|
|
13
|
-
export type MarketPools = OptionalKeys<Record<
|
|
14
|
-
export type MarketCollaterals = OptionalKeys<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export type CoinAmounts = OptionalKeys<Record<SupportPoolCoins, number>>;
|
|
18
|
-
export type MarketCoinAmounts = OptionalKeys<
|
|
19
|
-
Record<SupportMarketCoins, number>
|
|
20
|
-
>;
|
|
7
|
+
export type MarketPools = OptionalKeys<Record<string, MarketPool>>;
|
|
8
|
+
export type MarketCollaterals = OptionalKeys<Record<string, MarketCollateral>>;
|
|
9
|
+
export type CoinAmounts = OptionalKeys<Record<string, number>>;
|
|
10
|
+
export type MarketCoinAmounts = OptionalKeys<Record<string, number>>;
|
|
21
11
|
|
|
22
|
-
export type SCoinAmounts = OptionalKeys<Record<
|
|
12
|
+
export type SCoinAmounts = OptionalKeys<Record<string, number>>;
|
|
23
13
|
|
|
24
14
|
export type BalanceSheet = {
|
|
25
15
|
cash: string;
|
|
@@ -123,7 +113,7 @@ export type RiskModel = {
|
|
|
123
113
|
export type CollateralStat = { amount: string };
|
|
124
114
|
|
|
125
115
|
export type MarketPool = {
|
|
126
|
-
coinName:
|
|
116
|
+
coinName: string;
|
|
127
117
|
symbol: string;
|
|
128
118
|
coinType: string;
|
|
129
119
|
marketCoinType: string;
|
|
@@ -149,7 +139,7 @@ export type MarketPool = {
|
|
|
149
139
|
CalculatedMarketPoolData;
|
|
150
140
|
|
|
151
141
|
export type MarketCollateral = {
|
|
152
|
-
coinName:
|
|
142
|
+
coinName: string;
|
|
153
143
|
symbol: string;
|
|
154
144
|
coinType: string;
|
|
155
145
|
marketCoinType: string;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
import type { MarketPool } from './core';
|
|
2
2
|
import type { Spool } from './spool';
|
|
3
|
-
import type {
|
|
4
|
-
SupportPoolCoins,
|
|
5
|
-
SupportCollateralCoins,
|
|
6
|
-
SupportBorrowIncentiveRewardCoins,
|
|
7
|
-
} from '../constant';
|
|
8
3
|
|
|
9
4
|
type OptionalKeys<T> = {
|
|
10
5
|
[K in keyof T]?: T[K];
|
|
11
6
|
};
|
|
12
7
|
|
|
13
|
-
export type Lendings = OptionalKeys<Record<
|
|
8
|
+
export type Lendings = OptionalKeys<Record<string, Lending>>;
|
|
14
9
|
export type ObligationAccounts = OptionalKeys<
|
|
15
10
|
Record<string, ObligationAccount>
|
|
16
11
|
>;
|
|
@@ -72,17 +67,13 @@ export type ObligationAccount = {
|
|
|
72
67
|
totalDepositedPools: number;
|
|
73
68
|
totalBorrowedPools: number;
|
|
74
69
|
totalRewardedPools: number;
|
|
75
|
-
collaterals: OptionalKeys<
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
debts: OptionalKeys<Record<SupportPoolCoins, ObligationDebt>>;
|
|
79
|
-
borrowIncentives: OptionalKeys<
|
|
80
|
-
Record<SupportPoolCoins, ObligationBorrowIncentive>
|
|
81
|
-
>;
|
|
70
|
+
collaterals: OptionalKeys<Record<string, ObligationCollateral>>;
|
|
71
|
+
debts: OptionalKeys<Record<string, ObligationDebt>>;
|
|
72
|
+
borrowIncentives: OptionalKeys<Record<string, ObligationBorrowIncentive>>;
|
|
82
73
|
};
|
|
83
74
|
|
|
84
75
|
export type ObligationCollateral = {
|
|
85
|
-
coinName:
|
|
76
|
+
coinName: string;
|
|
86
77
|
coinType: string;
|
|
87
78
|
symbol: string;
|
|
88
79
|
coinDecimal: number;
|
|
@@ -99,7 +90,7 @@ export type ObligationCollateral = {
|
|
|
99
90
|
};
|
|
100
91
|
|
|
101
92
|
export type ObligationDebt = {
|
|
102
|
-
coinName:
|
|
93
|
+
coinName: string;
|
|
103
94
|
coinType: string;
|
|
104
95
|
symbol: string;
|
|
105
96
|
coinDecimal: number;
|
|
@@ -118,18 +109,19 @@ export type ObligationDebt = {
|
|
|
118
109
|
};
|
|
119
110
|
|
|
120
111
|
export type ObligationBorrowIcentiveReward = {
|
|
121
|
-
coinName:
|
|
112
|
+
coinName: string;
|
|
122
113
|
coinType: string;
|
|
123
114
|
symbol: string;
|
|
124
115
|
coinDecimal: number;
|
|
125
116
|
coinPrice: number;
|
|
117
|
+
weightedBorrowAmount: number;
|
|
126
118
|
availableClaimCoin: number;
|
|
127
119
|
availableClaimAmount: number;
|
|
128
120
|
boostValue: number;
|
|
129
121
|
};
|
|
130
122
|
|
|
131
123
|
export type ObligationBorrowIncentive = {
|
|
132
|
-
coinName:
|
|
124
|
+
coinName: string;
|
|
133
125
|
coinType: string;
|
|
134
126
|
symbol: string;
|
|
135
127
|
coinDecimal: number;
|
package/src/types/query/spool.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import type { SupportStakeMarketCoins } from '../constant';
|
|
2
|
-
|
|
3
1
|
type OptionalKeys<T> = {
|
|
4
2
|
[K in keyof T]?: T[K];
|
|
5
3
|
};
|
|
6
4
|
|
|
7
|
-
export type Spools = OptionalKeys<Record<
|
|
5
|
+
export type Spools = OptionalKeys<Record<string, Spool>>;
|
|
8
6
|
|
|
9
7
|
export type Spool = {
|
|
10
|
-
marketCoinName:
|
|
8
|
+
marketCoinName: string;
|
|
11
9
|
symbol: string;
|
|
12
10
|
coinType: string;
|
|
13
11
|
marketCoinType: string;
|
|
@@ -121,13 +119,9 @@ export type CalculatedSpoolRewardPoolData = {
|
|
|
121
119
|
rewardPerSec: number;
|
|
122
120
|
};
|
|
123
121
|
|
|
124
|
-
export type StakePools = OptionalKeys<
|
|
125
|
-
|
|
126
|
-
>;
|
|
127
|
-
export type StakeRewardPools = OptionalKeys<
|
|
128
|
-
Record<SupportStakeMarketCoins, StakeRewardPool>
|
|
129
|
-
>;
|
|
130
|
-
export type StakeAccounts = Record<SupportStakeMarketCoins, StakeAccount[]>;
|
|
122
|
+
export type StakePools = OptionalKeys<Record<string, StakePool>>;
|
|
123
|
+
export type StakeRewardPools = OptionalKeys<Record<string, StakeRewardPool>>;
|
|
124
|
+
export type StakeAccounts = Record<string, StakeAccount[]>;
|
|
131
125
|
|
|
132
126
|
export interface StakeAccount {
|
|
133
127
|
id: string;
|
package/src/types/utils.ts
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
|
-
import type { SupportCoins } from './constant';
|
|
2
|
-
|
|
3
1
|
export type OptionalKeys<T> = {
|
|
4
2
|
[K in keyof T]?: T[K];
|
|
5
3
|
};
|
|
6
4
|
|
|
7
|
-
export type CoinPrices = OptionalKeys<Record<
|
|
8
|
-
|
|
9
|
-
export type PoolAddressInfo = {
|
|
10
|
-
name: string;
|
|
11
|
-
coingeckoId: string;
|
|
12
|
-
decimal: number;
|
|
13
|
-
pythFeedId: string;
|
|
14
|
-
lendingPoolAddress?: string;
|
|
15
|
-
collateralPoolAddress?: string; // not all pool has collateral
|
|
16
|
-
borrowDynamic?: string;
|
|
17
|
-
interestModelId?: string;
|
|
18
|
-
borrowFeeKey?: string;
|
|
19
|
-
supplyLimitKey?: string;
|
|
20
|
-
borrowLimitKey?: string;
|
|
21
|
-
isolatedAssetKey?: string;
|
|
22
|
-
sCoinAddress: string | undefined;
|
|
23
|
-
marketCoinAddress: string;
|
|
24
|
-
sCoinName: string | undefined;
|
|
25
|
-
};
|
|
5
|
+
export type CoinPrices = OptionalKeys<Record<string, number>>;
|
package/src/utils/core.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { SuiObjectData } from '@mysten/sui/client';
|
|
|
2
2
|
|
|
3
3
|
export const parseObjectAs = <T>(object: SuiObjectData): T => {
|
|
4
4
|
if (!(object && object.content && 'fields' in object.content))
|
|
5
|
-
throw new Error(`Failed to parse object`);
|
|
5
|
+
throw new Error(`Failed to parse object ${object}`);
|
|
6
6
|
|
|
7
7
|
const fields = object.content.fields as any;
|
|
8
8
|
|
package/src/utils/query.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { normalizeStructTag
|
|
2
|
+
import { normalizeStructTag } from '@mysten/sui/utils';
|
|
3
3
|
import type { ScallopUtils } from '../models';
|
|
4
4
|
import type {
|
|
5
5
|
OriginMarketPoolData,
|
|
@@ -18,14 +18,11 @@ import type {
|
|
|
18
18
|
ParsedBorrowIncentivePoolData,
|
|
19
19
|
OriginBorrowIncentiveAccountData,
|
|
20
20
|
ParsedBorrowIncentiveAccountData,
|
|
21
|
-
SupportPoolCoins,
|
|
22
|
-
SupportCollateralCoins,
|
|
23
21
|
OriginBorrowIncentivePoolPointData,
|
|
24
22
|
ParsedBorrowIncentivePoolPointData,
|
|
25
23
|
CalculatedBorrowIncentivePoolPointData,
|
|
26
24
|
OriginBorrowIncentiveAccountPoolData,
|
|
27
25
|
ParsedBorrowIncentiveAccountPoolData,
|
|
28
|
-
SupportBorrowIncentiveRewardCoins,
|
|
29
26
|
} from '../types';
|
|
30
27
|
|
|
31
28
|
/**
|
|
@@ -72,10 +69,13 @@ export const calculateMarketPoolData = (
|
|
|
72
69
|
utils: ScallopUtils,
|
|
73
70
|
parsedMarketPoolData: ParsedMarketPoolData
|
|
74
71
|
): CalculatedMarketPoolData => {
|
|
75
|
-
const poolCoinName = utils.parseCoinNameFromType
|
|
72
|
+
const poolCoinName = utils.parseCoinNameFromType(
|
|
76
73
|
parsedMarketPoolData.coinType
|
|
77
74
|
);
|
|
75
|
+
|
|
78
76
|
const coinDecimal = utils.getCoinDecimal(poolCoinName);
|
|
77
|
+
if (coinDecimal === undefined)
|
|
78
|
+
throw new Error(`Coin decimal not found for ${poolCoinName}`);
|
|
79
79
|
|
|
80
80
|
const borrowYearFactor = 24 * 365 * 3600;
|
|
81
81
|
|
|
@@ -210,11 +210,12 @@ export const calculateMarketCollateralData = (
|
|
|
210
210
|
utils: ScallopUtils,
|
|
211
211
|
parsedMarketCollateralData: ParsedMarketCollateralData
|
|
212
212
|
): CalculatedMarketCollateralData => {
|
|
213
|
-
const collateralCoinName =
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
);
|
|
213
|
+
const collateralCoinName = utils.parseCoinNameFromType(
|
|
214
|
+
parsedMarketCollateralData.coinType
|
|
215
|
+
);
|
|
217
216
|
const coinDecimal = utils.getCoinDecimal(collateralCoinName);
|
|
217
|
+
if (coinDecimal === undefined)
|
|
218
|
+
throw new Error(`Coin decimal not found for ${collateralCoinName}`);
|
|
218
219
|
|
|
219
220
|
const maxCollateralCoin = BigNumber(
|
|
220
221
|
parsedMarketCollateralData.maxCollateralAmount
|
|
@@ -448,17 +449,12 @@ export const parseOriginBorrowIncentivePoolData = (
|
|
|
448
449
|
poolPoints: originBorrowIncentivePoolData.points.reduce(
|
|
449
450
|
(acc, point) => {
|
|
450
451
|
const parsed = parseOriginBorrowIncentivesPoolPointData(point);
|
|
451
|
-
const name = utils.
|
|
452
|
-
parseStructTag(parsed.pointType).name.toLowerCase()
|
|
453
|
-
) as SupportBorrowIncentiveRewardCoins;
|
|
452
|
+
const name = utils.parseCoinNameFromType(parsed.pointType) as string;
|
|
454
453
|
|
|
455
454
|
acc[name] = parsed;
|
|
456
455
|
return acc;
|
|
457
456
|
},
|
|
458
|
-
{} as Record<
|
|
459
|
-
SupportBorrowIncentiveRewardCoins,
|
|
460
|
-
ParsedBorrowIncentivePoolPointData
|
|
461
|
-
>
|
|
457
|
+
{} as Record<string, ParsedBorrowIncentivePoolPointData>
|
|
462
458
|
),
|
|
463
459
|
};
|
|
464
460
|
};
|
|
@@ -585,6 +581,7 @@ export const parseOriginBorrowIncentiveAccountPoolPointData = (
|
|
|
585
581
|
* @return Parsed borrow incentive account data
|
|
586
582
|
*/
|
|
587
583
|
export const parseOriginBorrowIncentiveAccountData = (
|
|
584
|
+
utils: ScallopUtils,
|
|
588
585
|
originBorrowIncentiveAccountData: OriginBorrowIncentiveAccountData
|
|
589
586
|
): ParsedBorrowIncentiveAccountData => {
|
|
590
587
|
return {
|
|
@@ -595,16 +592,11 @@ export const parseOriginBorrowIncentiveAccountData = (
|
|
|
595
592
|
pointList: originBorrowIncentiveAccountData.points_list.reduce(
|
|
596
593
|
(acc, point) => {
|
|
597
594
|
const parsed = parseOriginBorrowIncentiveAccountPoolPointData(point);
|
|
598
|
-
const name =
|
|
599
|
-
parsed.pointType
|
|
600
|
-
).name.toLowerCase() as SupportBorrowIncentiveRewardCoins;
|
|
595
|
+
const name = utils.parseCoinNameFromType(parsed.pointType);
|
|
601
596
|
acc[name] = parsed;
|
|
602
597
|
return acc;
|
|
603
598
|
},
|
|
604
|
-
{} as Record<
|
|
605
|
-
SupportBorrowIncentiveRewardCoins,
|
|
606
|
-
ParsedBorrowIncentiveAccountPoolData
|
|
607
|
-
>
|
|
599
|
+
{} as Record<string, ParsedBorrowIncentiveAccountPoolData>
|
|
608
600
|
),
|
|
609
601
|
};
|
|
610
602
|
};
|
package/src/utils/util.ts
CHANGED
|
@@ -1,85 +1,6 @@
|
|
|
1
1
|
import type { PriceFeed } from '@pythnetwork/pyth-sui-js';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
SUPPORT_COLLATERALS,
|
|
5
|
-
SUPPORT_SPOOLS_REWARDS,
|
|
6
|
-
MAX_LOCK_DURATION,
|
|
7
|
-
SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
8
|
-
SUPPORT_SCOIN,
|
|
9
|
-
SUPPORT_SUI_BRIDGE,
|
|
10
|
-
SUPPORT_WORMHOLE,
|
|
11
|
-
} from '../constants';
|
|
12
|
-
import type { ScallopAddress } from '../models';
|
|
13
|
-
import type {
|
|
14
|
-
SupportAssetCoins,
|
|
15
|
-
SupportCoins,
|
|
16
|
-
SupportMarketCoins,
|
|
17
|
-
SupportSCoin,
|
|
18
|
-
SupportSuiBridgeCoins,
|
|
19
|
-
SupportWormholeCoins,
|
|
20
|
-
} from '../types';
|
|
21
|
-
|
|
22
|
-
const COIN_SET = Array.from(
|
|
23
|
-
new Set([
|
|
24
|
-
...SUPPORT_POOLS,
|
|
25
|
-
...SUPPORT_COLLATERALS,
|
|
26
|
-
...SUPPORT_SPOOLS_REWARDS,
|
|
27
|
-
...SUPPORT_BORROW_INCENTIVE_REWARDS,
|
|
28
|
-
...SUPPORT_SCOIN,
|
|
29
|
-
])
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
export const isMarketCoin = (
|
|
33
|
-
coinName: SupportCoins
|
|
34
|
-
): coinName is SupportMarketCoins | SupportSCoin => {
|
|
35
|
-
const assetCoinName = coinName.slice(1).toLowerCase() as SupportAssetCoins;
|
|
36
|
-
return (
|
|
37
|
-
coinName.charAt(0).toLowerCase() === 's' && COIN_SET.includes(assetCoinName)
|
|
38
|
-
);
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export const isSuiBridgeAsset = (
|
|
42
|
-
coinName: any
|
|
43
|
-
): coinName is SupportSuiBridgeCoins => {
|
|
44
|
-
return SUPPORT_SUI_BRIDGE.includes(coinName);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export const isWormholeAsset = (
|
|
48
|
-
coinName: any
|
|
49
|
-
): coinName is SupportWormholeCoins => {
|
|
50
|
-
return SUPPORT_WORMHOLE.includes(coinName);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const parseAssetSymbol = (coinName: SupportCoins): string => {
|
|
54
|
-
if (isWormholeAsset(coinName)) {
|
|
55
|
-
return `w${coinName.slice(1).toUpperCase()}`;
|
|
56
|
-
}
|
|
57
|
-
if (isSuiBridgeAsset(coinName)) {
|
|
58
|
-
switch (coinName) {
|
|
59
|
-
case 'sbwbtc':
|
|
60
|
-
return 'sbwBTC';
|
|
61
|
-
default: {
|
|
62
|
-
return `sb${coinName.slice(2).toUpperCase()}`;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (isMarketCoin(coinName)) {
|
|
67
|
-
const assetCoinName = coinName.slice(1).toLowerCase() as SupportAssetCoins;
|
|
68
|
-
return coinName.slice(0, 1).toLowerCase() + parseAssetSymbol(assetCoinName);
|
|
69
|
-
}
|
|
70
|
-
switch (coinName) {
|
|
71
|
-
case 'afsui':
|
|
72
|
-
return 'afSUI';
|
|
73
|
-
case 'hasui':
|
|
74
|
-
return 'haSUI';
|
|
75
|
-
case 'vsui':
|
|
76
|
-
return 'vSUI';
|
|
77
|
-
case 'musd':
|
|
78
|
-
return 'mUSD';
|
|
79
|
-
default:
|
|
80
|
-
return coinName.toUpperCase();
|
|
81
|
-
}
|
|
82
|
-
};
|
|
2
|
+
import { MAX_LOCK_DURATION } from 'src/constants';
|
|
3
|
+
import { ScallopConstants } from 'src/models/scallopConstants';
|
|
83
4
|
|
|
84
5
|
/**
|
|
85
6
|
* Parse price from pyth price feed.
|
|
@@ -90,12 +11,13 @@ export const parseAssetSymbol = (coinName: SupportCoins): string => {
|
|
|
90
11
|
*/
|
|
91
12
|
export const parseDataFromPythPriceFeed = (
|
|
92
13
|
feed: PriceFeed,
|
|
93
|
-
|
|
14
|
+
constants: ScallopConstants
|
|
94
15
|
) => {
|
|
95
|
-
const assetCoinNames =
|
|
16
|
+
const assetCoinNames = [...constants.whitelist.lending] as string[];
|
|
96
17
|
const assetCoinName = assetCoinNames.find((assetCoinName) => {
|
|
97
18
|
return (
|
|
98
|
-
address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`) ===
|
|
19
|
+
constants.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`) ===
|
|
20
|
+
feed.id
|
|
99
21
|
);
|
|
100
22
|
});
|
|
101
23
|
if (assetCoinName) {
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { SupportPoolCoins } from 'src/types/constant/common';
|
|
2
|
-
|
|
3
|
-
export const COIN_GECKGO_IDS: Record<SupportPoolCoins, string> = {
|
|
4
|
-
// Sui Bridge
|
|
5
|
-
sbeth: 'ethereum',
|
|
6
|
-
sbusdt: 'tether',
|
|
7
|
-
sbwbtc: 'bitcoin',
|
|
8
|
-
// Wormhole
|
|
9
|
-
weth: 'ethereum',
|
|
10
|
-
wbtc: 'bitcoin',
|
|
11
|
-
wusdc: 'usdc',
|
|
12
|
-
wusdt: 'tether',
|
|
13
|
-
wapt: 'aptos',
|
|
14
|
-
wsol: 'solana',
|
|
15
|
-
// Sui Native
|
|
16
|
-
usdc: 'usdc',
|
|
17
|
-
// Sui LST
|
|
18
|
-
sui: 'sui',
|
|
19
|
-
afsui: 'sui',
|
|
20
|
-
hasui: 'sui',
|
|
21
|
-
vsui: 'sui',
|
|
22
|
-
// Stable
|
|
23
|
-
fdusd: 'first-digital-usd',
|
|
24
|
-
// DeFi
|
|
25
|
-
cetus: 'cetus-protocol',
|
|
26
|
-
sca: 'scallop-2',
|
|
27
|
-
deep: 'deepbook',
|
|
28
|
-
// Isolated Asset
|
|
29
|
-
fud: 'fud-the-pug',
|
|
30
|
-
blub: 'blub',
|
|
31
|
-
musd: 'meta-usd',
|
|
32
|
-
ns: 'suins-token',
|
|
33
|
-
usdy: 'ondo-us-dollar-yield',
|
|
34
|
-
};
|