Skip to content

Commit

Permalink
birdeye hot fix
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarpavlovsky committed Oct 15, 2023
1 parent 68148c5 commit cff0a19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
6 changes: 4 additions & 2 deletions apps/marginfi-v2-ui/src/store/lstStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import { create, StateCreator } from "zustand";
import * as solanaStakePool from "@solana/spl-stake-pool";
import { EPOCHS_PER_YEAR, StakeData, fetchStakeAccounts } from "~/utils";
import { TokenInfo, TokenInfoMap, TokenListContainer } from "@solana/spl-token-registry";
import { TokenAccount, TokenAccountMap, fetchBirdeyePrices } from "@mrgnlabs/marginfi-v2-ui-state";
// import { TokenAccount, TokenAccountMap, fetchBirdeyePrices } from "@mrgnlabs/marginfi-v2-ui-state";
import { TokenAccount, TokenAccountMap } from "@mrgnlabs/marginfi-v2-ui-state";
import { persist } from "zustand/middleware";
import BN from "bn.js";

Expand Down Expand Up @@ -293,7 +294,8 @@ async function fetchUserTokenAccounts(connection: Connection, walletAddress: Pub
}

async function fetchTokenPrices(mints: PublicKey[]): Promise<Map<string, number>> {
const prices = await fetchBirdeyePrices(mints);
// const prices = await fetchBirdeyePrices(mints);
const prices = new Array(mints.length).fill(0);
return new Map(prices.map((price, index) => [mints[index].toString(), price.toNumber()]));
}

Expand Down
23 changes: 13 additions & 10 deletions packages/marginfi-v2-ui-state/src/lib/mrgnlend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,18 +149,21 @@ export async function fetchEmissionsPriceMap(banks: Bank[], connection: Connecti
const banksWithEmissions = banks.filter((bank) => !bank.emissionsMint.equals(PublicKey.default));
const emissionsMints = banksWithEmissions.map((bank) => bank.emissionsMint);

const [birdeyePrices, mintAis] = await Promise.all([
fetchBirdeyePrices(emissionsMints),
connection.getMultipleAccountsInfo(emissionsMints),
]);
const mint = mintAis.map((ai) => MintLayout.decode(ai!.data));
const emissionsPrices = banksWithEmissions.map((bank, i) => ({
mint: bank.emissionsMint,
price: birdeyePrices[i],
decimals: mint[0].decimals,
}));
// const [birdeyePrices, mintAis] = await Promise.all([
// fetchBirdeyePrices(emissionsMints),
// connection.getMultipleAccountsInfo(emissionsMints),
// ]);
// const mint = mintAis.map((ai) => MintLayout.decode(ai!.data));
// const emissionsPrices = banksWithEmissions.map((bank, i) => ({
// mint: bank.emissionsMint,
// price: birdeyePrices[i],
// decimals: mint[0].decimals,
// }));
// @ts-ignore
const emissionsPrices = []

const tokenMap: TokenPriceMap = {};
// @ts-ignore
for (let { mint, price, decimals } of emissionsPrices) {
tokenMap[mint.toBase58()] = { price, decimals };
}
Expand Down

2 comments on commit cff0a19

@vercel
Copy link

@vercel vercel bot commented on cff0a19 Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

omni – ./apps/omni

omni-mrgn.vercel.app
omni-git-production-mrgn.vercel.app
omni-one.vercel.app
omni.marginfi.com

@vercel
Copy link

@vercel vercel bot commented on cff0a19 Oct 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.