Skip to content

Instantly share code, notes, and snippets.

View wuwe1's full-sized avatar

Wei Wu wuwe1

View GitHub Profile
@wuwe1
wuwe1 / get_pairs.py
Last active April 4, 2022 07:25
Get all Uniswap pairs and token0, token1
import asyncio
from brownie import network, multicall, config, interface
address_book = config["networks"][network.show_active()]
QUICK_V2_FACTORY = address_book["QUICK_V2_FACTORY"]
factory = interface.IUniswapV2Factory(QUICK_V2_FACTORY)
def get_all_pairs(factory):
from brownie import web3
def create2_address(address, salt, init_code):
"""CREATE2 opcode Python implementation.
EIP-104
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1014.md
"""
pre = "0xff"
from sympy import *
# https://certik.github.io/scipy-2013-tutorial/html/index.html#
# Tips:
# 1. SymPy expressions are immutable. No function will change them in-place.
# 2. `simplify` is entirely heuristical and can be unnecessarily slow.
# 3. `factor` is guaranteed to factor the polynomial into irreducible factors.
# 4. if you are only interested in making sure that the expression is in canceled form, `cancel` is more efficient than `factor`.
# 5. by default, SymPy will not perform power simplifications if they are not true in general.
@wuwe1
wuwe1 / USDT.t.sol
Last active November 5, 2022 11:44
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.10;
import "forge-std/Test.sol";
interface IERC20 {
event Approval(address indexed owner, address indexed spender, uint256 value);
event Transfer(address indexed from, address indexed to, uint256 value);
function name() external view returns (string memory);
@wuwe1
wuwe1 / tst.sh
Last active March 22, 2022 21:40
Run solidity file against a specific block number using eth_call
# inspired by https://www.saurik.com/optimism.html
function tst() {
blk=$1
bin=$2
value=$3
sig=$4
if [ -z $bin ] || [ -z $blk ] || [ -z $value ] || [ -z sig ]
then
echo 'Usage: tst blk bin'