@scallop-io/sui-scallop-sdk 1.3.4-alpha.6 → 1.3.4-isolated-asset.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/builders/borrowIncentiveBuilder.d.ts +12 -0
- package/dist/builders/coreBuilder.d.ts +12 -0
- package/dist/builders/index.d.ts +12 -0
- package/dist/builders/loyaltyProgramBuilder.d.ts +12 -0
- package/dist/builders/oracle.d.ts +14 -0
- package/dist/builders/referralBuilder.d.ts +12 -0
- package/dist/builders/sCoinBuilder.d.ts +4 -0
- package/dist/builders/spoolBuilder.d.ts +12 -0
- package/dist/builders/vescaBuilder.d.ts +25 -0
- package/dist/constants/cache.d.ts +14 -0
- package/dist/constants/coinGecko.d.ts +2 -0
- package/dist/constants/common.d.ts +20 -0
- package/dist/constants/enum.d.ts +14 -0
- package/dist/constants/flashloan.d.ts +2 -0
- package/dist/constants/index.d.ts +13 -0
- package/dist/constants/poolAddress.d.ts +5 -0
- package/dist/constants/pyth.d.ts +5 -0
- package/dist/constants/queryKeys.d.ts +56 -0
- package/dist/constants/rpc.d.ts +1 -0
- package/dist/constants/testAddress.d.ts +2 -0
- package/dist/constants/tokenBucket.d.ts +2 -0
- package/dist/constants/vesca.d.ts +5 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +438 -331
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +438 -331
- package/dist/index.mjs.map +1 -1
- package/dist/models/index.d.ts +8 -0
- package/dist/models/scallop.d.ts +74 -0
- package/dist/models/scallopAddress.d.ts +150 -0
- package/dist/models/scallopBuilder.d.ts +89 -0
- package/dist/models/scallopCache.d.ts +74 -0
- package/dist/models/scallopClient.d.ts +321 -0
- package/dist/models/scallopIndexer.d.ts +89 -0
- package/dist/models/scallopQuery.d.ts +497 -0
- package/dist/models/scallopUtils.d.ts +227 -0
- package/dist/models/suiKit.d.ts +2 -0
- package/dist/queries/borrowIncentiveQuery.d.ts +61 -0
- package/dist/queries/borrowLimitQuery.d.ts +9 -0
- package/dist/queries/coreQuery.d.ts +169 -0
- package/dist/queries/index.d.ts +12 -0
- package/dist/queries/isolatedAssetQuery.d.ts +14 -0
- package/dist/queries/loyaltyProgramQuery.d.ts +10 -0
- package/dist/queries/portfolioQuery.d.ts +75 -0
- package/dist/queries/priceQuery.d.ts +16 -0
- package/dist/queries/referralQuery.d.ts +7 -0
- package/dist/queries/sCoinQuery.d.ts +41 -0
- package/dist/queries/spoolQuery.d.ts +70 -0
- package/dist/queries/supplyLimitQuery.d.ts +9 -0
- package/dist/queries/vescaQuery.d.ts +36 -0
- package/dist/types/address.d.ts +107 -0
- package/dist/types/builder/borrowIncentive.d.ts +35 -0
- package/dist/types/builder/core.d.ts +56 -0
- package/dist/types/builder/index.d.ts +24 -0
- package/dist/types/builder/loyaltyProgram.d.ts +23 -0
- package/dist/types/builder/referral.d.ts +30 -0
- package/dist/types/builder/sCoin.d.ts +37 -0
- package/dist/types/builder/spool.d.ts +29 -0
- package/dist/types/builder/vesca.d.ts +51 -0
- package/dist/types/constant/common.d.ts +24 -0
- package/dist/types/constant/enum.d.ts +48 -0
- package/dist/types/constant/index.d.ts +2 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/model.d.ts +54 -0
- package/dist/types/query/borrowIncentive.d.ts +124 -0
- package/dist/types/query/core.d.ts +363 -0
- package/dist/types/query/index.d.ts +7 -0
- package/dist/types/query/loyaltyProgram.d.ts +5 -0
- package/dist/types/query/portfolio.d.ts +115 -0
- package/dist/types/query/sCoin.d.ts +1 -0
- package/dist/types/query/spool.d.ts +122 -0
- package/dist/types/query/vesca.d.ts +26 -0
- package/dist/types/utils.d.ts +21 -0
- package/dist/utils/builder.d.ts +15 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/indexer.d.ts +17 -0
- package/dist/utils/query.d.ts +62 -0
- package/dist/utils/tokenBucket.d.ts +11 -0
- package/dist/utils/util.d.ts +26 -0
- package/package.json +2 -2
- package/src/constants/coinGecko.ts +4 -2
- package/src/constants/common.ts +2 -0
- package/src/constants/enum.ts +25 -4
- package/src/constants/index.ts +1 -0
- package/src/constants/poolAddress.ts +7 -1
- package/src/constants/pyth.ts +2 -0
- package/src/constants/testAddress.ts +76 -35
- package/src/models/scallopBuilder.ts +2 -3
- package/src/models/scallopQuery.ts +26 -18
- package/src/models/scallopUtils.ts +5 -6
- package/src/queries/borrowLimitQuery.ts +53 -0
- package/src/queries/coreQuery.ts +238 -229
- package/src/queries/index.ts +1 -0
- package/src/queries/isolatedAssetQuery.ts +5 -5
- package/src/queries/referralQuery.ts +0 -1
- package/src/queries/spoolQuery.ts +1 -1
- package/src/queries/supplyLimitQuery.ts +23 -18
- package/src/types/query/core.ts +2 -0
- package/src/types/utils.ts +1 -1
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { SupportStakeMarketCoins } from '../constant';
|
|
2
|
+
type OptionalKeys<T> = {
|
|
3
|
+
[K in keyof T]?: T[K];
|
|
4
|
+
};
|
|
5
|
+
export type Spools = OptionalKeys<Record<SupportStakeMarketCoins, Spool>>;
|
|
6
|
+
export type Spool = {
|
|
7
|
+
marketCoinName: SupportStakeMarketCoins;
|
|
8
|
+
symbol: string;
|
|
9
|
+
coinType: string;
|
|
10
|
+
marketCoinType: string;
|
|
11
|
+
rewardCoinType: string;
|
|
12
|
+
sCoinType: string;
|
|
13
|
+
coinDecimal: number;
|
|
14
|
+
rewardCoinDecimal: number;
|
|
15
|
+
coinPrice: number;
|
|
16
|
+
marketCoinPrice: number;
|
|
17
|
+
rewardCoinPrice: number;
|
|
18
|
+
} & Required<Pick<ParsedSpoolData, 'maxPoint' | 'distributedPoint' | 'maxStake'>> & CalculatedSpoolData & SpoolRewardPool;
|
|
19
|
+
export type OriginSpoolData = {
|
|
20
|
+
stakeType: {
|
|
21
|
+
fields: {
|
|
22
|
+
name: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
maxDistributedPoint: string;
|
|
26
|
+
distributedPoint: string;
|
|
27
|
+
distributedPointPerPeriod: string;
|
|
28
|
+
pointDistributionTime: string;
|
|
29
|
+
maxStake: string;
|
|
30
|
+
stakes: string;
|
|
31
|
+
index: string;
|
|
32
|
+
createdAt: string;
|
|
33
|
+
lastUpdate: string;
|
|
34
|
+
};
|
|
35
|
+
export type ParsedSpoolData = {
|
|
36
|
+
stakeType: string;
|
|
37
|
+
maxPoint: number;
|
|
38
|
+
distributedPoint: number;
|
|
39
|
+
pointPerPeriod: number;
|
|
40
|
+
period: number;
|
|
41
|
+
maxStake: number;
|
|
42
|
+
staked: number;
|
|
43
|
+
index: number;
|
|
44
|
+
createdAt: number;
|
|
45
|
+
lastUpdate: number;
|
|
46
|
+
};
|
|
47
|
+
export type CalculatedSpoolData = {
|
|
48
|
+
stakedAmount: number;
|
|
49
|
+
stakedCoin: number;
|
|
50
|
+
stakedValue: number;
|
|
51
|
+
distributedPointPerSec: number;
|
|
52
|
+
accumulatedPoints: number;
|
|
53
|
+
currentPointIndex: number;
|
|
54
|
+
currentTotalDistributedPoint: number;
|
|
55
|
+
startDate: Date;
|
|
56
|
+
endDate: Date;
|
|
57
|
+
};
|
|
58
|
+
export type SpoolRewardPool = Required<Pick<ParsedSpoolRewardPoolData, 'exchangeRateNumerator' | 'exchangeRateDenominator'>> & CalculatedSpoolRewardPoolData;
|
|
59
|
+
export type OriginSpoolRewardPoolData = {
|
|
60
|
+
claimed_rewards: string;
|
|
61
|
+
exchange_rate_denominator: string;
|
|
62
|
+
exchange_rate_numerator: string;
|
|
63
|
+
rewards: string;
|
|
64
|
+
spool_id: string;
|
|
65
|
+
};
|
|
66
|
+
export type ParsedSpoolRewardPoolData = {
|
|
67
|
+
claimedRewards: number;
|
|
68
|
+
exchangeRateDenominator: number;
|
|
69
|
+
exchangeRateNumerator: number;
|
|
70
|
+
rewards: number;
|
|
71
|
+
spoolId: string;
|
|
72
|
+
};
|
|
73
|
+
export type CalculatedSpoolRewardPoolData = {
|
|
74
|
+
rewardApr: number;
|
|
75
|
+
totalRewardAmount: number;
|
|
76
|
+
totalRewardCoin: number;
|
|
77
|
+
totalRewardValue: number;
|
|
78
|
+
remaindRewardAmount: number;
|
|
79
|
+
remaindRewardCoin: number;
|
|
80
|
+
remaindRewardValue: number;
|
|
81
|
+
claimedRewardAmount: number;
|
|
82
|
+
claimedRewardCoin: number;
|
|
83
|
+
claimedRewardValue: number;
|
|
84
|
+
rewardPerSec: number;
|
|
85
|
+
};
|
|
86
|
+
export type StakePools = OptionalKeys<Record<SupportStakeMarketCoins, StakePool>>;
|
|
87
|
+
export type StakeRewardPools = OptionalKeys<Record<SupportStakeMarketCoins, StakeRewardPool>>;
|
|
88
|
+
export type StakeAccounts = Record<SupportStakeMarketCoins, StakeAccount[]>;
|
|
89
|
+
export interface StakeAccount {
|
|
90
|
+
id: string;
|
|
91
|
+
type: string;
|
|
92
|
+
stakePoolId: string;
|
|
93
|
+
stakeType: string;
|
|
94
|
+
staked: number;
|
|
95
|
+
index: number;
|
|
96
|
+
points: number;
|
|
97
|
+
totalPoints: number;
|
|
98
|
+
}
|
|
99
|
+
export interface StakePool {
|
|
100
|
+
id: string;
|
|
101
|
+
type: string;
|
|
102
|
+
maxPoint: number;
|
|
103
|
+
distributedPoint: number;
|
|
104
|
+
pointPerPeriod: number;
|
|
105
|
+
period: number;
|
|
106
|
+
maxStake: number;
|
|
107
|
+
stakeType: string;
|
|
108
|
+
totalStaked: number;
|
|
109
|
+
index: number;
|
|
110
|
+
createdAt: number;
|
|
111
|
+
lastUpdate: number;
|
|
112
|
+
}
|
|
113
|
+
export interface StakeRewardPool {
|
|
114
|
+
id: string;
|
|
115
|
+
type: string;
|
|
116
|
+
stakePoolId: string;
|
|
117
|
+
ratioDenominator: number;
|
|
118
|
+
ratioNumerator: number;
|
|
119
|
+
rewards: number;
|
|
120
|
+
claimedRewards: number;
|
|
121
|
+
}
|
|
122
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SuiObjectRef } from '@mysten/sui/client';
|
|
2
|
+
export type Vesca = {
|
|
3
|
+
id: string;
|
|
4
|
+
keyId: string;
|
|
5
|
+
keyObject?: SuiObjectRef;
|
|
6
|
+
object: SuiObjectRef;
|
|
7
|
+
lockedScaAmount: string;
|
|
8
|
+
lockedScaCoin: number;
|
|
9
|
+
currentVeScaBalance: number;
|
|
10
|
+
unlockAt: number;
|
|
11
|
+
};
|
|
12
|
+
export type VeScaTreasuryFields = {
|
|
13
|
+
total_ve_sca_amount: string;
|
|
14
|
+
sca_balance: string;
|
|
15
|
+
unlock_schedule: {
|
|
16
|
+
fields: {
|
|
17
|
+
locked_sca_amount: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type VeScaTreasuryInfo = {
|
|
22
|
+
totalLockedSca: number;
|
|
23
|
+
totalVeSca: number;
|
|
24
|
+
averageLockingPeriod: number;
|
|
25
|
+
averageLockingPeriodUnit: string;
|
|
26
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { SupportAssetCoins } from './constant';
|
|
2
|
+
export type OptionalKeys<T> = {
|
|
3
|
+
[K in keyof T]?: T[K];
|
|
4
|
+
};
|
|
5
|
+
export type CoinPrices = OptionalKeys<Record<SupportAssetCoins, number>>;
|
|
6
|
+
export type PriceMap = Map<SupportAssetCoins, {
|
|
7
|
+
price: number;
|
|
8
|
+
publishTime: number;
|
|
9
|
+
}>;
|
|
10
|
+
export type PoolAddressInfo = {
|
|
11
|
+
name: string;
|
|
12
|
+
coingeckoId: string;
|
|
13
|
+
decimal: number;
|
|
14
|
+
pythFeedId: string;
|
|
15
|
+
lendingPoolAddress: string;
|
|
16
|
+
collateralPoolAddress?: string;
|
|
17
|
+
sCoinAddress: string | undefined;
|
|
18
|
+
marketCoinAddress: string;
|
|
19
|
+
coinAddress: string;
|
|
20
|
+
sCoinName: string | undefined;
|
|
21
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
+
import type { SuiObjectArg } from '@scallop-io/sui-kit';
|
|
3
|
+
/**
|
|
4
|
+
* Check and get the sender from the transaction block.
|
|
5
|
+
*
|
|
6
|
+
* @param txBlock - TxBlock created by SuiKit.
|
|
7
|
+
* @return Sender of transaction.
|
|
8
|
+
*/
|
|
9
|
+
export declare const requireSender: (txBlock: SuiKitTxBlock) => string;
|
|
10
|
+
export declare const checkVesca: (prevUnlockAtInMillisTimestamp?: number) => void;
|
|
11
|
+
export declare const checkVescaExpired: (prevUnlockAtInMillisTimestamp: number) => void;
|
|
12
|
+
export declare const checkExtendLockPeriod: (lockPeriodInDays: number, newUnlockAtInSecondTimestamp: number, prevUnlockAtInMillisTimestamp?: number) => void;
|
|
13
|
+
export declare const checkLockSca: (scaAmountOrCoin: number | SuiObjectArg | undefined, lockPeriodInDays?: number, newUnlockAtInSecondTimestamp?: number, prevUnlockAtInMillisTimestamp?: number) => void;
|
|
14
|
+
export declare const checkExtendLockAmount: (scaAmount: number, prevUnlockAtInMillisTimestamp?: number) => void;
|
|
15
|
+
export declare const checkRenewExpiredVeSca: (scaAmount: number, lockPeriodInDays: number, prevUnlockAtInMillisTimestamp?: number) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generic wrapper for methods with indexer fallback.
|
|
3
|
+
*
|
|
4
|
+
* @param method - The method to call with fallback behavior.
|
|
5
|
+
* @param context - The context (`this`) of the class instance.
|
|
6
|
+
* @param args - The arguments to pass to the method.
|
|
7
|
+
* @returns The result of the method call.
|
|
8
|
+
*/
|
|
9
|
+
export declare function callMethodWithIndexerFallback(method: Function, context: any, ...args: any[]): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* This function creates a wrapper for methods that have an indexer parameter.
|
|
12
|
+
* It ensures fallback behavior if indexer fails.
|
|
13
|
+
*
|
|
14
|
+
* @param method - The method to wrap.
|
|
15
|
+
* @returns A function that applies indexer fallback.
|
|
16
|
+
*/
|
|
17
|
+
export declare function withIndexerFallback(method: Function): (...args: any[]) => Promise<any>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import type { ScallopUtils } from '../models';
|
|
3
|
+
import type { OriginMarketPoolData, ParsedMarketPoolData, CalculatedMarketPoolData, OriginMarketCollateralData, ParsedMarketCollateralData, CalculatedMarketCollateralData, OriginSpoolData, ParsedSpoolData, CalculatedSpoolData, OriginSpoolRewardPoolData, ParsedSpoolRewardPoolData, CalculatedSpoolRewardPoolData, OriginBorrowIncentivePoolData, ParsedBorrowIncentivePoolData, OriginBorrowIncentiveAccountData, ParsedBorrowIncentiveAccountData, OriginBorrowIncentivePoolPointData, ParsedBorrowIncentivePoolPointData, CalculatedBorrowIncentivePoolPointData, OriginBorrowIncentiveAccountPoolData, ParsedBorrowIncentiveAccountPoolData } from '../types';
|
|
4
|
+
/**
|
|
5
|
+
* Parse origin market pool data to a more readable format.
|
|
6
|
+
*
|
|
7
|
+
* @param originMarketPoolData - Origin market pool data
|
|
8
|
+
* @return Parsed market pool data
|
|
9
|
+
*/
|
|
10
|
+
export declare const parseOriginMarketPoolData: (originMarketPoolData: OriginMarketPoolData) => ParsedMarketPoolData;
|
|
11
|
+
export declare const calculateMarketPoolData: (utils: ScallopUtils, parsedMarketPoolData: ParsedMarketPoolData) => CalculatedMarketPoolData;
|
|
12
|
+
/**
|
|
13
|
+
* Parse origin market collateral data to a more readable format.
|
|
14
|
+
*
|
|
15
|
+
* @param originMarketCollateralData - Origin market collateral data
|
|
16
|
+
* @return Parsed market collateral data
|
|
17
|
+
*/
|
|
18
|
+
export declare const parseOriginMarketCollateralData: (originMarketCollateralData: OriginMarketCollateralData) => ParsedMarketCollateralData;
|
|
19
|
+
export declare const calculateMarketCollateralData: (utils: ScallopUtils, parsedMarketCollateralData: ParsedMarketCollateralData) => CalculatedMarketCollateralData;
|
|
20
|
+
/**
|
|
21
|
+
* Parse origin spool data to a more readable format.
|
|
22
|
+
*
|
|
23
|
+
* @param originSpoolData - Origin spool data
|
|
24
|
+
* @return Parsed spool data
|
|
25
|
+
*/
|
|
26
|
+
export declare const parseOriginSpoolData: (originSpoolData: OriginSpoolData) => ParsedSpoolData;
|
|
27
|
+
export declare const calculateSpoolData: (parsedSpoolData: ParsedSpoolData, stakeMarketCoinPrice: number, stakeMarketCoinDecimal: number) => CalculatedSpoolData;
|
|
28
|
+
/**
|
|
29
|
+
* Parse origin spool reward pool data to a more readable format.
|
|
30
|
+
*
|
|
31
|
+
* @param originRewardPoolData - Origin reward pool data
|
|
32
|
+
* @return Parsed spool reward pool data
|
|
33
|
+
*/
|
|
34
|
+
export declare const parseOriginSpoolRewardPoolData: (originSpoolRewardPoolData: OriginSpoolRewardPoolData) => ParsedSpoolRewardPoolData;
|
|
35
|
+
export declare const calculateSpoolRewardPoolData: (parsedSpoolData: ParsedSpoolData, parsedSpoolRewardPoolData: ParsedSpoolRewardPoolData, calculatedSpoolData: CalculatedSpoolData, rewardCoinPrice: number, rewardCoinDecimal: number) => CalculatedSpoolRewardPoolData;
|
|
36
|
+
export declare const parseOriginBorrowIncentivesPoolPointData: (originBorrowIncentivePoolPointData: OriginBorrowIncentivePoolPointData) => ParsedBorrowIncentivePoolPointData;
|
|
37
|
+
/**
|
|
38
|
+
* Parse origin borrow incentive pool data to a more readable format.
|
|
39
|
+
*
|
|
40
|
+
* @param originBorrowIncentivePoolData - Origin borrow incentive pool data
|
|
41
|
+
* @return Parsed borrow incentive pool data
|
|
42
|
+
*/
|
|
43
|
+
export declare const parseOriginBorrowIncentivePoolData: (originBorrowIncentivePoolData: OriginBorrowIncentivePoolData) => ParsedBorrowIncentivePoolData;
|
|
44
|
+
export declare const calculateBorrowIncentivePoolPointData: (parsedBorrowIncentivePoolPointData: ParsedBorrowIncentivePoolPointData, rewardCoinPrice: number, rewardCoinDecimal: number, poolCoinPrice: number, poolCoinDecimal: number) => CalculatedBorrowIncentivePoolPointData;
|
|
45
|
+
export declare const parseOriginBorrowIncentiveAccountPoolPointData: (originBorrowIncentiveAccountPoolPointData: OriginBorrowIncentiveAccountPoolData) => ParsedBorrowIncentiveAccountPoolData;
|
|
46
|
+
/**
|
|
47
|
+
* Parse origin borrow incentive account data to a more readable format.
|
|
48
|
+
*
|
|
49
|
+
* @param originBorrowIncentiveAccountData - Origin borrow incentive account data
|
|
50
|
+
* @return Parsed borrow incentive account data
|
|
51
|
+
*/
|
|
52
|
+
export declare const parseOriginBorrowIncentiveAccountData: (originBorrowIncentiveAccountData: OriginBorrowIncentiveAccountData) => ParsedBorrowIncentiveAccountData;
|
|
53
|
+
export declare const minBigNumber: (...args: BigNumber.Value[]) => BigNumber;
|
|
54
|
+
export declare const maxBigNumber: (...args: BigNumber.Value[]) => BigNumber;
|
|
55
|
+
/**
|
|
56
|
+
* Dynamically adjust the decrease or increase ratio according to the amount
|
|
57
|
+
* @param amount - The amount required to calculate factor.
|
|
58
|
+
* @param scaleStep - The scale step required to determine the factor..
|
|
59
|
+
* @param type - The type of the calculation.
|
|
60
|
+
* @return The estimated factor
|
|
61
|
+
* */
|
|
62
|
+
export declare const estimatedFactor: (amount: number, scaleStep: number, type: "increase" | "decrease") => number;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare class TokenBucket {
|
|
2
|
+
private tokensPerInterval;
|
|
3
|
+
private interval;
|
|
4
|
+
private tokens;
|
|
5
|
+
private lastRefill;
|
|
6
|
+
constructor(tokensPerInterval: number, intervalInMs: number);
|
|
7
|
+
refill(): void;
|
|
8
|
+
removeTokens(count: number): boolean;
|
|
9
|
+
}
|
|
10
|
+
declare const callWithRateLimit: <T>(tokenBucket: TokenBucket, fn: () => Promise<T>, retryDelayInMs?: number, maxRetries?: number, backoffFactor?: number) => Promise<T | null>;
|
|
11
|
+
export { TokenBucket, callWithRateLimit };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { PriceFeed } from '@pythnetwork/pyth-sui-js';
|
|
2
|
+
import type { ScallopAddress } from '../models';
|
|
3
|
+
import type { SupportAssetCoins, SupportCoins, SupportMarketCoins, SupportSCoin, SupportSuiBridgeCoins, SupportWormholeCoins } from '../types';
|
|
4
|
+
export declare const isMarketCoin: (coinName: SupportCoins) => coinName is SupportMarketCoins | SupportSCoin;
|
|
5
|
+
export declare const isSuiBridgeAsset: (coinName: any) => coinName is SupportSuiBridgeCoins;
|
|
6
|
+
export declare const isWormholeAsset: (coinName: any) => coinName is SupportWormholeCoins;
|
|
7
|
+
export declare const parseAssetSymbol: (coinName: SupportCoins) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Parse price from pyth price feed.
|
|
10
|
+
*
|
|
11
|
+
* @param feed - Price feed object from pyth.
|
|
12
|
+
* @param address - Scallop address instance.
|
|
13
|
+
* @return Price Data inclue coin name, price, and publish time.
|
|
14
|
+
*/
|
|
15
|
+
export declare const parseDataFromPythPriceFeed: (feed: PriceFeed, address: ScallopAddress) => {
|
|
16
|
+
coinName: SupportAssetCoins;
|
|
17
|
+
price: number;
|
|
18
|
+
publishTime: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Find the closest unlock round timestamp (12AM) to the given unlock at timestamp in seconds.
|
|
22
|
+
*
|
|
23
|
+
* @param unlockAtInSecondTimestamp - Unlock at in seconds timestamp to find the closest round.
|
|
24
|
+
* @returns Closest round (12AM) in seconds timestamp.
|
|
25
|
+
*/
|
|
26
|
+
export declare const findClosestUnlockRound: (unlockAtInSecondTimestamp: number) => number;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scallop-io/sui-scallop-sdk",
|
|
3
|
-
"version": "1.3.4-
|
|
3
|
+
"version": "1.3.4-isolated-asset.2",
|
|
4
4
|
"description": "Typescript sdk for interacting with Scallop contract on SUI",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sui",
|
|
@@ -149,7 +149,7 @@
|
|
|
149
149
|
"scripts": {
|
|
150
150
|
"clean": "rm -rf tsconfig.tsbuildinfo ./dist",
|
|
151
151
|
"build": "pnpm run build:types && pnpm run build:tsup",
|
|
152
|
-
"build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap
|
|
152
|
+
"build:tsup": "tsup ./src/index.ts --format esm,cjs --sourcemap",
|
|
153
153
|
"build:types": "tsc --build",
|
|
154
154
|
"watch:tsup": "tsup ./src/index.ts --format esm,cjs --clean --splitting --watch",
|
|
155
155
|
"watch:types": "tsc --watch",
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { SupportPoolCoins } from 'src/types/constant/common';
|
|
2
2
|
|
|
3
3
|
export const COIN_GECKGO_IDS: Record<SupportPoolCoins, string> = {
|
|
4
|
-
usdc: 'usdc
|
|
4
|
+
usdc: 'usdc',
|
|
5
5
|
sbeth: 'ethereum',
|
|
6
6
|
weth: 'ethereum',
|
|
7
7
|
wbtc: 'bitcoin',
|
|
8
|
-
wusdc: 'usdc
|
|
8
|
+
wusdc: 'usdc',
|
|
9
9
|
wusdt: 'tether',
|
|
10
10
|
sui: 'sui',
|
|
11
11
|
wapt: 'aptos',
|
|
@@ -15,4 +15,6 @@ export const COIN_GECKGO_IDS: Record<SupportPoolCoins, string> = {
|
|
|
15
15
|
hasui: 'sui',
|
|
16
16
|
vsui: 'sui',
|
|
17
17
|
sca: 'scallop-2',
|
|
18
|
+
deep: 'deepbook',
|
|
19
|
+
fud: 'fud-the-pug',
|
|
18
20
|
};
|
package/src/constants/common.ts
CHANGED
package/src/constants/enum.ts
CHANGED
|
@@ -16,6 +16,8 @@ export const coinDecimals: types.SupportCoinDecimals = {
|
|
|
16
16
|
hasui: 9,
|
|
17
17
|
vsui: 9,
|
|
18
18
|
sca: 9,
|
|
19
|
+
deep: 6,
|
|
20
|
+
fud: 5,
|
|
19
21
|
susdc: 6,
|
|
20
22
|
sweth: 8,
|
|
21
23
|
ssbeth: 8,
|
|
@@ -30,6 +32,8 @@ export const coinDecimals: types.SupportCoinDecimals = {
|
|
|
30
32
|
shasui: 9,
|
|
31
33
|
svsui: 9,
|
|
32
34
|
ssca: 9,
|
|
35
|
+
sdeep: 6,
|
|
36
|
+
sfud: 5,
|
|
33
37
|
};
|
|
34
38
|
|
|
35
39
|
export const assetCoins: types.AssetCoins = {
|
|
@@ -47,6 +51,8 @@ export const assetCoins: types.AssetCoins = {
|
|
|
47
51
|
hasui: 'hasui',
|
|
48
52
|
vsui: 'vsui',
|
|
49
53
|
sca: 'sca',
|
|
54
|
+
deep: 'deep',
|
|
55
|
+
fud: 'fud',
|
|
50
56
|
};
|
|
51
57
|
|
|
52
58
|
export const marketCoins: types.MarketCoins = {
|
|
@@ -64,6 +70,8 @@ export const marketCoins: types.MarketCoins = {
|
|
|
64
70
|
shasui: 'shasui',
|
|
65
71
|
svsui: 'svsui',
|
|
66
72
|
ssca: 'ssca',
|
|
73
|
+
sdeep: 'sdeep',
|
|
74
|
+
sfud: 'sfud',
|
|
67
75
|
};
|
|
68
76
|
|
|
69
77
|
export const sCoins: types.SCoins = {
|
|
@@ -140,6 +148,9 @@ export const coinIds: types.AssetCoinIds = {
|
|
|
140
148
|
sca: IS_VE_SCA_TEST
|
|
141
149
|
? '0x6cd813061a3adf3602b76545f076205f0c8e7ec1d3b1eab9a1da7992c18c0524'
|
|
142
150
|
: '0x7016aae72cfc67f2fadf55769c0a7dd54291a583b63051a5ed71081cce836ac6',
|
|
151
|
+
// isolated assets
|
|
152
|
+
deep: '0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP',
|
|
153
|
+
fud: '0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD',
|
|
143
154
|
};
|
|
144
155
|
|
|
145
156
|
export const wormholeCoinIds: types.WormholeCoinIds = {
|
|
@@ -161,14 +172,24 @@ export const sCoinIds: types.SCoinIds = {
|
|
|
161
172
|
'0x854950aa624b1df59fe64e630b2ba7c550642e9342267a33061d59fb31582da5::scallop_usdc::SCALLOP_USDC',
|
|
162
173
|
ssbeth:
|
|
163
174
|
'0xb14f82d8506d139eacef109688d1b71e7236bcce9b2c0ad526abcd6aa5be7de0::scallop_sb_eth::SCALLOP_SB_ETH',
|
|
164
|
-
ssui:
|
|
175
|
+
ssui:
|
|
176
|
+
// TODO: use prod value
|
|
177
|
+
// '0xaafc4f740de0dd0dde642a31148fb94517087052f19afb0f7bed1dc41a50c77b::scallop_sui::SCALLOP_SUI',
|
|
178
|
+
'0xf569919046f19a0c40b519ecfbb6ca0319698cd5908716c29b62ef56541f298b::scallop_sui::SCALLOP_SUI',
|
|
165
179
|
scetus:
|
|
166
180
|
'0xea346ce428f91ab007210443efcea5f5cdbbb3aae7e9affc0ca93f9203c31f0c::scallop_cetus::SCALLOP_CETUS',
|
|
167
|
-
ssca:
|
|
181
|
+
ssca:
|
|
182
|
+
// TODO: use prod value
|
|
183
|
+
// '0x5ca17430c1d046fae9edeaa8fd76c7b4193a00d764a0ecfa9418d733ad27bc1e::scallop_sca::SCALLOP_SCA',
|
|
184
|
+
'0x958428555e778e55918a59eb1c92c77f32b5c554fa3a5e56cd0815086b5072e7::scallop_sca::SCALLOP_SCA',
|
|
168
185
|
swusdc:
|
|
169
|
-
|
|
186
|
+
// TODO: use prod value
|
|
187
|
+
// '0xad4d71551d31092230db1fd482008ea42867dbf27b286e9c70a79d2a6191d58d::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
188
|
+
'0xf5447c4305a486d8c8557559887c2c39449ddb5e748f15d33946d02a1663c158::scallop_wormhole_usdc::SCALLOP_WORMHOLE_USDC',
|
|
170
189
|
swusdt:
|
|
171
|
-
|
|
190
|
+
// TODO: use prod value
|
|
191
|
+
// '0xe6e5a012ec20a49a3d1d57bd2b67140b96cd4d3400b9d79e541f7bdbab661f95::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
192
|
+
'0xac781d9f73058ff5e69f9bf8dde32f2e8c71c66d7fe8497fc83b2d9182254b22::scallop_wormhole_usdt::SCALLOP_WORMHOLE_USDT',
|
|
172
193
|
sweth:
|
|
173
194
|
'0x67540ceb850d418679e69f1fb6b2093d6df78a2a699ffc733f7646096d552e9b::scallop_wormhole_eth::SCALLOP_WORMHOLE_ETH',
|
|
174
195
|
safsui:
|
package/src/constants/index.ts
CHANGED
|
@@ -4,7 +4,7 @@ export const POOL_ADDRESSES: Record<
|
|
|
4
4
|
SupportPoolCoins,
|
|
5
5
|
{
|
|
6
6
|
lendingPoolAddress: string;
|
|
7
|
-
collateralPoolAddress
|
|
7
|
+
collateralPoolAddress?: string;
|
|
8
8
|
}
|
|
9
9
|
> = {
|
|
10
10
|
usdc: {
|
|
@@ -91,4 +91,10 @@ export const POOL_ADDRESSES: Record<
|
|
|
91
91
|
collateralPoolAddress:
|
|
92
92
|
'0xff677a5d9e9dc8f08f0a8681ebfc7481d1c7d57bc441f2881974adcdd7b13c31',
|
|
93
93
|
},
|
|
94
|
+
fud: {
|
|
95
|
+
lendingPoolAddress: '',
|
|
96
|
+
},
|
|
97
|
+
deep: {
|
|
98
|
+
lendingPoolAddress: '',
|
|
99
|
+
},
|
|
94
100
|
};
|
package/src/constants/pyth.ts
CHANGED
|
@@ -22,4 +22,6 @@ export const PYTH_FEED_IDS: Record<SupportPoolCoins, string> = {
|
|
|
22
22
|
hasui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
|
|
23
23
|
vsui: '23d7315113f5b1d3ba7a83604c44b94d79f4fd69af77f804fc7f920a6dc65744',
|
|
24
24
|
sca: '7e17f0ac105abe9214deb9944c30264f5986bf292869c6bd8e8da3ccd92d79bc',
|
|
25
|
+
deep: '29bdd5248234e33bd93d3b81100b5fa32eaa5997843847e2c2cb16d7c6d9f7ff',
|
|
26
|
+
fud: '6a4090703da959247727f2b490eb21aea95c8684ecfac675f432008830890c75',
|
|
25
27
|
};
|