Skip to content

Commit

Permalink
fix: ata creation missing due to missing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
k0beLeenders committed Dec 14, 2024
1 parent 7623170 commit 92ae3a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
44 changes: 23 additions & 21 deletions apps/marginfi-v2-trading/src/hooks/useMarginfiClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import React from "react";
import { useConnection } from "~/hooks/use-connection";
import { useTradeStoreV2 } from "~/store";
import { ArenaBank } from "~/store/tradeStoreV2";
import { BankMetadata } from "@mrgnlabs/mrgn-common";

type UseMarginfiClientProps = {
groupPk: PublicKey;
Expand All @@ -34,25 +35,16 @@ export function useMarginfiClient({
programId: defaultConfig.programId,
},
}: UseMarginfiClientProps) {
const [
arenaPools,
banksByBankPk,
groupsByGroupPk,
tokenAccountMap,
lutByGroupPk,
mintDataByMint,
bankMetadataCache,
wallet,
] = useTradeStoreV2((state) => [
state.arenaPools,
state.banksByBankPk,
state.groupsByGroupPk,
state.tokenAccountMap,
state.lutByGroupPk,
state.mintDataByMint,
state.bankMetadataCache,
state.wallet,
]);
const [arenaPools, banksByBankPk, groupsByGroupPk, tokenAccountMap, lutByGroupPk, mintDataByMint, wallet] =
useTradeStoreV2((state) => [
state.arenaPools,
state.banksByBankPk,
state.groupsByGroupPk,
state.tokenAccountMap,
state.lutByGroupPk,
state.mintDataByMint,
state.wallet,
]);
const { connection } = useConnection();

const client = React.useMemo(() => {
Expand Down Expand Up @@ -99,6 +91,17 @@ export function useMarginfiClient({

const program = new Program(idl, provider) as any as MarginfiProgram;

let bankMetadataByBankPk: Record<string, BankMetadata> = {};

[tokenBank, quoteBank].forEach((bank) => {
const bankPk = bank.info.rawBank.address.toBase58();
bankMetadataByBankPk[bankPk] = {
tokenAddress: bank.info.state.mint.toBase58(),
tokenName: bank.meta.tokenName,
tokenSymbol: bank.meta.tokenSymbol,
};
});

const client = new MarginfiClient(
{ groupPk, ...clientConfig },
program,
Expand All @@ -111,7 +114,7 @@ export function useMarginfiClient({
feedIdMap,
lut,
bankAddresses,
bankMetadataCache,
bankMetadataByBankPk,
clientOptions?.bundleSimRpcEndpoint,
clientOptions?.processTransactionStrategy
);
Expand All @@ -132,7 +135,6 @@ export function useMarginfiClient({
clientOptions?.processTransactionStrategy,
wallet,
clientConfig,
bankMetadataCache,
]);

return client;
Expand Down
1 change: 0 additions & 1 deletion packages/marginfi-client-v2/src/models/account/wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -870,7 +870,6 @@ class MarginfiAccountWrapper {
txs: (VersionedTransaction | Transaction)[],
banksToInspect: PublicKey[]
): Promise<SimulationResult> {
console.log("txs", txs);
const [mfiAccountData, ...bankData] = await this.client.simulateTransactions(txs, [
this.address,
...banksToInspect,
Expand Down

0 comments on commit 92ae3a9

Please sign in to comment.