Skip to content

Instantly share code, notes, and snippets.

View claytantor's full-sized avatar
💭
Doing and Being

Clay Graham claytantor

💭
Doing and Being
View GitHub Profile
@claytantor
claytantor / lmstudio-agent.py
Last active June 27, 2025 04:44
lmstudio-python first attempts at a Agent with Pydantic AI
class LMStudioResponse(BaseModel):
"""Model for LM Studio response"""
content: str = Field(..., description="The content of the response")
class LMStudioAgent:
model:lms.LLM = None
def __init__(
self,
@claytantor
claytantor / app.py
Created April 2, 2025 00:31
LM Studio and Pydantic AI in Python
from typing import Sequence
import requests
import os
from pydantic import BaseModel, Field, ValidationError
import json
# load the environment file with py-dotenv
from dotenv import load_dotenv
load_dotenv()
from openai import OpenAI
@claytantor
claytantor / SwapFormEnabled.js
Last active March 19, 2025 14:52
PookaSwaps for ReactJs and ethers.js 5.8.0
const SwapFormEnabled = ({config, signer}) => {
// Contract addresses
const DAI_ADDRESS = config.DAI_ADDRESS;
const POOKA_ADDRESS = config.POOKA_ADDRESS;
const SWAP_ROUTER_ADDRESS = config.UNIVERSAL_ROUTER_V2_ADDRESS;
const POOKA_HOOK_ADDRESS = config.POOKA_HOOK_ADDRESS;
const STATE_VIEW_ADDRESS = config.STATE_VIEW_ADDRESS;
const [swapFrom, setSwapFrom] = useState("");
{
"DAI_ADDRESS":"0xFF34B3d4Aee8ddCd6F9AFFFB6Fe49bD371b8a357",
"POOKA_ADDRESS":"0xAb01f22e992D01f5453057dA2F73833221E57848",
"POOKA_HOOK_ADDRESS":"0x6a5ab2649B3606452be27A06b541Bd2A09Dc8080",
"UNISWAP_V4_POOL_MANAGER":"0xE03A1074c86CFeDd5C142C4F04F1a1536e203543",
"UNISWAP_V4_SWAP_ROUTER":"0x3bFA4769FB09eefC5a80d6E87c3B9C650f7Ae48E",
"UNIVERSAL_ROUTER_V2_ADDRESS":"0x3a9d48ab9751398bbfa63ad67599bb04e4bdf98b"
}
@claytantor
claytantor / PookaValuationHook.sol
Last active February 19, 2025 04:19
Uniswap V4 Hook Example - PookaValuationHook
// SPDX-License-Identifier: MIT
pragma solidity 0.8.26;
// lib/v4-core/src/interfaces/IHooks.sol
import {IHooks} from "v4-core/interfaces/IHooks.sol";
import {Hooks} from "v4-core/libraries/Hooks.sol";
import {BaseHook} from "v4-periphery/base/hooks/BaseHook.sol";
import {BalanceDelta} from "v4-core/types/BalanceDelta.sol";
import {BeforeSwapDelta, BeforeSwapDeltaLibrary} from "v4-core/types/BeforeSwapDelta.sol";
import {TickMath} from "v4-core/libraries/TickMath.sol";
@claytantor
claytantor / SwapExampleV3.sol
Last active October 28, 2024 23:48
Swap Example for V3
// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity = 0.7.6;
pragma abicoder v2;
// import '@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol';
import '@uniswap/swap-router-contracts/contracts/interfaces/ISwapRouter02.sol';
interface IERC20 {
function balanceOf(address account) external view returns (uint256);
@claytantor
claytantor / gasestimate.js
Created October 28, 2024 19:08
Estimate gas on a swap
async function estimateTransactionCost(provider, contract) {
// Set up provider and contract
// const provider = new ethers.providers.InfuraProvider("sepolia", "YOUR_INFURA_PROJECT_ID");
// const wallet = new ethers.Wallet("YOUR_PRIVATE_KEY", provider);
// const contract = new ethers.Contract("CONTRACT_ADDRESS", contractAbi, wallet);
try {
// Estimate gas for the function
//const gasLimitMax = ethers.utils.parseUnits("10", "gwei");
const gasLimitMax = 500000;
@claytantor
claytantor / sendTxBuildSimlated.js
Last active April 2, 2025 20:28
Simulated Builder Tx on Titan
/**
RPC_ENDPOINT_ETHERS = "https://mainnet.infura.io/v3/<secret>"
BUILDER_RPC = "https://rpc.titanbuilder.xyz"
ETH_NETWORK = "mainnet"
*/
const ethers = require('ethers');
const {
FlashbotsBundleProvider,
} = require("@flashbots/ethers-provider-bundle");
@claytantor
claytantor / setFlashbotTx.js
Created October 24, 2024 16:35
Basic Fashbots Provider Simulation Example
const ethers = require('ethers');
const {
FlashbotsBundleProvider,
} = require("@flashbots/ethers-provider-bundle");
const dotenv = require("dotenv");
dotenv.config({ path: './config/.env.fbbundle.sepolia' });
const {
ETH_NETWORK,
update_PS1 () {
VENV_PROMPT="(${VIRTUAL_ENV##*/})"
if [ $VENV_PROMPT == "()" ]; then
VENV_PROMPT=""
fi
PS1="\[$(tput bold)\]\[\033[38;5;214m\]\u\[$(tput sgr0)\]\[$(tput sgr0)\]\[\033[38;5;76m\]@\[$(tput sgr0)\]\[\033[38;5;82m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;226m\]\W\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]"
PS1="$PS1$(__git_ps1 "\[\e[32m\][%s]\[\e[0m\]") $VENV_PROMPT $ "
}
shopt -u promptvars