This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Amount, toBigNumber } from "@mrgnlabs/mrgn-common"; | |
import { getMarginfiClient } from "./utils"; | |
import { Bank, OraclePrice } from "../src"; | |
import BigNumber from "bignumber.js"; | |
async function main() { | |
const client = await getMarginfiClient(); | |
const uxdBank = client.getBankByTokenSymbol("UXD"); | |
if (!uxdBank) { | |
throw new Error("UXD bank not found"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn convert_encoded_ui_transaction( | |
encoded_tx: EncodedTransactionWithStatusMeta, | |
) -> anyhow::Result<VersionedTransactionWithStatusMeta> { | |
Ok(VersionedTransactionWithStatusMeta { | |
transaction: encoded_tx.transaction.decode().unwrap(), | |
meta: convert_meta(encoded_tx.meta.unwrap())?, | |
}) | |
} | |
pub fn convert_meta(ui_meta: UiTransactionStatusMeta) -> anyhow::Result<TransactionStatusMeta> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from "fs"; | |
import { AccountInfo, Connection, PublicKey } from "@solana/web3.js"; | |
import { getConfig, MarginfiAccountWrapper, MarginfiClient } from "@mrgnlabs/marginfi-client-v2"; | |
const BANK_TOKEN = "SOL"; | |
// const BANK_TOKEN_MINT = "So11111111111111111111111111111111111111112"; | |
interface BankDepositor { | |
wallet: string; | |
userAccount: string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use itertools::Itertools; | |
use solana_account_decoder::parse_token::UiTokenAmount; | |
use solana_sdk::{ | |
hash::Hash, | |
instruction::CompiledInstruction, | |
message::{ | |
legacy, | |
v0::{self, LoadedAddresses, MessageAddressTableLookup}, | |
MessageHeader, VersionedMessage, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as BufferLayout from "buffer-layout"; | |
import { | |
AccountInfo, | |
ASSOCIATED_TOKEN_PROGRAM_ID, | |
Token, | |
TOKEN_PROGRAM_ID, | |
u64, | |
} from "@solana/spl-token"; | |
import { Connection, PublicKey } from "@solana/web3.js"; | |
import { BN } from "bn.js"; |