@gearbox-protocol/sdk 8.19.4 → 8.19.6

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.
@@ -37,6 +37,7 @@ var import_CurveStablePriceFeed = require("./CurveStablePriceFeed.js");
37
37
  var import_CurveUSDPriceFeed = require("./CurveUSDPriceFeed.js");
38
38
  var import_Erc4626PriceFeed = require("./Erc4626PriceFeed.js");
39
39
  var import_ExternalPriceFeed = require("./ExternalPriceFeed.js");
40
+ var import_getRawPriceUpdates = require("./getRawPriceUpdates.js");
40
41
  var import_MellowLRTPriceFeed = require("./MellowLRTPriceFeed.js");
41
42
  var import_PendleTWAPPTPriceFeed = require("./PendleTWAPPTPriceFeed.js");
42
43
  var import_PythPriceFeed = require("./PythPriceFeed.js");
@@ -99,6 +100,19 @@ class PriceFeedRegister extends import_base.SDKConstruct {
99
100
  this.#latestUpdate = latestUpdate;
100
101
  return result;
101
102
  }
103
+ /**
104
+ * Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
105
+ * @param priceFeeds
106
+ * @param logContext
107
+ * @returns
108
+ */
109
+ async generatePriceFeedsUpdates(priceFeeds, logContext = {}) {
110
+ const updates = await this.generatePriceFeedsUpdateTxs(
111
+ priceFeeds,
112
+ logContext
113
+ );
114
+ return (0, import_getRawPriceUpdates.getRawPriceUpdates)(updates);
115
+ }
102
116
  /**
103
117
  * Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
104
118
  * This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
@@ -131,14 +145,11 @@ class PriceFeedRegister extends import_base.SDKConstruct {
131
145
  * @returns
132
146
  */
