@gearbox-protocol/sdk 3.0.0-next.249 → 3.0.0-next.250
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/lib/redstone/api.d.ts +1 -1
- package/lib/redstone/api.js +24 -10
- package/package.json +3 -3
package/lib/redstone/api.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ export declare class RedstoneApi {
|
|
|
32
32
|
static getRedstonePriceFeeds: ({ priceOracleAddress, currentTokenData, provider, network, }: GetRedstoneFeedsProps) => Promise<{
|
|
33
33
|
main: RedstonePriceFeeds;
|
|
34
34
|
reserve: RedstonePriceFeeds;
|
|
35
|
-
allReserve: Record<`0x${string}`, `0x${string}
|
|
35
|
+
allReserve: Record<`0x${string}`, `0x${string}`[]>;
|
|
36
36
|
}>;
|
|
37
37
|
private static unwrapSecondStage;
|
|
38
38
|
private static unwrapThirdStage;
|
package/lib/redstone/api.js
CHANGED
|
@@ -274,20 +274,29 @@ class RedstoneApi {
|
|
|
274
274
|
const getReserve = (symbol) => (0, sdk_gov_1.getPriceFeedsByToken)(symbol, network)?.Reserve;
|
|
275
275
|
const mainPFData = this.getRedstonePF_Onchain(st3_NotTrustedMainPF, st4_MainTypeType, st4_MainFeedId, getMain, currentTokenData, false, network);
|
|
276
276
|
const reservePFData = this.getRedstonePF_Onchain(st3_ReservePF, st4_ReserveType, st4_ReserveFeedId, getReserve, currentTokenData, true, network);
|
|
277
|
+
const allReserve = st3_ReservePF.reduce((acc, [s, pf]) => {
|
|
278
|
+
const token = currentTokenData[s];
|
|
279
|
+
if (!acc[token])
|
|
280
|
+
acc[token] = [];
|
|
281
|
+
acc[token].push(pf);
|
|
282
|
+
return acc;
|
|
283
|
+
}, {});
|
|
277
284
|
return {
|
|
278
285
|
main: mainPFData,
|
|
279
286
|
reserve: reservePFData,
|
|
280
|
-
allReserve
|
|
287
|
+
allReserve,
|
|
281
288
|
};
|
|
282
289
|
};
|
|
283
290
|
static unwrapSecondStage(priceFeeds, feedsTypeResponse, priceFeedResponse) {
|
|
284
291
|
const result = priceFeeds.reduce((acc, [symbol, baseAddress], index) => {
|
|
285
292
|
const { error: typeError, result: feedType } = feedsTypeResponse[index];
|
|
286
293
|
const { error: feedError, result: feed } = priceFeedResponse[index];
|
|
287
|
-
const
|
|
288
|
-
Number(feedType) === sdk_gov_1.PriceFeedType.PENDLE_PT_TWAP_ORACLE;
|
|
294
|
+
const isRedstone = !typeError && Number(feedType) === sdk_gov_1.PriceFeedType.REDSTONE_ORACLE;
|
|
289
295
|
const hasFeed = !feedError && typeof feed === "string";
|
|
290
|
-
if (
|
|
296
|
+
if (isRedstone) {
|
|
297
|
+
acc.push([symbol, baseAddress]);
|
|
298
|
+
}
|
|
299
|
+
else if (hasFeed) {
|
|
291
300
|
acc.push([symbol, feed]);
|
|
292
301
|
}
|
|
293
302
|
else {
|
|
@@ -303,16 +312,21 @@ class RedstoneApi {
|
|
|
303
312
|
const { error: feed0Error, result: feed0 } = priceFeed0Response[index];
|
|
304
313
|
const { error: feed1Error, result: feed1 } = priceFeed1Response[index];
|
|
305
314
|
const isRedstone = !typeError && Number(feedType) === sdk_gov_1.PriceFeedType.REDSTONE_ORACLE;
|
|
315
|
+
const hasFeed0 = !feed0Error && typeof feed0 === "string";
|
|
316
|
+
const hasFeed1 = !feed1Error && typeof feed1 === "string";
|
|
306
317
|
if (isRedstone) {
|
|
307
318
|
acc.push([symbol, baseAddress]);
|
|
308
319
|
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
320
|
+
else if (hasFeed0 || hasFeed1) {
|
|
321
|
+
if (hasFeed0) {
|
|
322
|
+
acc.push([symbol, feed0]);
|
|
323
|
+
}
|
|
324
|
+
if (hasFeed1) {
|
|
325
|
+
acc.push([symbol, feed1]);
|
|
326
|
+
}
|
|
312
327
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
acc.push([symbol, feed1]);
|
|
328
|
+
else {
|
|
329
|
+
acc.push([symbol, baseAddress]);
|
|
316
330
|
}
|
|
317
331
|
return acc;
|
|
318
332
|
}, []);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gearbox-protocol/sdk",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.250",
|
|
4
4
|
"description": "Gearbox SDK",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"types": "./lib/index.d.ts",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"test": "npx mocha -r ts-node/register -r dotenv/config 'src/**/*.spec.ts'"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@gearbox-protocol/sdk-gov": "^2.
|
|
31
|
+
"@gearbox-protocol/sdk-gov": "^2.27.0",
|
|
32
32
|
"@wagmi/cli": "^2.1.13",
|
|
33
33
|
"axios": "^1.2.6",
|
|
34
34
|
"decimal.js-light": "^2.5.1",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@1inch/solidity-utils": "^2.2.27",
|
|
41
41
|
"@commitlint/cli": "^17.6.3",
|
|
42
42
|
"@commitlint/config-conventional": "^17.0.3",
|
|
43
|
+
"@gearbox-protocol/bots-v3": "^1.5.1",
|
|
43
44
|
"@gearbox-protocol/core-v2": "1.19.0-base.17",
|
|
44
45
|
"@gearbox-protocol/core-v3": "^1.50.0",
|
|
45
46
|
"@gearbox-protocol/eslint-config": "^1.4.1",
|
|
@@ -48,7 +49,6 @@
|
|
|
48
49
|
"@gearbox-protocol/periphery-v3": "^1.6.1",
|
|
49
50
|
"@gearbox-protocol/prettier-config": "^1.4.1",
|
|
50
51
|
"@gearbox-protocol/router": "^1.5.5",
|
|
51
|
-
"@gearbox-protocol/bots-v3": "^1.5.1",
|
|
52
52
|
"@gearbox-protocol/router-v3": "^1.37.0",
|
|
53
53
|
"@openzeppelin/contracts": "^4.9.3",
|
|
54
54
|
"@redstone-finance/evm-connector": "^0.5.4",
|