@gearbox-protocol/sdk 8.1.5 → 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 (58) hide show
  1. package/dist/cjs/sdk/GearboxSDK.js +20 -8
  2. package/dist/cjs/sdk/abi/oracles.js +141 -0
  3. package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +2 -1
  4. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +17 -23
  5. package/dist/cjs/sdk/market/pricefeeds/PythPriceFeed.js +9 -1
  6. package/dist/cjs/sdk/market/pricefeeds/RedstonePriceFeed.js +9 -7
  7. package/dist/cjs/sdk/market/pricefeeds/index.js +2 -0
  8. package/dist/cjs/sdk/market/pricefeeds/isUpdatablePriceFeed.js +30 -0
  9. package/dist/cjs/sdk/market/pricefeeds/updates/PriceUpdateTx.js +52 -0
  10. package/dist/cjs/sdk/market/pricefeeds/{RedstoneCache.js → updates/PriceUpdatesCache.js} +12 -12
  11. package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +189 -0
  12. package/dist/cjs/sdk/market/pricefeeds/{RedstoneUpdater.js → updates/RedstoneUpdater.js} +21 -45
  13. package/dist/cjs/sdk/market/pricefeeds/updates/index.js +31 -0
  14. package/dist/cjs/sdk/market/pricefeeds/updates/types.js +16 -0
  15. package/dist/cjs/sdk/utils/retry.js +4 -2
  16. package/dist/cjs/sdk/utils/viem/cast.js +5 -2
  17. package/dist/cjs/sdk/utils/viem/simulateMulticall.js +3 -1
  18. package/dist/cjs/sdk/utils/viem/simulateWithPriceUpdates.js +2 -2
  19. package/dist/esm/sdk/GearboxSDK.js +20 -8
  20. package/dist/esm/sdk/abi/oracles.js +140 -0
  21. package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +2 -1
  22. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +18 -24
  23. package/dist/esm/sdk/market/pricefeeds/PythPriceFeed.js +9 -1
  24. package/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js +8 -5
  25. package/dist/esm/sdk/market/pricefeeds/index.js +1 -0
  26. package/dist/esm/sdk/market/pricefeeds/isUpdatablePriceFeed.js +6 -0
  27. package/dist/esm/sdk/market/pricefeeds/updates/PriceUpdateTx.js +28 -0
  28. package/dist/esm/sdk/market/pricefeeds/{RedstoneCache.js → updates/PriceUpdatesCache.js} +8 -8
  29. package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +169 -0
  30. package/dist/esm/sdk/market/pricefeeds/{RedstoneUpdater.js → updates/RedstoneUpdater.js} +21 -44
  31. package/dist/esm/sdk/market/pricefeeds/updates/index.js +6 -0
  32. package/dist/esm/sdk/market/pricefeeds/updates/types.js +0 -0
  33. package/dist/esm/sdk/utils/retry.js +4 -2
  34. package/dist/esm/sdk/utils/viem/cast.js +5 -2
  35. package/dist/esm/sdk/utils/viem/simulateMulticall.js +3 -1
  36. package/dist/esm/sdk/utils/viem/simulateWithPriceUpdates.js +2 -2
  37. package/dist/types/sdk/GearboxSDK.d.ts +5 -1
  38. package/dist/types/sdk/abi/oracles.d.ts +212 -0
  39. package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +2 -2
  40. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +4 -4
  41. package/dist/types/sdk/market/pricefeeds/PythPriceFeed.d.ts +218 -4
  42. package/dist/types/sdk/market/pricefeeds/RedstonePriceFeed.d.ts +4 -4
  43. package/dist/types/sdk/market/pricefeeds/index.d.ts +1 -0
  44. package/dist/types/sdk/market/pricefeeds/isUpdatablePriceFeed.d.ts +2 -0
  45. package/dist/types/sdk/market/pricefeeds/types.d.ts +5 -2
  46. package/dist/types/sdk/market/pricefeeds/updates/PriceUpdateTx.d.ts +10 -0
  47. package/dist/types/sdk/market/pricefeeds/updates/PriceUpdatesCache.d.ts +17 -0
  48. package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +40 -0
  49. package/dist/types/sdk/market/pricefeeds/{RedstoneUpdater.d.ts → updates/RedstoneUpdater.d.ts} +11 -18
  50. package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.test.d.ts +1 -0
  51. package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +3 -0
  52. package/dist/types/sdk/market/pricefeeds/updates/types.d.ts +21 -0
  53. package/dist/types/sdk/utils/retry.d.ts +1 -0
  54. package/dist/types/sdk/utils/viem/cast.d.ts +1 -1
  55. package/dist/types/sdk/utils/viem/simulateMulticall.d.ts +1 -1
  56. package/dist/types/sdk/utils/viem/simulateWithPriceUpdates.d.ts +1 -1
  57. package/package.json +4 -1
  58. package/dist/types/sdk/market/pricefeeds/RedstoneCache.d.ts +0 -25
@@ -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.5",
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
- }