Skip to content

Instantly share code, notes, and snippets.

@banteg
banteg / model_flip_eth_a.py
Last active Oct 19, 2021
boilerplate makerdao auction keeper model using python
View model_flip_eth_a.py
#!/usr/bin/env python
import os
import sys
import json
import requests
discount = 0.15
def get_price():
resp = requests.get('https://api.coingecko.com/api/v3/simple/price', params={'ids': 'ethereum', 'vs_currencies': 'usd'})
@banteg
banteg / deposit.py
Last active Aug 13, 2021
eth2 mass deposit for lighthouse
View deposit.py
# 1. generate keys with `lighthouse account validator new random N`
# 2. run `python deposit.py`, it skips the ones already deposited and deposits the rest
import json
import sys
from pathlib import Path
from getpass import getpass
from eth_utils import encode_hex, decode_hex
from web3 import Web3
from web3.middleware import construct_sign_and_send_raw_middleware
View kadena-mined-blocks.csv
miner count
e7f7634e925541f368b827ad5c72421905100f6205285a78c19d7b4a38711805 54578
93ac6ca68b2540453261abdb962e3fdb878a5523c08caf9c4079aef92d3177be 37029
0e92c6030a05010c1e7bd40b7d8261fe5e9da2821d1411e3e440cb773463679a 13541
a248289e385c7cbac252eae9b03577c5d3f3a9a7a1f67ed43c65e9318dd65c18 12039
96cfb7db1a5f6989e5624c7dd81b5a2b3ebe1ddfd849ecba7cfdce15d201b0c9 11631
f37d819fc4a6e80286557807e0d39a66ff448daf355363da807902621e374ef0 9083
40c204ee9d55aba202e76c457c7ac0afccf7bce8768d2bb0f4696605eb342123 7722
d30c907adc0000d8a54e8c4f0843d05c500da3c2faa0fe943e085ab278abe751 7496
834ec56e02fbddf69886c3b2801fc39dad301c0d05406843288fb8f79c45b5c6 4644
View kadena-genesis-txs.md

transaction 1

(interface fungible-v1

  " Standard for fungible coins and tokens as specified in KIP-0002. "

   ; ----------------------------------------------------------------------
   ; Schema

   (defschema account-details
@banteg
banteg / yt-seek.sh
Created Apr 29, 2019
download fragment of a youtube video without downloading the whole thing
View yt-seek.sh
#!/bin/bash
NAME=yt-seek
if [ "$#" -ne 3 ]; then
echo "Usage: $NAME <url> <start> <duration>"
exit 1
fi
URL=$1
START=$2
View maker_chief.py
import json
from collections import Counter, defaultdict
from concurrent.futures import ThreadPoolExecutor
from dataclasses import dataclass, field
from decimal import Decimal
from itertools import count
from pathlib import Path
import click
import requests
@banteg
banteg / uniswap_total.py
Created Mar 6, 2019
tally ether locked across all uniswap exchanges
View uniswap_total.py
from concurrent.futures import ThreadPoolExecutor
from web3.auto import w3
from cryptocompare import get_price
abi = [{'name': 'NewExchange', 'inputs': [{'type': 'address', 'name': 'token', 'indexed': True}, {'type': 'address', 'name': 'exchange', 'indexed': True}], 'anonymous': False, 'type': 'event'}]
factory = w3.eth.contract('0xc0a47dFe034B400B47bDaD5FecDa2621de6c4d95', abi=abi)
new_exchange = factory.events.NewExchange().createFilter(fromBlock=6627917)
exchanges = [x.args.exchange for x in new_exchange.get_all_entries()]
@banteg
banteg / buffidai.py
Last active Feb 21, 2019
ethdenver vendor statistics
View buffidai.py
from dataclasses import dataclass
from operator import attrgetter
from web3 import Web3, HTTPProvider
from web3.utils.filters import construct_event_filter_params
from tabulate import tabulate
@dataclass
class Vendor:
address: str
View lto_rewards.py
import requests
import click
LTO_NODE_URL = 'http://127.0.0.1:6869'
LTO_API_KEY = '<your api password>'
s = requests.session()
s.headers['X-API-Key'] = LTO_API_KEY
View lto_bridge.py
import os
from operator import itemgetter
from json import JSONDecodeError
from time import sleep
import click
import requests
import pendulum