Function: update_range_order
The update_range_order
function can be used to create or update an existing range order. The function takes the amount that should be added to or subtracted from the range order. It also takes an order ID and a tick range.
If the order ID is associated with an existing order, that order will be updated; in this case, the tick range is optional, and if provided the order will also be moved from the current to the newly specified tick range. If the order ID does not correspond to an existing order, a new order will be created, and therefore the tick range is required.
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 tick range.
It then applies the specified update — increasing or decreasing the liquidity associated with the order by the given amount. Note that the increase or decrease 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.