resolveDispute
can avoid making another call to i_tokenContract.balanceOf
to save gas to calculate the amount of token to be received by the seller
account.
The total amount of token that will be distributed to the actors (buyer
, seller
, arbiter
depending on the fees and buyerAward
) is given by the amount of tokens owned by the Escrow
contract.
Given i_arbiterFee
and buyerAward
and given that uint256 tokenBalance = i_tokenContract.balanceOf(address(this));
this will be the actual distribution
Token received by arbiter
: i_arbiterFee
Token received by buyer
: buyerAward
Token received by seller
: tokenBalance - i_arbiterFee - buyerAward
There is no reason to make an external call again to the i_tokenContract
contract (external call cost + SLOAD) because we can already calculate the amount of tokens that will be received by the seller
By testing with forge snapshot
we can see that the gas saving is -15177 (-1.779%)
Manual
The client should consider making the following modification to the resolveDispute
function
The contest is live. Earn rewards by submitting a finding.
This is your time to appeal against judgements on your submissions.
Appeals are being carefully reviewed by our judges.