Assessment reports>Ostium>Threat Model>openTradeMarketTimeout

Function: openTradeMarketTimeout(uint256 _order)

Unregisters the open pending market order if time-out is reached.

Inputs

  • _order

    • Control: Fully controlled by the caller.

    • Constraints: No constraints.

    • Impact: The open pending market order ID to unregister.

Branches and code coverage

Intended branches

  • Unregisters the pending open market order and transfers USDC back to the trader.

Negative behavior

  • Revert if caller is not the trader.

  • Revert if the leverage of the trade is zero (no such trade).

  • Revert if no trade is found.

  • Revert if the time-out has not yet been reached.

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.reqID_pendingMarketOrder(_order)

    • What is controllable? _order.

    • If the return value is controllable, how is it used and how can it go wrong? Returns the PendingMarketOrder struct values. The return value is controllable as _order is taken as an argument but there are checks to ensure that the trader of the pending market order is the caller of this function.

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

  • storageT.unregisterPendingMarketOrder(_order, True)

    • What is controllable? _order.

    • If the return value is controllable, how is it used and how can it go wrong? Unregisters the pending market order — 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.

  • storageT.transferUsdc(address(storageT), sender, trade.collateral)

    • What is controllable? sender.

    • If the return value is controllable, how is it used and how can it go wrong? Transfers USDC from the storage to the sender.

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

Zellic © 2024Back to top ↑