Badger Citadel contest - PostMan56's results

Bringing BTC to DeFi

General Information

Platform: Code4rena

Start Date: 04/02/2022

Pot Size: $30,000 USDC

Total HM: 3

Participants: 37

Period: 3 days

Judge: leastwood

Id: 84

League: ETH

BadgerDAO

Findings Distribution

Researcher Performance

Rank: 34/37

Findings: 1

Award: $33.80

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

Awards

33.7964 USDC - $33.80

Labels

bug
G (Gas Optimization)
sponsor confirmed

External Links

Handle

PostMan56

Vulnerability details

Impact

This is my first time submitting so please let me know if it's bad or poorly explained

Small gas optimization in the function 'getTokenInLimitLeft' and use of uint256 vs uint8

Proof of Concept 'getTokenInLimitLeft'

function getTokenInLimitLeft() external view returns (uint256 limitLeft_) { if (totalTokenIn < tokenInLimit) { limitLeft_ = tokenInLimit - totalTokenIn; } }

In gas estimates(before):

"Creation": { "codeDepositCost": "3427600", "executionCost": "3828", "totalCost": "3431428" }
function getTokenInLimitLeft() external view returns (uint256 limitLeft_) { if (totalTokenIn <= tokenInLimit) { limitLeft_ = tokenInLimit - totalTokenIn; } }

In gas estimates(after):

"Creation": { "codeDepositCost": "3427400", "executionCost": "3828", "totalCost": "3431228" }

Proof of Concept uint256 vs uint8

uint8 can be found in lines: 56, 57, 65, 146

In gas estimates(before):

"Creation": { "codeDepositCost": "3427600", "executionCost": "3828", "totalCost": "3431428" }

In gas estimates(after):

"Creation": { "codeDepositCost": "3394800", "executionCost": "3787", "totalCost": "3398587" }

Tools Used

Remix gas estimates

< & > contains ISZERO opcode making it cost more To negate this add = after < or > to save 200 gas on contract deploy

use of uint256 is cheaper than uint8 in data types

#0 - GalloDaSballo

2022-02-14T13:55:03Z

Appreciate the well thoughtout findindg with POC and math

#1 - GalloDaSballo

2022-02-14T13:55:21Z

The only thing better would be a link to a gist / remix to verify the claims autonomously

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