@scallop-io/sui-scallop-sdk 0.44.1 → 0.44.3
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/constants/common.d.ts +5 -3
- package/dist/constants/enum.d.ts +4 -2
- package/dist/index.js +843 -228
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +803 -192
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopClient.d.ts +33 -2
- package/dist/models/scallopQuery.d.ts +36 -10
- package/dist/models/scallopUtils.d.ts +12 -4
- package/dist/queries/borrowIncentiveQuery.d.ts +24 -0
- package/dist/queries/coreQuery.d.ts +12 -0
- package/dist/queries/index.d.ts +1 -0
- package/dist/queries/portfolioQuery.d.ts +1 -0
- package/dist/queries/spoolQuery.d.ts +13 -5
- package/dist/types/address.d.ts +10 -2
- package/dist/types/builder/borrowIncentive.d.ts +31 -0
- package/dist/types/builder/index.d.ts +3 -1
- package/dist/types/constant/common.d.ts +5 -3
- package/dist/types/constant/enum.d.ts +9 -3
- package/dist/types/query/borrowIncentive.d.ts +118 -0
- package/dist/types/query/core.d.ts +1 -0
- package/dist/types/query/index.d.ts +1 -0
- package/dist/types/query/spool.d.ts +12 -13
- package/dist/utils/builder.d.ts +8 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/query.d.ts +33 -10
- package/dist/utils/util.d.ts +15 -1
- package/package.json +12 -12
- package/src/builders/borrowIncentiveBuilder.ts +257 -0
- package/src/builders/coreBuilder.ts +1 -14
- package/src/builders/index.ts +9 -2
- package/src/builders/spoolBuilder.ts +3 -16
- package/src/constants/common.ts +6 -1
- package/src/constants/enum.ts +18 -2
- package/src/models/scallopAddress.ts +47 -0
- package/src/models/scallopClient.ts +104 -2
- package/src/models/scallopQuery.ts +48 -14
- package/src/models/scallopUtils.ts +53 -15
- package/src/queries/borrowIncentiveQuery.ts +166 -0
- package/src/queries/coreQuery.ts +57 -15
- package/src/queries/index.ts +1 -0
- package/src/queries/spoolQuery.ts +78 -62
- package/src/types/address.ts +10 -2
- package/src/types/builder/borrowIncentive.ts +67 -0
- package/src/types/builder/index.ts +5 -1
- package/src/types/builder/spool.ts +0 -1
- package/src/types/constant/common.ts +10 -3
- package/src/types/constant/enum.ts +13 -3
- package/src/types/query/borrowIncentive.ts +150 -0
- package/src/types/query/core.ts +1 -1
- package/src/types/query/index.ts +1 -0
- package/src/types/query/spool.ts +28 -18
- package/src/utils/builder.ts +15 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/query.ts +277 -70
- package/src/utils/util.ts +59 -9
- package/dist/utils/oracle.d.ts +0 -14
- package/src/utils/oracle.ts +0 -36
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import type { SupportBorrowIncentiveCoins } from '../constant';
|
|
2
|
+
|
|
3
|
+
export interface BorrowIncentiveAccountKey {
|
|
4
|
+
id: string;
|
|
5
|
+
onwerId: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type OptionalKeys<T> = {
|
|
9
|
+
[K in keyof T]?: T[K];
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type BorrowIncentivePools = OptionalKeys<
|
|
13
|
+
Record<SupportBorrowIncentiveCoins, BorrowIncentivePool>
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export type BorrowIncentivePool = {
|
|
17
|
+
coinName: SupportBorrowIncentiveCoins;
|
|
18
|
+
symbol: string;
|
|
19
|
+
coinType: string;
|
|
20
|
+
rewardCoinType: string;
|
|
21
|
+
coinDecimal: number;
|
|
22
|
+
rewardCoinDecimal: number;
|
|
23
|
+
coinPrice: number;
|
|
24
|
+
rewardCoinPrice: number;
|
|
25
|
+
} & Required<
|
|
26
|
+
Pick<
|
|
27
|
+
ParsedBorrowIncentivePoolData,
|
|
28
|
+
'maxPoint' | 'distributedPoint' | 'maxStake'
|
|
29
|
+
>
|
|
30
|
+
> &
|
|
31
|
+
CalculatedBorrowIncentivePoolData &
|
|
32
|
+
BorrowIncentiveRewardPool;
|
|
33
|
+
|
|
34
|
+
export type OriginBorrowIncentivePoolData = {
|
|
35
|
+
created_at: string;
|
|
36
|
+
distributed_point: string;
|
|
37
|
+
distributed_point_per_period: string;
|
|
38
|
+
index: string;
|
|
39
|
+
last_update: string;
|
|
40
|
+
max_distributed_point: string;
|
|
41
|
+
max_stakes: string;
|
|
42
|
+
point_distribution_time: string;
|
|
43
|
+
pool_type: {
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
stakes: string;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export type ParsedBorrowIncentivePoolData = {
|
|
50
|
+
poolType: string;
|
|
51
|
+
maxPoint: number;
|
|
52
|
+
distributedPoint: number;
|
|
53
|
+
pointPerPeriod: number;
|
|
54
|
+
period: number;
|
|
55
|
+
maxStake: number;
|
|
56
|
+
staked: number;
|
|
57
|
+
index: number;
|
|
58
|
+
createdAt: number;
|
|
59
|
+
lastUpdate: number;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
export type CalculatedBorrowIncentivePoolData = {
|
|
63
|
+
stakedAmount: number;
|
|
64
|
+
stakedCoin: number;
|
|
65
|
+
stakedValue: number;
|
|
66
|
+
distributedPointPerSec: number;
|
|
67
|
+
accumulatedPoints: number;
|
|
68
|
+
currentPointIndex: number;
|
|
69
|
+
currentTotalDistributedPoint: number;
|
|
70
|
+
startDate: Date;
|
|
71
|
+
endDate: Date;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export type BorrowIncentiveRewardPool = Required<
|
|
75
|
+
Pick<
|
|
76
|
+
ParsedBorrowIncentiveRewardPoolData,
|
|
77
|
+
'exchangeRateNumerator' | 'exchangeRateDenominator'
|
|
78
|
+
>
|
|
79
|
+
> &
|
|
80
|
+
CalculatedBorrowIncentiveRewardPoolData;
|
|
81
|
+
|
|
82
|
+
export type OriginBorrowIncentiveRewardPoolData = {
|
|
83
|
+
claimed_rewards: string;
|
|
84
|
+
exchange_rate_denominator: string;
|
|
85
|
+
exchange_rate_numerator: string;
|
|
86
|
+
remaining_reward: string;
|
|
87
|
+
reward_type: {
|
|
88
|
+
name: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
export type ParsedBorrowIncentiveRewardPoolData = {
|
|
93
|
+
rewardType: string;
|
|
94
|
+
claimedRewards: number;
|
|
95
|
+
exchangeRateNumerator: number;
|
|
96
|
+
exchangeRateDenominator: number;
|
|
97
|
+
remainingRewards: number;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
export type CalculatedBorrowIncentiveRewardPoolData = {
|
|
101
|
+
rewardApr: number;
|
|
102
|
+
totalRewardAmount: number;
|
|
103
|
+
totalRewardCoin: number;
|
|
104
|
+
totalRewardValue: number;
|
|
105
|
+
remaindRewardAmount: number;
|
|
106
|
+
remaindRewardCoin: number;
|
|
107
|
+
remaindRewardValue: number;
|
|
108
|
+
claimedRewardAmount: number;
|
|
109
|
+
claimedRewardCoin: number;
|
|
110
|
+
claimedRewardValue: number;
|
|
111
|
+
rewardPerSec: number;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export type BorrowIncentiveAccounts = OptionalKeys<
|
|
115
|
+
Record<SupportBorrowIncentiveCoins, ParsedBorrowIncentiveAccountData>
|
|
116
|
+
>;
|
|
117
|
+
|
|
118
|
+
export type OriginBorrowIncentiveAccountData = {
|
|
119
|
+
amount: string;
|
|
120
|
+
index: string;
|
|
121
|
+
points: string;
|
|
122
|
+
pool_type: {
|
|
123
|
+
name: string;
|
|
124
|
+
};
|
|
125
|
+
total_points: string;
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export type ParsedBorrowIncentiveAccountData = {
|
|
129
|
+
poolType: string;
|
|
130
|
+
amount: number;
|
|
131
|
+
index: number;
|
|
132
|
+
points: number;
|
|
133
|
+
totalPoints: number;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* The query interface for `incentive_pools_query::incentive_pools_data` inspectTxn.
|
|
138
|
+
*/
|
|
139
|
+
export interface BorrowIncentivePoolsQueryInterface {
|
|
140
|
+
incentive_pools: OriginBorrowIncentivePoolData[];
|
|
141
|
+
reward_pool: OriginBorrowIncentiveRewardPoolData;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The query interface for `incentive_account_query::incentive_account_data` inspectTxn.
|
|
146
|
+
*/
|
|
147
|
+
export interface BorrowIncentiveAccountsQueryInterface {
|
|
148
|
+
incentive_states: OriginBorrowIncentiveAccountData[];
|
|
149
|
+
total_points: string;
|
|
150
|
+
}
|
package/src/types/query/core.ts
CHANGED
|
@@ -255,7 +255,7 @@ export type Market = {
|
|
|
255
255
|
data?: MarketQueryInterface;
|
|
256
256
|
};
|
|
257
257
|
|
|
258
|
-
export type Obligation = { id: string; keyId: string };
|
|
258
|
+
export type Obligation = { id: string; keyId: string; locked: boolean };
|
|
259
259
|
|
|
260
260
|
/**
|
|
261
261
|
* The query interface for `market_query::market_data` inspectTxn.
|
package/src/types/query/index.ts
CHANGED
package/src/types/query/spool.ts
CHANGED
|
@@ -4,13 +4,6 @@ type OptionalKeys<T> = {
|
|
|
4
4
|
[K in keyof T]?: T[K];
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export type StakePools = OptionalKeys<
|
|
8
|
-
Record<SupportStakeMarketCoins, StakePool>
|
|
9
|
-
>;
|
|
10
|
-
export type RewardPools = OptionalKeys<
|
|
11
|
-
Record<SupportStakeMarketCoins, RewardPool>
|
|
12
|
-
>;
|
|
13
|
-
export type StakeAccounts = Record<SupportStakeMarketCoins, StakeAccount[]>;
|
|
14
7
|
export type Spools = OptionalKeys<Record<SupportStakeMarketCoins, Spool>>;
|
|
15
8
|
|
|
16
9
|
export type Spool = {
|
|
@@ -24,10 +17,13 @@ export type Spool = {
|
|
|
24
17
|
coinPrice: number;
|
|
25
18
|
marketCoinPrice: number;
|
|
26
19
|
rewardCoinPrice: number;
|
|
27
|
-
} &
|
|
28
|
-
|
|
20
|
+
} & Required<
|
|
21
|
+
Pick<ParsedSpoolData, 'maxPoint' | 'distributedPoint' | 'maxStake'>
|
|
22
|
+
> &
|
|
23
|
+
CalculatedSpoolData &
|
|
24
|
+
SpoolRewardPool;
|
|
29
25
|
|
|
30
|
-
export type
|
|
26
|
+
export type OriginSpoolData = {
|
|
31
27
|
stakeType: { fields: { name: string } };
|
|
32
28
|
maxDistributedPoint: string;
|
|
33
29
|
distributedPoint: string;
|
|
@@ -40,7 +36,7 @@ export type OriginStakePoolData = {
|
|
|
40
36
|
lastUpdate: string;
|
|
41
37
|
};
|
|
42
38
|
|
|
43
|
-
export type
|
|
39
|
+
export type ParsedSpoolData = {
|
|
44
40
|
stakeType: string;
|
|
45
41
|
maxPoint: number;
|
|
46
42
|
distributedPoint: number;
|
|
@@ -53,7 +49,7 @@ export type ParsedStakePoolData = {
|
|
|
53
49
|
lastUpdate: number;
|
|
54
50
|
};
|
|
55
51
|
|
|
56
|
-
export type
|
|
52
|
+
export type CalculatedSpoolData = {
|
|
57
53
|
stakedAmount: number;
|
|
58
54
|
stakedCoin: number;
|
|
59
55
|
stakedValue: number;
|
|
@@ -65,7 +61,15 @@ export type CalculatedStakePoolData = {
|
|
|
65
61
|
endDate: Date;
|
|
66
62
|
};
|
|
67
63
|
|
|
68
|
-
export type
|
|
64
|
+
export type SpoolRewardPool = Required<
|
|
65
|
+
Pick<
|
|
66
|
+
ParsedSpoolRewardPoolData,
|
|
67
|
+
'exchangeRateNumerator' | 'exchangeRateDenominator'
|
|
68
|
+
>
|
|
69
|
+
> &
|
|
70
|
+
CalculatedSpoolRewardPoolData;
|
|
71
|
+
|
|
72
|
+
export type OriginSpoolRewardPoolData = {
|
|
69
73
|
claimed_rewards: string;
|
|
70
74
|
exchange_rate_denominator: string;
|
|
71
75
|
exchange_rate_numerator: string;
|
|
@@ -73,7 +77,7 @@ export type OriginRewardPoolData = {
|
|
|
73
77
|
spool_id: string;
|
|
74
78
|
};
|
|
75
79
|
|
|
76
|
-
export type
|
|
80
|
+
export type ParsedSpoolRewardPoolData = {
|
|
77
81
|
claimedRewards: number;
|
|
78
82
|
exchangeRateNumerator: number;
|
|
79
83
|
exchangeRateDenominator: number;
|
|
@@ -81,7 +85,7 @@ export type ParsedRewardPoolData = {
|
|
|
81
85
|
spoolId: string;
|
|
82
86
|
};
|
|
83
87
|
|
|
84
|
-
export type
|
|
88
|
+
export type CalculatedSpoolRewardPoolData = {
|
|
85
89
|
rewardApr: number;
|
|
86
90
|
totalRewardAmount: number;
|
|
87
91
|
totalRewardCoin: number;
|
|
@@ -93,10 +97,16 @@ export type CalculatedRewardPoolData = {
|
|
|
93
97
|
claimedRewardCoin: number;
|
|
94
98
|
claimedRewardValue: number;
|
|
95
99
|
rewardPerSec: number;
|
|
96
|
-
exchangeRateNumerator: number;
|
|
97
|
-
exchangeRateDenominator: number;
|
|
98
100
|
};
|
|
99
101
|
|
|
102
|
+
export type StakePools = OptionalKeys<
|
|
103
|
+
Record<SupportStakeMarketCoins, StakePool>
|
|
104
|
+
>;
|
|
105
|
+
export type StakeRewardPools = OptionalKeys<
|
|
106
|
+
Record<SupportStakeMarketCoins, StakeRewardPool>
|
|
107
|
+
>;
|
|
108
|
+
export type StakeAccounts = Record<SupportStakeMarketCoins, StakeAccount[]>;
|
|
109
|
+
|
|
100
110
|
export interface StakeAccount {
|
|
101
111
|
id: string;
|
|
102
112
|
type: string;
|
|
@@ -123,7 +133,7 @@ export interface StakePool {
|
|
|
123
133
|
lastUpdate: number;
|
|
124
134
|
}
|
|
125
135
|
|
|
126
|
-
export interface
|
|
136
|
+
export interface StakeRewardPool {
|
|
127
137
|
id: string;
|
|
128
138
|
type: string;
|
|
129
139
|
stakePoolId: string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
2
|
+
|
|
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 const requireSender = (txBlock: SuiKitTxBlock) => {
|
|
10
|
+
const sender = txBlock.blockData.sender;
|
|
11
|
+
if (!sender) {
|
|
12
|
+
throw new Error('Sender is required');
|
|
13
|
+
}
|
|
14
|
+
return sender;
|
|
15
|
+
};
|
package/src/utils/index.ts
CHANGED