Assessment reports>Ostium>Threat Model>topUpCollateral

Function: topUpCollateral(uint16 pairIndex, uint8 index, uint256 topUpAmount)

Adds more collateral to an open trade.

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.

  • topUpAmount

    • Control: Fully controlled by the caller.

    • Constraints: None.

    • Impact: The amount of collateral to be added to the open trade.

Branches and code coverage

Intended branches

  • The function increases the collateral and decreases the leverage, such tradeSize remains the same.

Negative behavior

  • Revert if no such trade is found.

  • Revert if leverage is less than the allowed minimum leverage for the pair.

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.

  • this.registry.getContractAddress("pairsStorage")

    • 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 pairsStorage contract address.

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

  • storageT.getOpenTrade(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? Checks the existence of the open trade; incorrect values may lead to incorrect trade-information retrieval.

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

  • pairsStorage.pairMinLeverage(t.pairIndex)

    • What is controllable? t.pairIndex.

    • If the return value is controllable, how is it used and how can it go wrong? Returns minimum leverage for the pairIndex.

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

  • storageT.updateTrade(t)

    • What is controllable? t.

    • If the return value is controllable, how is it used and how can it go wrong? Updates the trade's collateral and leverage — 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.

Zellic © 2024Back to top ↑