From 631cd4861a7f7216d6517f0b0eadb48cc4928a96 Mon Sep 17 00:00:00 2001 From: Noloquideus Date: Thu, 14 May 2026 00:24:01 +0300 Subject: [PATCH] feat: add 1 usdt --- .../services/payment_quote_service.py | 31 +++++++------------ 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/application/services/payment_quote_service.py b/src/application/services/payment_quote_service.py index 2bd006f..2632e47 100644 --- a/src/application/services/payment_quote_service.py +++ b/src/application/services/payment_quote_service.py @@ -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() + raise OrderTotalOutOfRangeException( + message='Order total exceeds maximum allowed amount', + ) return PaymentQuote( usdt_amount=usdt_amount,