Skip to content

Instantly share code, notes, and snippets.

View darkerego's full-sized avatar

Darkerego darkerego

View GitHub Profile
@darkerego
darkerego / equalizer_flash_loan.sol
Last active December 6, 2023 04:11
equalizer flash loan
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
interface IERC20 {
function approve(address spender, uint256 amount) external returns (bool);
}
interface IERC3156FlashBorrower {
function onFlashLoan(
address initiator,
@darkerego
darkerego / uniswap-v3-example.sol
Created September 6, 2023 13:04 — forked from mempirate/uniswap-v3-example.sol
Simple example on how to swap on UniswapV3 with the SwapRouter
//SPDX-License-Identifier: Unlicense
pragma solidity ^0.8.0;
pragma abicoder v2;
import "@uniswap/v2-periphery/contracts/interfaces/IWETH.sol";
import "@uniswap/v3-periphery/contracts/interfaces/ISwapRouter.sol";
import "@uniswap/v3-core/contracts/libraries/LowGasSafeMath.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
@darkerego
darkerego / gist:edce02f936b6441b93e3ca66ae817780
Last active September 1, 2023 22:00
Attempting to Revert Static Calls
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TestStateChange {
uint public originalValue = 123;
uint public oldValue;
uint public incrementer = 0;
bytes4 public constant CHANGE_SEL = bytes4(keccak256(bytes('changeState(uint256)')));
bytes4 public constant WRAP_CHANGE_SEL = bytes4(keccak256(bytes('wrapChangeState(uint256)')));
error CallFailedError(string reason,address msgSender,address txOrigin);
@darkerego
darkerego / test_call.sol
Last active August 8, 2023 21:34
Solidity Assembly Call & Get Return Data / Revert with Reason
//SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
// 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2
contract TestExec {
address owner;
constructor() {
owner = msg.sender;
}
@darkerego
darkerego / ahttp_client.py
Last active July 30, 2023 23:50
AioHttp Client Skeleton Class
import asyncio
import json
import aiohttp
class AsyncHttpClient:
def __init__(self, _headers=None, base_url: str = None, timeout: (int, float) = 60):
"""
A skeletal asynchronous HTTP class. Because I found myself writing this same code
@darkerego
darkerego / bscrescue.py
Last active July 25, 2023 07:44
Bloxroute bsc rescue
#!/usr/bin/env python3
# Python 3.7 or higher required due to the use of asyncio.run()
import argparse
import asyncio, json, ssl
import math
import os
import json
import re
import websocket
@darkerego
darkerego / snap.sh
Created July 10, 2023 20:51
Proton Testnet grab snapshot and restart node
#!/bin/bash
echo 'Changing directories ... '
cd /opt/ProtonTestnet/protonNode
echo "Delete old snaps"
rm snapshots/*
echo "Downloading latest snap "
cd snapshots
wget https://backup.cryptolions.io/ProtonTestNet/snapshots/latest-snapshot.bin.zst
unzstd latest-snapshot.bin.zst
@darkerego
darkerego / multichain_w3.py
Created May 17, 2023 21:48
Multichain Web3
import asyncio
import logging
import os
from web3.middleware import geth_poa_middleware
import utils.termstyle
import web3
cp = utils.termstyle.ColorPrinter(0)
@darkerego
darkerego / pycat.py
Created May 12, 2023 18:44
Command Line Tool for Posting to Termbin
#!/usr/bin/env python3.10
import asyncio
import os.path
import sys
from asyncio import StreamReader, StreamWriter
class PyCat:
def __init__(self, host: str, port: int, _loop: asyncio.AbstractEventLoop):
self._loop = _loop
@darkerego
darkerego / mnemonic_utils.py
Created March 3, 2023 02:26
Ethereum Mnemonic to Key Generator CLI Tool
#!/usr/bin/env python3
import argparse
import binascii
import hashlib
import hmac
import struct
import web3
from base58 import b58encode_check
from ecdsa.curves import SECP256k1