@gearbox-protocol/sdk 8.0.3 → 8.1.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 (52) 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/chain/chains.js +2 -2
  4. package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +2 -1
  5. package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +17 -23
  6. package/dist/cjs/sdk/market/pricefeeds/PythPriceFeed.js +9 -1
  7. package/dist/cjs/sdk/market/pricefeeds/RedstonePriceFeed.js +9 -7
  8. package/dist/cjs/sdk/market/pricefeeds/index.js +2 -0
  9. package/dist/cjs/sdk/market/pricefeeds/isUpdatablePriceFeed.js +30 -0
  10. package/dist/cjs/sdk/market/pricefeeds/updates/PriceUpdateTx.js +52 -0
  11. package/dist/cjs/sdk/market/pricefeeds/{RedstoneCache.js → updates/PriceUpdatesCache.js} +12 -12
  12. package/dist/cjs/sdk/market/pricefeeds/updates/PythUpdater.js +175 -0
  13. package/dist/cjs/sdk/market/pricefeeds/{RedstoneUpdater.js → updates/RedstoneUpdater.js} +21 -45
  14. package/dist/cjs/sdk/market/pricefeeds/updates/index.js +31 -0
  15. package/dist/cjs/sdk/market/pricefeeds/updates/types.js +16 -0
  16. package/dist/cjs/sdk/utils/retry.js +4 -2
  17. package/dist/esm/sdk/GearboxSDK.js +20 -8
  18. package/dist/esm/sdk/abi/oracles.js +140 -0
  19. package/dist/esm/sdk/chain/chains.js +2 -2
  20. package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +2 -1
  21. package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +18 -24
  22. package/dist/esm/sdk/market/pricefeeds/PythPriceFeed.js +9 -1
  23. package/dist/esm/sdk/market/pricefeeds/RedstonePriceFeed.js +8 -5
  24. package/dist/esm/sdk/market/pricefeeds/index.js +1 -0
  25. package/dist/esm/sdk/market/pricefeeds/isUpdatablePriceFeed.js +6 -0
  26. package/dist/esm/sdk/market/pricefeeds/updates/PriceUpdateTx.js +28 -0
  27. package/dist/esm/sdk/market/pricefeeds/{RedstoneCache.js → updates/PriceUpdatesCache.js} +8 -8
  28. package/dist/esm/sdk/market/pricefeeds/updates/PythUpdater.js +151 -0
  29. package/dist/esm/sdk/market/pricefeeds/{RedstoneUpdater.js → updates/RedstoneUpdater.js} +21 -44
  30. package/dist/esm/sdk/market/pricefeeds/updates/index.js +6 -0
  31. package/dist/esm/sdk/market/pricefeeds/updates/types.js +0 -0
  32. package/dist/esm/sdk/utils/retry.js +4 -2
  33. package/dist/types/sdk/GearboxSDK.d.ts +5 -1
  34. package/dist/types/sdk/abi/oracles.d.ts +212 -0
  35. package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +2 -2
  36. package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +4 -4
  37. package/dist/types/sdk/market/pricefeeds/PythPriceFeed.d.ts +218 -4
  38. package/dist/types/sdk/market/pricefeeds/RedstonePriceFeed.d.ts +4 -4
  39. package/dist/types/sdk/market/pricefeeds/index.d.ts +1 -0
  40. package/dist/types/sdk/market/pricefeeds/isUpdatablePriceFeed.d.ts +2 -0
  41. package/dist/types/sdk/market/pricefeeds/types.d.ts +5 -2
  42. package/dist/types/sdk/market/pricefeeds/updates/PriceUpdateTx.d.ts +10 -0
  43. package/dist/types/sdk/market/pricefeeds/updates/PriceUpdatesCache.d.ts +17 -0
  44. package/dist/types/sdk/market/pricefeeds/updates/PythUpdater.d.ts +40 -0
  45. package/dist/types/sdk/market/pricefeeds/{RedstoneUpdater.d.ts → updates/RedstoneUpdater.d.ts} +11 -18
  46. package/dist/types/sdk/market/pricefeeds/updates/RedstoneUpdater.test.d.ts +1 -0
  47. package/dist/types/sdk/market/pricefeeds/updates/index.d.ts +3 -0
  48. package/dist/types/sdk/market/pricefeeds/updates/types.d.ts +21 -0
  49. package/dist/types/sdk/sdk-legacy/core/creditAccount.d.ts +2 -2
  50. package/dist/types/sdk/utils/retry.d.ts +1 -0
  51. package/package.json +1 -1
  52. 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
+ }
@@ -134,8 +134,8 @@ export declare class CreditAccountData_Legacy {
134
134
  constructor(payload: CreditAccountDataPayload);
135
135
  static sortBalances(balances: Record<Address, bigint>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): Array<[Address, bigint]>;
136
136
  static sortAssets<T extends Asset>(balances: Array<T>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): T[];
137
- static assetComparator<T extends Asset>(t1: T, t2: T, prices1: Record<Address, bigint> | undefined, prices2: Record<Address, bigint> | undefined, tokens1: Record<Address, TokenData> | undefined, tokens2: Record<Address, TokenData> | undefined): 1 | -1 | 0;
138
- static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1 | 0;
137
+ static assetComparator<T extends Asset>(t1: T, t2: T, prices1: Record<Address, bigint> | undefined, prices2: Record<Address, bigint> | undefined, tokens1: Record<Address, TokenData> | undefined, tokens2: Record<Address, TokenData> | undefined): 1 | 0 | -1;
138
+ static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | 0 | -1;
139
139
  static amountAbcComparator(t1: bigint, t2: bigint): 1 | -1;
140
140
  isForbidden(token: Address): boolean;
141
141
  isQuoted(token: Address): boolean;
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.0.3",
3
+ "version": "8.1.0-next.1",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -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
- }