Cally contest - MadWookie's results

Earn yield on your NFTs or tokens via covered call vaults.

General Information

Platform: Code4rena

Start Date: 10/05/2022

Pot Size: $50,000 USDC

Total HM: 13

Participants: 100

Period: 5 days

Judge: HardlyDifficult

Total Solo HM: 1

Id: 122

League: ETH

Cally

Findings Distribution

Researcher Performance

Rank: 64/100

Findings: 2

Award: $61.73

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

31.6149 USDC - $31.61

Labels

bug
duplicate
2 (Med Risk)
upgraded by judge

External Links

Judge has assessed an item in Issue #164 as Medium risk. The relevant finding follows:

File:Cally.sol#224 require(msg.value >= premium, "Incorrect ETH amount sent"); Using == operator is 3 gas cheaper than >=. This also keeps people from acedently overpaying when buying an option.

Summary Implementing each of these would reduce the deploymnt cost from 5,431,682 to 5,387,621 and reduces buyOption from 75,765 to 75,013.

#0 - HardlyDifficult

2022-06-01T20:20:10Z

Gas optimizations

  1. File:Cally.sol#223
uint256 premium = getPremium(vaultId);
require(msg.value >= premium, "Incorrect ETH amount sent");

Can become

require(msg.value >= getPremium(vaultId), "Incorrect ETH amount sent");

Variable premium is not needed as it is only used once. Saves 2600 gas in deployment and 12 gas in buyoption(). 2. File:Cally.sol#227

uint32 auctionStartTimestamp = vault.currentExpiration;
require(block.timestamp >= auctionStartTimestamp, "Auction not started");

Can become

require(block.timestamp >= vault.currentExpiration, "Auction not started");

auctionStartTimestamp varable is not needed as vault.currentExpiration is only used once in the function. Saves 1800 gas in deployment and 4 gas in buyOption

  1. File: Cally.sol#395
Vault memory vault = _vaults[vaultId];
return premiumOptions[vault.premiumIndex];

Can become

return premiumOptions[_vaults[vaultId].premiumIndex];

This can save quite of bit of gas as the whole Vault struct doesnt have to be copied into memory. 42252 gas is saved on deployment and 733 gas in buyOption() when getPremium() is called.

4.File: Cally.sol#444


if (isVaultToken) {
    _vaultBeneficiaries[id] = address(0);
}

Can become

if (id % 2 != 0) {
    _vaultBeneficiaries[id] = address(0);
}

The calcuation can be done in the if statement to save 1400 gas on deployment and 13 from transferFrom().

  1. File:Cally.sol#224
require(msg.value >= premium, "Incorrect ETH amount sent");

Using == operator is 3 gas cheaper than >=. This also keeps people from acedently overpaying when buying an option.

Summary Implementing each of these would reduce the deploymnt cost from 5,431,682 to 5,387,621 and reduces buyOption from 75,765 to 75,013.

#0 - outdoteth

2022-05-16T20:19:20Z

This can be bumped to a medium severity issue: Using == operator is 3 gas cheaper than >=. This also keeps people from acedently overpaying when buying an option: https://github.com/code-423n4/2022-05-cally-findings/issues/84

#1 - HardlyDifficult

2022-05-31T15:26:21Z

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