Skip to content

Instantly share code, notes, and snippets.

View adpthegreat's full-sized avatar
💭
Currently chewing glass, please hold

ADPtheGreat adpthegreat

💭
Currently chewing glass, please hold
View GitHub Profile
@adpthegreat
adpthegreat / analyzing-geth.md
Last active July 14, 2025 14:06 — forked from roninjin10/analyzing-geth.md
Analyzing Geth’s EVM Interpreter (Pre-EOF Execution Path)

Analyzing Geth’s EVM Interpreter (Pre-EOF Execution Path)

Overview: The Go-Ethereum (Geth) client implements the Ethereum Virtual Machine (EVM) as an interpreter that executes contract bytecode. This analysis focuses on the legacy (pre-EOF) execution path in Geth’s core/vm package, highlighting how the interpreter loop works, how the stack/memory are managed, gas accounting, execution context setup, and performance-oriented design choices. Geth’s interpreter is a classic stack-based virtual machine, maintaining a program counter (PC), operand stack, memory, and gas meter during execution. We will walk through the interpreter’s structure and internals with references to Geth’s source code.

Interpreter Loop and Opcode Dispatch

At the heart of Geth’s EVM is the EVMInterpreter.Run loop, which sequentially fetches and executes opcodes until termination. On each iteration, the interpreter reads the next opcode from the contract’s code using the program counter (pc) and dispatches to the corresponding implem

Just think of it the swapping logic in terms of buying and selling LP tokens

JOINING POOL ->

  • we want to receive X amount of LP Tokens
  • we calculate internally the amount of tokenA and tokenB we need to send to the pool using calcTokensOutGivenExactLpTokenIn
  • we approve them for spending
  • we receive LP Token

REMOVED

  • constraints - The output of _calcLpTokenOutGivenExactTokensIn() must be greater than the min Amount of LP token we want to receive, that is (our specifiedAmount)

The Candy Machine NFT Rarity Exploit: Complete Analysis

ELI5: Explain Like I'm 5

Imagine a special gumball machine that gives out toys. Some toys are common (not worth much), and some are super rare and valuable. Normally, when you put in a coin, you're supposed to get a random toy - maybe common, maybe rare if you're lucky.

But I discovered something amazing! This gumball machine isn't really random at all. It decides which toy to give you based on a secret pattern. I built special glasses that can see which toy is about to come out before I put in my coin.

At first, my trick worked like this: I'd peek through my special glasses, and if I saw a boring toy coming next, I wouldn't put in my coin. I'd only spend my money when I saw a super cool rare toy was next.

@adpthegreat
adpthegreat / main.md
Last active April 7, 2025 18:10 — forked from hediet/main.md
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";


interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
@adpthegreat
adpthegreat / CoWAMM tycho protocol SDK integration.md
Last active March 6, 2025 19:10
Plan for Integrating CowAMM into Tycho protocol SDK

#Technical Details and implementation methods

Provide a summary on how CowAMM contracts call each other

Orders - batch_auction - solvers - execution

  • Multiple users orders are bundled together then signed off chain and sent to the protocol , solvers participate in an auction to settle the orders, when trades are first sent to the CoWProtocol, the GPv2settlement contract decodes the order parameters from the trade , and the winning solver calls the permissioned settle method that takes in the trade data and other important parameters .

  • If any operation to be executed is access restricted, the GPv2settlement contract first queries the GPv2AllowlistAuthentication contract to determine if the caller is a solver

@adpthegreat
adpthegreat / pissed off
Created January 6, 2025 11:56 — forked from staccDOTsol/pissed off
pissed off
import {
AddressLookupTableAccount,
Connection,
Keypair,
PublicKey,
TransactionInstruction,
} from "@solana/web3.js";
import { getMarginfiClient } from "./utils";
import { createJupiterApiClient } from "@jup-ag/api";
import { nativeToUi } from "@mrgnlabs/mrgn-common";