Skip to content

Instantly share code, notes, and snippets.

View amilz's full-sized avatar

amilz amilz

View GitHub Profile
@amilz
amilz / raydium-swap-parse.js
Last active December 28, 2024 15:39
QuickNode Stream - Raydium Swap Parse
/**
* Major modifications from V1:
* 1. Changed architecture to class-based
* 2. Added support for multiple mints
* 3. Added native SOL support
* 4. Handled 0 pre-balance token accounts
* 5. Handled optional accounts for Raydium's swap instructions
*/
class AmmInstructionProcessor {
@amilz
amilz / anchorToKinobi.ts
Created May 16, 2024 15:11
Script to Convert Anchor IDL (tested on v0.30) to Umi Client Library
// @ts-nocheck
import { AnchorIdl, rootNodeFromAnchor } from "@kinobi-so/nodes-from-anchor";
import { createFromRoot, renderJavaScriptVisitor } from "@metaplex-foundation/kinobi";
import { RootNode } from "@kinobi-so/node-types";
import { renderJavaScriptUmiVisitor } from "@kinobi-so/renderers";
import anchorIdl from "../target/idl/kinobi_test.json";
function appendStringToDefinedTypeNames(rootNode: RootNode, appendString: string): RootNode {
const rootNodeCopy = JSON.parse(JSON.stringify(rootNode));
rootNodeCopy.program.definedTypes.forEach(definedType => {
@amilz
amilz / app.ts
Created January 2, 2024 18:42
Solana Fungible Token (Umi)
// January 02, 2024
import { Transaction, SystemProgram, Keypair, Connection, PublicKey, TransactionInstruction, AccountMeta } from "@solana/web3.js";
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults";
import { CreateMetadataAccountV3InstructionAccounts, DataV2Args, createMetadataAccountV3 } from "@metaplex-foundation/mpl-token-metadata";
import { fromWeb3JsKeypair, fromWeb3JsPublicKey, toWeb3JsPublicKey } from "@metaplex-foundation/umi-web3js-adapters";
import { Instruction, TransactionBuilder, createSignerFromKeypair } from "@metaplex-foundation/umi";
import { MINT_SIZE, TOKEN_PROGRAM_ID, createInitializeMintInstruction, getMinimumBalanceForRentExemptMint, getAssociatedTokenAddress, createAssociatedTokenAccountInstruction, createMintToInstruction } from '@solana/spl-token';
import secret from '../wallets/authority.json';