@scallop-io/sui-scallop-sdk 0.44.15 → 0.44.17
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 +1 -1
- package/dist/constants/pyth.d.ts +3 -0
- package/dist/index.js +120 -88
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +120 -88
- package/dist/index.mjs.map +1 -1
- package/dist/models/scallopBuilder.d.ts +2 -1
- package/dist/models/scallopClient.d.ts +2 -2
- package/dist/models/scallopQuery.d.ts +11 -4
- package/dist/models/scallopUtils.d.ts +4 -2
- package/dist/queries/coreQuery.d.ts +2 -2
- package/dist/queries/spoolQuery.d.ts +2 -0
- package/dist/types/model.d.ts +4 -1
- package/dist/types/query/borrowIncentive.d.ts +0 -5
- package/dist/types/query/spool.d.ts +0 -7
- package/package.json +1 -1
- package/src/builders/oracle.ts +24 -12
- package/src/constants/common.ts +2 -0
- package/src/constants/enum.ts +4 -0
- package/src/constants/pyth.ts +6 -0
- package/src/models/scallopAddress.ts +8 -0
- package/src/models/scallopBuilder.ts +7 -4
- package/src/models/scallopClient.ts +7 -6
- package/src/models/scallopQuery.ts +8 -4
- package/src/models/scallopUtils.ts +40 -22
- package/src/queries/spoolQuery.ts +28 -48
- package/src/types/model.ts +4 -1
- package/src/types/query/borrowIncentive.ts +0 -5
- package/src/types/query/spool.ts +0 -7
- package/src/utils/query.ts +0 -18
|
@@ -30,8 +30,9 @@ export declare class ScallopBuilder {
|
|
|
30
30
|
* Request the scallop API to initialize data.
|
|
31
31
|
*
|
|
32
32
|
* @param force - Whether to force initialization.
|
|
33
|
+
* @param address - ScallopAddress instance.
|
|
33
34
|
*/
|
|
34
|
-
init(force?: boolean): Promise<void>;
|
|
35
|
+
init(force?: boolean, address?: ScallopAddress): Promise<void>;
|
|
35
36
|
/**
|
|
36
37
|
* Create a scallop txBlock instance that enhances transaction block.
|
|
37
38
|
*
|
|
@@ -31,9 +31,9 @@ export declare class ScallopClient {
|
|
|
31
31
|
/**
|
|
32
32
|
* Request the scallop API to initialize data.
|
|
33
33
|
*
|
|
34
|
-
* @param
|
|
34
|
+
* @param force - Whether to force initialization.
|
|
35
35
|
*/
|
|
36
|
-
init(
|
|
36
|
+
init(force?: boolean): Promise<void>;
|
|
37
37
|
/**
|
|
38
38
|
* Query market data.
|
|
39
39
|
*
|
|
@@ -25,9 +25,10 @@ export declare class ScallopQuery {
|
|
|
25
25
|
/**
|
|
26
26
|
* Request the scallop API to initialize data.
|
|
27
27
|
*
|
|
28
|
-
* @param
|
|
28
|
+
* @param force - Whether to force initialization.
|
|
29
|
+
* @param address - ScallopAddress instance.
|
|
29
30
|
*/
|
|
30
|
-
init(
|
|
31
|
+
init(force?: boolean, address?: ScallopAddress): Promise<void>;
|
|
31
32
|
/**
|
|
32
33
|
* Query market data.
|
|
33
34
|
* @param indexer - Whether to use indexer.
|
|
@@ -148,17 +149,17 @@ export declare class ScallopQuery {
|
|
|
148
149
|
* @return All market market coin amounts.
|
|
149
150
|
*/
|
|
150
151
|
getMarketCoinAmounts(marketCoinNames?: SupportMarketCoins[], ownerAddress?: string): Promise<{
|
|
152
|
+
seth?: number | undefined;
|
|
151
153
|
ssui?: number | undefined;
|
|
152
154
|
susdc?: number | undefined;
|
|
153
155
|
susdt?: number | undefined;
|
|
156
|
+
scetus?: number | undefined;
|
|
154
157
|
safsui?: number | undefined;
|
|
155
158
|
shasui?: number | undefined;
|
|
156
159
|
svsui?: number | undefined;
|
|
157
|
-
seth?: number | undefined;
|
|
158
160
|
sbtc?: number | undefined;
|
|
159
161
|
sapt?: number | undefined;
|
|
160
162
|
ssol?: number | undefined;
|
|
161
|
-
scetus?: number | undefined;
|
|
162
163
|
}>;
|
|
163
164
|
/**
|
|
164
165
|
* Get market coin amount.
|
|
@@ -183,9 +184,11 @@ export declare class ScallopQuery {
|
|
|
183
184
|
* @return Spools data.
|
|
184
185
|
*/
|
|
185
186
|
getSpools(stakeMarketCoinNames?: SupportStakeMarketCoins[], indexer?: boolean): Promise<{
|
|
187
|
+
seth?: import("../types").Spool | undefined;
|
|
186
188
|
ssui?: import("../types").Spool | undefined;
|
|
187
189
|
susdc?: import("../types").Spool | undefined;
|
|
188
190
|
susdt?: import("../types").Spool | undefined;
|
|
191
|
+
scetus?: import("../types").Spool | undefined;
|
|
189
192
|
safsui?: import("../types").Spool | undefined;
|
|
190
193
|
shasui?: import("../types").Spool | undefined;
|
|
191
194
|
svsui?: import("../types").Spool | undefined;
|
|
@@ -224,9 +227,11 @@ export declare class ScallopQuery {
|
|
|
224
227
|
* @return Stake pools data.
|
|
225
228
|
*/
|
|
226
229
|
getStakePools(stakeMarketCoinNames?: SupportStakeMarketCoins[]): Promise<{
|
|
230
|
+
seth?: import("../types").StakePool | undefined;
|
|
227
231
|
ssui?: import("../types").StakePool | undefined;
|
|
228
232
|
susdc?: import("../types").StakePool | undefined;
|
|
229
233
|
susdt?: import("../types").StakePool | undefined;
|
|
234
|
+
scetus?: import("../types").StakePool | undefined;
|
|
230
235
|
safsui?: import("../types").StakePool | undefined;
|
|
231
236
|
shasui?: import("../types").StakePool | undefined;
|
|
232
237
|
svsui?: import("../types").StakePool | undefined;
|
|
@@ -253,9 +258,11 @@ export declare class ScallopQuery {
|
|
|
253
258
|
* @return Stake reward pools data.
|
|
254
259
|
*/
|
|
255
260
|
getStakeRewardPools(stakeMarketCoinNames?: SupportStakeMarketCoins[]): Promise<{
|
|
261
|
+
seth?: import("../types").StakeRewardPool | undefined;
|
|
256
262
|
ssui?: import("../types").StakeRewardPool | undefined;
|
|
257
263
|
susdc?: import("../types").StakeRewardPool | undefined;
|
|
258
264
|
susdt?: import("../types").StakeRewardPool | undefined;
|
|
265
|
+
scetus?: import("../types").StakeRewardPool | undefined;
|
|
259
266
|
safsui?: import("../types").StakeRewardPool | undefined;
|
|
260
267
|
shasui?: import("../types").StakeRewardPool | undefined;
|
|
261
268
|
svsui?: import("../types").StakeRewardPool | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SuiAddressArg } from '@scallop-io/sui-kit';
|
|
2
|
+
import { ScallopAddress } from './scallopAddress';
|
|
2
3
|
import type { ScallopUtilsParams, ScallopInstanceParams, SupportCoins, SupportAssetCoins, SupportMarketCoins, SupportStakeMarketCoins, SupportBorrowIncentiveCoins, CoinWrappedType } from '../types';
|
|
3
4
|
/**
|
|
4
5
|
* @description
|
|
@@ -23,9 +24,10 @@ export declare class ScallopUtils {
|
|
|
23
24
|
/**
|
|
24
25
|
* Request the scallop API to initialize data.
|
|
25
26
|
*
|
|
26
|
-
* @param
|
|
27
|
+
* @param force - Whether to force initialization.
|
|
28
|
+
* @param address - ScallopAddress instance.
|
|
27
29
|
*/
|
|
28
|
-
init(
|
|
30
|
+
init(force?: boolean, address?: ScallopAddress): Promise<void>;
|
|
29
31
|
/**
|
|
30
32
|
* Convert coin name to symbol.
|
|
31
33
|
*
|
|
@@ -151,17 +151,17 @@ export declare const getCoinAmount: (query: ScallopQuery, assetCoinName: Support
|
|
|
151
151
|
* @return All owned market coins amount.
|
|
152
152
|
*/
|
|
153
153
|
export declare const getMarketCoinAmounts: (query: ScallopQuery, marketCoinNames?: SupportMarketCoins[], ownerAddress?: string) => Promise<{
|
|
154
|
+
seth?: number | undefined;
|
|
154
155
|
ssui?: number | undefined;
|
|
155
156
|
susdc?: number | undefined;
|
|
156
157
|
susdt?: number | undefined;
|
|
158
|
+
scetus?: number | undefined;
|
|
157
159
|
safsui?: number | undefined;
|
|
158
160
|
shasui?: number | undefined;
|
|
159
161
|
svsui?: number | undefined;
|
|
160
|
-
seth?: number | undefined;
|
|
161
162
|
sbtc?: number | undefined;
|
|
162
163
|
sapt?: number | undefined;
|
|
163
164
|
ssol?: number | undefined;
|
|
164
|
-
scetus?: number | undefined;
|
|
165
165
|
}>;
|
|
166
166
|
/**
|
|
167
167
|
* Query owned market coin (sCoin) amount.
|
|
@@ -9,9 +9,11 @@ import type { MarketPool, Spool, StakePool, StakeRewardPool, StakeAccounts, Supp
|
|
|
9
9
|
* @return Spools data.
|
|
10
10
|
*/
|
|
11
11
|
export declare const getSpools: (query: ScallopQuery, stakeMarketCoinNames?: SupportStakeMarketCoins[], indexer?: boolean) => Promise<{
|
|
12
|
+
seth?: Spool | undefined;
|
|
12
13
|
ssui?: Spool | undefined;
|
|
13
14
|
susdc?: Spool | undefined;
|
|
14
15
|
susdt?: Spool | undefined;
|
|
16
|
+
scetus?: Spool | undefined;
|
|
15
17
|
safsui?: Spool | undefined;
|
|
16
18
|
shasui?: Spool | undefined;
|
|
17
19
|
svsui?: Spool | undefined;
|
package/dist/types/model.d.ts
CHANGED
|
@@ -23,6 +23,9 @@ export type ScallopClientParams = ScallopParams & {
|
|
|
23
23
|
};
|
|
24
24
|
export type ScallopBuilderParams = ScallopParams & {
|
|
25
25
|
walletAddress?: string;
|
|
26
|
+
pythEndpoints?: string[];
|
|
26
27
|
};
|
|
27
28
|
export type ScallopQueryParams = ScallopParams;
|
|
28
|
-
export type ScallopUtilsParams = ScallopParams
|
|
29
|
+
export type ScallopUtilsParams = ScallopParams & {
|
|
30
|
+
pythEndpoints?: string[];
|
|
31
|
+
};
|
|
@@ -59,8 +59,6 @@ export type OriginBorrowIncentiveRewardPoolData = {
|
|
|
59
59
|
claimed_rewards: string;
|
|
60
60
|
exchange_rate_denominator: string;
|
|
61
61
|
exchange_rate_numerator: string;
|
|
62
|
-
rewards_fee_rate_denominator: string;
|
|
63
|
-
rewards_fee_rate_numerator: string;
|
|
64
62
|
remaining_reward: string;
|
|
65
63
|
reward_type: {
|
|
66
64
|
name: string;
|
|
@@ -71,8 +69,6 @@ export type ParsedBorrowIncentiveRewardPoolData = {
|
|
|
71
69
|
claimedRewards: number;
|
|
72
70
|
exchangeRateDenominator: number;
|
|
73
71
|
exchangeRateNumerator: number;
|
|
74
|
-
rewardsFeeRateDenominator: number;
|
|
75
|
-
rewardsFeeRateNumerator: number;
|
|
76
72
|
remainingRewards: number;
|
|
77
73
|
};
|
|
78
74
|
export type CalculatedBorrowIncentiveRewardPoolData = {
|
|
@@ -87,7 +83,6 @@ export type CalculatedBorrowIncentiveRewardPoolData = {
|
|
|
87
83
|
claimedRewardCoin: number;
|
|
88
84
|
claimedRewardValue: number;
|
|
89
85
|
rewardPerSec: number;
|
|
90
|
-
rewardFee: number;
|
|
91
86
|
};
|
|
92
87
|
export type BorrowIncentiveAccounts = OptionalKeys<Record<SupportBorrowIncentiveCoins, ParsedBorrowIncentiveAccountData>>;
|
|
93
88
|
export type OriginBorrowIncentiveAccountData = {
|
|
@@ -59,8 +59,6 @@ export type OriginSpoolRewardPoolData = {
|
|
|
59
59
|
claimed_rewards: string;
|
|
60
60
|
exchange_rate_denominator: string;
|
|
61
61
|
exchange_rate_numerator: string;
|
|
62
|
-
fee_rate_denominator: string;
|
|
63
|
-
fee_rate_numerator: string;
|
|
64
62
|
rewards: string;
|
|
65
63
|
spool_id: string;
|
|
66
64
|
};
|
|
@@ -68,8 +66,6 @@ export type ParsedSpoolRewardPoolData = {
|
|
|
68
66
|
claimedRewards: number;
|
|
69
67
|
exchangeRateDenominator: number;
|
|
70
68
|
exchangeRateNumerator: number;
|
|
71
|
-
feeRateDenominator: number;
|
|
72
|
-
feeRateNumerator: number;
|
|
73
69
|
rewards: number;
|
|
74
70
|
spoolId: string;
|
|
75
71
|
};
|
|
@@ -85,7 +81,6 @@ export type CalculatedSpoolRewardPoolData = {
|
|
|
85
81
|
claimedRewardCoin: number;
|
|
86
82
|
claimedRewardValue: number;
|
|
87
83
|
rewardPerSec: number;
|
|
88
|
-
rewardFee: number;
|
|
89
84
|
};
|
|
90
85
|
export type StakePools = OptionalKeys<Record<SupportStakeMarketCoins, StakePool>>;
|
|
91
86
|
export type StakeRewardPools = OptionalKeys<Record<SupportStakeMarketCoins, StakeRewardPool>>;
|
|
@@ -120,8 +115,6 @@ export interface StakeRewardPool {
|
|
|
120
115
|
stakePoolId: string;
|
|
121
116
|
ratioDenominator: number;
|
|
122
117
|
ratioNumerator: number;
|
|
123
|
-
feeRateDenominator: number;
|
|
124
|
-
feeRateNumerator: number;
|
|
125
118
|
rewards: number;
|
|
126
119
|
claimedRewards: number;
|
|
127
120
|
}
|
package/package.json
CHANGED
package/src/builders/oracle.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { TransactionArgument } from '@mysten/sui.js/transactions';
|
|
|
8
8
|
import type { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
|
|
9
9
|
import type { ScallopBuilder } from '../models';
|
|
10
10
|
import type { SupportAssetCoins, SupportOracleType } from '../types';
|
|
11
|
+
import { PYTH_ENDPOINTS } from 'src/constants/pyth';
|
|
11
12
|
|
|
12
13
|
/**
|
|
13
14
|
* Update the price of the oracle for multiple coin.
|
|
@@ -34,18 +35,29 @@ export const updateOracles = async (
|
|
|
34
35
|
const priceIds = assetCoinNames.map((assetCoinName) =>
|
|
35
36
|
builder.address.get(`core.coins.${assetCoinName}.oracle.pyth.feed`)
|
|
36
37
|
);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
38
|
+
|
|
39
|
+
// iterate through the endpoints
|
|
40
|
+
const endpoints =
|
|
41
|
+
builder.params.pythEndpoints ??
|
|
42
|
+
PYTH_ENDPOINTS[builder.isTestnet ? 'testnet' : 'mainnet'];
|
|
43
|
+
for (const endpoint of endpoints) {
|
|
44
|
+
try {
|
|
45
|
+
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
46
|
+
const priceUpdateData =
|
|
47
|
+
await pythConnection.getPriceFeedsUpdateData(priceIds);
|
|
48
|
+
await pythClient.updatePriceFeeds(
|
|
49
|
+
txBlock.txBlock,
|
|
50
|
+
priceUpdateData,
|
|
51
|
+
priceIds
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
break;
|
|
55
|
+
} catch (e) {
|
|
56
|
+
console.warn(
|
|
57
|
+
`Failed to update price feeds with endpoint ${endpoint}: ${e}`
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
49
61
|
}
|
|
50
62
|
|
|
51
63
|
// Remove duplicate coin names.
|
package/src/constants/common.ts
CHANGED
package/src/constants/enum.ts
CHANGED
|
@@ -64,18 +64,22 @@ export const marketCoins: MarketCoins = {
|
|
|
64
64
|
};
|
|
65
65
|
|
|
66
66
|
export const stakeMarketCoins: StakeMarketCoins = {
|
|
67
|
+
seth: 'seth',
|
|
67
68
|
ssui: 'ssui',
|
|
68
69
|
susdc: 'susdc',
|
|
69
70
|
susdt: 'susdt',
|
|
71
|
+
scetus: 'scetus',
|
|
70
72
|
safsui: 'safsui',
|
|
71
73
|
shasui: 'shasui',
|
|
72
74
|
svsui: 'svsui',
|
|
73
75
|
};
|
|
74
76
|
|
|
75
77
|
export const spoolRewardCoins: StakeRewardCoins = {
|
|
78
|
+
seth: 'sui',
|
|
76
79
|
ssui: 'sui',
|
|
77
80
|
susdc: 'sui',
|
|
78
81
|
susdt: 'sui',
|
|
82
|
+
scetus: 'sui',
|
|
79
83
|
safsui: 'sui',
|
|
80
84
|
shasui: 'sui',
|
|
81
85
|
svsui: 'sui',
|
|
@@ -191,6 +191,10 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
191
191
|
adminCap: '',
|
|
192
192
|
object: '',
|
|
193
193
|
pools: {
|
|
194
|
+
seth: {
|
|
195
|
+
id: '',
|
|
196
|
+
rewardPoolId: '',
|
|
197
|
+
},
|
|
194
198
|
ssui: {
|
|
195
199
|
id: '',
|
|
196
200
|
rewardPoolId: '',
|
|
@@ -203,6 +207,10 @@ const EMPTY_ADDRESSES: AddressesInterface = {
|
|
|
203
207
|
id: '',
|
|
204
208
|
rewardPoolId: '',
|
|
205
209
|
},
|
|
210
|
+
scetus: {
|
|
211
|
+
id: '',
|
|
212
|
+
rewardPoolId: '',
|
|
213
|
+
},
|
|
206
214
|
safsui: {
|
|
207
215
|
id: '',
|
|
208
216
|
rewardPoolId: '',
|
|
@@ -74,13 +74,16 @@ export class ScallopBuilder {
|
|
|
74
74
|
* Request the scallop API to initialize data.
|
|
75
75
|
*
|
|
76
76
|
* @param force - Whether to force initialization.
|
|
77
|
+
* @param address - ScallopAddress instance.
|
|
77
78
|
*/
|
|
78
|
-
public async init(force: boolean = false) {
|
|
79
|
-
if (force || !this.address.getAddresses()) {
|
|
79
|
+
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
80
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
80
81
|
await this.address.read();
|
|
82
|
+
} else {
|
|
83
|
+
this.address = address;
|
|
81
84
|
}
|
|
82
|
-
await this.query.init(force);
|
|
83
|
-
await this.utils.init(force);
|
|
85
|
+
await this.query.init(force, this.address);
|
|
86
|
+
await this.utils.init(force, this.address);
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
/**
|
|
@@ -84,15 +84,16 @@ export class ScallopClient {
|
|
|
84
84
|
/**
|
|
85
85
|
* Request the scallop API to initialize data.
|
|
86
86
|
*
|
|
87
|
-
* @param
|
|
87
|
+
* @param force - Whether to force initialization.
|
|
88
88
|
*/
|
|
89
|
-
public async init(
|
|
90
|
-
if (
|
|
89
|
+
public async init(force: boolean = false) {
|
|
90
|
+
if (force || !this.address.getAddresses()) {
|
|
91
91
|
await this.address.read();
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
await this.
|
|
95
|
-
await this.
|
|
93
|
+
|
|
94
|
+
await this.builder.init(force, this.address);
|
|
95
|
+
await this.query.init(force, this.address);
|
|
96
|
+
await this.utils.init(force, this.address);
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
/* ==================== Query Method ==================== */
|
|
@@ -87,13 +87,17 @@ export class ScallopQuery {
|
|
|
87
87
|
/**
|
|
88
88
|
* Request the scallop API to initialize data.
|
|
89
89
|
*
|
|
90
|
-
* @param
|
|
90
|
+
* @param force - Whether to force initialization.
|
|
91
|
+
* @param address - ScallopAddress instance.
|
|
91
92
|
*/
|
|
92
|
-
public async init(
|
|
93
|
-
if (
|
|
93
|
+
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
94
|
+
if (force || !this.address.getAddresses() || !address?.getAddresses()) {
|
|
94
95
|
await this.address.read();
|
|
96
|
+
} else {
|
|
97
|
+
this.address = address;
|
|
95
98
|
}
|
|
96
|
-
|
|
99
|
+
|
|
100
|
+
await this.utils.init(force, this.address);
|
|
97
101
|
}
|
|
98
102
|
|
|
99
103
|
/* ==================== Core Query Methods ==================== */
|
|
@@ -33,6 +33,7 @@ import type {
|
|
|
33
33
|
PriceMap,
|
|
34
34
|
CoinWrappedType,
|
|
35
35
|
} from '../types';
|
|
36
|
+
import { PYTH_ENDPOINTS } from 'src/constants/pyth';
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* @description
|
|
@@ -81,13 +82,19 @@ export class ScallopUtils {
|
|
|
81
82
|
/**
|
|
82
83
|
* Request the scallop API to initialize data.
|
|
83
84
|
*
|
|
84
|
-
* @param
|
|
85
|
+
* @param force - Whether to force initialization.
|
|
86
|
+
* @param address - ScallopAddress instance.
|
|
85
87
|
*/
|
|
86
|
-
public async init(
|
|
87
|
-
if (
|
|
88
|
+
public async init(force: boolean = false, address?: ScallopAddress) {
|
|
89
|
+
if (force || !this._address.getAddresses() || !address?.getAddresses()) {
|
|
88
90
|
await this._address.read();
|
|
91
|
+
} else {
|
|
92
|
+
this._address = address;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (!this._query.address.getAddresses()) {
|
|
96
|
+
await this._query.init(force, this._address);
|
|
89
97
|
}
|
|
90
|
-
await this._query.init(forece);
|
|
91
98
|
}
|
|
92
99
|
|
|
93
100
|
/**
|
|
@@ -391,25 +398,36 @@ export class ScallopUtils {
|
|
|
391
398
|
}
|
|
392
399
|
|
|
393
400
|
if (lackPricesCoinNames.length > 0) {
|
|
394
|
-
const
|
|
395
|
-
this.
|
|
396
|
-
|
|
397
|
-
: 'https://hermes.pyth.network'
|
|
398
|
-
);
|
|
399
|
-
const priceIds = lackPricesCoinNames.map((coinName) =>
|
|
400
|
-
this._address.get(`core.coins.${coinName}.oracle.pyth.feed`)
|
|
401
|
-
);
|
|
401
|
+
const endpoints =
|
|
402
|
+
this.params.pythEndpoints ??
|
|
403
|
+
PYTH_ENDPOINTS[this.isTestnet ? 'testnet' : 'mainnet'];
|
|
402
404
|
try {
|
|
403
|
-
const
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
405
|
+
for (const endpoint of endpoints) {
|
|
406
|
+
try {
|
|
407
|
+
const pythConnection = new SuiPriceServiceConnection(endpoint);
|
|
408
|
+
const priceIds = lackPricesCoinNames.map((coinName) =>
|
|
409
|
+
this._address.get(`core.coins.${coinName}.oracle.pyth.feed`)
|
|
410
|
+
);
|
|
411
|
+
const priceFeeds =
|
|
412
|
+
(await pythConnection.getLatestPriceFeeds(priceIds)) || [];
|
|
413
|
+
for (const [index, feed] of priceFeeds.entries()) {
|
|
414
|
+
const data = parseDataFromPythPriceFeed(feed, this._address);
|
|
415
|
+
const coinName = lackPricesCoinNames[index];
|
|
416
|
+
this._priceMap.set(coinName, {
|
|
417
|
+
price: data.price,
|
|
418
|
+
publishTime: data.publishTime,
|
|
419
|
+
});
|
|
420
|
+
coinPrices[coinName] = data.price;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
break;
|
|
424
|
+
} catch (e) {
|
|
425
|
+
console.warn(
|
|
426
|
+
`Failed to update price feeds with endpoint ${endpoint}: ${e}`
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
throw new Error('Failed to update price feeds with all endpoins');
|
|
413
431
|
}
|
|
414
432
|
} catch (_e) {
|
|
415
433
|
for (const coinName of lackPricesCoinNames) {
|
|
@@ -111,7 +111,6 @@ export const getSpool = async (
|
|
|
111
111
|
) => {
|
|
112
112
|
const coinName = query.utils.parseCoinName<SupportStakeCoins>(marketCoinName);
|
|
113
113
|
marketPool = marketPool || (await query.getMarketPool(coinName, indexer));
|
|
114
|
-
const spoolPkgId = query.address.get(`spool.id`);
|
|
115
114
|
const poolId = query.address.get(`spool.pools.${marketCoinName}.id`);
|
|
116
115
|
const rewardPoolId = query.address.get(
|
|
117
116
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
@@ -140,15 +139,6 @@ export const getSpool = async (
|
|
|
140
139
|
showContent: true,
|
|
141
140
|
},
|
|
142
141
|
});
|
|
143
|
-
const spoolRewardFeeDynamicFieldsResponse = await query.suiKit
|
|
144
|
-
.client()
|
|
145
|
-
.getDynamicFieldObject({
|
|
146
|
-
parentId: rewardPoolId,
|
|
147
|
-
name: {
|
|
148
|
-
type: `${spoolPkgId}::rewards_pool::RewardsPoolFeeKey`,
|
|
149
|
-
value: { dummy_field: false },
|
|
150
|
-
},
|
|
151
|
-
});
|
|
152
142
|
|
|
153
143
|
if (
|
|
154
144
|
marketPool &&
|
|
@@ -162,7 +152,6 @@ export const getSpool = async (
|
|
|
162
152
|
|
|
163
153
|
const spoolObject = spoolObjectResponse[0].data;
|
|
164
154
|
const rewardPoolObject = spoolObjectResponse[1].data;
|
|
165
|
-
const rewardFeeObject = spoolRewardFeeDynamicFieldsResponse.data;
|
|
166
155
|
if (spoolObject.content && 'fields' in spoolObject.content) {
|
|
167
156
|
const spoolFields = spoolObject.content.fields as any;
|
|
168
157
|
const parsedSpoolData = parseOriginSpoolData({
|
|
@@ -187,21 +176,12 @@ export const getSpool = async (
|
|
|
187
176
|
marketCoinDecimal
|
|
188
177
|
);
|
|
189
178
|
|
|
190
|
-
if (
|
|
191
|
-
rewardPoolObject.content &&
|
|
192
|
-
rewardFeeObject?.content &&
|
|
193
|
-
'fields' in rewardPoolObject.content &&
|
|
194
|
-
'fields' in rewardFeeObject.content
|
|
195
|
-
) {
|
|
179
|
+
if (rewardPoolObject.content && 'fields' in rewardPoolObject.content) {
|
|
196
180
|
const rewardPoolFields = rewardPoolObject.content.fields as any;
|
|
197
|
-
const rewardFeeFields = (rewardFeeObject.content.fields as any).value
|
|
198
|
-
.fields;
|
|
199
181
|
const parsedSpoolRewardPoolData = parseOriginSpoolRewardPoolData({
|
|
200
182
|
claimed_rewards: rewardPoolFields.claimed_rewards,
|
|
201
183
|
exchange_rate_numerator: rewardPoolFields.exchange_rate_numerator,
|
|
202
184
|
exchange_rate_denominator: rewardPoolFields.exchange_rate_denominator,
|
|
203
|
-
fee_rate_numerator: rewardFeeFields.fee_rate_numerator,
|
|
204
|
-
fee_rate_denominator: rewardFeeFields.fee_rate_denominator,
|
|
205
185
|
rewards: rewardPoolFields.rewards,
|
|
206
186
|
spool_id: rewardPoolFields.spool_id,
|
|
207
187
|
});
|
|
@@ -289,9 +269,11 @@ export const getStakeAccounts = async (
|
|
|
289
269
|
} while (hasNextPage);
|
|
290
270
|
|
|
291
271
|
const stakeAccounts: StakeAccounts = {
|
|
272
|
+
seth: [],
|
|
292
273
|
ssui: [],
|
|
293
274
|
susdc: [],
|
|
294
275
|
susdt: [],
|
|
276
|
+
scetus: [],
|
|
295
277
|
safsui: [],
|
|
296
278
|
shasui: [],
|
|
297
279
|
svsui: [],
|
|
@@ -327,7 +309,18 @@ export const getStakeAccounts = async (
|
|
|
327
309
|
const index = Number(fields.index);
|
|
328
310
|
const points = Number(fields.points);
|
|
329
311
|
const totalPoints = Number(fields.total_points);
|
|
330
|
-
if (normalizeStructTag(type) === stakeMarketCoinTypes.
|
|
312
|
+
if (normalizeStructTag(type) === stakeMarketCoinTypes.seth) {
|
|
313
|
+
stakeAccounts.seth.push({
|
|
314
|
+
id,
|
|
315
|
+
type: normalizeStructTag(type),
|
|
316
|
+
stakePoolId,
|
|
317
|
+
stakeType: normalizeStructTag(stakeType),
|
|
318
|
+
staked,
|
|
319
|
+
index,
|
|
320
|
+
points,
|
|
321
|
+
totalPoints,
|
|
322
|
+
});
|
|
323
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.ssui) {
|
|
331
324
|
stakeAccounts.ssui.push({
|
|
332
325
|
id,
|
|
333
326
|
type: normalizeStructTag(type),
|
|
@@ -360,6 +353,17 @@ export const getStakeAccounts = async (
|
|
|
360
353
|
points,
|
|
361
354
|
totalPoints,
|
|
362
355
|
});
|
|
356
|
+
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.scetus) {
|
|
357
|
+
stakeAccounts.scetus.push({
|
|
358
|
+
id,
|
|
359
|
+
type: normalizeStructTag(type),
|
|
360
|
+
stakePoolId,
|
|
361
|
+
stakeType: normalizeStructTag(stakeType),
|
|
362
|
+
staked,
|
|
363
|
+
index,
|
|
364
|
+
points,
|
|
365
|
+
totalPoints,
|
|
366
|
+
});
|
|
363
367
|
} else if (normalizeStructTag(type) === stakeMarketCoinTypes.safsui) {
|
|
364
368
|
stakeAccounts.safsui.push({
|
|
365
369
|
id,
|
|
@@ -473,7 +477,6 @@ export const getStakeRewardPool = async (
|
|
|
473
477
|
query: ScallopQuery,
|
|
474
478
|
marketCoinName: SupportStakeMarketCoins
|
|
475
479
|
) => {
|
|
476
|
-
const spoolPkgId = query.address.get('spool.id');
|
|
477
480
|
const poolId = query.address.get(
|
|
478
481
|
`spool.pools.${marketCoinName}.rewardPoolId`
|
|
479
482
|
);
|
|
@@ -485,34 +488,15 @@ export const getStakeRewardPool = async (
|
|
|
485
488
|
showType: true,
|
|
486
489
|
},
|
|
487
490
|
});
|
|
488
|
-
|
|
489
|
-
.client()
|
|
490
|
-
.getDynamicFieldObject({
|
|
491
|
-
parentId: poolId,
|
|
492
|
-
name: {
|
|
493
|
-
type: `${spoolPkgId}::rewards_pool::RewardsPoolFeeKey`,
|
|
494
|
-
value: { dummy_field: false },
|
|
495
|
-
},
|
|
496
|
-
});
|
|
497
|
-
if (
|
|
498
|
-
stakeRewardPoolObjectResponse.data &&
|
|
499
|
-
stakeRewardFeeDynamicFieldsResponse.data
|
|
500
|
-
) {
|
|
491
|
+
if (stakeRewardPoolObjectResponse.data) {
|
|
501
492
|
const stakeRewardPoolObject = stakeRewardPoolObjectResponse.data;
|
|
502
|
-
const stakeRewardFeeDynamicFieldObject =
|
|
503
|
-
stakeRewardFeeDynamicFieldsResponse.data;
|
|
504
493
|
const id = stakeRewardPoolObject.objectId;
|
|
505
494
|
const type = stakeRewardPoolObject.type!;
|
|
506
495
|
if (
|
|
507
496
|
stakeRewardPoolObject.content &&
|
|
508
|
-
|
|
509
|
-
'fields' in stakeRewardPoolObject.content &&
|
|
510
|
-
'fields' in stakeRewardFeeDynamicFieldObject.content
|
|
497
|
+
'fields' in stakeRewardPoolObject.content
|
|
511
498
|
) {
|
|
512
499
|
const rewardPoolFields = stakeRewardPoolObject.content.fields as any;
|
|
513
|
-
const rewardFeeFields = (
|
|
514
|
-
stakeRewardFeeDynamicFieldObject.content.fields as any
|
|
515
|
-
).value.fields;
|
|
516
500
|
const stakePoolId = String(rewardPoolFields.spool_id);
|
|
517
501
|
const ratioNumerator = Number(rewardPoolFields.exchange_rate_numerator);
|
|
518
502
|
const ratioDenominator = Number(
|
|
@@ -520,8 +504,6 @@ export const getStakeRewardPool = async (
|
|
|
520
504
|
);
|
|
521
505
|
const rewards = Number(rewardPoolFields.rewards);
|
|
522
506
|
const claimedRewards = Number(rewardPoolFields.claimed_rewards);
|
|
523
|
-
const feeRateNumerator = Number(rewardFeeFields.fee_rate_numerator);
|
|
524
|
-
const feeRateDenominator = Number(rewardFeeFields.fee_rate_denominator);
|
|
525
507
|
|
|
526
508
|
stakeRewardPool = {
|
|
527
509
|
id,
|
|
@@ -529,8 +511,6 @@ export const getStakeRewardPool = async (
|
|
|
529
511
|
stakePoolId,
|
|
530
512
|
ratioNumerator,
|
|
531
513
|
ratioDenominator,
|
|
532
|
-
feeRateNumerator,
|
|
533
|
-
feeRateDenominator,
|
|
534
514
|
rewards,
|
|
535
515
|
claimedRewards,
|
|
536
516
|
};
|