Created
June 29, 2017 18:38
-
-
Save jaekwon/fdbe2bc79b309e8e54caeac03c1e010b to your computer and use it in GitHub Desktop.
Bancor simulation
This file contains 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
balance = 1.0 # amount of reserve tokens | |
supply = 1000.0 # amount of smart tokens | |
crr = 0.001 # arbitrary reserve ratio | |
def printInfo(): | |
price = computePrice() | |
print "balance", balance, "supply", supply, "price", price | |
def computePrice(): | |
return balance / (supply * crr) | |
print "Initial price", computePrice() | |
# keep buying | |
i = 0 | |
while True: | |
# debug | |
if i % 10000 == 0: | |
printInfo() | |
import time | |
time.sleep(0.1) | |
i+=1 | |
# how much to purchase: 1.0 reserve token | |
purchase = 1.0 | |
price = computePrice() | |
balance += purchase | |
supply += purchase / price |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment