Skip to content

Commit

Permalink
feat: the two latest banks added will show in announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Nov 1, 2024
1 parent ce9a9f7 commit 2f93090
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions apps/marginfi-v2-ui/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,14 @@ export default function HomePage() {

const annoucements = React.useMemo(() => {
let banks: (ExtendedBankInfo | undefined)[] = [];
banks.push(extendedBankInfos.find((bank) => bank.meta.tokenSymbol === "hSOL"));

if (marginfiClient?.banks) {
const latestBankKey = Array.from(marginfiClient.banks.keys())[0];
banks.push(extendedBankInfos.find((bank) => bank.address.toString() === latestBankKey.toString()));
const latestBankKeys = Array.from(marginfiClient.banks.keys()).splice(0, 2);
banks.push(
...latestBankKeys
.map((bankKey) => extendedBankInfos.find((bank) => bank.address.toBase58() === bankKey))
.filter((bank): bank is ExtendedBankInfo => bank !== undefined)
);
}

banks = banks.filter((bank): bank is ExtendedBankInfo => bank !== undefined);
Expand Down

0 comments on commit 2f93090

Please sign in to comment.