@gearbox-protocol/sdk 9.8.2 → 9.9.0
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.
- package/dist/cjs/sdk/chain/chains.js +3 -1
- package/dist/cjs/sdk/market/oracle/PriceOracleBaseContract.js +1 -1
- package/dist/cjs/sdk/market/pricefeeds/AbstractPriceFeed.js +6 -0
- package/dist/cjs/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -1
- package/dist/esm/sdk/chain/chains.js +3 -1
- package/dist/esm/sdk/market/oracle/PriceOracleBaseContract.js +1 -1
- package/dist/esm/sdk/market/pricefeeds/AbstractPriceFeed.js +6 -0
- package/dist/esm/sdk/market/pricefeeds/PriceFeedsRegister.js +2 -1
- package/dist/types/sdk/market/pricefeeds/AbstractPriceFeed.d.ts +1 -0
- package/dist/types/sdk/market/pricefeeds/PriceFeedsRegister.d.ts +1 -1
- package/dist/types/sdk/market/pricefeeds/types.d.ts +1 -0
- package/package.json +4 -4
|
@@ -291,7 +291,9 @@ const chains = {
|
|
|
291
291
|
Plasma: (0, import_viem.defineChain)({
|
|
292
292
|
...import_chains.plasma,
|
|
293
293
|
network: "Plasma",
|
|
294
|
-
defaultMarketConfigurators: {
|
|
294
|
+
defaultMarketConfigurators: {
|
|
295
|
+
"0x7a133fbd01736fd076158307c9476cc3877f1af5": "Invariant Group"
|
|
296
|
+
},
|
|
295
297
|
isPublic: true,
|
|
296
298
|
wellKnownToken: {
|
|
297
299
|
address: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
|
|
@@ -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.
|
|
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
|
-
|
|
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);
|
|
@@ -276,7 +276,9 @@ const chains = {
|
|
|
276
276
|
Plasma: defineChain({
|
|
277
277
|
...plasma,
|
|
278
278
|
network: "Plasma",
|
|
279
|
-
defaultMarketConfigurators: {
|
|
279
|
+
defaultMarketConfigurators: {
|
|
280
|
+
"0x7a133fbd01736fd076158307c9476cc3877f1af5": "Invariant Group"
|
|
281
|
+
},
|
|
280
282
|
isPublic: true,
|
|
281
283
|
wellKnownToken: {
|
|
282
284
|
address: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
|
|
@@ -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.
|
|
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
|
-
|
|
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);
|
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "9.9.0",
|
|
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.
|
|
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.
|
|
76
|
-
"pino": "^9.
|
|
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",
|