Skip to content

Commit

Permalink
Remove lnpayment, tick, onchain model contraints based on .env
Browse files Browse the repository at this point in the history
  • Loading branch information
Reckless-Satoshi committed Oct 4, 2023
1 parent 57d1524 commit cbb6f73
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions api/logics.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ def compute_swap_fee_rate(balance):
shape = str(config("SWAP_FEE_SHAPE"))

if shape == "linear":
MIN_SWAP_FEE = float(config("MIN_SWAP_FEE"))
MIN_SWAP_FEE = config("MIN_SWAP_FEE", cast=float, default=0.01)
MIN_POINT = float(config("MIN_POINT"))
MAX_SWAP_FEE = float(config("MAX_SWAP_FEE"))
MAX_POINT = float(config("MAX_POINT"))
Expand All @@ -600,7 +600,7 @@ def compute_swap_fee_rate(balance):
)

elif shape == "exponential":
MIN_SWAP_FEE = float(config("MIN_SWAP_FEE"))
MIN_SWAP_FEE = config("MIN_SWAP_FEE", cast=float, default=0.01)
MAX_SWAP_FEE = float(config("MAX_SWAP_FEE"))
SWAP_LAMBDA = float(config("SWAP_LAMBDA"))
swap_fee_rate = MIN_SWAP_FEE + (MAX_SWAP_FEE - MIN_SWAP_FEE) * math.exp(
Expand Down
4 changes: 2 additions & 2 deletions api/models/ln_payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from decouple import config
from django.conf import settings
from django.contrib.auth.models import User
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
Expand Down Expand Up @@ -78,7 +78,7 @@ class FailureReason(models.IntegerChoices):
num_satoshis = models.PositiveBigIntegerField(
validators=[
MinValueValidator(100),
MaxValueValidator(1.5 * config("MAX_TRADE", cast=int, default=1_000_000)),
MaxValueValidator(1.5 * settings.MAX_TRADE),
]
)
# Routing budget in PPM
Expand Down
8 changes: 6 additions & 2 deletions api/models/market_tick.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class MarketTick(models.Model):
fee = models.DecimalField(
max_digits=4,
decimal_places=4,
default=config("FEE", cast=float, default=0),
default=0,
validators=[MinValueValidator(0), MaxValueValidator(1)],
)

Expand All @@ -71,7 +71,11 @@ def log_a_tick(order):
premium = 100 * (price / market_exchange_rate - 1)

market_tick = MarketTick.objects.create(
price=price, volume=volume, premium=premium, currency=order.currency
price=price,
volume=volume,
premium=premium,
currency=order.currency,
fee=config("FEE", cast=float, default=0),
)

return market_tick
Expand Down
17 changes: 4 additions & 13 deletions api/models/onchain_payment.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from decouple import config
from django.conf import settings
from django.contrib.auth.models import User
from django.core.validators import MaxValueValidator, MinValueValidator
from django.db import models
Expand All @@ -7,9 +7,6 @@

from control.models import BalanceLog

MAX_TRADE = config("MAX_TRADE", cast=int, default=1_000_000)
MIN_SWAP_AMOUNT = config("MIN_SWAP_AMOUNT", cast=int, default=1_000_000)


class OnchainPayment(models.Model):
class Concepts(models.IntegerChoices):
Expand Down Expand Up @@ -48,17 +45,11 @@ def get_balance():

num_satoshis = models.PositiveBigIntegerField(
null=True,
validators=[
MinValueValidator(0.5 * MIN_SWAP_AMOUNT),
MaxValueValidator(1.5 * MAX_TRADE),
],
validators=[MinValueValidator(0), MaxValueValidator(1.5 * settings.MAX_TRADE)],
)
sent_satoshis = models.PositiveBigIntegerField(
null=True,
validators=[
MinValueValidator(0.5 * MIN_SWAP_AMOUNT),
MaxValueValidator(1.5 * MAX_TRADE),
],
validators=[MinValueValidator(0), MaxValueValidator(1.5 * settings.MAX_TRADE)],
)
# fee in sats/vbyte with mSats decimals fee_msat
suggested_mining_fee_rate = models.DecimalField(
Expand Down Expand Up @@ -91,7 +82,7 @@ def get_balance():
swap_fee_rate = models.DecimalField(
max_digits=4,
decimal_places=2,
default=config("MIN_SWAP_FEE", cast=float, default=0.01) * 100,
default=1,
null=False,
blank=False,
)
Expand Down

0 comments on commit cbb6f73

Please sign in to comment.