Protocol do not work with rebasing token, holders might not able to claim rewards due to token balance is rebased
In the distributeAssets()
function, reward is constant and saved on rewards
mapping:
uint256 _portion = asset.amount * _positionStake / stakeTotal; // <---
uint256 costInEuros = _portion * 10 ** (18 - asset.token.dec) * uint256(assetPriceUsd) / uint256(priceEurUsd)
* _hundredPC / _collateralRate;
if (costInEuros > _position.EUROs) {
_portion = _portion * _position.EUROs / costInEuros; // <----
costInEuros = _position.EUROs;
}
_position.EUROs -= costInEuros;
rewards[abi.encodePacked(_position.holder, asset.token.symbol)] += _portion; // <--- save total rewards of the token
Rewards is claimed by calling claimRewards()
function:
function claimRewards() external {
ITokenManager.Token[] memory _tokens = ITokenManager(tokenManager).getAcceptedTokens();
for (uint256 i = 0; i < _tokens.length; i++) {
ITokenManager.Token memory _token = _tokens[i];
uint256 _rewardAmount = rewards[abi.encodePacked(msg.sender, _token.symbol)]; // <-- get rewards amount
if (_rewardAmount > 0) {
delete rewards[abi.encodePacked(msg.sender, _token.symbol)];
if (_token.addr == address(0)) {
(bool _sent,) = payable(msg.sender).call{value: _rewardAmount}("");
require(_sent);
} else {
IERC20(_token.addr).transfer(msg.sender, _rewardAmount); // <-- transfer reward to user
}
}
}
}
If input token is rebasing token, holders might not able to withdraw token due to lack of avaiable balance in the contract
Holder's reward can be locked in the contract due to rebasing
Manual review
Reward should be transfered to holders directly instead of saving at the contract.
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.