Assessment reports>Ostium>Threat Model>updateOpenLimitOrder

Function: updateOpenLimitOrder(uint16 pairIndex, uint8 index, uint192 price, uint192 tp, uint192 sl)

The function updates an open limit order.

Inputs

  • pairIndex

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The index of the trading pair.

  • index

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The index of the order.

  • price

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The price level to set.

  • tp

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The take-profit price.

  • sl

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The stop-loss price.

Branches and code coverage

Intended branches

  • If the new TP and SL are in the correct range, update the open limit order.

Negative behavior

  • Revert if there is no such limit order.

  • Revert if _tp is set and not valid according to order type.

  • Revert if _sl is set and not valid according to order type.

  • Revert if there is a pending trigger.

Function call analysis

  • this.registry.getContractAddress("tradingStorage")

    • What is controllable? N/A.

    • If the return value is controllable, how is it used and how can it go wrong? Returned value is the TradingStorage contract address.

    • What happens if it reverts, reenters or does other unusual control flow? N/A.

  • storageT.hasOpenLimitOrder(sender, pairIndex, index)

    • What is controllable? sender, pairIndex, and index.

    • If the return value is controllable, how is it used and how can it go wrong? Returns true if there is such open limit order.

    • What happens if it reverts, reenters or does other unusual control flow? N/A.

  • storageT.getOpenLimitOrder(sender, pairIndex, index)

    • What is controllable? sender, pairIndex, and index.

    • If the return value is controllable, how is it used and how can it go wrong? Returns the open limit order.

    • What happens if it reverts, reenters or does other unusual control flow? N/A.

  • this.checkNoPendingTrigger(storageT, sender, pairIndex, index, LimitOrder.OPEN) -> storageT.orderTriggerBlock(trader, pairIndex, index, orderType)

    • What is controllable? trader, pairIndex, and index.

    • If the return value is controllable, how is it used and how can it go wrong? Returns the order trigger block for that orderType.

    • What happens if it reverts, reenters or does other unusual control flow? N/A.

  • storageT.updateOpenLimitOrder(o)

    • What is controllable? o.

    • If the return value is controllable, how is it used and how can it go wrong? Updates the open limit order based on the provided information — no return value.

    • What happens if it reverts, reenters, or does other unusual control flow? If it reverts, the entire call will revert — no reentrancy scenarios.

  • TradeUtils.setTradeLastUpdated(this.registry.getContractAddress("callbacks"), sender, pairIndex, index, TradeType.LIMIT, ChainUtils.getBlockNumber())

    • What is controllable? sender, pairIndex, and index.

    • If the return value is controllable, how is it used and how can it go wrong? No return value.

    • What happens if it reverts, reenters or does other unusual control flow? N/A.

  • this.registry.getContractAddress("callbacks")

    • What is controllable? N/A.

    • If the return value is controllable, how is it used and how can it go wrong? Returned value is the callback contract address.

    • What happens if it reverts, reenters or does other unusual control flow? N/A.

Zellic © 2024Back to top ↑