Skip to content

Commit c44c97e

Browse files
committed
fix: add findByPool for markets
1 parent e27af6e commit c44c97e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/sdk/market/MarketRegister.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,17 @@ export class MarketRegister extends SDKConstruct {
196196
return market;
197197
}
198198
}
199-
throw new Error(`cannot find price oracle ${address}`);
199+
throw new Error(`cannot find market for price oracle ${address}`);
200+
}
201+
202+
public async findByPool(address: Address): Promise<MarketSuite> {
203+
const addr = address.toLowerCase();
204+
for (const market of this.markets) {
205+
if (market.pool.pool.address.toLowerCase() === addr) {
206+
return market;
207+
}
208+
}
209+
throw new Error(`cannot find market for pool ${address}`);
200210
}
201211

202212
public get marketsMap() {

0 commit comments

Comments
 (0)