Skip to content

Commit 4e894cd

Browse files
committed
fix: add find by price oracle method
1 parent fb9b336 commit 4e894cd

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

src/sdk/market/MarketRegister.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { MarketConfiguratorContract } from "./MarketConfiguratorContract";
1717
import { MarketFactory } from "./MarketFactory";
1818
import type { PoolFactory } from "./PoolFactory";
1919
import { rawTxToMulticallPriceUpdate } from "./pricefeeds";
20-
import type { PriceOracleContract } from "./PriceOracleContract";
2120

2221
export class MarketRegister extends SDKConstruct {
2322
#logger?: ILogger;
@@ -151,15 +150,6 @@ export class MarketRegister extends SDKConstruct {
151150
throw new Error(`cannot find credit manager ${creditManager}`);
152151
}
153152

154-
public findPriceOracle(address: Address): PriceOracleContract {
155-
for (const market of this.markets) {
156-
if (market.priceOracle.address.toLowerCase() === address.toLowerCase()) {
157-
return market.priceOracle;
158-
}
159-
}
160-
throw new Error(`cannot find price oracle ${address}`);
161-
}
162-
163153
public findByCreditManager(creditManager: Address): MarketFactory {
164154
const market = this.markets.find(m =>
165155
m.creditManagers.some(
@@ -174,6 +164,15 @@ export class MarketRegister extends SDKConstruct {
174164
return market;
175165
}
176166

167+
public findByPriceOracle(address: Address): MarketFactory {
168+
for (const market of this.markets) {
169+
if (market.priceOracle.address.toLowerCase() === address.toLowerCase()) {
170+
return market;
171+
}
172+
}
173+
throw new Error(`cannot find price oracle ${address}`);
174+
}
175+
177176
public get markets(): MarketFactory[] {
178177
return this.#markets.values();
179178
}

src/sdk/market/PriceOracleContract.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -325,12 +325,12 @@ export class PriceOracleContract extends BaseContract<abi> {
325325
): [token: Address | undefined, reserve: boolean] {
326326
for (const [token, pf] of this.mainPriceFeeds.entries()) {
327327
if (pf.address === priceFeed) {
328-
return [token as Address, false];
328+
return [token, false];
329329
}
330330
}
331331
for (const [token, pf] of this.reservePriceFeeds.entries()) {
332332
if (pf.address === priceFeed) {
333-
return [token as Address, true];
333+
return [token, true];
334334
}
335335
}
336336
// TODO: this is v3.0 legacy code, should be gone after full v.3.1 rollout

0 commit comments

Comments
 (0)