@gearbox-protocol/sdk 8.1.6 → 8.2.0-next.1

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.
Files changed (67) hide show
  1. package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +3 -1
  2. package/dist/cjs/plugins/pools-history/Pools7DAgoPlugin.js +6 -1
  3. package/dist/cjs/sdk/GearboxSDK.js +20 -8
  4. package/dist/cjs/sdk/abi/oracles.js +141 -0
  5. package/dist/cjs/sdk/chain/chains.js +4 -4
  6. package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +2 -1
  7. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +17 -23
  8. package/dist/cjs/sdk/market/pricefeeds/PythPriceFeed.js +9 -1
  9. package/dist/cjs/sdk/market/pricefeeds/RedstonePriceFeed.js +9 -7
  10. package/dist/cjs/sdk/market/pricefeeds/index.js +2 -0
  11. package/dist/cjs/sdk/market/pricefeeds/isUpdatablePriceFeed.js +30 -0
  12. package/dist/cjs/sdk/market/pricefeeds/updates/PriceUpdateTx.js +52 -0
  13. package/dist/cjs/sdk/market/pricefeeds/{RedstoneCache.js → updates/PriceUpdatesCache.js} +12 -12
  14. package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +189 -0
  15. package/dist/cjs/sdk/market/pricefeeds/{RedstoneUpdater.js → updates/RedstoneUpdater.js} +21 -45
  16. package/dist/cjs/sdk/market/pricefeeds/updates/index.js +31 -0
  17. package/dist/cjs/sdk/market/pricefeeds/updates/types.js +16 -0
  18. package/dist/cjs/sdk/sdk-legacy/tokens/tokenData.js +1 -2
  19. package/dist/cjs/sdk/utils/retry.js +4 -2
  20. package/dist/cjs/sdk/utils/viem/cast.js +5 -2
  21. package/dist/cjs/sdk/utils/viem/simulateMulticall.js +3 -1
  22. package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +2 -2
  23. package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +3 -1
  24. package/dist/esm/plugins/pools-history/Pools7DAgoPlugin.js +6 -1
  25. package/dist/esm/sdk/GearboxSDK.js +20 -8
  26. package/dist/esm/sdk/abi/oracles.js +140 -0
  27. package/dist/esm/sdk/chain/chains.js +4 -4
  28. package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +2 -1
  29. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +18 -24
  30. package/dist/esm/sdk/market/pricefeeds/PythPriceFeed.js +9 -1
  31. package/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js +8 -5
  32. package/dist/esm/sdk/market/pricefeeds/index.js +1 -0
  33. package/dist/esm/sdk/market/pricefeeds/isUpdatablePriceFeed.js +6 -0
  34. package/dist/esm/sdk/market/pricefeeds/updates/PriceUpdateTx.js +28 -0
  35. package/dist/esm/sdk/market/pricefeeds/{RedstoneCache.js → updates/PriceUpdatesCache.js} +8 -8
  36. package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +169 -0
  37. package/dist/esm/sdk/market/pricefeeds/{RedstoneUpdater.js → updates/RedstoneUpdater.js} +21 -44
  38. package/dist/esm/sdk/market/pricefeeds/updates/index.js +6 -0
  39. package/dist/esm/sdk/market/pricefeeds/updates/types.js +0 -0
  40. package/dist/esm/sdk/sdk-legacy/tokens/tokenData.js +1 -2
  41. package/dist/esm/sdk/utils/retry.js +4 -2
  42. package/dist/esm/sdk/utils/viem/cast.js +5 -2
  43. package/dist/esm/sdk/utils/viem/simulateMulticall.js +3 -1
  44. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +2 -2
  45. package/dist/types/sdk/GearboxSDK.d.ts +5 -1
  46. package/dist/types/sdk/abi/oracles.d.ts +212 -0
  47. package/dist/types/sdk/chain/chains.d.ts +1 -1
  48. package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +2 -2
  49. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +4 -4
  50. package/dist/types/sdk/market/pricefeeds/PythPriceFeed.d.ts +218 -4
  51. package/dist/types/sdk/market/pricefeeds/RedstonePriceFeed.d.ts +4 -4
  52. package/dist/types/sdk/market/pricefeeds/index.d.ts +1 -0
  53. package/dist/types/sdk/market/pricefeeds/isUpdatablePriceFeed.d.ts +2 -0
  54. package/dist/types/sdk/market/pricefeeds/types.d.ts +5 -2
  55. package/dist/types/sdk/market/pricefeeds/updates/PriceUpdateTx.d.ts +10 -0
  56. package/dist/types/sdk/market/pricefeeds/updates/PriceUpdatesCache.d.ts +17 -0
  57. package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +40 -0
  58. package/dist/types/sdk/market/pricefeeds/{RedstoneUpdater.d.ts → updates/RedstoneUpdater.d.ts} +11 -18
  59. package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.test.d.ts +1 -0
  60. package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +3 -0
  61. package/dist/types/sdk/market/pricefeeds/updates/types.d.ts +21 -0
  62. package/dist/types/sdk/utils/retry.d.ts +1 -0
  63. package/dist/types/sdk/utils/viem/cast.d.ts +1 -1
  64. package/dist/types/sdk/utils/viem/simulateMulticall.d.ts +1 -1
  65. package/dist/types/sdk/utils/viem/simulateWithPriceUpdates.d.ts +1 -1
  66. package/package.json +4 -1
  67. package/dist/types/sdk/market/pricefeeds/RedstoneCache.d.ts +0 -25
