feat: add 1 usdt
This commit is contained in:
@@ -6,8 +6,10 @@ from src.application.contracts import ICache, ILogger
|
||||
from src.application.domain.exceptions import OrderTotalOutOfRangeException, ServiceUnavailableException
|
||||
|
||||
|
||||
_MIN_USDT_AMOUNT: Decimal = Decimal('1')
|
||||
|
||||
_FEE_TIERS: tuple[tuple[Decimal, Decimal, Decimal, bool, bool], ...] = (
|
||||
(Decimal('0.08'), Decimal('5000'), Decimal('30000'), True, True),
|
||||
(Decimal('0.08'), Decimal('0'), Decimal('30000'), True, True),
|
||||
(Decimal('0.06'), Decimal('30000'), Decimal('100000'), False, True),
|
||||
(Decimal('0.04'), Decimal('100000'), Decimal('600000'), False, True),
|
||||
)
|
||||
@@ -50,6 +52,11 @@ class PaymentQuoteService:
|
||||
|
||||
|
||||
async def get_quote(self, usdt_amount: Decimal) -> PaymentQuote:
|
||||
if usdt_amount < _MIN_USDT_AMOUNT:
|
||||
raise OrderTotalOutOfRangeException(
|
||||
message='Order total is below minimum allowed amount',
|
||||
)
|
||||
|
||||
rate_raw = await self._remote_cache.hget('tradex:rub:rate', 'value')
|
||||
gas_raw = await self._remote_cache.hget('gwei:eth:last', 'normal_rub')
|
||||
self._logger.info(f'Actual market values: rate={rate_raw}, gas={gas_raw}')
|
||||
@@ -80,25 +87,9 @@ class PaymentQuoteService:
|
||||
break
|
||||
|
||||
if chosen_rate is None or service_fee is None or total_price is None:
|
||||
total_if_lowest_fee = (
|
||||
base_rub
|
||||
+ (base_rub * Decimal('0.04')).quantize(Decimal('0.01'))
|
||||
+ gas_fee
|
||||
).quantize(Decimal('0.01'))
|
||||
if total_if_lowest_fee > Decimal('600000'):
|
||||
raise OrderTotalOutOfRangeException(
|
||||
message='Order total exceeds maximum allowed amount',
|
||||
)
|
||||
total_if_highest_fee = (
|
||||
base_rub
|
||||
+ (base_rub * Decimal('0.08')).quantize(Decimal('0.01'))
|
||||
+ gas_fee
|
||||
).quantize(Decimal('0.01'))
|
||||
if total_if_highest_fee < Decimal('5000'):
|
||||
raise OrderTotalOutOfRangeException(
|
||||
message='Order total is below minimum allowed amount',
|
||||
)
|
||||
raise OrderTotalOutOfRangeException()
|
||||
|
||||
return PaymentQuote(
|
||||
usdt_amount=usdt_amount,
|
||||
|
||||
Reference in New Issue
Block a user