Function: _debit(address _from, uint256 _amountLD, uint256 _minAmountLD, uint32 _dstEid)
This is an internal function that handles token debit logic during cross-chain token transfers.
Inputs
_fromControl: Full control.
Constraints:
msg.sender.Impact: The address of the token sender.
_amountLDControl: Full control.
Constraints: The caller must own enough tokens to transfer.
Impact: The amount of OFT tokens specified by the caller to send to the
_dstEidchain.
_minAmountLDControl: Full control.
Constraints: N/A.
Impact: Determine the minimum amount of tokens that should be transferred after dust removal.
_dstEidControl: Full control.
Constraints:
peersshould contain the_dstEid. Only the owner can set up eIDs that can be used.Impact: The ID of the destination chain where tokens will be sent.
Branches and code coverage
Intended branches
The expected amount of tokens are burned.
The
innerTokenbalance of the contract is not changed.
Negative behavior
The caller does not own enough tokens to transfer.
The caller does not provide an approval.
The
amountReceivedLDis less than_minAmountLD.The
_dstEidis not supported.
Function call analysis
super._debitView(_amountLD, _minAmountLD, _dstEid);What is controllable?
_amountLD,_minAmountLD, and_dstEid.If the return value is controllable, how is it used and how can it go wrong? Returns
amountSentLDandamountReceivedLD, which are equal since the default_debitViewimplementation from the OFTCore contract is used. These values represent_amountLDafter dust removal based on thedecimalConversionRate.What happens if it reverts, reenters or does other unusual control flow? Reverts if
amountReceivedLDis less than_minAmountLD.
IERC20(address(innerToken)).transferFrom(_from, address(this), amountSentLD);What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? There is no return value here.
What happens if it reverts, reenters or does other unusual control flow? Transfers the
amountSentLD(without dust) to this contract. This function reverts ifmsg.senderhas not granted sufficient allowance.
IMintSelfBurnToken(address(innerToken)).burn(amountSentLD);What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? There is no return value here.
What happens if it reverts, reenters or does other unusual control flow? Burns the specified amount of tokens from the contract’s balance. There should be no issues here, as the specified tokens are transferred to the contract’s balance in advance.