GET Get Locked Params

/get_locked_params

get_locked_params/{symbol}?leverage={leverage}

Example Query:

https://base-hedger82.rasa.capital/get_locked_params/BTCUSDT?leverage=9

Example Response:

{"cva":"6.00","partyAmm":"91.00","lf":"3.00","leverage":"9.0","partyBmm":"0"}

These parameters are solver-defined and based on a cn value. You can read more about this calculation here.

More information about calculating the maintenance margin can be found here.

Get Locked Params Rasa Implementation

Router

@common_router.get(
    '/get_locked_params/{symbol}',
    responses={status.HTTP_200_OK: {"model": LockedParamsResponseSchema}},
    response_model=LockedParamsResponseSchema
)
@with_context_db_session
async def get_locked_params(
    symbol: symbol_enum,
    leverage: float
):
    dynamic_lock_params = get_dynamic_lock_params(symbol, leverage)
    if dynamic_lock_params is False:
        raise ErrorCodeResponse(
            status_code=400,
            error=ErrorInfoContainer.invalid_leverage
        )

    # Cast all values to strings for JSON consistency
    dynamic_lock_params = {k: str(v) for k, v in dynamic_lock_params.items()}

    # Echo back the requested leverage
    dynamic_lock_params['leverage'] = str(leverage)

    # Append the hedger’s party-B margin-multiplier
    dynamic_lock_params['partyBmm'] = str(
        HedgerParameters.get_by_key_convert_decimal(
            f'quote_boundaries::{symbol}::hedger::mm::percentage'
        )
    )

    return dynamic_lock_params

Logic

Compute Dynamic Parameters

dynamic_lock_params = get_dynamic_lock_params(symbol, leverage)

Calls the risk-model function, which returns a dict of:

  • cva (collateral valuation adjustment)

  • partyAmm (party A margin multiplier)

  • lf (liquidity fee portion)

  • Returns False if the requested leverage is outside the valid range.

Validate Leverage

if dynamic_lock_params is False:
    raise ErrorCodeResponse(400, ErrorInfoContainer.invalid_leverage)
  • If the risk-model rejects the leverage, returns a 400 with a structured error.

Normalize to Strings

dynamic_lock_params = {k: str(v) for k, v in dynamic_lock_params.items()}
  • Ensures all numeric values serialize cleanly as JSON strings.

Augment with Leverage & PartyBmm

dynamic_lock_params['leverage'] = str(leverage)
dynamic_lock_params['partyBmm'] = str(
    HedgerParameters.get_by_key_convert_decimal(
        f'quote_boundaries::{symbol}::hedger::mm::percentage'
    )
)
  • Echoes back the input leverage.

  • Reads your hedger’s configured “party B margin multiplier” from the database/config.

Return

  • Yields a JSON object:

    {
      "cva": "6.00",
      "partyAmm": "91.00",
      "lf": "3.00",
      "leverage": "9.0",
      "partyBmm": "0"
    }

Steps to Implement Your Own Version

Define the Response Schema

class LockedParamsResponseSchema(BaseModel):
    cva: str
    partyAmm: str
    lf: str
    leverage: str
    partyBmm: str

Write a Risk-Model Function

  • Implement get_dynamic_lock_params(symbol: str, leverage: float) → dict | False.

  • Should return a dict with cva, partyAmm, lf if valid, or False for invalid leverage.

  • Logic to base this on can be found further up.

Configure HedgerParameters

  • Ensure your HedgerParameters table or config contains the key quote_boundaries::{symbol}::hedger::mm::percentage if you're following this example.

Most hedgers will return 0 for the partyB parameter as initially the partyB is not required to add a maintenance margin, however they will require allocating a certain amount of maintenance margin to ensure they doesn't face instant liquidation.

Last updated