Skip to content

Instantly share code, notes, and snippets.

View Aviksaikat's full-sized avatar
💭
I tell people secrets, it makes them like me

Saikat Karmakar Aviksaikat

💭
I tell people secrets, it makes them like me
View GitHub Profile
@Aviksaikat
Aviksaikat / pyproject.toml
Created August 20, 2023 00:38
poetry config
[tool.poetry]
name = "Flash_loan_arbritage"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
readme = "README.md"
packages = [{include = "Flash_loan_arbritage"}]
[tool.poetry.dependencies]
python = ">=3.10,<3.11"
@Aviksaikat
Aviksaikat / ape-config.yaml
Created August 20, 2023 00:37
uniswap ape-config
name: flash_loan_arbritage
plugins:
- name: solidity
- name: alchemy
- name: foundry
- name: infura
- name: etherscan
ethereum:
default_network: mainnet-fork
mainnet_fork:
@Aviksaikat
Aviksaikat / getEvents.py
Created August 20, 2023 00:36
Get contract events using ape
from ape import project
address = "0xdead"
#contract = project.ContractName.at(address)
contract = project.IUniswapV2Factory.at(address)
for logs in contract.PairCreated:
print(logs)
@Aviksaikat
Aviksaikat / loadInterfacesApe.py
Created August 16, 2023 20:29
Load a contract using interface in ape
# create a interfaces folder inside the contracts folder & put the interfaces inside them
from ape import project
contract = project.contractName.at(contract_address)
# ex
uniswap_v2_router = project.ISwapV2Router02.at(Uniswap_V2_Router_address)
@Aviksaikat
Aviksaikat / fix_after_gitignore.sh
Created August 14, 2023 13:42
remove ignored files from .gitignore
#!/bin/bash
git rm -r --cached . && git add . && git commit -am "Remove ignored files"
echo "Now run git push to make the changes to the remove repo"
@Aviksaikat
Aviksaikat / remove.sh
Created May 18, 2023 11:09
remove none tagged docker images
docker images | grep "<none>" | awk '{print $3}' | xargs docker rmi
@Aviksaikat
Aviksaikat / update_docker_images.sh
Last active May 18, 2023 11:08
Update all your docker images
docker images --format "{{.Repository}}:{{.Tag}}" | xargs -L1 docker pull
# then remove the "<none>" tagged images
docker images | grep "<none>" | awk '{print $3}' | xargs docker rmi
@Aviksaikat
Aviksaikat / encodeWithSignature.py
Created May 16, 2023 23:51
How to do `abi.encodeWithSignature` in python
value = Contract.methodName.encode_input()
print(value)
# wrong
# >> '0xa7a7e4e8'
value = Contract.methodName.encode_input()
# add padding to make it 32 bytes
value = value + "0" * (66 - len(value))
print(value)
# correct
#>> '0xa7a7e4e800000000000000000000000000000000000000000000000000000000'
@Aviksaikat
Aviksaikat / int_to_b32.py
Created May 15, 2023 13:27
convert an integer to bytes32
from brownie import web3
value = 1
# * convert it to bytes32
value = value.to_bytes(32, byteorder="big")
>>> value
b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01'
>>> value.hex()
@Aviksaikat
Aviksaikat / b32-u256.py
Last active May 20, 2024 07:43
bytes32 to int(uint256)
from brownie import web3
web3.toInt(bytes32Data)
# ape
from ape import convert
convert(bytes32Data, int)