Function: leverage(address authorizer, address market, uint256 price, uint256 deadline, uint8 v, bytes32 r, bytes32 s)
This allows leveraging with signature.
Inputs
authorizerControl: Fully controlled by the caller.
Constraints: Checked to be the owner of the contract and part of a valid signature.
Impact: Authorizer of the leverage.
marketControl: Fully controlled by the caller.
Constraints: Checked to be the address of the contract.
Impact: Market address.
priceControl: Fully controlled by the caller.
Constraints: Checked to be a valid price.
Impact: Price of the leverage.
deadlineControl: Fully controlled by the caller.
Constraints: Checked to be in the future and part of a valid signature.
Impact: Deadline of the leverage.
amountControl: Fully controlled by the caller.
Constraints: Checked to be a valid amount --- not included in the signature.
Impact: Amount of the leverage.
vControl: Fully controlled by the caller.
Constraints: Checked to be a valid signature.
Impact: Signature v.
rControl: Fully controlled by the caller.
Constraints: Checked to be a valid signature.
Impact: Signature r.
sControl: Fully controlled by the caller.
Constraints: Checked to be a valid signature.
Impact: Signature s.
Branches and code coverage (including function calls)
Intended branches
Ensure that the signature constructed from
authorizer,market,price,deadline,v,r, andsis valid.Ensure the authorizer is the owner of the contract.
Ensure that the market is the address of the contract.
Ensure that the deadline is in the future.
Validate the amount to be leveraged against the price.
Increase the collateral balance of the sender by the amount leveraged.
Increase the debt balance of the sender by the amount leveraged.
Mint to the Market the credit fee amount.
Negative behavior
Signature should not be replayable. Currently it is.
Assumes
_ownercannot beaddress(0).