computablelabs / goest

Golang testing and sandbox for the Computable Protocol. 0xb00.
MIT License
8 stars 0 forks source link

getSupportPrice() branch error #122

Closed rbharath closed 5 years ago

rbharath commented 5 years ago

The line

https://github.com/computablelabs/computable/blob/master/contracts/Reserve.vy#L49

has a bug. When this branch is triggered, the support price explodes and it becomes extremely expensive to invest in the market. The market is essentially no longer usable at this point. Here's an IPython notebook that duplicates the error condition:

https://github.com/computablelabs/economics/pull/7

This line will have to be modified to no longer trigger the explosion.

rbharath commented 5 years ago

Simulations in https://github.com/computablelabs/economics/pull/8 provide evidence that a fix could be to swap the line:

return price_floor + ((spread * reserve) / 100)

with the line

return price_floor + ((spread * reserve * 1000000000) / (100 * 1000000000000000000)) # NOTE the multipliers ONE_GWEI and ONE_ETH

This basically re-uses the style of equation in https://github.com/computablelabs/computable/blob/master/contracts/Reserve.vy#L51 (which works) but thresholds the denominator at 1 MKT. This seems to fix the issue in simulation.

rbharath commented 5 years ago

A bugfix should add a test in the go test-suite that would have caught this issue earlier.

rbharath commented 5 years ago

Fixed in https://github.com/computablelabs/goest/pull/123.