Created
April 21, 2017 00:14
-
-
Save veox/c3e957760d7c102e78a9420bbfab849e to your computer and use it in GitHub Desktop.
WIP Rough chart for GNO price during auction
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
| #!/usr/bin/env python3.6 | |
| # plot for : | |
| # https://github.com/ConsenSys/gnosis-contracts/blob/security_audit/contracts/solidity/DO/DutchAuction.sol#L236 | |
| import matplotlib.pyplot as plot | |
| # about now (early night 2017-04-21) | |
| #STARTBLOCK = 3_571_520 | |
| # expected on early night of 2017-04-24 | |
| STARTBLOCK = 3_588_800 | |
| # magicnum in contract (see header) | |
| PRICEFACTOR = 4500 | |
| # would have been a high starting price | |
| #PRICEFACTOR = 1_000_000 | |
| # magicnum: average block time around 15 secs now, so 5760 blocks per day | |
| DAY = 5760 | |
| def gen(startblock, pricefactor): | |
| currentblock = startblock | |
| while True: | |
| # magic contract formula (see header) | |
| price = pricefactor * pow(10,18) / (currentblock - startblock + 7500) + 1 | |
| (yield currentblock, price) | |
| currentblock += DAY | |
| return | |
| pricegen = gen(startblock = STARTBLOCK, pricefactor = PRICEFACTOR) | |
| # fuck you matplotlib and your numpy arrays | |
| B = [] | |
| P = [] | |
| while True: | |
| block, price = pricegen.send(None) | |
| #print(block, price / pow(10,18)) | |
| B.append(block) | |
| P.append(price / pow(10,18)) # in ether | |
| # FIXME: should be timed transition comparison, price < stop price, not arbitrary | |
| if block > STARTBLOCK + 30*DAY or price < pow(10,15): | |
| break | |
| # PLOT | |
| #plot.plot(B, P, marker = 'o') | |
| #plot.xlabel('B (block number)') | |
| plot.plot(P, marker = 'o') | |
| plot.xlabel('t (time, days)') | |
| plot.ylabel('P (price, ether)') | |
| #plot.legend() | |
| plot.grid() | |
| plot.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment