@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
@@ -0,0 +1,17 @@
1
+ import type { TimestampedCalldata } from "./types.js";
2
+ export interface PriceUpdatesCacheOptions {
3
+ /**
4
+ * Assume that in historical mode we only need to fetch once and then reuse from cache forever
5
+ */
6
+ historical: boolean;
7
+ /**
8
+ * TTL in milliseconds
9
+ */
10
+ ttl: number;
11
+ }
12
+ export declare class PriceUpdatesCache {
13
+ #private;
14
+ constructor(opts: PriceUpdatesCacheOptions);
15
+ get(...path: Array<number | string>): Omit<TimestampedCalldata, "cached"> | undefined;
16
+ set(value: Omit<TimestampedCalldata, "cached">, ...path: Array<number | string>): void;
17
+ }
@@ -0,0 +1,40 @@
1
+ import { SDKConstruct } from "../../../base/index.js";
2
+ import type { GearboxSDK } from "../../../GearboxSDK.js";
3
+ import type { IPriceFeedContract } from "../types.js";
4
+ import { PriceUpdateTx } from "./PriceUpdateTx.js";
5
+ import type { IPriceUpdater, IPriceUpdateTask } from "./types.js";
6
+ export type PythUpdateTask = IPriceUpdateTask;
7
+ declare class PythUpdateTx extends PriceUpdateTx<PythUpdateTask> {
8
+ readonly name = "pyth";
9
+ }
10
+ export interface PythOptions {
11
+ /**
12
+ * Fixed pyth historic timestamp in seconds
13
+ * Set to true to enable pyth historical mode using timestamp from attach block
14
+ */
15
+ historicTimestamp?: number | true;
16
+ /**
17
+ * Override Hermes API with this proxy. Can be used to set caching proxies, to avoid rate limiting
18
+ */
19
+ apiProxy?: string;
20
+ /**
21
+ * TTL for pyth cache in milliseconds
22
+ * If 0, disables caching
23
+ * If not set, uses some default value
24
+ * Cache is always enabled in historical mode
25
+ */
26
+ cacheTTL?: number;
27
+ /**
28
+ * When true, no error will be thrown when pyth is unable to fetch data for some feeds
29
+ */
30
+ ignoreMissingFeeds?: boolean;
31
+ }
32
+ /**
33
+ * Class to update multiple pyth price feeds at once
34
+ */
35
+ export declare class PythUpdater extends SDKConstruct implements IPriceUpdater<PythUpdateTask> {
36
+ #private;
37
+ constructor(sdk: GearboxSDK, opts?: PythOptions);
38
+ getUpdateTxs(feeds: IPriceFeedContract[], logContext?: Record<string, any>): Promise<PythUpdateTx[]>;
39
+ }
40
+ export {};
@@ -1,21 +1,13 @@
1
- import type { Address } from "viem";
2
- import { SDKConstruct } from "../../base/index.js";
3
- import type { GearboxSDK } from "../../GearboxSDK.js";
4
- import type { IPriceUpdateTx, RawTx } from "../../types/index.js";
5
- import type { RedstonePriceFeedContract } from "./RedstonePriceFeed.js";
6
- export interface RedstoneUpdateTask {
7
- dataFeedId: string;
1
+ import { SDKConstruct } from "../../../base/index.js";
2
+ import type { GearboxSDK } from "../../../GearboxSDK.js";
3
+ import type { IPriceFeedContract } from "../types.js";
4
+ import { PriceUpdateTx } from "./PriceUpdateTx.js";
5
+ import type { IPriceUpdater, IPriceUpdateTask } from "./types.js";
6
+ interface RedstoneUpdateTask extends IPriceUpdateTask {
8
7
  dataServiceId: string;
9
- priceFeed: Address;
10
- timestamp: number;
11
- cached: boolean;
12
8
  }
13
- export declare class RedstoneUpdateTx implements IPriceUpdateTx<RedstoneUpdateTask> {
14
- readonly raw: RawTx;
15
- readonly data: RedstoneUpdateTask;
16
- constructor(raw: RawTx, data: RedstoneUpdateTask);
17
- get pretty(): string;
18
- validateTimestamp(blockTimestamp: bigint): "valid" | "too old" | "in future";
9
+ declare class RedstoneUpdateTx extends PriceUpdateTx<RedstoneUpdateTask> {
10
+ readonly name = "redstone";
19
11
  }
20
12
  export interface RedstoneOptions {
21
13
  /**
@@ -46,8 +38,9 @@ export interface RedstoneOptions {
46
38
  /**
47
39
  * Class to update multiple redstone price feeds at once
48
40
  */
49
- export declare class RedstoneUpdater extends SDKConstruct {
41
+ export declare class RedstoneUpdater extends SDKConstruct implements IPriceUpdater<RedstoneUpdateTask> {
50
42
  #private;
51
43
  constructor(sdk: GearboxSDK, opts?: RedstoneOptions);
52
- getUpdateTxs(feeds: RedstonePriceFeedContract[], logContext?: Record<string, any>): Promise<RedstoneUpdateTx[]>;
44
+ getUpdateTxs(feeds: IPriceFeedContract[], logContext?: Record<string, any>): Promise<RedstoneUpdateTx[]>;
53
45
  }
46
+ export {};
@@ -0,0 +1,3 @@
1
+ export { type PythOptions, PythUpdater } from "./PythUpdater.js";
2
+ export { type RedstoneOptions, RedstoneUpdater } from "./RedstoneUpdater.js";
3
+ export type * from "./types.js";
@@ -0,0 +1,21 @@
1
+ import type { Address } from "viem";
2
+ import type { IPriceUpdateTx } from "../../../types/index.js";
3
+ import type { IPriceFeedContract } from "../types.js";
4
+ export interface IPriceUpdateTask {
5
+ dataFeedId: string;
6
+ priceFeed: Address;
7
+ timestamp: number;
8
+ cached: boolean;
9
+ }
10
+ export interface IPriceUpdater<T extends IPriceUpdateTask = IPriceUpdateTask> {
11
+ getUpdateTxs: (feeds: IPriceFeedContract[], logContext?: Record<string, any>) => Promise<IPriceUpdateTx<T>[]>;
12
+ }
13
+ export interface TimestampedCalldata {
14
+ dataFeedId: string;
15
+ data: `0x${string}`;
16
+ /**
17
+ * This timestamp is in seconds
18
+ */
19
+ timestamp: number;
20
+ cached: boolean;
21
+ }
@@ -1,5 +1,6 @@
1
1
  export interface RetryOptions {
2
2
  attempts?: number;
3
3
  interval?: number;
4
+ exponent?: number;
4
5
  }
5
6
  export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
@@ -1,2 +1,2 @@
1
1
  import type { CallParameters } from "viem";
2
- export declare function generateCastTraceCall(params: CallParameters): string;
2
+ export declare function generateCastTraceCall(params: CallParameters, rpcUrl?: string): string;
@@ -2,7 +2,7 @@ import type { AbiStateMutability, Address, CallParameters, Chain, Client, Contra
2
2
  export type SimulateMulticallParameters<contracts extends readonly unknown[] = readonly ContractFunctionParameters[], allowFailure extends boolean = true, options extends {
3
3
  optional?: boolean;
4
4
  properties?: Record<string, any>;
5
- } = {}> = Pick<CallParameters, "blockNumber" | "blockTag" | "gas" | "account"> & {
5
+ } = {}> = Pick<CallParameters, "blockNumber" | "blockTag" | "gas" | "account" | "value"> & {
6
6
  allowFailure?: allowFailure | boolean | undefined;
7
7
  contracts: MulticallContracts<Narrow<contracts>, {
8
8
  mutability: AbiStateMutability;
@@ -38,5 +38,5 @@ export declare class SimulateWithPriceUpdatesError extends BaseError {
38
38
  cause?: Error;
39
39
  readonly timestamp?: bigint;
40
40
  constructor(cause: Error | undefined, params: SimulateWithPriceUpdatesErrorParams);
41
- getCastTraceCall(): string;
41
+ getCastTraceCall(rpcUrl?: string): string;
42
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.1.6",
3
+ "version": "8.2.0-next.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -55,9 +55,12 @@
55
55
  "typecheck:ci": "tsc --noEmit"
56
56
  },
57
57
  "dependencies": {
58
+ "@pythnetwork/price-service-sdk": "^1.8.0",
58
59
  "@redstone-finance/evm-connector": "^0.7.5",
59
60
  "@redstone-finance/protocol": "^0.7.5",
61
+ "@types/bn.js": "^5.2.0",
60
62
  "abitype": "^1.0.8",
63
+ "bn.js": "^5.2.2",
61
64
  "date-fns": "^4.1.0",
62
65
  "decimal.js-light": "^2.5.1",
63
66
  "keyv": "^5.3.3",
@@ -1,25 +0,0 @@
1
- export interface TimestampedCalldata {
2
- dataFeedId: string;
3
- data: `0x${string}`;
4
- /**
5
- * This timestamp is in seconds
6
- */
7
- timestamp: number;
8
- cached: boolean;
9
- }
10
- export interface RedstoneCacheOptions {
11
- /**
12
- * Assume that in historical mode we only need to fetch once and then reuse from cache forever
13
- */
14
- historical: boolean;
15
- /**
16
- * TTL in milliseconds
17
- */
18
- ttl: number;
19
- }
20
- export declare class RedstoneCache {
21
- #private;
22
- constructor(opts: RedstoneCacheOptions);
23
- get(dataServiceId: string, dataFeedId: string, uniqueSignersCount: number): Omit<TimestampedCalldata, "cached"> | undefined;
24
- set(dataServiceId: string, dataFeedId: string, uniqueSignersCount: number, value: Omit<TimestampedCalldata, "cached">): void;
25
- }