Function: updateTp(uint16 pairIndex, uint8 index, uint192 newTp)
Updates the take-profit value of the 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.
newTp
Control: Fully controlled by the caller.
Constraints: None.
Impact: The new take-profit value.
Branches and code coverage
Intended branches
Updates the take profit to the new value and sets the last updated block number.
Negative behavior
Revert if there is a pending trigger.
Revert if leverage of the trade is zero (no such trade).
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.checkNoPendingTrigger(storageT, sender, pairIndex, index, LimitOrder.TP) -> storageT.orderTriggerBlock(trader, pairIndex, index, orderType)
What is controllable?
trader
,pairIndex
, andindex
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.getOpenTrade(sender, pairIndex, index)
What is controllable?
sender
,pairIndex
, andindex
.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.
storageT.updateTp(sender, pairIndex, index, newTp)
What is controllable?
sender
,pairIndex
,index
, andnewTp
.If the return value is controllable, how is it used and how can it go wrong? Updates the take-profit value for the trade — no return value.
What happens if it reverts, reenters or does other unusual control flow? N/A.
TradeUtils.setTpLastUpdated(this.registry.getContractAddress("callbacks"), sender, pairIndex, index, TradeType.MARKET, ChainUtils.getBlockNumber())
What is controllable?
sender
,pairIndex
, andindex
.If the return value is controllable, how is it used and how can it go wrong? Sets the block number when the TP was updated — 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.
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.