Skip to content

Commit 02089e5

Browse files
committed
fix: sort credit accounts
1 parent f870e54 commit 02089e5

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/accounts/CreditAccountsService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export class CreditAccountsService extends SDKConstruct {
107107
* TODO: do we want to expose "reverting"?
108108
* TODO: do we want to expose MarketFilter in any way? If so, we need to check that the MarketFilter is compatibled with attached markets?
109109
* @param args
110-
* @returns
110+
* @returns returned credit accounts are sorted by health factor in ascending order
111111
*/
112112
public async getCreditAccounts(
113113
args?: CreditAccountFilter,
@@ -153,7 +153,8 @@ export class CreditAccountsService extends SDKConstruct {
153153
} while (offset !== 0n);
154154
}
155155

156-
return allCAs;
156+
// sort by health factor ascending
157+
return allCAs.sort((a, b) => Number(a.healthFactor - b.healthFactor));
157158
}
158159

159160
/**

src/market/pricefeeds/PriceFeedsRegister.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ import { ZeroPriceFeedContract } from "./ZeroPriceFeed";
2929
* PriceFeedRegister acts as a chain-level cache to avoid creating multiple contract instances.
3030
* It's reused by PriceFeedFactory belonging to different markets
3131
*
32-
* ugly workaround for the face that "stalenessPeriod" is not "PriceFeed"'s attribute
33-
* for example, chainlink price feed can have one staleness period as a top-level oracle entry,
34-
* and another staleness period when it's a part of a composite price feed
35-
*
3632
**/
3733
export class PriceFeedRegister extends SDKConstruct {
3834
public readonly logger?: ILogger;

0 commit comments

Comments
 (0)