@@ -15,8 +15,7 @@ const ALIASES = {
15
15
  PT_corn_pumpBTC_26DEC2024: "p.c.pumpBTC(26.12.24)",
16
16
  PT_sUSDe_27MAR2025: "p.sUSDe(27.03.25)",
17
17
  PT_sUSDe_29MAY2025: "p.sUSDe(29.05.25)",
18
- PT_beraSTONE_10APR2025: "p.beraSTONE(10.04.25)",
19
- PT_uptBTC_14AUG2025: "p.uptBTC(14.08.25)"
18
+ PT_beraSTONE_10APR2025: "p.beraSTONE(10.04.25)"
20
19
  };
21
20
  class TokenData {
22
21
  address;
@@ -1,5 +1,6 @@
1
1
  async function retry(fn, options = {}) {
2
- const { attempts = 3, interval = 200 } = options;
2
+ const { attempts = 3, interval = 200, exponent = 1 } = options;
3
+ let wait = interval;
3
4
  let cause;
4
5
  for (let i = 0; i < attempts; i++) {
5
6
  try {
@@ -8,8 +9,9 @@ async function retry(fn, options = {}) {
8
9
  } catch (e) {
9
10
  cause = e;
10
11
  await new Promise((resolve) => {
11
- setTimeout(resolve, interval);
12
+ setTimeout(resolve, wait);
12
13
  });
14
+ wait = wait * exponent;
13
15
  }
14
16
  }
15
17
  throw new Error(`all attempts failed: ${cause}`);
@@ -1,6 +1,9 @@
1
- function generateCastTraceCall(params) {
1
+ function generateCastTraceCall(params, rpcUrl) {
2
2
  const { to, data, blockNumber, gas, gasPrice, maxPriorityFeePerGas, value } = params;
3
- const cmd = ["cast", "call", "--trace", "--rpc-url", "$RPC_URL"];
3
+ const cmd = ["cast", "call", "--trace"];
4
+ if (rpcUrl) {
5
+ cmd.push("--rpc-url", rpcUrl);
6
+ }
4
7
  if (blockNumber) {
5
8
  cmd.push("--block", blockNumber.toString());
6
9
  }
@@ -17,6 +17,7 @@ async function simulateMulticall(client, parameters) {
17
17
  blockNumber,
18
18
  blockTag,
19
19
  gas,
20
+ value,
20
21
  multicallAddress: multicallAddress_
21
22
  } = parameters;
22
23
  const contracts = parameters.contracts;
@@ -74,7 +75,8 @@ async function simulateMulticall(client, parameters) {
74
75
  blockTag,
75
76
  // does not infer well that either blockNumber or blockTag must be present
76
77
  gas,
77
- account
78
+ account,
79
+ value
78
80
  };
79
81
  const results = [];
80
82
  const { data } = await getAction(client, call, "call")(request);
@@ -201,8 +201,8 @@ class SimulateWithPriceUpdatesError extends BaseError {
201
201
  this.timestamp = timestamp;
202
202
  this.#request = request;
203
203
  }
204
- getCastTraceCall() {
205
- return this.#request ? generateCastTraceCall(this.#request) : "";
204
+ getCastTraceCall(rpcUrl) {
205
+ return this.#request ? generateCastTraceCall(this.#request, rpcUrl) : "";
206
206
  }
207
207
  }
208
208
  export {
@@ -8,7 +8,7 @@ import type { IAddressProviderContract } from "./core/index.js";
8
8
  import { BotListContract, GearStakingContract } from "./core/index.js";
9
9
  import { MarketRegister } from "./market/MarketRegister.js";
10
10
  import { PriceFeedRegister } from "./market/pricefeeds/index.js";
11
- import type { RedstoneOptions } from "./market/pricefeeds/RedstoneUpdater.js";
11
+ import type { PythOptions, RedstoneOptions } from "./market/pricefeeds/updates/index.js";
12
12
  import { type PluginsMap } from "./plugins/index.js";
13
13
  import { type IRouterContract } from "./router/index.js";
14
14
  import type { GearboxState, GearboxStateHuman, ILogger, MultiCall } from "./types/index.js";
@@ -51,6 +51,10 @@ export interface SDKOptions<Plugins extends PluginsMap> {
51
51
  * Options related to redstone price feeds
52
52
  */
53
53
  redstone?: RedstoneOptions;
54
+ /**
55
+ * Options related to pyth price feeds
56
+ */
57
+ pyth?: PythOptions;
54
58
  }
55
59
  export type HydrateOptions<Plugins extends PluginsMap> = Omit<SDKOptions<Plugins>, "blockNumber" | "addressProvider" | "marketConfigurators">;
56
60
  export interface SyncStateOptions {
@@ -6157,3 +6157,215 @@ export declare const pendleTWAPPTPriceFeedAbi: readonly [{
6157
6157
  readonly name: "StalePriceException";
6158
6158
  readonly inputs: readonly [];
6159
6159
  }];
6160
+ export declare const pythPriceFeedAbi: readonly [{
6161
+ readonly type: "constructor";
6162
+ readonly inputs: readonly [{
6163
+ readonly name: "_token";
6164
+ readonly type: "address";
6165
+ readonly internalType: "address";
6166
+ }, {
6167
+ readonly name: "_priceFeedId";
6168
+ readonly type: "bytes32";
6169
+ readonly internalType: "bytes32";
6170
+ }, {
6171
+ readonly name: "_pyth";
6172
+ readonly type: "address";
6173
+ readonly internalType: "address";
6174
+ }, {
6175
+ readonly name: "_maxConfToPriceRatio";
6176
+ readonly type: "uint256";
6177
+ readonly internalType: "uint256";
6178
+ }, {
6179
+ readonly name: "descriptionTicker";
6180
+ readonly type: "string";
6181
+ readonly internalType: "string";
6182
+ }];
6183
+ readonly stateMutability: "nonpayable";
6184
+ }, {
6185
+ readonly type: "receive";
6186
+ readonly stateMutability: "payable";
6187
+ }, {
6188
+ readonly type: "function";
6189
+ readonly name: "contractType";
6190
+ readonly inputs: readonly [];
6191
+ readonly outputs: readonly [{
6192
+ readonly name: "";
6193
+ readonly type: "bytes32";
6194
+ readonly internalType: "bytes32";
6195
+ }];
6196
+ readonly stateMutability: "view";
6197
+ }, {
6198
+ readonly type: "function";
6199
+ readonly name: "decimals";
6200
+ readonly inputs: readonly [];
6201
+ readonly outputs: readonly [{
6202
+ readonly name: "";
6203
+ readonly type: "uint8";
6204
+ readonly internalType: "uint8";
6205
+ }];
6206
+ readonly stateMutability: "view";
6207
+ }, {
6208
+ readonly type: "function";
6209
+ readonly name: "description";
6210
+ readonly inputs: readonly [];
6211
+ readonly outputs: readonly [{
6212
+ readonly name: "";
6213
+ readonly type: "string";
6214
+ readonly internalType: "string";
6215
+ }];
6216
+ readonly stateMutability: "view";
6217
+ }, {
6218
+ readonly type: "function";
6219
+ readonly name: "latestRoundData";
6220
+ readonly inputs: readonly [];
6221
+ readonly outputs: readonly [{
6222
+ readonly name: "";
6223
+ readonly type: "uint80";
6224
+ readonly internalType: "uint80";
6225
+ }, {
6226
+ readonly name: "";
6227
+ readonly type: "int256";
6228
+ readonly internalType: "int256";
6229
+ }, {
6230
+ readonly name: "";
6231
+ readonly type: "uint256";
6232
+ readonly internalType: "uint256";
6233
+ }, {
6234
+ readonly name: "";
6235
+ readonly type: "uint256";
6236
+ readonly internalType: "uint256";
6237
+ }, {
6238
+ readonly name: "";
6239
+ readonly type: "uint80";
6240
+ readonly internalType: "uint80";
6241
+ }];
6242
+ readonly stateMutability: "view";
6243
+ }, {
6244
+ readonly type: "function";
6245
+ readonly name: "maxConfToPriceRatio";
6246
+ readonly inputs: readonly [];
6247
+ readonly outputs: readonly [{
6248
+ readonly name: "";
6249
+ readonly type: "uint256";
6250
+ readonly internalType: "uint256";
6251
+ }];
6252
+ readonly stateMutability: "view";
6253
+ }, {
6254
+ readonly type: "function";
6255
+ readonly name: "priceFeedId";
6256
+ readonly inputs: readonly [];
6257
+ readonly outputs: readonly [{
6258
+ readonly name: "";
6259
+ readonly type: "bytes32";
6260
+ readonly internalType: "bytes32";
6261
+ }];
6262
+ readonly stateMutability: "view";
6263
+ }, {
6264
+ readonly type: "function";
6265
+ readonly name: "pyth";
6266
+ readonly inputs: readonly [];
6267
+ readonly outputs: readonly [{
6268
+ readonly name: "";
6269
+ readonly type: "address";
6270
+ readonly internalType: "address";
6271
+ }];
6272
+ readonly stateMutability: "view";
6273
+ }, {
6274
+ readonly type: "function";
6275
+ readonly name: "serialize";
6276
+ readonly inputs: readonly [];
6277
+ readonly outputs: readonly [{
6278
+ readonly name: "";
6279
+ readonly type: "bytes";
6280
+ readonly internalType: "bytes";
6281
+ }];
6282
+ readonly stateMutability: "view";
6283
+ }, {
6284
+ readonly type: "function";
6285
+ readonly name: "skipPriceCheck";
6286
+ readonly inputs: readonly [];
6287
+ readonly outputs: readonly [{
6288
+ readonly name: "";
6289
+ readonly type: "bool";
6290
+ readonly internalType: "bool";
6291
+ }];
6292
+ readonly stateMutability: "view";
6293
+ }, {
6294
+ readonly type: "function";
6295
+ readonly name: "token";
6296
+ readonly inputs: readonly [];
6297
+ readonly outputs: readonly [{
6298
+ readonly name: "";
6299
+ readonly type: "address";
6300
+ readonly internalType: "address";
6301
+ }];
6302
+ readonly stateMutability: "view";
6303
+ }, {
6304
+ readonly type: "function";
6305
+ readonly name: "updatable";
6306
+ readonly inputs: readonly [];
6307
+ readonly outputs: readonly [{
6308
+ readonly name: "";
6309
+ readonly type: "bool";
6310
+ readonly internalType: "bool";
6311
+ }];
6312
+ readonly stateMutability: "view";
6313
+ }, {
6314
+ readonly type: "function";
6315
+ readonly name: "updatePrice";
6316
+ readonly inputs: readonly [{
6317
+ readonly name: "data";
6318
+ readonly type: "bytes";
6319
+ readonly internalType: "bytes";
6320
+ }];
6321
+ readonly outputs: readonly [];
6322
+ readonly stateMutability: "nonpayable";
6323
+ }, {
6324
+ readonly type: "function";
6325
+ readonly name: "version";
6326
+ readonly inputs: readonly [];
6327
+ readonly outputs: readonly [{
6328
+ readonly name: "";
6329
+ readonly type: "uint256";
6330
+ readonly internalType: "uint256";
6331
+ }];
6332
+ readonly stateMutability: "view";
6333
+ }, {
6334
+ readonly type: "event";
6335
+ readonly name: "UpdatePrice";
6336
+ readonly inputs: readonly [{
6337
+ readonly name: "price";
6338
+ readonly type: "uint256";
6339
+ readonly indexed: false;
6340
+ readonly internalType: "uint256";
6341
+ }];
6342
+ readonly anonymous: false;
6343
+ }, {
6344
+ readonly type: "error";
6345
+ readonly name: "ConfToPriceRatioTooHighException";
6346
+ readonly inputs: readonly [];
6347
+ }, {
6348
+ readonly type: "error";
6349
+ readonly name: "IncorrectExpectedPublishTimestampException";
6350
+ readonly inputs: readonly [];
6351
+ }, {
6352
+ readonly type: "error";
6353
+ readonly name: "IncorrectParameterException";
6354
+ readonly inputs: readonly [];
6355
+ }, {
6356
+ readonly type: "error";
6357
+ readonly name: "IncorrectPriceDecimalsException";
6358
+ readonly inputs: readonly [];
6359
+ }, {
6360
+ readonly type: "error";
6361
+ readonly name: "IncorrectPriceException";
6362
+ readonly inputs: readonly [];
6363
+ }, {
6364
+ readonly type: "error";
6365
+ readonly name: "PriceTimestampTooFarAheadException";
6366
+ readonly inputs: readonly [];
6367
+ }, {
6368
+ readonly type: "error";
6369
+ readonly name: "PriceTimestampTooFarBehindException";
6370
+ readonly inputs: readonly [];
6371
+ }];
@@ -1,6 +1,6 @@
1
1
  import type { Address, Chain } from "viem";
2
2
  import { z } from "zod";
3
- export type Curator = "Chaos Labs" | "K3" | "cp0x" | "Re7";
3
+ export type Curator = "Chaos Labs" | "K3" | "cp0x";
4
4
  export interface GearboxChain extends Chain {
5
5
  network: NetworkType;
6
6
  defaultMarketConfigurators: Record<Address, Curator>;
@@ -4,7 +4,7 @@ import { BaseContract } from "../../base/index.js";
4
4
  import type { GearboxSDK } from "../../GearboxSDK.js";
5
5
  import type { PriceFeedStateHuman } from "../../types/index.js";
6
6
  import { PriceFeedRef } from "./PriceFeedRef.js";
7
- import type { IPriceFeedContract, PriceFeedContractType } from "./types.js";
7
+ import type { IPriceFeedContract, IUpdatablePriceFeedContract, PriceFeedContractType } from "./types.js";
8
8
  export type PartialPriceFeedTreeNode = RequiredBy<Partial<PriceFeedTreeNode>, "baseParams">;
9
9
  export type PriceFeedConstructorArgs<abi extends Abi | readonly unknown[]> = PartialPriceFeedTreeNode & {
10
10
  abi: abi;
@@ -30,5 +30,5 @@ export declare abstract class AbstractPriceFeedContract<const abi extends Abi |
30
30
  answer(overrides?: {
31
31
  blockNumber?: bigint;
32
32
  }): Promise<bigint>;
33
- updatableDependencies(): IPriceFeedContract[];
33
+ updatableDependencies(): IUpdatablePriceFeedContract[];
34
34
  }
@@ -5,9 +5,8 @@ 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 { RedstoneOptions, RedstoneUpdateTask } from "./RedstoneUpdater.js";
9
- import { RedstoneUpdater } from "./RedstoneUpdater.js";
10
8
  import type { IPriceFeedContract, UpdatePriceFeedsResult } from "./types.js";
9
+ import type { IPriceUpdater, IPriceUpdateTask, PythOptions, RedstoneOptions } from "./updates/index.js";
11
10
  export type PriceFeedRegisterHooks = {
12
11
  /**
13
12
  * Emitted when transactions to update price feeds have been generated, but before they're used anywhere
@@ -16,10 +15,11 @@ export type PriceFeedRegisterHooks = {
16
15
  };
17
16
  export interface PriceFeedRegisterOptions {
18
17
  redstone?: RedstoneOptions;
18
+ pyth?: PythOptions;
19
19
  }
20
20
  export interface LatestUpdate {
21
21
  timestamp: number;
22
- redstone: RedstoneUpdateTask[];
22
+ updates: IPriceUpdateTask[];
23
23
  }
24
24
  /**
25
25
  * PriceFeedRegister acts as a chain-level cache to avoid creating multiple contract instances.
@@ -29,7 +29,7 @@ export interface LatestUpdate {
29
29
  export declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeedRegisterHooks> {
30
30
  #private;
31
31
  readonly logger?: ILogger;
32
- readonly redstoneUpdater: RedstoneUpdater;
32
+ readonly updaters: IPriceUpdater[];
33
33
  constructor(sdk: GearboxSDK, opts?: PriceFeedRegisterOptions);
34
34
  addHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
35
35
  removeHook: <K extends "updatesGenerated">(hookName: K, fn: (...args: PriceFeedRegisterHooks[K]) => void | Promise<void>) => void;
@@ -1,14 +1,228 @@
1
- import type { Address } from "viem";
1
+ import type { Address, Hex } from "viem";
2
2
  import type { GearboxSDK } from "../../GearboxSDK.js";
3
+ import type { RawTx } from "../../types/index.js";
3
4
  import type { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
4
5
  import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
5
- declare const abi: readonly [];
6
+ import type { IUpdatablePriceFeedContract } from "./types.js";
7
+ declare const abi: readonly [{
8
+ readonly type: "constructor";
9
+ readonly inputs: readonly [{
10
+ readonly name: "_token";
11
+ readonly type: "address";
12
+ readonly internalType: "address";
13
+ }, {
14
+ readonly name: "_priceFeedId";
15
+ readonly type: "bytes32";
16
+ readonly internalType: "bytes32";
17
+ }, {
18
+ readonly name: "_pyth";
19
+ readonly type: "address";
20
+ readonly internalType: "address";
21
+ }, {
22
+ readonly name: "_maxConfToPriceRatio";
23
+ readonly type: "uint256";
24
+ readonly internalType: "uint256";
25
+ }, {
26
+ readonly name: "descriptionTicker";
27
+ readonly type: "string";
28
+ readonly internalType: "string";
29
+ }];
30
+ readonly stateMutability: "nonpayable";
31
+ }, {
32
+ readonly type: "receive";
33
+ readonly stateMutability: "payable";
34
+ }, {
35
+ readonly type: "function";
36
+ readonly name: "contractType";
37
+ readonly inputs: readonly [];
38
+ readonly outputs: readonly [{
39
+ readonly name: "";
40
+ readonly type: "bytes32";
41
+ readonly internalType: "bytes32";
42
+ }];
43
+ readonly stateMutability: "view";
44
+ }, {
45
+ readonly type: "function";
46
+ readonly name: "decimals";
47
+ readonly inputs: readonly [];
48
+ readonly outputs: readonly [{
49
+ readonly name: "";
50
+ readonly type: "uint8";
51
+ readonly internalType: "uint8";
52
+ }];
53
+ readonly stateMutability: "view";
54
+ }, {
55
+ readonly type: "function";
56
+ readonly name: "description";
57
+ readonly inputs: readonly [];
58
+ readonly outputs: readonly [{
59
+ readonly name: "";
60
+ readonly type: "string";
61
+ readonly internalType: "string";
62
+ }];
63
+ readonly stateMutability: "view";
64
+ }, {
65
+ readonly type: "function";
66
+ readonly name: "latestRoundData";
67
+ readonly inputs: readonly [];
68
+ readonly outputs: readonly [{
69
+ readonly name: "";
70
+ readonly type: "uint80";
71
+ readonly internalType: "uint80";
72
+ }, {
73
+ readonly name: "";
74
+ readonly type: "int256";
75
+ readonly internalType: "int256";
76
+ }, {
77
+ readonly name: "";
78
+ readonly type: "uint256";
79
+ readonly internalType: "uint256";
80
+ }, {
81
+ readonly name: "";
82
+ readonly type: "uint256";
83
+ readonly internalType: "uint256";
84
+ }, {
85
+ readonly name: "";
86
+ readonly type: "uint80";
87
+ readonly internalType: "uint80";
88
+ }];
89
+ readonly stateMutability: "view";
90
+ }, {
91
+ readonly type: "function";
92
+ readonly name: "maxConfToPriceRatio";
93
+ readonly inputs: readonly [];
94
+ readonly outputs: readonly [{
95
+ readonly name: "";
96
+ readonly type: "uint256";
97
+ readonly internalType: "uint256";
98
+ }];
99
+ readonly stateMutability: "view";
100
+ }, {
101
+ readonly type: "function";
102
+ readonly name: "priceFeedId";
103
+ readonly inputs: readonly [];
104
+ readonly outputs: readonly [{
105
+ readonly name: "";
106
+ readonly type: "bytes32";
107
+ readonly internalType: "bytes32";
108
+ }];
109
+ readonly stateMutability: "view";
110
+ }, {
111
+ readonly type: "function";
112
+ readonly name: "pyth";
113
+ readonly inputs: readonly [];
114
+ readonly outputs: readonly [{
115
+ readonly name: "";
116
+ readonly type: "address";
117
+ readonly internalType: "address";
118
+ }];
119
+ readonly stateMutability: "view";
120
+ }, {
121
+ readonly type: "function";
122
+ readonly name: "serialize";
123
+ readonly inputs: readonly [];
124
+ readonly outputs: readonly [{
125
+ readonly name: "";
126
+ readonly type: "bytes";
127
+ readonly internalType: "bytes";
128
+ }];
129
+ readonly stateMutability: "view";
130
+ }, {
131
+ readonly type: "function";
132
+ readonly name: "skipPriceCheck";
133
+ readonly inputs: readonly [];
134
+ readonly outputs: readonly [{
135
+ readonly name: "";
136
+ readonly type: "bool";
137
+ readonly internalType: "bool";
138
+ }];
139
+ readonly stateMutability: "view";
140
+ }, {
141
+ readonly type: "function";
142
+ readonly name: "token";
143
+ readonly inputs: readonly [];
144
+ readonly outputs: readonly [{
145
+ readonly name: "";
146
+ readonly type: "address";
147
+ readonly internalType: "address";
148
+ }];
149
+ readonly stateMutability: "view";
150
+ }, {
151
+ readonly type: "function";
152
+ readonly name: "updatable";
153
+ readonly inputs: readonly [];
154
+ readonly outputs: readonly [{
155
+ readonly name: "";
156
+ readonly type: "bool";
157
+ readonly internalType: "bool";
158
+ }];
159
+ readonly stateMutability: "view";
160
+ }, {
161
+ readonly type: "function";
162
+ readonly name: "updatePrice";
163
+ readonly inputs: readonly [{
164
+ readonly name: "data";
165
+ readonly type: "bytes";
166
+ readonly internalType: "bytes";
167
+ }];
168
+ readonly outputs: readonly [];
169
+ readonly stateMutability: "nonpayable";
170
+ }, {
171
+ readonly type: "function";
172
+ readonly name: "version";
173
+ readonly inputs: readonly [];
174
+ readonly outputs: readonly [{
175
+ readonly name: "";
176
+ readonly type: "uint256";
177
+ readonly internalType: "uint256";
178
+ }];
179
+ readonly stateMutability: "view";
180
+ }, {
181
+ readonly type: "event";
182
+ readonly name: "UpdatePrice";
183
+ readonly inputs: readonly [{
184
+ readonly name: "price";
185
+ readonly type: "uint256";
186
+ readonly indexed: false;
187
+ readonly internalType: "uint256";
188
+ }];
189
+ readonly anonymous: false;
190
+ }, {
191
+ readonly type: "error";
192
+ readonly name: "ConfToPriceRatioTooHighException";
193
+ readonly inputs: readonly [];
194
+ }, {
195
+ readonly type: "error";
196
+ readonly name: "IncorrectExpectedPublishTimestampException";
197
+ readonly inputs: readonly [];
198
+ }, {
199
+ readonly type: "error";
200
+ readonly name: "IncorrectParameterException";
201
+ readonly inputs: readonly [];
202
+ }, {
203
+ readonly type: "error";
204
+ readonly name: "IncorrectPriceDecimalsException";
205
+ readonly inputs: readonly [];
206
+ }, {
207
+ readonly type: "error";
208
+ readonly name: "IncorrectPriceException";
209
+ readonly inputs: readonly [];
210
+ }, {
211
+ readonly type: "error";
212
+ readonly name: "PriceTimestampTooFarAheadException";
213
+ readonly inputs: readonly [];
214
+ }, {
215
+ readonly type: "error";
216
+ readonly name: "PriceTimestampTooFarBehindException";
217
+ readonly inputs: readonly [];
218
+ }];
6
219
  type abi = typeof abi;
7
- export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> {
220
+ export declare class PythPriceFeed extends AbstractPriceFeedContract<abi> implements IUpdatablePriceFeedContract {
8
221
  readonly token: Address;
9
- readonly priceFeedId: Address;
222
+ readonly priceFeedId: Hex;
10
223
  readonly pyth: Address;
11
224
  readonly maxConfToPriceRatio?: bigint;
12
225
  constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
226
+ createPriceUpdateTx(data: `0x${string}`): RawTx;
13
227
  }
14
228
  export {};
@@ -1,12 +1,12 @@
1
1
  import type { Address, Hex } from "viem";
2
2
  import { redstonePriceFeedAbi } from "../../abi/index.js";
3
3
  import type { GearboxSDK } from "../../GearboxSDK.js";
4
- import type { RedstonePriceFeedStateHuman } from "../../types/index.js";
4
+ import type { RawTx, RedstonePriceFeedStateHuman } from "../../types/index.js";
5
5
  import type { PartialPriceFeedTreeNode } from "./AbstractPriceFeed.js";
6
6
  import { AbstractPriceFeedContract } from "./AbstractPriceFeed.js";
7
- import type { IPriceFeedContract } from "./types.js";
7
+ import type { IUpdatablePriceFeedContract } from "./types.js";
8
8
  type abi = typeof redstonePriceFeedAbi;
9
- export declare class RedstonePriceFeedContract extends AbstractPriceFeedContract<abi> {
9
+ export declare class RedstonePriceFeedContract extends AbstractPriceFeedContract<abi> implements IUpdatablePriceFeedContract {
10
10
  readonly token: Address;
11
11
  readonly dataServiceId: string;
12
12
  readonly dataId: string;
@@ -16,6 +16,6 @@ export declare class RedstonePriceFeedContract extends AbstractPriceFeedContract
16
16
  readonly lastPayloadTimestamp: number;
17
17
  constructor(sdk: GearboxSDK, args: PartialPriceFeedTreeNode);
18
18
  stateHuman(raw?: boolean): Omit<RedstonePriceFeedStateHuman, "stalenessPeriod">;
19
+ createPriceUpdateTx(data: `0x${string}`): RawTx;
19
20
  }
20
- export declare function isRedstone(pf: IPriceFeedContract): pf is RedstonePriceFeedContract;
21
21
  export {};
@@ -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 "./isUpdatablePriceFeed.js";
11
12
  export * from "./MellowLRTPriceFeed.js";
12
13
  export * from "./PendleTWAPPTPriceFeed.js";
13
14
  export * from "./PriceFeedRef.js";
@@ -0,0 +1,2 @@
1
+ import type { IPriceFeedContract, IUpdatablePriceFeedContract } from "./types.js";
2
+ export declare function isUpdatablePriceFeed(pf: IPriceFeedContract): pf is IUpdatablePriceFeedContract;
@@ -1,6 +1,6 @@
1
1
  import type { UnionOmit } from "viem";
2
2
  import type { IBaseContract } from "../../base/index.js";
3
- import type { IPriceUpdateTx, PriceFeedStateHuman } from "../../types/index.js";
3
+ import type { IPriceUpdateTx, PriceFeedStateHuman, RawTx } from "../../types/index.js";
4
4
  import type { PriceFeedRef } from "./PriceFeedRef.js";
5
5
  export type PriceFeedUsageType = "Main" | "Reserve";
6
6
  export type PriceFeedContractTypeLegacy = "PF_BALANCER_STABLE_LP_ORACLE" | "PF_BALANCER_WEIGHTED_LP_ORACLE" | "PF_BOUNDED_ORACLE" | "PF_CHAINLINK_ORACLE" | "PF_COMPOSITE_ORACLE" | "PF_CURVE_CRYPTO_LP_ORACLE" | "PF_CURVE_STABLE_LP_ORACLE" | "PF_CURVE_USD_ORACLE" | "PF_ERC4626_ORACLE" | "PF_MELLOW_LRT_ORACLE" | "PF_PENDLE_PT_TWAP_ORACLE" | "PF_PYTH_ORACLE" | "PF_REDSTONE_ORACLE" | "PF_WSTETH_ORACLE" | "PF_YEARN_ORACLE" | "PF_ZERO_ORACLE";
@@ -27,7 +27,10 @@ export interface IPriceFeedContract extends IBaseContract {
27
27
  * Returns all updatable depenedencies (uderlying price feeds) of this price feed, including price feed itself, if it's updatable
28
28
  * @returns
29
29
  */
30
- updatableDependencies: () => IPriceFeedContract[];
30
+ updatableDependencies: () => IUpdatablePriceFeedContract[];
31
+ }
32
+ export interface IUpdatablePriceFeedContract extends IPriceFeedContract {
33
+ createPriceUpdateTx: (data: `0x${string}`) => RawTx;
31
34
  }
32
35
  export interface ILPPriceFeedContract extends IPriceFeedContract {
33
36
  getValue: () => Promise<bigint>;
@@ -0,0 +1,10 @@
1
+ import type { IPriceUpdateTx, RawTx } from "../../../types/index.js";
2
+ import type { IPriceUpdateTask } from "./types.js";
3
+ export declare abstract class PriceUpdateTx<T extends IPriceUpdateTask = IPriceUpdateTask> implements IPriceUpdateTx<T> {
4
+ readonly raw: RawTx;
5
+ readonly data: T;
6
+ abstract readonly name: string;
7
+ constructor(raw: RawTx, data: T);
8
+ get pretty(): string;
9
+ validateTimestamp(blockTimestamp: bigint): "valid" | "too old" | "in future";
10
+ }