Rounds the price to the nearest 1/10 of 1 Dai.
eg:
while s=29 - 35, p= 1.500000000000000000 // unrounded = 1.53148...
while s=36 - 44, p= 1.600000000000000000 // unrounded = 1.55630
Also cleans up some comments and unneeded stuff from the contract.
The last remaining addition to the contract (apart from possible gas-optimizations) is to add the call to the DAO contract to initiate minting an FYI token for the author.
Next steps are:
3.) take a closer look at how to get the DAO to do what we need it to do
4.) add the call to the DAO in the hook
5.) deploy rinkeby test system
Note on gas:
Base case (No hook) for purchase:
values are: Min, Max, Average, # of calls, cost $
With the hook:
No price update: 199358 gas for a first key, 109577 gas for a key extension
With price update: 225561 gas for a first key, 135768 gas for a key extension
So, around 26,000 extra gas for updating the price (which we're doing far less often now).
For reference, it costs:
21000 gas to send eth
20000 gas to write to storage the first time( 5000 to update it afterwards)
Overall, even for our worst-case scenario(first time key purchase with a price update), we're well below the max values for the purchase function without even using the hook!
Rounds the price to the nearest 1/10 of 1 Dai. eg: while s=29 - 35, p= 1.500000000000000000 // unrounded = 1.53148... while s=36 - 44, p= 1.600000000000000000 // unrounded = 1.55630
Also cleans up some comments and unneeded stuff from the contract.
The last remaining addition to the contract (apart from possible gas-optimizations) is to add the call to the DAO contract to initiate minting an FYI token for the author.
Next steps are: 3.) take a closer look at how to get the DAO to do what we need it to do 4.) add the call to the DAO in the hook 5.) deploy rinkeby test system
Note on gas: Base case (No hook) for purchase: values are: Min, Max, Average, # of calls, cost $
![IMAGE](quiver-image-url/BAFB1CBD1EB78D39C9924213036A0A47.jpg =1522x57)![image](https://user-images.githubusercontent.com/17053076/86366699-547ead80-bc38-11ea-86d7-c777c9b955c1.png)
With the hook: No price update: 199358 gas for a first key, 109577 gas for a key extension With price update: 225561 gas for a first key, 135768 gas for a key extension
So, around 26,000 extra gas for updating the price (which we're doing far less often now). For reference, it costs:
Overall, even for our worst-case scenario(first time key purchase with a price update), we're well below the max values for the purchase function without even using the hook!