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
account
Control: 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.
amount
Control: 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
Deposit
event has been emitted.The
collateral
balance of theaccount
has 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?
account
andamount
.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?
account
andamount
.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
collateral
balance will be increased by the amount.