Function: deposit(address account, uint256 amount)
This function transfers amount of the USDC tokens from the provided account to this contract and increases the collateral[account] balance by this amount. It emits the Deposit event.
Inputs
accountControl: Full control.
Constraints: The caller should be the account itself or an approved operator of this account.
Impact: The deposit will be made on behalf of the account.
amountControl: Full control.
Constraints: The account should own enough USDC tokens to transfer.
Impact: The amount of USDC tokens to be deposited.
Branches and code coverage
Intended branches
A
Depositevent has been emitted.The
collateralbalance of theaccounthas been increased by theamount.The USDC balance of this contract has been increased by the
amount.The USDC balance of the account has been decreased by the
amount.
Negative behavior
The caller is not an account or approved operator of this account.
Account does not own enough USDC tokens.
Function call analysis
MarginAccountLib.deposit(this._getClearingHouse().marginAccount[account], account, amount) -> USDC.safeTransferFrom(account, address(this), amount)What is controllable?
accountandamount.If the return value is controllable, how is it used and how can it go wrong? There is no return value.
What happens if it reverts, reenters or does other unusual control flow? It reverts when the account does not have enough USDC tokens or if the allowance is insufficient.
MarginAccountLib.deposit(this._getClearingHouse().marginAccount[account], account, amount) -> self.creditAccount(account, amount)What is controllable?
accountandamount.If the return value is controllable, how is it used and how can it go wrong? There is no return value.
What happens if it reverts, reenters or does other unusual control flow? There are no problems; the
collateralbalance will be increased by the amount.