async def updateMarket(
marketId: int,
name: str,
minLeverage: float,
maxLeverage: float,
minTradeSize: float,
maxTradeSize: float,
tickDecimals: int,
lotSize: int,
sizeDecimals: int,
tradeFeePct: int,
maxEntitlement: int,
insuranceFundEntitlementPct: int,
maxImbalance: int,
maintenanceMarginRatio: int,
seizureThreshold: int,
adlThreshold: int,
shockFactor: int,
maxIFFractionAllowed: int,
):
contract = retrieveContract()
w3 = retrieveWeb3Instance()
tick_units = tickDecimals
feeStruct = namedtuple(
"FeeConfig",
[
"tradeFeePct",
"maxEntitlement",
"insuranceFundEntitlementPct",
"maxImbalance",
],
)
adlConfigStruct = namedtuple(
"MarketADLConfig",
[
"maintenanceMarginRatio",
"seizureThreshold",
"adlThreshold",
"shockFactor",
"maxIFFractionAllowed",
],
)
MyStruct = namedtuple(
"MarketConfigInput",
[
"name",
"minLeverage",
"maxLeverage",
"minTradeSize",
"maxTradeSize",
"tickDecimals",
"lotSize",
"sizeDecimals",
"feeConfig",
"adlConfig",
],
)
my_fee_data = feeStruct(
tradeFeePct, maxEntitlement, insuranceFundEntitlementPct, maxImbalance
)
my_adl_config = adlConfigStruct(
maintenanceMarginRatio,
seizureThreshold,
adlThreshold,
shockFactor,
maxIFFractionAllowed,
)
my_struct_data = MyStruct(
name=Web3.to_bytes(text=name).ljust(32, b"\0"),
minLeverage=convertFloatToUINT(minLeverage, LEVERAGE_SCALAR),
maxLeverage=convertFloatToUINT(maxLeverage, LEVERAGE_SCALAR),
minTradeSize=convertFloatToUINT(minTradeSize, USDC_DECIMALS),
maxTradeSize=convertFloatToUINT(maxTradeSize, USDC_DECIMALS),
tickDecimals=tickDecimals,
lotSize=lotSize,
sizeDecimals=sizeDecimals,
feeConfig=my_fee_data,
adlConfig=my_adl_config,
)
transaction = contract.functions.updateMarket(
marketId, my_struct_data
).build_transaction(
{
"from": Web3.to_checksum_address(os.getenv("ACCOUNT")),
"nonce": w3.eth.get_transaction_count(
Web3.to_checksum_address(os.getenv("ACCOUNT"))
),
}
)
await submitTransactionWithOracle(w3, transaction, marketId)