diff --git a/web_app/api/position.py b/web_app/api/position.py index 92b08be8..e41661d7 100644 --- a/web_app/api/position.py +++ b/web_app/api/position.py @@ -4,18 +4,73 @@ from fastapi import APIRouter, HTTPException +from pydantic import BaseModel from web_app.api.serializers.transaction import ( LoopLiquidityData, RepayTransactionDataResponse, ) from web_app.api.serializers.position import PositionFormData -from web_app.contract_tools.constants import TokenParams +from web_app.contract_tools.constants import ( + TokenParams, + TokenMultipliers, + ) from web_app.contract_tools.mixins.deposit import DepositMixin from web_app.db.crud import PositionDBConnector router = APIRouter() # Initialize the router position_db_connector = PositionDBConnector() # Initialize the PositionDBConnector +class TokenMultiplierResponse(BaseModel): + """ + This class defines the structure of the response for the token multiplier + endpoint, encapsulating a dictionary where each token symbol: + (e.g., "ETH", "STRK") + is mapped to its respective multiplier value. + + ### Parameters: + - **multipliers**: A dictionary containing token symbols as keys: + (e.g., "ETH", "STRK", "USDC") + and their respective multipliers as values. + + ### Returns: + A structured JSON response with each token and its multiplier. + """ + multipliers: dict[str, float] + + class Config: + """ + Metadata for TokenMultiplierResponse + with example JSON response format in **schema_extra**. + """ + schema_extra = { + "example": { + "multipliers": { + "ETH": 5.0, + "STRK": 2.5, + "USDC": 5.0 + } + } + } + + +@router.get( + "/api/get-multipliers", + tags=["Position Operations"], + response_model=TokenMultiplierResponse, + summary="Get token multipliers", + response_description="Returns token multipliers", + ) +async def get_multipliers() -> TokenMultiplierResponse: + """ + This Endpoint retrieves the multipliers for tokens like ETH, STRK, and USDC. + """ + multipliers = { + "ETH": TokenMultipliers.ETH, + "STRK": TokenMultipliers.STRK, + "USDC": TokenMultipliers.USDC + } + return TokenMultiplierResponse(multipliers=multipliers) + @router.post( "/api/create-position", diff --git a/web_app/contract_tools/constants.py b/web_app/contract_tools/constants.py index 921666c4..85fdf325 100644 --- a/web_app/contract_tools/constants.py +++ b/web_app/contract_tools/constants.py @@ -21,12 +21,22 @@ class TokenConfig: """ Class to hold the token configuration for the pools. """ - + address: str decimals: int name: str +@dataclass(frozen=True) +class TokenMultipliers: + """ + Class to hold the predefined multipliers for supported tokens/ + """ + ETH: float = 5.0 + STRK: float = 2.5 + USDC: float = 5.0 + + class TokenParams: """ Class to hold the token configurations for tokens as class-level variables.