This repository has been archived by the owner on May 26, 2023. It is now read-only.
berndartmueller - Too few ICHI
v2 farming reward tokens transferred to the user due to incorrect decimal precision
#319
Labels
Has Duplicates
A valid issue with 1+ other issues describing the same vulnerability
High
A valid High severity issue
Reward
A payout will be made for this issue
Sponsor Confirmed
The sponsor acknowledged this issue is valid
Will Fix
The sponsor confirmed this issue will be fixed
berndartmueller
high
Too few
ICHI
v2 farming reward tokens transferred to the user due to incorrect decimal precisionSummary
The
burn
function in theWIchiFarm
contract transfers too fewICHI
v2 farming reward tokens to the caller due to using 9 decimals instead of 18 decimals for theICHI
v2 token.Vulnerability Detail
Closing an ICHI vault spell farming position burns the wrapped ICHI vault LP tokens (
WIchiFarm
ERC-1155 tokens). Farming rewards are harvested from the ICHI farm (see contract on Etherscan) and received asICHI
v1 tokens.The
ICHI
v1 ERC-20 token uses 9 decimals (see token on Etherscan), whereas theICHI
v2 ERC-20 token uses 18 decimals (see token on Etherscan).Those received
ICHI
v1 tokens are then converted to v2 tokens in line 134.To calculate the user's share of eligible
ICHI
v2 reward tokens, the reward per share accumulatorstIchiPerShare
at the time of minting theWIchiFarm
token and the currentenIchiPerShare
accumulator is used.However, those accumulator values are in 9 decimals precision (please see the
ichiFarmV2.harvest
function for proof thatpool.accIchiPerShare
uses 9 decimals, otherwise theICHI
token transfer would fail due to inflated_pendingIchi
). Given thatamount
is in 18 decimals, the calculation ofstIchi
andenIchi
in lines 143 and 144 will result in a value with 9 decimals precision.As previously mentioned, the
ICHI
v2 token uses 18 decimals. Therefore, too fewICHI
v2 tokens are transferred.Impact
Users will receive substantially fewer
ICHI
v2 farming reward tokens than expected.Code Snippet
wrapper/WIchiFarm.sol#L143-L144
Tool used
Manual Review
Recommendation
Consider changing the denominator in lines 143 and 144 from
1e18
to1e9
to use the required18
decimals for theICHI
v2 token.The text was updated successfully, but these errors were encountered: