From 02581fa95c418b4a38c36f76891e6eab0aa256ba Mon Sep 17 00:00:00 2001 From: Andrew Chiw Date: Tue, 2 Jun 2020 16:18:27 +0200 Subject: [PATCH] Commons.dai_to_tokens() simulates how many tokens would x DAI buy you --- hatch.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/hatch.py b/hatch.py index 384ed8a..08a01a7 100644 --- a/hatch.py +++ b/hatch.py @@ -126,8 +126,9 @@ class Commons: return money_returned, realized_price - def token_price(self): + def dai_to_tokens(self, dai): """ - Query the bonding curve for the current token price, given the size of the commons's collateral pool. + Given the size of the common's collateral pool, return how many tokens would x DAI buy you. """ - return self.bonding_curve.get_token_price(self._collateral_pool) \ No newline at end of file + price = self.bonding_curve.get_token_price(self._collateral_pool) + return dai / price \ No newline at end of file