Created
April 7, 2018 21:21
-
-
Save bogatyy/06ed7ef82efaf02c2c3b2f3a37d658c5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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