ebtc-protocol / ebtc

GNU General Public License v3.0
48 stars 24 forks source link

add safeCast for liquidatorRewardShare in CdpManager #773

Closed rayeaster closed 5 months ago

rayeaster commented 5 months ago

add safe downcast for CdpManager internal variable LiquidatorRewardShare from uint256 to uint128

using code from openzeppelin https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeCast.sol#L305

getrecon-bot commented 5 months ago
Job ID 6e0af66e-5571-4345-9d6d-909cf508cb3d
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-05ed8ecafe741056e
Instance Type c5.2xlarge
Status Started
Elapsed
getrecon-bot commented 5 months ago
Job ID 6e0af66e-5571-4345-9d6d-909cf508cb3d
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-05ed8ecafe741056e
Instance Type c5.2xlarge
Status Running
Elapsed 51 seconds
getrecon-bot commented 5 months ago
Job ID 6e0af66e-5571-4345-9d6d-909cf508cb3d
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-05ed8ecafe741056e
Instance Type c5.2xlarge
Status Running
Elapsed 52 seconds
CodingNameKiki commented 5 months ago

It's worth spending some time investigating if we can rebase stETH to that degree (I don't think so)

With every positive rebase, the value of shares allocated for 0.2 stETH gets smaller and smaller with time.

 uint256 _liquidatorRewardShares = collateral.getSharesByPooledEth(LIQUIDATOR_REWARD);
getrecon-bot commented 5 months ago
Job ID 6e0af66e-5571-4345-9d6d-909cf508cb3d
Command yarn && git submodule init && git submodule update && solc-select use 0.8.17 && cd packages/contracts/ && yarn echidna --test-mode assertion --test-limit 600000
Instance ID i-05ed8ecafe741056e
Instance Type c5.2xlarge
Status Success
Elapsed 1 day 10 hours 4 minutes 21 seconds
dapp-whisperer commented 5 months ago

needs overflow tests but can scope to a separate PR