callback( uint256 id_, uint256 inputAmount_, uint256 outputAmount_ ) external
Intended behavior.
Depending on the implementation of the
_callbackfunction,callbackis supposed to send thepayoutTokensback to the teller.
Negative behavior.
Shouldn’t send the
payoutTokento someone else other than theteller.Shouldn’t allow a teller with a different
aggregatorto call the function
Preconditions.
Assumes
msg.senderis approved.Assumes that a market for that
idexists within theaggregators'marketsAssumes that the whitelist is the same as the aggregator’s; OTHERWISE, it could theoretically be called by a malicious
msg.sendersince there are two different whitelists. Thatmsg.sendercould then exploit the contract and drain allpayoutToken; they should use the Aggregator’s whitelist just as they do with getting the markets
Postconditions.
quoteToken.balanceOf(address(this)) += inputAmount,payoutToken_.balanceOf(address(this)) -= outputAmountquoteToken.balanceOf(msg.sender) -= inputAmount,payoutToken_.balanceOf(msg.sender) += outputAmountpriorBalancesmapping should be updated properly (for both tokens)
Inputs.
uint256 id_ - controlled
uint256 inputAmount_ - controlled, but there is a check that the balance was increased by the corresponding value of the
quoteTokentokens.uint256 outputAmount* - controlled, there are no checks on the
outputAmount*value, that is, any amount ofpayoutTokentokens can be sent to themsg.sender. Therefore, the market owner must be very careful with the whitelist of trusted callers.
Examine all function calls the function makes.
Call to
_callback(id, quoteToken, inputAmount_, payoutToken, outputAmount_): any logic implemented by the owner of the market (it’s implementation agnostic); seems like the responsibility is shifted towards market owner.