Wrong implementation of twAML in function TapiocaOptionBroker.exitPosition()
#1103
Labels
3 (High Risk)
Assets can be stolen/lost/compromised directly
bug
Something isn't working
duplicate-1623
satisfactory
satisfies C4 submission criteria; eligible for awards
sponsor confirmed
Sponsor agrees this is a problem and intends to fix it (OK to use w/ "disagree with severity")
Lines of code
https://github.com/Tapioca-DAO/tap-token-audit/blob/59749be5bc2286f0bdbf59d7ddc258ddafd49a9f/contracts/options/TapiocaOptionBroker.sol#L314-L322
Vulnerability details
Impact
Incorrect accounting for
pool.cumulative
can lead to incorrect voting power calculation in the broker contract.Proof of Concept
The function
TapiocaOptionBroker.exitPosition()
is utilized to exit a twAML (twTAP) participation.Note that the participation entry tracks the average magnitude as it was at the time the participant entered. So, to exit the twAML, we need to reverse the participation process. In other words, if the position has voting power and is
divergenceForce
, the correct exit process should be:However, in the function
TapiocaOptionBroker.exitPosition()
, thepool.cumulative
is updated withpool.averageMagnitude
instead ofparticipation.averageMagnitude
, leading to an incorrect implementation.To consolidate the issue, we can examine the update of exit process in
twTAP.sol
in this link:Tools Used
Manual review
Recommended Mitigation Steps
Modifying the update of
pool.cumulative
as follows:Assessed type
Other
The text was updated successfully, but these errors were encountered: