@gearbox-protocol/sdk 9.8.1 → 9.8.3

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.
@@ -231,7 +231,7 @@ class PriceOracleBaseContract extends import_base.BaseContract {
231
231
  }
232
232
  for (const node of tree) {
233
233
  this.#priceFeedTree.upsert(node.baseParams.addr, node);
234
- this.sdk.priceFeeds.getOrCreate(node);
234
+ this.sdk.priceFeeds.upsert(node);
235
235
  }
236
236
  for (const entry of entries) {
237
237
  const { token, priceFeed, reserve, stalenessPeriod } = entry;
@@ -101,6 +101,12 @@ class AbstractPriceFeedContract extends import_base.BaseContract {
101
101
  }
102
102
  return this.#answer;
103
103
  }
104
+ updateAnswer(answer) {
105
+ if (this.#answer === void 0) {
106
+ throw new PartialPriceFeedInitError(this.#args);
107
+ }
108
+ this.#answer = answer;
109
+ }
104
110
  get priceFeedType() {
105
111
  return this.contractType;
106
112
  }
@@ -196,9 +196,10 @@ class PriceFeedRegister extends import_base.SDKConstruct {
196
196
  mustGet(address) {
197
197
  return this.#feeds.mustGet(address);
198
198
  }
199
- getOrCreate(data) {
199
+ upsert(data) {
200
200
  const existing = this.#feeds.get(data.baseParams.addr);
201
201
  if (existing?.loaded) {
202
+ existing.updateAnswer(data.answer);
202
203
  return existing;
203
204
  }
204
205
  const feed = this.create(data);
@@ -42,6 +42,7 @@ const HUMAN_READABLE_TITLES = {
42
42
  PT_uptBTC_14AUG2025: "pt.uptBTC(14.08.25)",
43
43
  PT_sUSDX_1SEP2025: "pt.sUSDX(1.09.25)",
44
44
  PT_sUSDf_25SEP2025: "pt.sUSDf(25.09.25)",
45
+ ["PT-sUSDf-29JAN2026"]: "pt.sUSDf(29.01.26)",
45
46
  PT_USDf_29JAN2026: "pt.USDf(29.01.26)",
46
47
  stkcvxllamathena_v3_1: "stkcvxllamathena",
47
48
  stkcvxRLUSDUSDC_v3_1: "stkcvxRLUSDUSDC",
@@ -202,7 +202,7 @@ class PriceOracleBaseContract extends BaseContract {
202
202
  }
203
203
  for (const node of tree) {
204
204
  this.#priceFeedTree.upsert(node.baseParams.addr, node);
205
- this.sdk.priceFeeds.getOrCreate(node);
205
+ this.sdk.priceFeeds.upsert(node);
206
206
  }
207
207
  for (const entry of entries) {
208
208
  const { token, priceFeed, reserve, stalenessPeriod } = entry;
@@ -77,6 +77,12 @@ class AbstractPriceFeedContract extends BaseContract {
77
77
  }
78
78
  return this.#answer;
79
79
  }
80
+ updateAnswer(answer) {
81
+ if (this.#answer === void 0) {
82
+ throw new PartialPriceFeedInitError(this.#args);
83
+ }
84
+ this.#answer = answer;
85
+ }
80
86
  get priceFeedType() {
81
87
  return this.contractType;
82
88
  }
@@ -185,9 +185,10 @@ class PriceFeedRegister extends SDKConstruct {
185
185
  mustGet(address) {
186
186
  return this.#feeds.mustGet(address);
187
187
  }
188
- getOrCreate(data) {
188
+ upsert(data) {
189
189
  const existing = this.#feeds.get(data.baseParams.addr);
190
190
  if (existing?.loaded) {
191
+ existing.updateAnswer(data.answer);
191
192
  return existing;
192
193
  }
193
194
  const feed = this.create(data);
@@ -19,6 +19,7 @@ const HUMAN_READABLE_TITLES = {
19
19
  PT_uptBTC_14AUG2025: "pt.uptBTC(14.08.25)",
20
20
  PT_sUSDX_1SEP2025: "pt.sUSDX(1.09.25)",
21
21
  PT_sUSDf_25SEP2025: "pt.sUSDf(25.09.25)",
22
+ ["PT-sUSDf-29JAN2026"]: "pt.sUSDf(29.01.26)",
22
23
  PT_USDf_29JAN2026: "pt.USDf(29.01.26)",
23
24
  stkcvxllamathena_v3_1: "stkcvxllamathena",
24
25
  stkcvxRLUSDUSDC_v3_1: "stkcvxRLUSDUSDC",
@@ -25,6 +25,7 @@ export declare abstract class AbstractPriceFeedContract<const abi extends Abi |
25
25
  get skipCheck(): boolean;
26
26
  get underlyingPriceFeeds(): readonly PriceFeedRef[];
27
27
  get answer(): PriceFeedAnswer;
28
+ updateAnswer(answer: PriceFeedAnswer): void;
28
29
  get priceFeedType(): PriceFeedContractType;
29
30
  stateHuman(raw?: boolean): UnionOmit<PriceFeedStateHuman, "stalenessPeriod">;
30
31
  updatableDependencies(): IUpdatablePriceFeedContract[];
@@ -97,7 +97,7 @@ export declare class PriceFeedRegister extends SDKConstruct implements IHooks<Pr
97
97
  }): Promise<PriceUpdateV310[]>;
98
98
  has(address: Address): boolean;
99
99
  mustGet(address: Address): IPriceFeedContract;
100
- getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
100
+ upsert(data: PriceFeedTreeNode): IPriceFeedContract;
101
101
  /**
102
102
  * Loads PARTIAL information about all updatable price feeds from MarketCompressor
103
103
  * Discovered price feeds are not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
@@ -24,6 +24,7 @@ export interface IPriceFeedContract extends IBaseContract {
24
24
  readonly answer: PriceFeedAnswer;
25
25
  readonly skipCheck: boolean;
26
26
  readonly underlyingPriceFeeds: readonly PriceFeedRef[];
27
+ updateAnswer: (answer: PriceFeedAnswer) => void;
27
28
  stateHuman: (raw?: boolean) => UnionOmit<PriceFeedStateHuman, "stalenessPeriod">;
28
29
  /**
29
30
  * Returns all updatable depenedencies (uderlying price feeds) of this price feed, including price feed itself, if it's updatable
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "9.8.1",
3
+ "version": "9.8.3",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -61,7 +61,7 @@
61
61
  "date-fns": "^4.1.0",
62
62
  "decimal.js-light": "^2.5.1",
63
63
  "viem": ">=2.23.15 <3.0.0",
64
- "zod": "^4.1.9"
64
+ "zod": "^4.1.11"
65
65
  },
66
66
  "devDependencies": {
67
67
  "@biomejs/biome": "^2.2.4",
@@ -72,8 +72,8 @@
72
72
  "axios": "^1.12.2",
73
73
  "cross-spawn": "^7.0.6",
74
74
  "husky": "^9.1.7",
75
- "lint-staged": "^16.1.6",
76
- "pino": "^9.10.0",
75
+ "lint-staged": "^16.2.0",
76
+ "pino": "^9.11.0",
77
77
  "pino-pretty": "^13.1.1",
78
78
  "tsup": "^8.5.0",
79
79
  "tsx": "^4.20.5",