133
147
  async generateExternalPriceFeedsUpdates(feeds, block) {
134
- const { txs } = await this.generateExternalPriceFeedsUpdateTxs(
148
+ const updates = await this.generateExternalPriceFeedsUpdateTxs(
135
149
  feeds,
136
150
  block
137
151
  );
138
- return txs.map((tx) => ({
139
- priceFeed: tx.data.priceFeed,
140
- data: tx.raw.callData
141
- }));
152
+ return (0, import_getRawPriceUpdates.getRawPriceUpdates)(updates);
142
153
  }
143
154
  has(address) {
144
155
  return this.#feeds.has(address);
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var getRawPriceUpdates_exports = {};
20
+ __export(getRawPriceUpdates_exports, {
21
+ getRawPriceUpdates: () => getRawPriceUpdates
22
+ });
23
+ module.exports = __toCommonJS(getRawPriceUpdates_exports);
24
+ var import_viem = require("viem");
25
+ var import_iUpdatablePriceFeed = require("../../../abi/iUpdatablePriceFeed.js");
26
+ function getRawPriceUpdates(updates) {
27
+ return updates.txs.map((tx) => {
28
+ const data = (0, import_viem.decodeFunctionData)({
29
+ abi: import_iUpdatablePriceFeed.iUpdatablePriceFeedAbi,
30
+ data: tx.raw.callData
31
+ });
32
+ return {
33
+ priceFeed: tx.raw.to,
34
+ data: data.args[0]
35
+ };
36
+ });
37
+ }
38
+ // Annotate the CommonJS export names for ESM import in node:
39
+ 0 && (module.exports = {
40
+ getRawPriceUpdates
41
+ });
@@ -25,6 +25,7 @@ __reExport(pricefeeds_exports, require("./CurveStablePriceFeed.js"), module.expo
25
25
  __reExport(pricefeeds_exports, require("./CurveUSDPriceFeed.js"), module.exports);
26
26
  __reExport(pricefeeds_exports, require("./Erc4626PriceFeed.js"), module.exports);
27
27
  __reExport(pricefeeds_exports, require("./ExternalPriceFeed.js"), module.exports);
28
+ __reExport(pricefeeds_exports, require("./getRawPriceUpdates.js"), module.exports);
28
29
  __reExport(pricefeeds_exports, require("./isUpdatablePriceFeed.js"), module.exports);
29
30
  __reExport(pricefeeds_exports, require("./MellowLRTPriceFeed.js"), module.exports);
30
31
  __reExport(pricefeeds_exports, require("./PendleTWAPPTPriceFeed.js"), module.exports);
@@ -48,6 +49,7 @@ __reExport(pricefeeds_exports, require("./ZeroPriceFeed.js"), module.exports);
48
49
  ...require("./CurveUSDPriceFeed.js"),
49
50
  ...require("./Erc4626PriceFeed.js"),
50
51
  ...require("./ExternalPriceFeed.js"),
52
+ ...require("./getRawPriceUpdates.js"),
51
53
  ...require("./isUpdatablePriceFeed.js"),
52
54
  ...require("./MellowLRTPriceFeed.js"),
53
55
  ...require("./PendleTWAPPTPriceFeed.js"),
@@ -20,6 +20,7 @@ import { CurveStablePriceFeedContract } from "./CurveStablePriceFeed.js";
20
20
  import { CurveUSDPriceFeedContract } from "./CurveUSDPriceFeed.js";
21
21
  import { Erc4626PriceFeedContract } from "./Erc4626PriceFeed.js";
22
22
  import { ExternalPriceFeedContract } from "./ExternalPriceFeed.js";
23
+ import { getRawPriceUpdates } from "./getRawPriceUpdates.js";
23
24
  import { MellowLRTPriceFeedContract } from "./MellowLRTPriceFeed.js";
24
25
  import { PendleTWAPPTPriceFeed } from "./PendleTWAPPTPriceFeed.js";
25
26
  import { PythPriceFeed } from "./PythPriceFeed.js";
@@ -82,6 +83,19 @@ class PriceFeedRegister extends SDKConstruct {
82
83
  this.#latestUpdate = latestUpdate;
83
84
  return result;
84
85
  }
86
+ /**
87
+ * Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
88
+ * @param priceFeeds
89
+ * @param logContext
90
+ * @returns
91
+ */
92
+ async generatePriceFeedsUpdates(priceFeeds, logContext = {}) {
93
+ const updates = await this.generatePriceFeedsUpdateTxs(
94
+ priceFeeds,
95
+ logContext
96
+ );
97
+ return getRawPriceUpdates(updates);
98
+ }
85
99
  /**
86
100
  * Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
87
101
  * This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
@@ -114,14 +128,11 @@ class PriceFeedRegister extends SDKConstruct {
114
128
  * @returns
115
129
  */
116
130
  async generateExternalPriceFeedsUpdates(feeds, block) {
117
- const { txs } = await this.generateExternalPriceFeedsUpdateTxs(
131
+ const updates = await this.generateExternalPriceFeedsUpdateTxs(
118
132
  feeds,
119
133
  block
120
134
  );
121
- return txs.map((tx) => ({
122
- priceFeed: tx.data.priceFeed,
123
- data: tx.raw.callData
124
- }));
135
+ return getRawPriceUpdates(updates);
125
136
  }
126
137
  has(address) {
127
138
  return this.#feeds.has(address);
@@ -0,0 +1,17 @@
1
+ import { decodeFunctionData } from "viem";
2
+ import { iUpdatablePriceFeedAbi } from "../../../abi/iUpdatablePriceFeed.js";
3
+ function getRawPriceUpdates(updates) {
4
+ return updates.txs.map((tx) => {
5
+ const data = decodeFunctionData({
6
+ abi: iUpdatablePriceFeedAbi,
7
+ data: tx.raw.callData
8
+ });
9
+ return {
10
+ priceFeed: tx.raw.to,
11
+ data: data.args[0]
12
+ };
13
+ });
14
+ }
15
+ export {
16
+ getRawPriceUpdates
17
+ };
@@ -8,6 +8,7 @@ export * from "./CurveStablePriceFeed.js";
8
8
  export * from "./CurveUSDPriceFeed.js";
9
9
  export * from "./Erc4626PriceFeed.js";
10
10
  export * from "./ExternalPriceFeed.js";
11
+ export * from "./getRawPriceUpdates.js";
11
12
  export * from "./isUpdatablePriceFeed.js";
12
13
  export * from "./MellowLRTPriceFeed.js";
13
14
  export * from "./PendleTWAPPTPriceFeed.js";
@@ -1,11 +1,11 @@
1
- import type { Address, BlockTag, Hex } from "viem";
1
+ import type { Address, BlockTag } from "viem";
2
2
  import type { PriceFeedTreeNode } from "../../base/index.js";
3
3
  import { SDKConstruct } from "../../base/index.js";
4
4
  import type { GearboxSDK } from "../../GearboxSDK.js";
5
5
  import type { ILogger } from "../../types/index.js";
6
6
  import type { IHooks } from "../../utils/internal/index.js";
7
7
  import { type PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
8
- import type { IPriceFeedContract, UpdatePriceFeedsResult } from "./types.js";
8
+ import type { IPriceFeedContract, PriceUpdateRaw, UpdatePriceFeedsResult } from "./types.js";
9
9
  import type { IPriceUpdater, IPriceUpdateTask, PythOptions, RedstoneOptions } from "./updates/index.js";
10
10
  export type PriceFeedRegisterHooks = {
11
11
  /**
@@ -40,6 +40,13 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
40
40
  * @returns
41
41
  */
42
42
  generatePriceFeedsUpdateTxs(priceFeeds?: IPriceFeedContract[], logContext?: Record<string, any>): Promise<UpdatePriceFeedsResult>;
43
+ /**
44
+ * Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
45
+ * @param priceFeeds
46
+ * @param logContext
47
+ * @returns
48
+ */
49
+ generatePriceFeedsUpdates(priceFeeds?: IPriceFeedContract[], logContext?: Record<string, any>): Promise<PriceUpdateRaw[]>;
43
50
  /**
44
51
  * Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds
45
52
  * This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
@@ -62,10 +69,7 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
62
69
  blockNumber: bigint;
63
70
  } | {
64
71
  blockTag: BlockTag;
65
- }): Promise<Array<{
66
- priceFeed: Address;
67
- data: Hex;
68
- }>>;
72
+ }): Promise<PriceUpdateRaw[]>;
69
73
  has(address: Address): boolean;
70
74
  mustGet(address: Address): IPriceFeedContract;
71
75
  getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
@@ -0,0 +1,2 @@
1
+ import type { PriceUpdateRaw, UpdatePriceFeedsResult } from "./types.js";
2
+ export declare function getRawPriceUpdates(updates: UpdatePriceFeedsResult): PriceUpdateRaw[];
@@ -8,6 +8,7 @@ export * from "./CurveStablePriceFeed.js";
8
8
  export * from "./CurveUSDPriceFeed.js";
9
9
  export * from "./Erc4626PriceFeed.js";
10
10
  export * from "./ExternalPriceFeed.js";
11
+ export * from "./getRawPriceUpdates.js";
11
12
  export * from "./isUpdatablePriceFeed.js";
12
13
  export * from "./MellowLRTPriceFeed.js";
13
14
  export * from "./PendleTWAPPTPriceFeed.js";
@@ -1,4 +1,4 @@
1
- import type { UnionOmit } from "viem";
1
+ import type { Address, Hex, UnionOmit } from "viem";
2
2
  import type { IBaseContract } from "../../base/index.js";
3
3
  import type { IPriceUpdateTx, PriceFeedStateHuman, RawTx } from "../../types/index.js";
4
4
  import type { PriceFeedRef } from "./PriceFeedRef.js";
@@ -41,3 +41,13 @@ export interface UpdatePriceFeedsResult {
41
41
  txs: IPriceUpdateTx[];
42
42
  timestamp: number;
43
43
  }
44
+ export interface PriceUpdateRaw {
45
+ /**
46
+ * IUpdatablePriceFeed contract address
47
+ */
48
+ priceFeed: Address;
49
+ /**
50
+ * Data that can be passed to IUpdatablePriceFeed.updatePrice
51
+ */
52
+ data: Hex;
53
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.19.4",
3
+ "version": "8.19.6",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",