@gearbox-protocol/sdk 3.0.0-vfour.65 → 3.0.0-vfour.67
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/index.cjs +91 -83
- package/dist/cjs/sdk/index.d.ts +315 -6
- package/dist/esm/sdk/index.d.mts +315 -6
- package/dist/esm/sdk/index.mjs +92 -84
- package/package.json +1 -1
package/dist/cjs/sdk/index.cjs
CHANGED
|
@@ -19152,10 +19152,7 @@ var AddressMap = class {
|
|
|
19152
19152
|
this.#map = /* @__PURE__ */ new Map();
|
|
19153
19153
|
if (entries) {
|
|
19154
19154
|
for (const [address, value] of entries) {
|
|
19155
|
-
const key =
|
|
19156
|
-
if (!viem.isAddress(key)) {
|
|
19157
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19158
|
-
}
|
|
19155
|
+
const key = viem.getAddress(address);
|
|
19159
19156
|
this.#map.set(key, value);
|
|
19160
19157
|
}
|
|
19161
19158
|
}
|
|
@@ -19169,10 +19166,7 @@ var AddressMap = class {
|
|
|
19169
19166
|
if (this.#frozen) {
|
|
19170
19167
|
throw new Error(`AddressMap is frozen`);
|
|
19171
19168
|
}
|
|
19172
|
-
const key =
|
|
19173
|
-
if (!viem.isAddress(key)) {
|
|
19174
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19175
|
-
}
|
|
19169
|
+
const key = viem.getAddress(address);
|
|
19176
19170
|
this.#map.set(key, value);
|
|
19177
19171
|
}
|
|
19178
19172
|
/**
|
|
@@ -19184,10 +19178,7 @@ var AddressMap = class {
|
|
|
19184
19178
|
if (this.#frozen) {
|
|
19185
19179
|
throw new Error(`AddressMap is frozen`);
|
|
19186
19180
|
}
|
|
19187
|
-
const key =
|
|
19188
|
-
if (!viem.isAddress(key)) {
|
|
19189
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19190
|
-
}
|
|
19181
|
+
const key = viem.getAddress(address);
|
|
19191
19182
|
if (this.#map.has(key)) {
|
|
19192
19183
|
throw new Error(`address ${address} already exists`);
|
|
19193
19184
|
}
|
|
@@ -19199,10 +19190,7 @@ var AddressMap = class {
|
|
|
19199
19190
|
* @returns
|
|
19200
19191
|
*/
|
|
19201
19192
|
has(address) {
|
|
19202
|
-
const key =
|
|
19203
|
-
if (!viem.isAddress(key)) {
|
|
19204
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19205
|
-
}
|
|
19193
|
+
const key = viem.getAddress(address);
|
|
19206
19194
|
return this.#map.has(key);
|
|
19207
19195
|
}
|
|
19208
19196
|
/**
|
|
@@ -19211,10 +19199,7 @@ var AddressMap = class {
|
|
|
19211
19199
|
* @returns
|
|
19212
19200
|
*/
|
|
19213
19201
|
get(address) {
|
|
19214
|
-
const key =
|
|
19215
|
-
if (!viem.isAddress(key)) {
|
|
19216
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19217
|
-
}
|
|
19202
|
+
const key = viem.getAddress(address);
|
|
19218
19203
|
return this.#map.get(key);
|
|
19219
19204
|
}
|
|
19220
19205
|
/**
|
|
@@ -19229,6 +19214,9 @@ var AddressMap = class {
|
|
|
19229
19214
|
}
|
|
19230
19215
|
return v;
|
|
19231
19216
|
}
|
|
19217
|
+
clear() {
|
|
19218
|
+
this.#map.clear();
|
|
19219
|
+
}
|
|
19232
19220
|
entries() {
|
|
19233
19221
|
return Array.from(this.#map.entries());
|
|
19234
19222
|
}
|
|
@@ -21346,13 +21334,14 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
21346
21334
|
}
|
|
21347
21335
|
return result;
|
|
21348
21336
|
}
|
|
21349
|
-
get(address) {
|
|
21350
|
-
return this.#feeds.get(address);
|
|
21351
|
-
}
|
|
21352
21337
|
mustGet(address) {
|
|
21353
21338
|
return this.#feeds.mustGet(address);
|
|
21354
21339
|
}
|
|
21355
|
-
|
|
21340
|
+
getOrCreate(data) {
|
|
21341
|
+
const existing = this.#feeds.get(data.baseParams.addr);
|
|
21342
|
+
if (existing) {
|
|
21343
|
+
return existing;
|
|
21344
|
+
}
|
|
21356
21345
|
const feed = this.#create(data);
|
|
21357
21346
|
this.#feeds.upsert(data.baseParams.addr, feed);
|
|
21358
21347
|
return feed;
|
|
@@ -21425,11 +21414,11 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21425
21414
|
/**
|
|
21426
21415
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
21427
21416
|
*/
|
|
21428
|
-
mainPriceFeeds =
|
|
21417
|
+
mainPriceFeeds = new AddressMap();
|
|
21429
21418
|
/**
|
|
21430
21419
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
21431
21420
|
*/
|
|
21432
|
-
reservePriceFeeds =
|
|
21421
|
+
reservePriceFeeds = new AddressMap();
|
|
21433
21422
|
/**
|
|
21434
21423
|
* Mapping Token => Price in underlying
|
|
21435
21424
|
*/
|
|
@@ -21438,7 +21427,7 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21438
21427
|
* Mapping Token => Price in underlying
|
|
21439
21428
|
*/
|
|
21440
21429
|
reservePrices = new AddressMap();
|
|
21441
|
-
#priceFeedTree;
|
|
21430
|
+
#priceFeedTree = [];
|
|
21442
21431
|
constructor(sdk, data, underlying) {
|
|
21443
21432
|
super(sdk, {
|
|
21444
21433
|
...data.baseParams,
|
|
@@ -21447,32 +21436,7 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21447
21436
|
});
|
|
21448
21437
|
this.underlying = underlying;
|
|
21449
21438
|
const { priceFeedMapping, priceFeedStructure } = data;
|
|
21450
|
-
this.#
|
|
21451
|
-
for (const node of priceFeedStructure) {
|
|
21452
|
-
sdk.priceFeeds.create(node);
|
|
21453
|
-
}
|
|
21454
|
-
priceFeedMapping.forEach((node) => {
|
|
21455
|
-
const { token, priceFeed, reserve, stalenessPeriod } = node;
|
|
21456
|
-
const ref = new PriceFeedRef(sdk, priceFeed, stalenessPeriod);
|
|
21457
|
-
const price = this.#priceFeedTree.find(
|
|
21458
|
-
(n) => n.baseParams.addr === priceFeed
|
|
21459
|
-
)?.answer?.price;
|
|
21460
|
-
if (reserve) {
|
|
21461
|
-
this.reservePriceFeeds[token] = ref;
|
|
21462
|
-
if (price) {
|
|
21463
|
-
this.reservePrices.upsert(token, price);
|
|
21464
|
-
}
|
|
21465
|
-
} else {
|
|
21466
|
-
this.mainPriceFeeds[token] = ref;
|
|
21467
|
-
if (price) {
|
|
21468
|
-
this.mainPrices.upsert(token, price);
|
|
21469
|
-
}
|
|
21470
|
-
}
|
|
21471
|
-
this.#labelPriceFeed(priceFeed, reserve ? "Reserve" : "Main", token);
|
|
21472
|
-
});
|
|
21473
|
-
this.logger?.debug(
|
|
21474
|
-
`Got ${Object.keys(this.mainPriceFeeds).length} main and ${Object.keys(this.reservePriceFeeds).length} reserve price feeds`
|
|
21475
|
-
);
|
|
21439
|
+
this.#loadState(priceFeedMapping, priceFeedStructure);
|
|
21476
21440
|
}
|
|
21477
21441
|
processLog(log) {
|
|
21478
21442
|
switch (log.eventName) {
|
|
@@ -21496,8 +21460,8 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21496
21460
|
const main = opts?.main ?? true;
|
|
21497
21461
|
const reserve = opts?.reserve ?? true;
|
|
21498
21462
|
return tokens.flatMap((t) => [
|
|
21499
|
-
main ? this.mainPriceFeeds
|
|
21500
|
-
reserve ? this.reservePriceFeeds
|
|
21463
|
+
main ? this.mainPriceFeeds.get(t)?.priceFeed : void 0,
|
|
21464
|
+
reserve ? this.reservePriceFeeds.get(t)?.priceFeed : void 0
|
|
21501
21465
|
]).filter((f) => !!f);
|
|
21502
21466
|
}
|
|
21503
21467
|
/**
|
|
@@ -21579,6 +21543,65 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21579
21543
|
async updatePrices() {
|
|
21580
21544
|
await this.sdk.marketRegister.updatePrices([this.address]);
|
|
21581
21545
|
}
|
|
21546
|
+
syncStateMulticall() {
|
|
21547
|
+
const args = [this.address];
|
|
21548
|
+
if (this.version === 300) {
|
|
21549
|
+
args.push(
|
|
21550
|
+
Array.from(
|
|
21551
|
+
/* @__PURE__ */ new Set([
|
|
21552
|
+
this.underlying,
|
|
21553
|
+
...this.mainPriceFeeds.keys(),
|
|
21554
|
+
...this.reservePriceFeeds.keys()
|
|
21555
|
+
])
|
|
21556
|
+
)
|
|
21557
|
+
);
|
|
21558
|
+
}
|
|
21559
|
+
return {
|
|
21560
|
+
call: {
|
|
21561
|
+
abi: iPriceFeedCompressorAbi,
|
|
21562
|
+
address: this.sdk.addressProvider.getLatestVersion(
|
|
21563
|
+
AP_PRICE_FEED_COMPRESSOR
|
|
21564
|
+
),
|
|
21565
|
+
functionName: "getPriceFeeds",
|
|
21566
|
+
args
|
|
21567
|
+
},
|
|
21568
|
+
onResult: ([entries, tree]) => {
|
|
21569
|
+
this.#loadState(entries, tree);
|
|
21570
|
+
}
|
|
21571
|
+
};
|
|
21572
|
+
}
|
|
21573
|
+
#loadState(entries, tree) {
|
|
21574
|
+
this.#priceFeedTree = tree;
|
|
21575
|
+
this.mainPriceFeeds.clear();
|
|
21576
|
+
this.reservePriceFeeds.clear();
|
|
21577
|
+
this.mainPrices.clear();
|
|
21578
|
+
this.reservePrices.clear();
|
|
21579
|
+
for (const node of tree) {
|
|
21580
|
+
this.sdk.priceFeeds.getOrCreate(node);
|
|
21581
|
+
}
|
|
21582
|
+
entries.forEach((node) => {
|
|
21583
|
+
const { token, priceFeed, reserve, stalenessPeriod } = node;
|
|
21584
|
+
const ref = new PriceFeedRef(this.sdk, priceFeed, stalenessPeriod);
|
|
21585
|
+
const price = this.#priceFeedTree.find(
|
|
21586
|
+
(n) => n.baseParams.addr === priceFeed
|
|
21587
|
+
)?.answer?.price;
|
|
21588
|
+
if (reserve) {
|
|
21589
|
+
this.reservePriceFeeds.upsert(token, ref);
|
|
21590
|
+
if (price) {
|
|
21591
|
+
this.reservePrices.upsert(token, price);
|
|
21592
|
+
}
|
|
21593
|
+
} else {
|
|
21594
|
+
this.mainPriceFeeds.upsert(token, ref);
|
|
21595
|
+
if (price) {
|
|
21596
|
+
this.mainPrices.upsert(token, price);
|
|
21597
|
+
}
|
|
21598
|
+
}
|
|
21599
|
+
this.#labelPriceFeed(priceFeed, reserve ? "Reserve" : "Main", token);
|
|
21600
|
+
});
|
|
21601
|
+
this.logger?.debug(
|
|
21602
|
+
`Got ${Object.keys(this.mainPriceFeeds).length} main and ${Object.keys(this.reservePriceFeeds).length} reserve price feeds`
|
|
21603
|
+
);
|
|
21604
|
+
}
|
|
21582
21605
|
#labelPriceFeed(address, usage, token) {
|
|
21583
21606
|
this.sdk.provider.addressLabels.set(address, (label) => {
|
|
21584
21607
|
const symbol = this.sdk.tokensMeta.symbol(token);
|
|
@@ -21597,12 +21620,12 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21597
21620
|
* @returns
|
|
21598
21621
|
*/
|
|
21599
21622
|
#findTokenForPriceFeed(priceFeed) {
|
|
21600
|
-
for (const [token, pf] of
|
|
21623
|
+
for (const [token, pf] of this.mainPriceFeeds.entries()) {
|
|
21601
21624
|
if (pf.address === priceFeed) {
|
|
21602
21625
|
return [token, false];
|
|
21603
21626
|
}
|
|
21604
21627
|
}
|
|
21605
|
-
for (const [token, pf] of
|
|
21628
|
+
for (const [token, pf] of this.reservePriceFeeds.entries()) {
|
|
21606
21629
|
if (pf.address === priceFeed) {
|
|
21607
21630
|
return [token, true];
|
|
21608
21631
|
}
|
|
@@ -21617,13 +21640,13 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21617
21640
|
return {
|
|
21618
21641
|
...super.stateHuman(raw),
|
|
21619
21642
|
mainPriceFeeds: Object.fromEntries(
|
|
21620
|
-
|
|
21643
|
+
this.mainPriceFeeds.entries().map(([token, v]) => [
|
|
21621
21644
|
this.labelAddress(token),
|
|
21622
21645
|
v.stateHuman(raw)
|
|
21623
21646
|
])
|
|
21624
21647
|
),
|
|
21625
21648
|
reservePriceFeeds: Object.fromEntries(
|
|
21626
|
-
|
|
21649
|
+
this.reservePriceFeeds.entries().map(([token, v]) => [
|
|
21627
21650
|
this.labelAddress(token),
|
|
21628
21651
|
v.stateHuman(raw)
|
|
21629
21652
|
])
|
|
@@ -21986,26 +22009,19 @@ var MarketRegister = class extends SDKConstruct {
|
|
|
21986
22009
|
this.#logger?.info(`loaded ${markets.length} markets`);
|
|
21987
22010
|
}
|
|
21988
22011
|
/**
|
|
21989
|
-
* Loads new prices for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
21990
|
-
*
|
|
22012
|
+
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
22013
|
+
* Supports v300 and v310 oracles
|
|
21991
22014
|
*/
|
|
21992
22015
|
async updatePrices(oracles) {
|
|
21993
|
-
const
|
|
21994
|
-
if (!
|
|
22016
|
+
const multicalls = this.markets.map((m) => m.priceOracle).filter((o) => !oracles || oracles.includes(o.address)).map((o) => o.syncStateMulticall());
|
|
22017
|
+
if (!multicalls.length) {
|
|
21995
22018
|
return;
|
|
21996
22019
|
}
|
|
21997
22020
|
const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
|
|
21998
22021
|
const resp = await simulateMulticall(this.provider.publicClient, {
|
|
21999
22022
|
contracts: [
|
|
22000
22023
|
...txs.map(rawTxToMulticallPriceUpdate),
|
|
22001
|
-
...
|
|
22002
|
-
abi: iPriceFeedCompressorAbi,
|
|
22003
|
-
address: this.sdk.addressProvider.getLatestVersion(
|
|
22004
|
-
AP_PRICE_FEED_COMPRESSOR
|
|
22005
|
-
),
|
|
22006
|
-
functionName: "getPriceFeeds",
|
|
22007
|
-
args: [o]
|
|
22008
|
-
}))
|
|
22024
|
+
...multicalls.map((mc) => mc.call)
|
|
22009
22025
|
],
|
|
22010
22026
|
allowFailure: false,
|
|
22011
22027
|
gas: 550000000n,
|
|
@@ -22013,18 +22029,10 @@ var MarketRegister = class extends SDKConstruct {
|
|
|
22013
22029
|
// we cannot have price updates and compressor request in different batches
|
|
22014
22030
|
});
|
|
22015
22031
|
const oraclesStates = resp.slice(txs.length);
|
|
22016
|
-
for (let i = 0; i <
|
|
22017
|
-
const
|
|
22018
|
-
const
|
|
22019
|
-
|
|
22020
|
-
for (const { token, priceFeed, reserve } of entries) {
|
|
22021
|
-
const price = tree.find((n) => n.baseParams.addr === priceFeed)?.answer?.price;
|
|
22022
|
-
if (reserve && price) {
|
|
22023
|
-
oracle.reservePrices.upsert(token, price);
|
|
22024
|
-
} else if (price) {
|
|
22025
|
-
oracle.mainPrices.upsert(token, price);
|
|
22026
|
-
}
|
|
22027
|
-
}
|
|
22032
|
+
for (let i = 0; i < multicalls.length; i++) {
|
|
22033
|
+
const handler = multicalls[i].onResult;
|
|
22034
|
+
const result = oraclesStates[i];
|
|
22035
|
+
handler(result);
|
|
22028
22036
|
}
|
|
22029
22037
|
}
|
|
22030
22038
|
get state() {
|
package/dist/cjs/sdk/index.d.ts
CHANGED
|
@@ -22086,6 +22086,7 @@ declare class AddressMap<T> {
|
|
|
22086
22086
|
* @returns
|
|
22087
22087
|
*/
|
|
22088
22088
|
mustGet(address: string): T;
|
|
22089
|
+
clear(): void;
|
|
22089
22090
|
entries(): Array<[Address, T]>;
|
|
22090
22091
|
values(): T[];
|
|
22091
22092
|
keys(): Address[];
|
|
@@ -22297,9 +22298,8 @@ declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeed
|
|
|
22297
22298
|
* @returns
|
|
22298
22299
|
*/
|
|
22299
22300
|
generatePriceFeedsUpdateTxs(priceFeeds?: IPriceFeedContract[]): Promise<UpdatePriceFeedsResult>;
|
|
22300
|
-
get(address: Address): IPriceFeedContract | undefined;
|
|
22301
22301
|
mustGet(address: Address): IPriceFeedContract;
|
|
22302
|
-
|
|
22302
|
+
getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
|
|
22303
22303
|
/**
|
|
22304
22304
|
* Set redstone historical timestamp
|
|
22305
22305
|
* @param timestampMs in milliseconds
|
|
@@ -22468,11 +22468,11 @@ declare class PriceOracleContract extends BaseContract<abi$c> {
|
|
|
22468
22468
|
/**
|
|
22469
22469
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
22470
22470
|
*/
|
|
22471
|
-
readonly mainPriceFeeds:
|
|
22471
|
+
readonly mainPriceFeeds: AddressMap<PriceFeedRef>;
|
|
22472
22472
|
/**
|
|
22473
22473
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
22474
22474
|
*/
|
|
22475
|
-
readonly reservePriceFeeds:
|
|
22475
|
+
readonly reservePriceFeeds: AddressMap<PriceFeedRef>;
|
|
22476
22476
|
/**
|
|
22477
22477
|
* Mapping Token => Price in underlying
|
|
22478
22478
|
*/
|
|
@@ -22523,6 +22523,315 @@ declare class PriceOracleContract extends BaseContract<abi$c> {
|
|
|
22523
22523
|
* Does not update price feeds, only updates prices
|
|
22524
22524
|
*/
|
|
22525
22525
|
updatePrices(): Promise<void>;
|
|
22526
|
+
syncStateMulticall(): {
|
|
22527
|
+
call: {
|
|
22528
|
+
abi: readonly [{
|
|
22529
|
+
readonly type: "function";
|
|
22530
|
+
readonly inputs: readonly [];
|
|
22531
|
+
readonly name: "contractType";
|
|
22532
|
+
readonly outputs: readonly [{
|
|
22533
|
+
readonly name: "";
|
|
22534
|
+
readonly internalType: "bytes32";
|
|
22535
|
+
readonly type: "bytes32";
|
|
22536
|
+
}];
|
|
22537
|
+
readonly stateMutability: "view";
|
|
22538
|
+
}, {
|
|
22539
|
+
readonly type: "function";
|
|
22540
|
+
readonly inputs: readonly [{
|
|
22541
|
+
readonly name: "priceOracle";
|
|
22542
|
+
readonly internalType: "address";
|
|
22543
|
+
readonly type: "address";
|
|
22544
|
+
}, {
|
|
22545
|
+
readonly name: "tokens";
|
|
22546
|
+
readonly internalType: "address[]";
|
|
22547
|
+
readonly type: "address[]";
|
|
22548
|
+
}];
|
|
22549
|
+
readonly name: "getPriceFeeds";
|
|
22550
|
+
readonly outputs: readonly [{
|
|
22551
|
+
readonly name: "priceFeedMap";
|
|
22552
|
+
readonly internalType: "struct PriceFeedMapEntry[]";
|
|
22553
|
+
readonly type: "tuple[]";
|
|
22554
|
+
readonly components: readonly [{
|
|
22555
|
+
readonly name: "token";
|
|
22556
|
+
readonly internalType: "address";
|
|
22557
|
+
readonly type: "address";
|
|
22558
|
+
}, {
|
|
22559
|
+
readonly name: "reserve";
|
|
22560
|
+
readonly internalType: "bool";
|
|
22561
|
+
readonly type: "bool";
|
|
22562
|
+
}, {
|
|
22563
|
+
readonly name: "priceFeed";
|
|
22564
|
+
readonly internalType: "address";
|
|
22565
|
+
readonly type: "address";
|
|
22566
|
+
}, {
|
|
22567
|
+
readonly name: "stalenessPeriod";
|
|
22568
|
+
readonly internalType: "uint32";
|
|
22569
|
+
readonly type: "uint32";
|
|
22570
|
+
}];
|
|
22571
|
+
}, {
|
|
22572
|
+
readonly name: "priceFeedTree";
|
|
22573
|
+
readonly internalType: "struct PriceFeedTreeNode[]";
|
|
22574
|
+
readonly type: "tuple[]";
|
|
22575
|
+
readonly components: readonly [{
|
|
22576
|
+
readonly name: "baseParams";
|
|
22577
|
+
readonly internalType: "struct BaseParams";
|
|
22578
|
+
readonly type: "tuple";
|
|
22579
|
+
readonly components: readonly [{
|
|
22580
|
+
readonly name: "addr";
|
|
22581
|
+
readonly internalType: "address";
|
|
22582
|
+
readonly type: "address";
|
|
22583
|
+
}, {
|
|
22584
|
+
readonly name: "version";
|
|
22585
|
+
readonly internalType: "uint256";
|
|
22586
|
+
readonly type: "uint256";
|
|
22587
|
+
}, {
|
|
22588
|
+
readonly name: "contractType";
|
|
22589
|
+
readonly internalType: "bytes32";
|
|
22590
|
+
readonly type: "bytes32";
|
|
22591
|
+
}, {
|
|
22592
|
+
readonly name: "serializedParams";
|
|
22593
|
+
readonly internalType: "bytes";
|
|
22594
|
+
readonly type: "bytes";
|
|
22595
|
+
}];
|
|
22596
|
+
}, {
|
|
22597
|
+
readonly name: "decimals";
|
|
22598
|
+
readonly internalType: "uint8";
|
|
22599
|
+
readonly type: "uint8";
|
|
22600
|
+
}, {
|
|
22601
|
+
readonly name: "skipCheck";
|
|
22602
|
+
readonly internalType: "bool";
|
|
22603
|
+
readonly type: "bool";
|
|
22604
|
+
}, {
|
|
22605
|
+
readonly name: "updatable";
|
|
22606
|
+
readonly internalType: "bool";
|
|
22607
|
+
readonly type: "bool";
|
|
22608
|
+
}, {
|
|
22609
|
+
readonly name: "underlyingFeeds";
|
|
22610
|
+
readonly internalType: "address[]";
|
|
22611
|
+
readonly type: "address[]";
|
|
22612
|
+
}, {
|
|
22613
|
+
readonly name: "underlyingStalenessPeriods";
|
|
22614
|
+
readonly internalType: "uint32[]";
|
|
22615
|
+
readonly type: "uint32[]";
|
|
22616
|
+
}, {
|
|
22617
|
+
readonly name: "answer";
|
|
22618
|
+
readonly internalType: "struct PriceFeedAnswer";
|
|
22619
|
+
readonly type: "tuple";
|
|
22620
|
+
readonly components: readonly [{
|
|
22621
|
+
readonly name: "price";
|
|
22622
|
+
readonly internalType: "int256";
|
|
22623
|
+
readonly type: "int256";
|
|
22624
|
+
}, {
|
|
22625
|
+
readonly name: "updatedAt";
|
|
22626
|
+
readonly internalType: "uint256";
|
|
22627
|
+
readonly type: "uint256";
|
|
22628
|
+
}, {
|
|
22629
|
+
readonly name: "success";
|
|
22630
|
+
readonly internalType: "bool";
|
|
22631
|
+
readonly type: "bool";
|
|
22632
|
+
}];
|
|
22633
|
+
}];
|
|
22634
|
+
}];
|
|
22635
|
+
readonly stateMutability: "view";
|
|
22636
|
+
}, {
|
|
22637
|
+
readonly type: "function";
|
|
22638
|
+
readonly inputs: readonly [{
|
|
22639
|
+
readonly name: "priceOracle";
|
|
22640
|
+
readonly internalType: "address";
|
|
22641
|
+
readonly type: "address";
|
|
22642
|
+
}];
|
|
22643
|
+
readonly name: "getPriceFeeds";
|
|
22644
|
+
readonly outputs: readonly [{
|
|
22645
|
+
readonly name: "priceFeedMap";
|
|
22646
|
+
readonly internalType: "struct PriceFeedMapEntry[]";
|
|
22647
|
+
readonly type: "tuple[]";
|
|
22648
|
+
readonly components: readonly [{
|
|
22649
|
+
readonly name: "token";
|
|
22650
|
+
readonly internalType: "address";
|
|
22651
|
+
readonly type: "address";
|
|
22652
|
+
}, {
|
|
22653
|
+
readonly name: "reserve";
|
|
22654
|
+
readonly internalType: "bool";
|
|
22655
|
+
readonly type: "bool";
|
|
22656
|
+
}, {
|
|
22657
|
+
readonly name: "priceFeed";
|
|
22658
|
+
readonly internalType: "address";
|
|
22659
|
+
readonly type: "address";
|
|
22660
|
+
}, {
|
|
22661
|
+
readonly name: "stalenessPeriod";
|
|
22662
|
+
readonly internalType: "uint32";
|
|
22663
|
+
readonly type: "uint32";
|
|
22664
|
+
}];
|
|
22665
|
+
}, {
|
|
22666
|
+
readonly name: "priceFeedTree";
|
|
22667
|
+
readonly internalType: "struct PriceFeedTreeNode[]";
|
|
22668
|
+
readonly type: "tuple[]";
|
|
22669
|
+
readonly components: readonly [{
|
|
22670
|
+
readonly name: "baseParams";
|
|
22671
|
+
readonly internalType: "struct BaseParams";
|
|
22672
|
+
readonly type: "tuple";
|
|
22673
|
+
readonly components: readonly [{
|
|
22674
|
+
readonly name: "addr";
|
|
22675
|
+
readonly internalType: "address";
|
|
22676
|
+
readonly type: "address";
|
|
22677
|
+
}, {
|
|
22678
|
+
readonly name: "version";
|
|
22679
|
+
readonly internalType: "uint256";
|
|
22680
|
+
readonly type: "uint256";
|
|
22681
|
+
}, {
|
|
22682
|
+
readonly name: "contractType";
|
|
22683
|
+
readonly internalType: "bytes32";
|
|
22684
|
+
readonly type: "bytes32";
|
|
22685
|
+
}, {
|
|
22686
|
+
readonly name: "serializedParams";
|
|
22687
|
+
readonly internalType: "bytes";
|
|
22688
|
+
readonly type: "bytes";
|
|
22689
|
+
}];
|
|
22690
|
+
}, {
|
|
22691
|
+
readonly name: "decimals";
|
|
22692
|
+
readonly internalType: "uint8";
|
|
22693
|
+
readonly type: "uint8";
|
|
22694
|
+
}, {
|
|
22695
|
+
readonly name: "skipCheck";
|
|
22696
|
+
readonly internalType: "bool";
|
|
22697
|
+
readonly type: "bool";
|
|
22698
|
+
}, {
|
|
22699
|
+
readonly name: "updatable";
|
|
22700
|
+
readonly internalType: "bool";
|
|
22701
|
+
readonly type: "bool";
|
|
22702
|
+
}, {
|
|
22703
|
+
readonly name: "underlyingFeeds";
|
|
22704
|
+
readonly internalType: "address[]";
|
|
22705
|
+
readonly type: "address[]";
|
|
22706
|
+
}, {
|
|
22707
|
+
readonly name: "underlyingStalenessPeriods";
|
|
22708
|
+
readonly internalType: "uint32[]";
|
|
22709
|
+
readonly type: "uint32[]";
|
|
22710
|
+
}, {
|
|
22711
|
+
readonly name: "answer";
|
|
22712
|
+
readonly internalType: "struct PriceFeedAnswer";
|
|
22713
|
+
readonly type: "tuple";
|
|
22714
|
+
readonly components: readonly [{
|
|
22715
|
+
readonly name: "price";
|
|
22716
|
+
readonly internalType: "int256";
|
|
22717
|
+
readonly type: "int256";
|
|
22718
|
+
}, {
|
|
22719
|
+
readonly name: "updatedAt";
|
|
22720
|
+
readonly internalType: "uint256";
|
|
22721
|
+
readonly type: "uint256";
|
|
22722
|
+
}, {
|
|
22723
|
+
readonly name: "success";
|
|
22724
|
+
readonly internalType: "bool";
|
|
22725
|
+
readonly type: "bool";
|
|
22726
|
+
}];
|
|
22727
|
+
}];
|
|
22728
|
+
}];
|
|
22729
|
+
readonly stateMutability: "view";
|
|
22730
|
+
}, {
|
|
22731
|
+
readonly type: "function";
|
|
22732
|
+
readonly inputs: readonly [{
|
|
22733
|
+
readonly name: "priceFeeds";
|
|
22734
|
+
readonly internalType: "address[]";
|
|
22735
|
+
readonly type: "address[]";
|
|
22736
|
+
}];
|
|
22737
|
+
readonly name: "loadPriceFeedTree";
|
|
22738
|
+
readonly outputs: readonly [{
|
|
22739
|
+
readonly name: "priceFeedTree";
|
|
22740
|
+
readonly internalType: "struct PriceFeedTreeNode[]";
|
|
22741
|
+
readonly type: "tuple[]";
|
|
22742
|
+
readonly components: readonly [{
|
|
22743
|
+
readonly name: "baseParams";
|
|
22744
|
+
readonly internalType: "struct BaseParams";
|
|
22745
|
+
readonly type: "tuple";
|
|
22746
|
+
readonly components: readonly [{
|
|
22747
|
+
readonly name: "addr";
|
|
22748
|
+
readonly internalType: "address";
|
|
22749
|
+
readonly type: "address";
|
|
22750
|
+
}, {
|
|
22751
|
+
readonly name: "version";
|
|
22752
|
+
readonly internalType: "uint256";
|
|
22753
|
+
readonly type: "uint256";
|
|
22754
|
+
}, {
|
|
22755
|
+
readonly name: "contractType";
|
|
22756
|
+
readonly internalType: "bytes32";
|
|
22757
|
+
readonly type: "bytes32";
|
|
22758
|
+
}, {
|
|
22759
|
+
readonly name: "serializedParams";
|
|
22760
|
+
readonly internalType: "bytes";
|
|
22761
|
+
readonly type: "bytes";
|
|
22762
|
+
}];
|
|
22763
|
+
}, {
|
|
22764
|
+
readonly name: "decimals";
|
|
22765
|
+
readonly internalType: "uint8";
|
|
22766
|
+
readonly type: "uint8";
|
|
22767
|
+
}, {
|
|
22768
|
+
readonly name: "skipCheck";
|
|
22769
|
+
readonly internalType: "bool";
|
|
22770
|
+
readonly type: "bool";
|
|
22771
|
+
}, {
|
|
22772
|
+
readonly name: "updatable";
|
|
22773
|
+
readonly internalType: "bool";
|
|
22774
|
+
readonly type: "bool";
|
|
22775
|
+
}, {
|
|
22776
|
+
readonly name: "underlyingFeeds";
|
|
22777
|
+
readonly internalType: "address[]";
|
|
22778
|
+
readonly type: "address[]";
|
|
22779
|
+
}, {
|
|
22780
|
+
readonly name: "underlyingStalenessPeriods";
|
|
22781
|
+
readonly internalType: "uint32[]";
|
|
22782
|
+
readonly type: "uint32[]";
|
|
22783
|
+
}, {
|
|
22784
|
+
readonly name: "answer";
|
|
22785
|
+
readonly internalType: "struct PriceFeedAnswer";
|
|
22786
|
+
readonly type: "tuple";
|
|
22787
|
+
readonly components: readonly [{
|
|
22788
|
+
readonly name: "price";
|
|
22789
|
+
readonly internalType: "int256";
|
|
22790
|
+
readonly type: "int256";
|
|
22791
|
+
}, {
|
|
22792
|
+
readonly name: "updatedAt";
|
|
22793
|
+
readonly internalType: "uint256";
|
|
22794
|
+
readonly type: "uint256";
|
|
22795
|
+
}, {
|
|
22796
|
+
readonly name: "success";
|
|
22797
|
+
readonly internalType: "bool";
|
|
22798
|
+
readonly type: "bool";
|
|
22799
|
+
}];
|
|
22800
|
+
}];
|
|
22801
|
+
}];
|
|
22802
|
+
readonly stateMutability: "view";
|
|
22803
|
+
}, {
|
|
22804
|
+
readonly type: "function";
|
|
22805
|
+
readonly inputs: readonly [];
|
|
22806
|
+
readonly name: "version";
|
|
22807
|
+
readonly outputs: readonly [{
|
|
22808
|
+
readonly name: "";
|
|
22809
|
+
readonly internalType: "uint256";
|
|
22810
|
+
readonly type: "uint256";
|
|
22811
|
+
}];
|
|
22812
|
+
readonly stateMutability: "view";
|
|
22813
|
+
}, {
|
|
22814
|
+
readonly type: "event";
|
|
22815
|
+
readonly anonymous: false;
|
|
22816
|
+
readonly inputs: readonly [{
|
|
22817
|
+
readonly name: "contractType";
|
|
22818
|
+
readonly internalType: "bytes32";
|
|
22819
|
+
readonly type: "bytes32";
|
|
22820
|
+
readonly indexed: true;
|
|
22821
|
+
}, {
|
|
22822
|
+
readonly name: "serializer";
|
|
22823
|
+
readonly internalType: "address";
|
|
22824
|
+
readonly type: "address";
|
|
22825
|
+
readonly indexed: true;
|
|
22826
|
+
}];
|
|
22827
|
+
readonly name: "SetSerializer";
|
|
22828
|
+
}];
|
|
22829
|
+
address: `0x${string}`;
|
|
22830
|
+
functionName: string;
|
|
22831
|
+
args: any[];
|
|
22832
|
+
};
|
|
22833
|
+
onResult: ([entries, tree]: [PriceFeedMapEntry[], PriceFeedTreeNode[]]) => void;
|
|
22834
|
+
};
|
|
22526
22835
|
stateHuman(raw?: boolean): PriceOracleV3StateHuman;
|
|
22527
22836
|
}
|
|
22528
22837
|
|
|
@@ -24223,8 +24532,8 @@ declare class MarketRegister extends SDKConstruct {
|
|
|
24223
24532
|
loadMarkets(curators: Address[]): Promise<void>;
|
|
24224
24533
|
syncState(): Promise<void>;
|
|
24225
24534
|
/**
|
|
24226
|
-
* Loads new prices for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
24227
|
-
*
|
|
24535
|
+
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
24536
|
+
* Supports v300 and v310 oracles
|
|
24228
24537
|
*/
|
|
24229
24538
|
updatePrices(oracles?: Address[]): Promise<void>;
|
|
24230
24539
|
get state(): MarketData[];
|
package/dist/esm/sdk/index.d.mts
CHANGED
|
@@ -22086,6 +22086,7 @@ declare class AddressMap<T> {
|
|
|
22086
22086
|
* @returns
|
|
22087
22087
|
*/
|
|
22088
22088
|
mustGet(address: string): T;
|
|
22089
|
+
clear(): void;
|
|
22089
22090
|
entries(): Array<[Address, T]>;
|
|
22090
22091
|
values(): T[];
|
|
22091
22092
|
keys(): Address[];
|
|
@@ -22297,9 +22298,8 @@ declare class PriceFeedRegister extends SDKConstruct implements IHooks<PriceFeed
|
|
|
22297
22298
|
* @returns
|
|
22298
22299
|
*/
|
|
22299
22300
|
generatePriceFeedsUpdateTxs(priceFeeds?: IPriceFeedContract[]): Promise<UpdatePriceFeedsResult>;
|
|
22300
|
-
get(address: Address): IPriceFeedContract | undefined;
|
|
22301
22301
|
mustGet(address: Address): IPriceFeedContract;
|
|
22302
|
-
|
|
22302
|
+
getOrCreate(data: PriceFeedTreeNode): IPriceFeedContract;
|
|
22303
22303
|
/**
|
|
22304
22304
|
* Set redstone historical timestamp
|
|
22305
22305
|
* @param timestampMs in milliseconds
|
|
@@ -22468,11 +22468,11 @@ declare class PriceOracleContract extends BaseContract<abi$c> {
|
|
|
22468
22468
|
/**
|
|
22469
22469
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
22470
22470
|
*/
|
|
22471
|
-
readonly mainPriceFeeds:
|
|
22471
|
+
readonly mainPriceFeeds: AddressMap<PriceFeedRef>;
|
|
22472
22472
|
/**
|
|
22473
22473
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
22474
22474
|
*/
|
|
22475
|
-
readonly reservePriceFeeds:
|
|
22475
|
+
readonly reservePriceFeeds: AddressMap<PriceFeedRef>;
|
|
22476
22476
|
/**
|
|
22477
22477
|
* Mapping Token => Price in underlying
|
|
22478
22478
|
*/
|
|
@@ -22523,6 +22523,315 @@ declare class PriceOracleContract extends BaseContract<abi$c> {
|
|
|
22523
22523
|
* Does not update price feeds, only updates prices
|
|
22524
22524
|
*/
|
|
22525
22525
|
updatePrices(): Promise<void>;
|
|
22526
|
+
syncStateMulticall(): {
|
|
22527
|
+
call: {
|
|
22528
|
+
abi: readonly [{
|
|
22529
|
+
readonly type: "function";
|
|
22530
|
+
readonly inputs: readonly [];
|
|
22531
|
+
readonly name: "contractType";
|
|
22532
|
+
readonly outputs: readonly [{
|
|
22533
|
+
readonly name: "";
|
|
22534
|
+
readonly internalType: "bytes32";
|
|
22535
|
+
readonly type: "bytes32";
|
|
22536
|
+
}];
|
|
22537
|
+
readonly stateMutability: "view";
|
|
22538
|
+
}, {
|
|
22539
|
+
readonly type: "function";
|
|
22540
|
+
readonly inputs: readonly [{
|
|
22541
|
+
readonly name: "priceOracle";
|
|
22542
|
+
readonly internalType: "address";
|
|
22543
|
+
readonly type: "address";
|
|
22544
|
+
}, {
|
|
22545
|
+
readonly name: "tokens";
|
|
22546
|
+
readonly internalType: "address[]";
|
|
22547
|
+
readonly type: "address[]";
|
|
22548
|
+
}];
|
|
22549
|
+
readonly name: "getPriceFeeds";
|
|
22550
|
+
readonly outputs: readonly [{
|
|
22551
|
+
readonly name: "priceFeedMap";
|
|
22552
|
+
readonly internalType: "struct PriceFeedMapEntry[]";
|
|
22553
|
+
readonly type: "tuple[]";
|
|
22554
|
+
readonly components: readonly [{
|
|
22555
|
+
readonly name: "token";
|
|
22556
|
+
readonly internalType: "address";
|
|
22557
|
+
readonly type: "address";
|
|
22558
|
+
}, {
|
|
22559
|
+
readonly name: "reserve";
|
|
22560
|
+
readonly internalType: "bool";
|
|
22561
|
+
readonly type: "bool";
|
|
22562
|
+
}, {
|
|
22563
|
+
readonly name: "priceFeed";
|
|
22564
|
+
readonly internalType: "address";
|
|
22565
|
+
readonly type: "address";
|
|
22566
|
+
}, {
|
|
22567
|
+
readonly name: "stalenessPeriod";
|
|
22568
|
+
readonly internalType: "uint32";
|
|
22569
|
+
readonly type: "uint32";
|
|
22570
|
+
}];
|
|
22571
|
+
}, {
|
|
22572
|
+
readonly name: "priceFeedTree";
|
|
22573
|
+
readonly internalType: "struct PriceFeedTreeNode[]";
|
|
22574
|
+
readonly type: "tuple[]";
|
|
22575
|
+
readonly components: readonly [{
|
|
22576
|
+
readonly name: "baseParams";
|
|
22577
|
+
readonly internalType: "struct BaseParams";
|
|
22578
|
+
readonly type: "tuple";
|
|
22579
|
+
readonly components: readonly [{
|
|
22580
|
+
readonly name: "addr";
|
|
22581
|
+
readonly internalType: "address";
|
|
22582
|
+
readonly type: "address";
|
|
22583
|
+
}, {
|
|
22584
|
+
readonly name: "version";
|
|
22585
|
+
readonly internalType: "uint256";
|
|
22586
|
+
readonly type: "uint256";
|
|
22587
|
+
}, {
|
|
22588
|
+
readonly name: "contractType";
|
|
22589
|
+
readonly internalType: "bytes32";
|
|
22590
|
+
readonly type: "bytes32";
|
|
22591
|
+
}, {
|
|
22592
|
+
readonly name: "serializedParams";
|
|
22593
|
+
readonly internalType: "bytes";
|
|
22594
|
+
readonly type: "bytes";
|
|
22595
|
+
}];
|
|
22596
|
+
}, {
|
|
22597
|
+
readonly name: "decimals";
|
|
22598
|
+
readonly internalType: "uint8";
|
|
22599
|
+
readonly type: "uint8";
|
|
22600
|
+
}, {
|
|
22601
|
+
readonly name: "skipCheck";
|
|
22602
|
+
readonly internalType: "bool";
|
|
22603
|
+
readonly type: "bool";
|
|
22604
|
+
}, {
|
|
22605
|
+
readonly name: "updatable";
|
|
22606
|
+
readonly internalType: "bool";
|
|
22607
|
+
readonly type: "bool";
|
|
22608
|
+
}, {
|
|
22609
|
+
readonly name: "underlyingFeeds";
|
|
22610
|
+
readonly internalType: "address[]";
|
|
22611
|
+
readonly type: "address[]";
|
|
22612
|
+
}, {
|
|
22613
|
+
readonly name: "underlyingStalenessPeriods";
|
|
22614
|
+
readonly internalType: "uint32[]";
|
|
22615
|
+
readonly type: "uint32[]";
|
|
22616
|
+
}, {
|
|
22617
|
+
readonly name: "answer";
|
|
22618
|
+
readonly internalType: "struct PriceFeedAnswer";
|
|
22619
|
+
readonly type: "tuple";
|
|
22620
|
+
readonly components: readonly [{
|
|
22621
|
+
readonly name: "price";
|
|
22622
|
+
readonly internalType: "int256";
|
|
22623
|
+
readonly type: "int256";
|
|
22624
|
+
}, {
|
|
22625
|
+
readonly name: "updatedAt";
|
|
22626
|
+
readonly internalType: "uint256";
|
|
22627
|
+
readonly type: "uint256";
|
|
22628
|
+
}, {
|
|
22629
|
+
readonly name: "success";
|
|
22630
|
+
readonly internalType: "bool";
|
|
22631
|
+
readonly type: "bool";
|
|
22632
|
+
}];
|
|
22633
|
+
}];
|
|
22634
|
+
}];
|
|
22635
|
+
readonly stateMutability: "view";
|
|
22636
|
+
}, {
|
|
22637
|
+
readonly type: "function";
|
|
22638
|
+
readonly inputs: readonly [{
|
|
22639
|
+
readonly name: "priceOracle";
|
|
22640
|
+
readonly internalType: "address";
|
|
22641
|
+
readonly type: "address";
|
|
22642
|
+
}];
|
|
22643
|
+
readonly name: "getPriceFeeds";
|
|
22644
|
+
readonly outputs: readonly [{
|
|
22645
|
+
readonly name: "priceFeedMap";
|
|
22646
|
+
readonly internalType: "struct PriceFeedMapEntry[]";
|
|
22647
|
+
readonly type: "tuple[]";
|
|
22648
|
+
readonly components: readonly [{
|
|
22649
|
+
readonly name: "token";
|
|
22650
|
+
readonly internalType: "address";
|
|
22651
|
+
readonly type: "address";
|
|
22652
|
+
}, {
|
|
22653
|
+
readonly name: "reserve";
|
|
22654
|
+
readonly internalType: "bool";
|
|
22655
|
+
readonly type: "bool";
|
|
22656
|
+
}, {
|
|
22657
|
+
readonly name: "priceFeed";
|
|
22658
|
+
readonly internalType: "address";
|
|
22659
|
+
readonly type: "address";
|
|
22660
|
+
}, {
|
|
22661
|
+
readonly name: "stalenessPeriod";
|
|
22662
|
+
readonly internalType: "uint32";
|
|
22663
|
+
readonly type: "uint32";
|
|
22664
|
+
}];
|
|
22665
|
+
}, {
|
|
22666
|
+
readonly name: "priceFeedTree";
|
|
22667
|
+
readonly internalType: "struct PriceFeedTreeNode[]";
|
|
22668
|
+
readonly type: "tuple[]";
|
|
22669
|
+
readonly components: readonly [{
|
|
22670
|
+
readonly name: "baseParams";
|
|
22671
|
+
readonly internalType: "struct BaseParams";
|
|
22672
|
+
readonly type: "tuple";
|
|
22673
|
+
readonly components: readonly [{
|
|
22674
|
+
readonly name: "addr";
|
|
22675
|
+
readonly internalType: "address";
|
|
22676
|
+
readonly type: "address";
|
|
22677
|
+
}, {
|
|
22678
|
+
readonly name: "version";
|
|
22679
|
+
readonly internalType: "uint256";
|
|
22680
|
+
readonly type: "uint256";
|
|
22681
|
+
}, {
|
|
22682
|
+
readonly name: "contractType";
|
|
22683
|
+
readonly internalType: "bytes32";
|
|
22684
|
+
readonly type: "bytes32";
|
|
22685
|
+
}, {
|
|
22686
|
+
readonly name: "serializedParams";
|
|
22687
|
+
readonly internalType: "bytes";
|
|
22688
|
+
readonly type: "bytes";
|
|
22689
|
+
}];
|
|
22690
|
+
}, {
|
|
22691
|
+
readonly name: "decimals";
|
|
22692
|
+
readonly internalType: "uint8";
|
|
22693
|
+
readonly type: "uint8";
|
|
22694
|
+
}, {
|
|
22695
|
+
readonly name: "skipCheck";
|
|
22696
|
+
readonly internalType: "bool";
|
|
22697
|
+
readonly type: "bool";
|
|
22698
|
+
}, {
|
|
22699
|
+
readonly name: "updatable";
|
|
22700
|
+
readonly internalType: "bool";
|
|
22701
|
+
readonly type: "bool";
|
|
22702
|
+
}, {
|
|
22703
|
+
readonly name: "underlyingFeeds";
|
|
22704
|
+
readonly internalType: "address[]";
|
|
22705
|
+
readonly type: "address[]";
|
|
22706
|
+
}, {
|
|
22707
|
+
readonly name: "underlyingStalenessPeriods";
|
|
22708
|
+
readonly internalType: "uint32[]";
|
|
22709
|
+
readonly type: "uint32[]";
|
|
22710
|
+
}, {
|
|
22711
|
+
readonly name: "answer";
|
|
22712
|
+
readonly internalType: "struct PriceFeedAnswer";
|
|
22713
|
+
readonly type: "tuple";
|
|
22714
|
+
readonly components: readonly [{
|
|
22715
|
+
readonly name: "price";
|
|
22716
|
+
readonly internalType: "int256";
|
|
22717
|
+
readonly type: "int256";
|
|
22718
|
+
}, {
|
|
22719
|
+
readonly name: "updatedAt";
|
|
22720
|
+
readonly internalType: "uint256";
|
|
22721
|
+
readonly type: "uint256";
|
|
22722
|
+
}, {
|
|
22723
|
+
readonly name: "success";
|
|
22724
|
+
readonly internalType: "bool";
|
|
22725
|
+
readonly type: "bool";
|
|
22726
|
+
}];
|
|
22727
|
+
}];
|
|
22728
|
+
}];
|
|
22729
|
+
readonly stateMutability: "view";
|
|
22730
|
+
}, {
|
|
22731
|
+
readonly type: "function";
|
|
22732
|
+
readonly inputs: readonly [{
|
|
22733
|
+
readonly name: "priceFeeds";
|
|
22734
|
+
readonly internalType: "address[]";
|
|
22735
|
+
readonly type: "address[]";
|
|
22736
|
+
}];
|
|
22737
|
+
readonly name: "loadPriceFeedTree";
|
|
22738
|
+
readonly outputs: readonly [{
|
|
22739
|
+
readonly name: "priceFeedTree";
|
|
22740
|
+
readonly internalType: "struct PriceFeedTreeNode[]";
|
|
22741
|
+
readonly type: "tuple[]";
|
|
22742
|
+
readonly components: readonly [{
|
|
22743
|
+
readonly name: "baseParams";
|
|
22744
|
+
readonly internalType: "struct BaseParams";
|
|
22745
|
+
readonly type: "tuple";
|
|
22746
|
+
readonly components: readonly [{
|
|
22747
|
+
readonly name: "addr";
|
|
22748
|
+
readonly internalType: "address";
|
|
22749
|
+
readonly type: "address";
|
|
22750
|
+
}, {
|
|
22751
|
+
readonly name: "version";
|
|
22752
|
+
readonly internalType: "uint256";
|
|
22753
|
+
readonly type: "uint256";
|
|
22754
|
+
}, {
|
|
22755
|
+
readonly name: "contractType";
|
|
22756
|
+
readonly internalType: "bytes32";
|
|
22757
|
+
readonly type: "bytes32";
|
|
22758
|
+
}, {
|
|
22759
|
+
readonly name: "serializedParams";
|
|
22760
|
+
readonly internalType: "bytes";
|
|
22761
|
+
readonly type: "bytes";
|
|
22762
|
+
}];
|
|
22763
|
+
}, {
|
|
22764
|
+
readonly name: "decimals";
|
|
22765
|
+
readonly internalType: "uint8";
|
|
22766
|
+
readonly type: "uint8";
|
|
22767
|
+
}, {
|
|
22768
|
+
readonly name: "skipCheck";
|
|
22769
|
+
readonly internalType: "bool";
|
|
22770
|
+
readonly type: "bool";
|
|
22771
|
+
}, {
|
|
22772
|
+
readonly name: "updatable";
|
|
22773
|
+
readonly internalType: "bool";
|
|
22774
|
+
readonly type: "bool";
|
|
22775
|
+
}, {
|
|
22776
|
+
readonly name: "underlyingFeeds";
|
|
22777
|
+
readonly internalType: "address[]";
|
|
22778
|
+
readonly type: "address[]";
|
|
22779
|
+
}, {
|
|
22780
|
+
readonly name: "underlyingStalenessPeriods";
|
|
22781
|
+
readonly internalType: "uint32[]";
|
|
22782
|
+
readonly type: "uint32[]";
|
|
22783
|
+
}, {
|
|
22784
|
+
readonly name: "answer";
|
|
22785
|
+
readonly internalType: "struct PriceFeedAnswer";
|
|
22786
|
+
readonly type: "tuple";
|
|
22787
|
+
readonly components: readonly [{
|
|
22788
|
+
readonly name: "price";
|
|
22789
|
+
readonly internalType: "int256";
|
|
22790
|
+
readonly type: "int256";
|
|
22791
|
+
}, {
|
|
22792
|
+
readonly name: "updatedAt";
|
|
22793
|
+
readonly internalType: "uint256";
|
|
22794
|
+
readonly type: "uint256";
|
|
22795
|
+
}, {
|
|
22796
|
+
readonly name: "success";
|
|
22797
|
+
readonly internalType: "bool";
|
|
22798
|
+
readonly type: "bool";
|
|
22799
|
+
}];
|
|
22800
|
+
}];
|
|
22801
|
+
}];
|
|
22802
|
+
readonly stateMutability: "view";
|
|
22803
|
+
}, {
|
|
22804
|
+
readonly type: "function";
|
|
22805
|
+
readonly inputs: readonly [];
|
|
22806
|
+
readonly name: "version";
|
|
22807
|
+
readonly outputs: readonly [{
|
|
22808
|
+
readonly name: "";
|
|
22809
|
+
readonly internalType: "uint256";
|
|
22810
|
+
readonly type: "uint256";
|
|
22811
|
+
}];
|
|
22812
|
+
readonly stateMutability: "view";
|
|
22813
|
+
}, {
|
|
22814
|
+
readonly type: "event";
|
|
22815
|
+
readonly anonymous: false;
|
|
22816
|
+
readonly inputs: readonly [{
|
|
22817
|
+
readonly name: "contractType";
|
|
22818
|
+
readonly internalType: "bytes32";
|
|
22819
|
+
readonly type: "bytes32";
|
|
22820
|
+
readonly indexed: true;
|
|
22821
|
+
}, {
|
|
22822
|
+
readonly name: "serializer";
|
|
22823
|
+
readonly internalType: "address";
|
|
22824
|
+
readonly type: "address";
|
|
22825
|
+
readonly indexed: true;
|
|
22826
|
+
}];
|
|
22827
|
+
readonly name: "SetSerializer";
|
|
22828
|
+
}];
|
|
22829
|
+
address: `0x${string}`;
|
|
22830
|
+
functionName: string;
|
|
22831
|
+
args: any[];
|
|
22832
|
+
};
|
|
22833
|
+
onResult: ([entries, tree]: [PriceFeedMapEntry[], PriceFeedTreeNode[]]) => void;
|
|
22834
|
+
};
|
|
22526
22835
|
stateHuman(raw?: boolean): PriceOracleV3StateHuman;
|
|
22527
22836
|
}
|
|
22528
22837
|
|
|
@@ -24223,8 +24532,8 @@ declare class MarketRegister extends SDKConstruct {
|
|
|
24223
24532
|
loadMarkets(curators: Address[]): Promise<void>;
|
|
24224
24533
|
syncState(): Promise<void>;
|
|
24225
24534
|
/**
|
|
24226
|
-
* Loads new prices for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
24227
|
-
*
|
|
24535
|
+
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
24536
|
+
* Supports v300 and v310 oracles
|
|
24228
24537
|
*/
|
|
24229
24538
|
updatePrices(oracles?: Address[]): Promise<void>;
|
|
24230
24539
|
get state(): MarketData[];
|
package/dist/esm/sdk/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getAddress, bytesToString, toBytes, prepareEncodeFunctionData, encodeAbiParameters, concatHex, getContract, isHex, decodeFunctionData, encodeFunctionData, decodeAbiParameters, erc4626Abi, http, fallback, defineChain, createPublicClient, getChainContractAddress, getContractError, multicall3Abi, AbiDecodingZeroDataError, RawContractError, decodeFunctionResult, BaseError, parseEventLogs, hexToBytes } from 'viem';
|
|
2
2
|
import { formatAbiItem, getAction } from 'viem/utils';
|
|
3
3
|
import { intervalToDuration, formatDuration as formatDuration$1 } from 'date-fns';
|
|
4
4
|
import { DataServiceWrapper } from '@redstone-finance/evm-connector';
|
|
@@ -19150,10 +19150,7 @@ var AddressMap = class {
|
|
|
19150
19150
|
this.#map = /* @__PURE__ */ new Map();
|
|
19151
19151
|
if (entries) {
|
|
19152
19152
|
for (const [address, value] of entries) {
|
|
19153
|
-
const key = address
|
|
19154
|
-
if (!isAddress(key)) {
|
|
19155
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19156
|
-
}
|
|
19153
|
+
const key = getAddress(address);
|
|
19157
19154
|
this.#map.set(key, value);
|
|
19158
19155
|
}
|
|
19159
19156
|
}
|
|
@@ -19167,10 +19164,7 @@ var AddressMap = class {
|
|
|
19167
19164
|
if (this.#frozen) {
|
|
19168
19165
|
throw new Error(`AddressMap is frozen`);
|
|
19169
19166
|
}
|
|
19170
|
-
const key = address
|
|
19171
|
-
if (!isAddress(key)) {
|
|
19172
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19173
|
-
}
|
|
19167
|
+
const key = getAddress(address);
|
|
19174
19168
|
this.#map.set(key, value);
|
|
19175
19169
|
}
|
|
19176
19170
|
/**
|
|
@@ -19182,10 +19176,7 @@ var AddressMap = class {
|
|
|
19182
19176
|
if (this.#frozen) {
|
|
19183
19177
|
throw new Error(`AddressMap is frozen`);
|
|
19184
19178
|
}
|
|
19185
|
-
const key = address
|
|
19186
|
-
if (!isAddress(key)) {
|
|
19187
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19188
|
-
}
|
|
19179
|
+
const key = getAddress(address);
|
|
19189
19180
|
if (this.#map.has(key)) {
|
|
19190
19181
|
throw new Error(`address ${address} already exists`);
|
|
19191
19182
|
}
|
|
@@ -19197,10 +19188,7 @@ var AddressMap = class {
|
|
|
19197
19188
|
* @returns
|
|
19198
19189
|
*/
|
|
19199
19190
|
has(address) {
|
|
19200
|
-
const key = address
|
|
19201
|
-
if (!isAddress(key)) {
|
|
19202
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19203
|
-
}
|
|
19191
|
+
const key = getAddress(address);
|
|
19204
19192
|
return this.#map.has(key);
|
|
19205
19193
|
}
|
|
19206
19194
|
/**
|
|
@@ -19209,10 +19197,7 @@ var AddressMap = class {
|
|
|
19209
19197
|
* @returns
|
|
19210
19198
|
*/
|
|
19211
19199
|
get(address) {
|
|
19212
|
-
const key = address
|
|
19213
|
-
if (!isAddress(key)) {
|
|
19214
|
-
throw new Error(`value "${address}" is not an address`);
|
|
19215
|
-
}
|
|
19200
|
+
const key = getAddress(address);
|
|
19216
19201
|
return this.#map.get(key);
|
|
19217
19202
|
}
|
|
19218
19203
|
/**
|
|
@@ -19227,6 +19212,9 @@ var AddressMap = class {
|
|
|
19227
19212
|
}
|
|
19228
19213
|
return v;
|
|
19229
19214
|
}
|
|
19215
|
+
clear() {
|
|
19216
|
+
this.#map.clear();
|
|
19217
|
+
}
|
|
19230
19218
|
entries() {
|
|
19231
19219
|
return Array.from(this.#map.entries());
|
|
19232
19220
|
}
|
|
@@ -21344,13 +21332,14 @@ var PriceFeedRegister = class extends SDKConstruct {
|
|
|
21344
21332
|
}
|
|
21345
21333
|
return result;
|
|
21346
21334
|
}
|
|
21347
|
-
get(address) {
|
|
21348
|
-
return this.#feeds.get(address);
|
|
21349
|
-
}
|
|
21350
21335
|
mustGet(address) {
|
|
21351
21336
|
return this.#feeds.mustGet(address);
|
|
21352
21337
|
}
|
|
21353
|
-
|
|
21338
|
+
getOrCreate(data) {
|
|
21339
|
+
const existing = this.#feeds.get(data.baseParams.addr);
|
|
21340
|
+
if (existing) {
|
|
21341
|
+
return existing;
|
|
21342
|
+
}
|
|
21354
21343
|
const feed = this.#create(data);
|
|
21355
21344
|
this.#feeds.upsert(data.baseParams.addr, feed);
|
|
21356
21345
|
return feed;
|
|
@@ -21423,11 +21412,11 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21423
21412
|
/**
|
|
21424
21413
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
21425
21414
|
*/
|
|
21426
|
-
mainPriceFeeds =
|
|
21415
|
+
mainPriceFeeds = new AddressMap();
|
|
21427
21416
|
/**
|
|
21428
21417
|
* Mapping Token => [PriceFeed Address, stalenessPeriod]
|
|
21429
21418
|
*/
|
|
21430
|
-
reservePriceFeeds =
|
|
21419
|
+
reservePriceFeeds = new AddressMap();
|
|
21431
21420
|
/**
|
|
21432
21421
|
* Mapping Token => Price in underlying
|
|
21433
21422
|
*/
|
|
@@ -21436,7 +21425,7 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21436
21425
|
* Mapping Token => Price in underlying
|
|
21437
21426
|
*/
|
|
21438
21427
|
reservePrices = new AddressMap();
|
|
21439
|
-
#priceFeedTree;
|
|
21428
|
+
#priceFeedTree = [];
|
|
21440
21429
|
constructor(sdk, data, underlying) {
|
|
21441
21430
|
super(sdk, {
|
|
21442
21431
|
...data.baseParams,
|
|
@@ -21445,32 +21434,7 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21445
21434
|
});
|
|
21446
21435
|
this.underlying = underlying;
|
|
21447
21436
|
const { priceFeedMapping, priceFeedStructure } = data;
|
|
21448
|
-
this.#
|
|
21449
|
-
for (const node of priceFeedStructure) {
|
|
21450
|
-
sdk.priceFeeds.create(node);
|
|
21451
|
-
}
|
|
21452
|
-
priceFeedMapping.forEach((node) => {
|
|
21453
|
-
const { token, priceFeed, reserve, stalenessPeriod } = node;
|
|
21454
|
-
const ref = new PriceFeedRef(sdk, priceFeed, stalenessPeriod);
|
|
21455
|
-
const price = this.#priceFeedTree.find(
|
|
21456
|
-
(n) => n.baseParams.addr === priceFeed
|
|
21457
|
-
)?.answer?.price;
|
|
21458
|
-
if (reserve) {
|
|
21459
|
-
this.reservePriceFeeds[token] = ref;
|
|
21460
|
-
if (price) {
|
|
21461
|
-
this.reservePrices.upsert(token, price);
|
|
21462
|
-
}
|
|
21463
|
-
} else {
|
|
21464
|
-
this.mainPriceFeeds[token] = ref;
|
|
21465
|
-
if (price) {
|
|
21466
|
-
this.mainPrices.upsert(token, price);
|
|
21467
|
-
}
|
|
21468
|
-
}
|
|
21469
|
-
this.#labelPriceFeed(priceFeed, reserve ? "Reserve" : "Main", token);
|
|
21470
|
-
});
|
|
21471
|
-
this.logger?.debug(
|
|
21472
|
-
`Got ${Object.keys(this.mainPriceFeeds).length} main and ${Object.keys(this.reservePriceFeeds).length} reserve price feeds`
|
|
21473
|
-
);
|
|
21437
|
+
this.#loadState(priceFeedMapping, priceFeedStructure);
|
|
21474
21438
|
}
|
|
21475
21439
|
processLog(log) {
|
|
21476
21440
|
switch (log.eventName) {
|
|
@@ -21494,8 +21458,8 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21494
21458
|
const main = opts?.main ?? true;
|
|
21495
21459
|
const reserve = opts?.reserve ?? true;
|
|
21496
21460
|
return tokens.flatMap((t) => [
|
|
21497
|
-
main ? this.mainPriceFeeds
|
|
21498
|
-
reserve ? this.reservePriceFeeds
|
|
21461
|
+
main ? this.mainPriceFeeds.get(t)?.priceFeed : void 0,
|
|
21462
|
+
reserve ? this.reservePriceFeeds.get(t)?.priceFeed : void 0
|
|
21499
21463
|
]).filter((f) => !!f);
|
|
21500
21464
|
}
|
|
21501
21465
|
/**
|
|
@@ -21577,6 +21541,65 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21577
21541
|
async updatePrices() {
|
|
21578
21542
|
await this.sdk.marketRegister.updatePrices([this.address]);
|
|
21579
21543
|
}
|
|
21544
|
+
syncStateMulticall() {
|
|
21545
|
+
const args = [this.address];
|
|
21546
|
+
if (this.version === 300) {
|
|
21547
|
+
args.push(
|
|
21548
|
+
Array.from(
|
|
21549
|
+
/* @__PURE__ */ new Set([
|
|
21550
|
+
this.underlying,
|
|
21551
|
+
...this.mainPriceFeeds.keys(),
|
|
21552
|
+
...this.reservePriceFeeds.keys()
|
|
21553
|
+
])
|
|
21554
|
+
)
|
|
21555
|
+
);
|
|
21556
|
+
}
|
|
21557
|
+
return {
|
|
21558
|
+
call: {
|
|
21559
|
+
abi: iPriceFeedCompressorAbi,
|
|
21560
|
+
address: this.sdk.addressProvider.getLatestVersion(
|
|
21561
|
+
AP_PRICE_FEED_COMPRESSOR
|
|
21562
|
+
),
|
|
21563
|
+
functionName: "getPriceFeeds",
|
|
21564
|
+
args
|
|
21565
|
+
},
|
|
21566
|
+
onResult: ([entries, tree]) => {
|
|
21567
|
+
this.#loadState(entries, tree);
|
|
21568
|
+
}
|
|
21569
|
+
};
|
|
21570
|
+
}
|
|
21571
|
+
#loadState(entries, tree) {
|
|
21572
|
+
this.#priceFeedTree = tree;
|
|
21573
|
+
this.mainPriceFeeds.clear();
|
|
21574
|
+
this.reservePriceFeeds.clear();
|
|
21575
|
+
this.mainPrices.clear();
|
|
21576
|
+
this.reservePrices.clear();
|
|
21577
|
+
for (const node of tree) {
|
|
21578
|
+
this.sdk.priceFeeds.getOrCreate(node);
|
|
21579
|
+
}
|
|
21580
|
+
entries.forEach((node) => {
|
|
21581
|
+
const { token, priceFeed, reserve, stalenessPeriod } = node;
|
|
21582
|
+
const ref = new PriceFeedRef(this.sdk, priceFeed, stalenessPeriod);
|
|
21583
|
+
const price = this.#priceFeedTree.find(
|
|
21584
|
+
(n) => n.baseParams.addr === priceFeed
|
|
21585
|
+
)?.answer?.price;
|
|
21586
|
+
if (reserve) {
|
|
21587
|
+
this.reservePriceFeeds.upsert(token, ref);
|
|
21588
|
+
if (price) {
|
|
21589
|
+
this.reservePrices.upsert(token, price);
|
|
21590
|
+
}
|
|
21591
|
+
} else {
|
|
21592
|
+
this.mainPriceFeeds.upsert(token, ref);
|
|
21593
|
+
if (price) {
|
|
21594
|
+
this.mainPrices.upsert(token, price);
|
|
21595
|
+
}
|
|
21596
|
+
}
|
|
21597
|
+
this.#labelPriceFeed(priceFeed, reserve ? "Reserve" : "Main", token);
|
|
21598
|
+
});
|
|
21599
|
+
this.logger?.debug(
|
|
21600
|
+
`Got ${Object.keys(this.mainPriceFeeds).length} main and ${Object.keys(this.reservePriceFeeds).length} reserve price feeds`
|
|
21601
|
+
);
|
|
21602
|
+
}
|
|
21580
21603
|
#labelPriceFeed(address, usage, token) {
|
|
21581
21604
|
this.sdk.provider.addressLabels.set(address, (label) => {
|
|
21582
21605
|
const symbol = this.sdk.tokensMeta.symbol(token);
|
|
@@ -21595,12 +21618,12 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21595
21618
|
* @returns
|
|
21596
21619
|
*/
|
|
21597
21620
|
#findTokenForPriceFeed(priceFeed) {
|
|
21598
|
-
for (const [token, pf] of
|
|
21621
|
+
for (const [token, pf] of this.mainPriceFeeds.entries()) {
|
|
21599
21622
|
if (pf.address === priceFeed) {
|
|
21600
21623
|
return [token, false];
|
|
21601
21624
|
}
|
|
21602
21625
|
}
|
|
21603
|
-
for (const [token, pf] of
|
|
21626
|
+
for (const [token, pf] of this.reservePriceFeeds.entries()) {
|
|
21604
21627
|
if (pf.address === priceFeed) {
|
|
21605
21628
|
return [token, true];
|
|
21606
21629
|
}
|
|
@@ -21615,13 +21638,13 @@ var PriceOracleContract = class extends BaseContract {
|
|
|
21615
21638
|
return {
|
|
21616
21639
|
...super.stateHuman(raw),
|
|
21617
21640
|
mainPriceFeeds: Object.fromEntries(
|
|
21618
|
-
|
|
21641
|
+
this.mainPriceFeeds.entries().map(([token, v]) => [
|
|
21619
21642
|
this.labelAddress(token),
|
|
21620
21643
|
v.stateHuman(raw)
|
|
21621
21644
|
])
|
|
21622
21645
|
),
|
|
21623
21646
|
reservePriceFeeds: Object.fromEntries(
|
|
21624
|
-
|
|
21647
|
+
this.reservePriceFeeds.entries().map(([token, v]) => [
|
|
21625
21648
|
this.labelAddress(token),
|
|
21626
21649
|
v.stateHuman(raw)
|
|
21627
21650
|
])
|
|
@@ -21984,26 +22007,19 @@ var MarketRegister = class extends SDKConstruct {
|
|
|
21984
22007
|
this.#logger?.info(`loaded ${markets.length} markets`);
|
|
21985
22008
|
}
|
|
21986
22009
|
/**
|
|
21987
|
-
* Loads new prices for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
21988
|
-
*
|
|
22010
|
+
* Loads new prices and price feeds for given oracles from PriceFeedCompressor, defaults to all oracles
|
|
22011
|
+
* Supports v300 and v310 oracles
|
|
21989
22012
|
*/
|
|
21990
22013
|
async updatePrices(oracles) {
|
|
21991
|
-
const
|
|
21992
|
-
if (!
|
|
22014
|
+
const multicalls = this.markets.map((m) => m.priceOracle).filter((o) => !oracles || oracles.includes(o.address)).map((o) => o.syncStateMulticall());
|
|
22015
|
+
if (!multicalls.length) {
|
|
21993
22016
|
return;
|
|
21994
22017
|
}
|
|
21995
22018
|
const { txs } = await this.sdk.priceFeeds.generatePriceFeedsUpdateTxs();
|
|
21996
22019
|
const resp = await simulateMulticall(this.provider.publicClient, {
|
|
21997
22020
|
contracts: [
|
|
21998
22021
|
...txs.map(rawTxToMulticallPriceUpdate),
|
|
21999
|
-
...
|
|
22000
|
-
abi: iPriceFeedCompressorAbi,
|
|
22001
|
-
address: this.sdk.addressProvider.getLatestVersion(
|
|
22002
|
-
AP_PRICE_FEED_COMPRESSOR
|
|
22003
|
-
),
|
|
22004
|
-
functionName: "getPriceFeeds",
|
|
22005
|
-
args: [o]
|
|
22006
|
-
}))
|
|
22022
|
+
...multicalls.map((mc) => mc.call)
|
|
22007
22023
|
],
|
|
22008
22024
|
allowFailure: false,
|
|
22009
22025
|
gas: 550000000n,
|
|
@@ -22011,18 +22027,10 @@ var MarketRegister = class extends SDKConstruct {
|
|
|
22011
22027
|
// we cannot have price updates and compressor request in different batches
|
|
22012
22028
|
});
|
|
22013
22029
|
const oraclesStates = resp.slice(txs.length);
|
|
22014
|
-
for (let i = 0; i <
|
|
22015
|
-
const
|
|
22016
|
-
const
|
|
22017
|
-
|
|
22018
|
-
for (const { token, priceFeed, reserve } of entries) {
|
|
22019
|
-
const price = tree.find((n) => n.baseParams.addr === priceFeed)?.answer?.price;
|
|
22020
|
-
if (reserve && price) {
|
|
22021
|
-
oracle.reservePrices.upsert(token, price);
|
|
22022
|
-
} else if (price) {
|
|
22023
|
-
oracle.mainPrices.upsert(token, price);
|
|
22024
|
-
}
|
|
22025
|
-
}
|
|
22030
|
+
for (let i = 0; i < multicalls.length; i++) {
|
|
22031
|
+
const handler = multicalls[i].onResult;
|
|
22032
|
+
const result = oraclesStates[i];
|
|
22033
|
+
handler(result);
|
|
22026
22034
|
}
|
|
22027
22035
|
}
|
|
22028
22036
|
get state() {
|