Function: set_limit_order
The set_limit_order
function can be used to create or update an existing limit order. Similarly to update_limit_order
, the function takes an order ID and a liquidity size; if the order ID corresponds to an existing order, the existing order is updated. Otherwise, a new order is created. Instead of receiving an increase or decrease, set_limit_order
takes a specific amount to which the order liquidity should be changed to.
The function ensures that safe mode is not enabled and that the caller is a registered liquidity provider. If an existing order ID and a new tick range were provided, it moves the existing order to the new price level.
It then sets the order liquidity to the given amount. The amount can be specified in terms of an amount of assets or in terms of liquidity.
The user balance is updated every time their position is changed, ensuring the balance is always consistent with the position.