Skip to content

Commit

Permalink
dashboard/models: Add value_in_udt bounty property.
Browse files Browse the repository at this point in the history
The value_in_usdt property returns value of the bounty using first available
ConversionRate after web3_created bounty creation time.

Issue: gitcoinco#693
  • Loading branch information
cryptomental authored and Przemyslaw Szulczynski committed Apr 10, 2018
1 parent 2c1db08 commit 41deda6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app/dashboard/models.py
Expand Up @@ -376,6 +376,18 @@ def value_in_usdt_now(self):
except Exception:
return None

@property
def value_in_usdt(self):
decimals = 10 ** 18
if self.token_name == 'USDT':
return float(self.value_in_token)
if self.token_name == 'DAI':
return float(self.value_in_token / 10 ** 18)
try:
return round(float(convert_amount(self.value_in_eth, 'ETH', 'USDT', self.web3_created)) / decimals, 2)
except Exception:
return None

@property
def token_value_in_usdt_now(self):
return round(convert_token_to_usdt(self.token_name), 2)
Expand Down

0 comments on commit 41deda6

Please sign in to comment.