Skip to content

Instantly share code, notes, and snippets.

@bogatyy
Created April 7, 2018 21:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bogatyy/06ed7ef82efaf02c2c3b2f3a37d658c5 to your computer and use it in GitHub Desktop.
Save bogatyy/06ed7ef82efaf02c2c3b2f3a37d658c5 to your computer and use it in GitHub Desktop.
def handle_transaction(tx):
# if(tx[u'to'] == KITTY_AUCTION):
# kitty_frontrun(tx)
if (tx[u'to'] == KITTY_CORE_CONTRACT):
kitty_instabid(tx)
def kitty_instabid(tx):
if (get_tx_method(tx) == CREATE_SALE_AUCTION):
generation, cooldown, price = get_kitty_params(tx)
gas_price = int(tx[u'gasPrice'], 16)
is_good_deal = price < calculateThresholdPrice(generation, cooldown)
if (is_good_deal):
try_buy_kitty(..., gas_price=gas_price) # buy in same block
await_confirmation(tx)
try_buy_kitty(..., gas_price=200 gwei) # buy in next block
while True:
tx = nextPendingTX()
handle_transaction(tx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment