Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[MASTER]
disable=fixme,too-few-public-methods,too-many-instance-attributes,too-many-arguments,logging-fstring-interpolation,too-many-locals,duplicate-code, def buy_amount(self) -> Decimal:
disable=fixme,logging-fstring-interpolation,too-many-arguments

extension-pkg-allow-list=pydantic
11 changes: 8 additions & 3 deletions src/models/order.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
from src.models.exchange_rate import ExchangeRate as XRate
from src.models.token import Token, TokenBalance
from src.models.types import NumericType
from src.util.constants import Constants
from src.util.constants import (
RAISE_ON_MAX_SELL_AMOUNT_VIOLATION,
RAISE_ON_LIMIT_XRATE_VIOLATION,
)
from src.util.numbers import decimal_to_str

OrderSerializedType = dict[str, Any]
Expand Down Expand Up @@ -39,6 +42,8 @@ class Order:
a cost-bounded {buy|sell} order or a {buy|sell} market order.
"""

# pylint: disable=too-many-instance-attributes

def __init__(
self,
order_id: str,
Expand Down Expand Up @@ -303,7 +308,7 @@ def execute(
f"sell (max) : {ymax.balance}"
)
logging.error(message)
if Constants.RAISE_ON_MAX_SELL_AMOUNT_VIOLATION:
if RAISE_ON_MAX_SELL_AMOUNT_VIOLATION:
raise ValueError(message)
sell_amount = min(sell_amount, ymax)

Expand All @@ -330,7 +335,7 @@ def execute(
f"limit (max): {self.max_limit}"
)
logging.error(message)
if Constants.RAISE_ON_LIMIT_XRATE_VIOLATION:
if RAISE_ON_LIMIT_XRATE_VIOLATION:
raise ValueError(message)

# Store execution information.
Expand Down
2 changes: 2 additions & 0 deletions src/models/solver_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class SolverArgs:
"""Parameters passed in POST URL"""

# pylint: disable=too-many-instance-attributes

auction_id: Optional[str]
instance_name: str
time_limit: int
Expand Down
4 changes: 2 additions & 2 deletions src/models/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Optional, Union

from src.models.types import NumericType
from src.util.constants import Constants
from src.util.constants import DECIMAL_STR_PREC


class Token:
Expand Down Expand Up @@ -101,7 +101,7 @@ def __str__(self) -> str:
"external_price",
"internal_buffer",
]:
value = value.quantize(Constants.DECIMAL_STR_PREC)
value = value.quantize(DECIMAL_STR_PREC)
_str += f"\n-- {attr} : {value}"

return _str
Expand Down
2 changes: 2 additions & 0 deletions src/models/uniswap.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class Uniswap:
An Uniswap pool is represented by two token balances.
"""

# pylint: disable=too-many-instance-attributes

def __init__(
self,
pool_id: str,
Expand Down
20 changes: 8 additions & 12 deletions src/util/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@

from decimal import Decimal

# Precision of Decimal in strings (to be used as x.quantize(DECIMAL_STR_PREC)).
DECIMAL_STR_PREC = Decimal("1e-10")

class Constants:
"""Configuration parameters for the solver."""
# Should an exception be raised when the solution violates the
# max sell amount constraint.
RAISE_ON_MAX_SELL_AMOUNT_VIOLATION = False

# Precision of Decimal in strings (to be used as x.quantize(DECIMAL_STR_PREC)).
DECIMAL_STR_PREC = Decimal("1e-10")

# Should an exception be raised when the solution violates the
# max sell amount constraint.
RAISE_ON_MAX_SELL_AMOUNT_VIOLATION = False

# Should an exception be raised when the solution violates the
# limit exchange rate constraint.
RAISE_ON_LIMIT_XRATE_VIOLATION = False
# Should an exception be raised when the solution violates the
# limit exchange rate constraint.
RAISE_ON_LIMIT_XRATE_VIOLATION = False
4 changes: 3 additions & 1 deletion src/util/exec_plan_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@


class ExecPlanCoords:
"""The position coordinates of the uniswap in the execution plan.
"""The position coordinates of the AMM in the execution plan.

The position is defined by a pair of integers:
* Id of the sequence.
* Position within that sequence.
"""

# pylint: disable=too-few-public-methods

def __init__(self, sequence: int, position: int):
self.sequence = sequence
self.position = position
Expand Down
2 changes: 2 additions & 0 deletions src/util/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ class OrderModel(BaseModel):
class Config:
"""Includes example in generated openapi file"""

# pylint: disable=too-few-public-methods
schema_extra = {
"example": {
"sell_token": "0x6b175474e89094c44da98b954eedeac495271d0f",
Expand Down Expand Up @@ -326,6 +327,7 @@ class BatchAuctionModel(BaseModel):
class Config:
"""Includes example in generated openapi file"""

# pylint: disable=too-few-public-methods
schema_extra = {"example": example_instance}


Expand Down