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 Oct 1, 2023. It is now read-only.
sherlock-admin opened this issue
Mar 27, 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
Treasury doesn't get depositFee when user deposits into epochs using the zero epoch method
Summary
In Carousel contract, depositFee is charged only when the users deposit to an epoch directly, specifying the correct epochId. If the deposit happens via the epochId of zero, treasury doesnt get the deposit fee and only relayer benefits. This causes loss to the protocol.
Also the protocol is not able to enforce the rule of increasing depositFee on deposits closer to the epoch begin time.
Vulnerability Detail
There are two ways to deposit tokens into an epoch.
By calling the deposit or depositETH function by mentioning a non-zero _id which corresponds to the specific epochId which you want to deposit your tokens into.
By calling the deposit or depositETH function by mentioning a zero _id. In this case the deposited tokens are queued into an array and a relayer, will add these funds for you, on your behalf, into the next available epoch.
In the first case of direct deposit, a deposit fee (of maximum 2.5%) is charged by the contract and sent to the treasury address.
In the second case of indirect deposit, there is no deposit fee charged and so, the treasury doesn't benefit from the deposit. Instead, the relayer who is processing the deposit queue gets a fee called relayerFee.
This causes loss to the protocol treasury.
Impact
Protocol treaury losses depositFee as depositors use the zero epochId method to deposit into epochs.
Also the deposit fee is supposed to be linearly increasing as the user deposits close to the beginning of the epoch. If there is no deposit fee charged on the deposit, then users can avoid this fee and do their deposits in the last block before the beginning of the epoch without encountering any additional fees.
Code Snippet
Parts of the _deposit function which deals with the depositFee for epochId > 0 and the part where the deposit details are pushed into the depositQueue for epochId = 0.
function _deposit(
uint256_id,
uint256_assets,
address_receiver
) internal {
// mint logic, either in queue or direct depositif (_id !=0) {
uint256 assetsToDeposit = _assets;
if (depositFee >0) {
uint256 feeAmount = _assets.mulDivDown(fee, 10000);
assetsToDeposit = _assets - feeAmount;
_asset().safeTransfer(treasury, feeAmount);
}
} else {
depositQueue.push(
QueueItem({assets: _assets, receiver: _receiver, epochId: _id})
);
The part where relayerFee is sent to the relayer for processing the deposit queue. This is from the mintDepositInQueue function.
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
ElKu
medium
Treasury doesn't get depositFee when user deposits into epochs using the zero epoch method
Summary
In Carousel contract,
depositFee
is charged only when the users deposit to an epoch directly, specifying the correct epochId. If the deposit happens via the epochId ofzero
, treasury doesnt get the deposit fee and onlyrelayer
benefits. This causes loss to the protocol.Also the protocol is not able to enforce the rule of increasing depositFee on deposits closer to the epoch begin time.
Vulnerability Detail
There are two ways to deposit tokens into an epoch.
deposit
ordepositETH
function by mentioning a non-zero_id
which corresponds to the specificepochId
which you want to deposit your tokens into.deposit
ordepositETH
function by mentioning a zero_id
. In this case the deposited tokens are queued into an array and arelayer
, will add these funds for you, on your behalf, into the next available epoch.In the first case of direct deposit, a deposit fee (of maximum 2.5%) is charged by the contract and sent to the
treasury
address.In the second case of indirect deposit, there is no deposit fee charged and so, the treasury doesn't benefit from the deposit. Instead, the
relayer
who is processing the deposit queue gets a fee calledrelayerFee
.This causes loss to the protocol treasury.
Impact
Protocol treaury losses depositFee as depositors use the zero epochId method to deposit into epochs.
Also the deposit fee is supposed to be linearly increasing as the user deposits close to the beginning of the epoch. If there is no deposit fee charged on the deposit, then users can avoid this fee and do their deposits in the last block before the beginning of the epoch without encountering any additional fees.
Code Snippet
Parts of the _deposit function which deals with the depositFee for epochId > 0 and the part where the deposit details are pushed into the
depositQueue
for epochId = 0.The part where relayerFee is sent to the relayer for processing the deposit queue. This is from the mintDepositInQueue function.
Tool used
Manual Review, VSCode.
Recommendation
The deposit fee should be charged in all cases.
Duplicate of #75
The text was updated successfully, but these errors were encountered: