Yieldy contest - Kaiziron's results

A protocol for gaining single side yields on various tokens.

General Information

Platform: Code4rena

Start Date: 21/06/2022

Pot Size: $50,000 USDC

Total HM: 31

Participants: 99

Period: 5 days

Judges: moose-code, JasoonS, denhampreen

Total Solo HM: 17

Id: 139

League: ETH

Yieldy

Findings Distribution

Researcher Performance

Rank: 66/99

Findings: 2

Award: $79.72

🌟 Selected for report: 0

🚀 Solo Findings: 0

Unsafe ERC20 Operation(s)

Information : L001 - Unsafe ERC20 Operation(s)

Instances include :

Staking.sol:471: IYieldy(YIELDY_TOKEN).transfer( Migration.sol:48: IYieldy(OLD_YIELDY_TOKEN).transferFrom(

Recommendation

It is recommended to always use OpenZeppelin's SafeERC20 library

Use != 0 instead of > 0 when comparing unsigned integers

!= 0 will do the same as > 0 for unsigned integers, but != 0 costs less gas compared to > 0 for unsigned integers in require statements with the optimizer enabled.

Instances include :

Yieldy.sol:83: require(_totalSupply > 0, "Can't rebase if not circulating"); Yieldy.sol:96: require(rebasingCreditsPerToken > 0, "Invalid change in supply"); Staking.sol:118: require(_recipient.amount > 0, "Must enter valid amount"); Staking.sol:410: require(_amount > 0, "Must have valid amount"); Staking.sol:572: require(_amount > 0, "Invalid amount"); Staking.sol:604: require(_amount > 0, "Invalid amount");

Recommendation

It is recommended to replace > 0 with != 0, as they do the same thing for unsigned integers, and '!= 0' costs less gas compared to > 0 in require statements with the optimizer enabled, also enable the optimizer.

For example :

Yieldy.sol:83: require(_totalSupply != 0, "Can't rebase if not circulating");

Don't explicitly initialize variables with the default value

Uninitialized variables are assigned with the default value of their type, initializing a variable with its default value costs unnecessary gas.

Instances include :

Staking.sol:636: int128 from = 0; Staking.sol:637: int128 to = 0;

Recommendation

It is recommended to initialize variables without assigning them the default value, for example :

Staking.sol:636: int128 from;

If possible, use prefix increment instead of postfix increment

Prefix increment ++i returns the updated value after it's incremented and postfix increment i++ returns the original value then increments it. Prefix increment costs less gas compared to postfix increment.

Instances includes :

Staking.sol:708: epoch.number++;

Recommendation

It is recommended to use prefix increment instead of postfix one when the return value is not needed, as both of them will give the same result and prefix increment costs less gas.

For example :

Staking.sol:708: ++epoch.number;

Public function that could be declared external

public functions that are never called by the contract unstakeAllFromTokemak() should be declared external to save gas.

Instances includes :

Staking.sol:370: function unstakeAllFromTokemak() public onlyOwner {

Recommendation

It is recommended to set the visibility of unstakeAllFromTokemak() to external, as it is never called by the contract, and it will cost less gas by setting to external compare to public.

For example :

Staking.sol:370: function unstakeAllFromTokemak() external onlyOwner {
AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter