You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 26, 2023. It is now read-only.
github-actionsbot opened this issue
Mar 1, 2023
· 0 comments
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
WIchiFarm#burn sends too few IchiV2 tokens to users
Summary
IchiV1 is a 9dp token and IchiV2 is an 18dp token. IchiFarmV2 distributes and tracks rewards in IchiV1. The issue is that WIchiFarm converts the V1 tokens received to V2 tokens but then uses the 9dp accIchiPerShare to determine the number of tokens to send to the user. The result is that the end user receives a fraction of the tokens they should and the other tokens are trapped forever in the contract.
Rewards collected from IchiFarm are paid as IchiV1 tokens, which has 9 dp. These rewards are converted to IchiV2 tokens before being sent to the user. The issue is that IchiV2 is an 18 dp token. When sending the tokens it sends the 9 dp IchiV1 token amount to the user. This means that only a fraction of the tokens will be sent to the user and all the other tokens will be irretrievable.
Above is the harvest function for the IchiFarm, which will be used for the example below.
Example:
Imagine a user deposits 1e18 LP tokens when accIchiPerShare = 0. This gives stIchiPerShare = 0 and rewardDebt = 0. Now the accIchiPerShare increases to 1e9 and the user withdraws. This triggers the harvest function which transfers IchiV1 to WIchiFarm:
We can see that the contract will send the user 1e9 IchiV2 when it should be sending 1e18.
The extra IchiV2 that collects in the contract is irretrievable leading to near entire loss of Ichi rewards for all users who use WIchiFarm for their LP.
Impact
Loss of nearly all Ichi token rewards for LP holders
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
DuplicateA valid issue that is a duplicate of an issue with `Has Duplicates` labelHighA valid High severity issueRewardA payout will be made for this issue
0x52
high
WIchiFarm#burn sends too few IchiV2 tokens to users
Summary
IchiV1 is a 9dp token and IchiV2 is an 18dp token. IchiFarmV2 distributes and tracks rewards in IchiV1. The issue is that WIchiFarm converts the V1 tokens received to V2 tokens but then uses the 9dp accIchiPerShare to determine the number of tokens to send to the user. The result is that the end user receives a fraction of the tokens they should and the other tokens are trapped forever in the contract.
Vulnerability Detail
Rewards collected from IchiFarm are paid as IchiV1 tokens, which has 9 dp. These rewards are converted to IchiV2 tokens before being sent to the user. The issue is that IchiV2 is an 18 dp token. When sending the tokens it sends the 9 dp IchiV1 token amount to the user. This means that only a fraction of the tokens will be sent to the user and all the other tokens will be irretrievable.
Above is the harvest function for the IchiFarm, which will be used for the example below.
Example:
Imagine a user deposits 1e18 LP tokens when accIchiPerShare = 0. This gives stIchiPerShare = 0 and rewardDebt = 0. Now the accIchiPerShare increases to 1e9 and the user withdraws. This triggers the harvest function which transfers IchiV1 to WIchiFarm:
This will transfer 1e9 IchiV1 to WIchiFarm. This will be redeemed for IchiV2 which has 18 dp:
Next we calculate the amount of IchiV2 send to the user:
We can see that the contract will send the user 1e9 IchiV2 when it should be sending 1e18.
The extra IchiV2 that collects in the contract is irretrievable leading to near entire loss of Ichi rewards for all users who use WIchiFarm for their LP.
Impact
Loss of nearly all Ichi token rewards for LP holders
Code Snippet
https://github.com/sherlock-audit/2023-02-blueberry/blob/main/contracts/wrapper/WIchiFarm.sol#L116-L150
Tool used
Manual Review
Recommendation
The reward token amount needs to be scaled by 1e9 to make sure the user gets the proper amount of rewards:
Duplicate of #319
The text was updated successfully, but these errors were encountered: