Ejemplo n.º 1
0
    def test_calculate_token_quantity(self):
        value = '100000'
        decimals = 3
        expected = Decimal('100')

        result = calculate_token_quantity(value, decimals)
        self.assertEqual(result, expected)
Ejemplo n.º 2
0
    def test_calculate_token_quantity_just_fraction(self):
        value = '500'
        decimals = 3
        expected = Decimal('0.5')

        result = calculate_token_quantity(value, decimals)
        self.assertEqual(result, expected)
Ejemplo n.º 3
0
def get_base_bounty_values(bounty):
    base_fields = narrower(bounty, ['title', 'bounty_id', 'tokenSymbol', 'tokenDecimals'])
    base_fields['total_value'] = calculate_token_quantity(bounty.fulfillmentAmount, bounty.tokenDecimals)
    base_fields['usd_price'] = Decimal(bounty.usd_price).quantize(Decimal(10) ** -2)
    base_fields['deadline'] = bounty.deadline.strftime('%m/%d/%Y')
    base_fields['token_price'] = 'Unkown Price' if not bounty.token else Decimal(bounty.token.price_usd).quantize(Decimal(10) ** -2)
    base_fields['token_lock_price'] = 'Unkown Price' if not bounty.tokenLockPrice else Decimal(bounty.tokenLockPrice).quantize(Decimal(10) ** -2)
    base_fields['link'] = bounty_url_for(bounty.bounty_id, bounty.platform)
    return base_fields