Putty contest - samruna's results

An order-book based american options market for NFTs and ERC20s.

General Information

Platform: Code4rena

Start Date: 29/06/2022

Pot Size: $50,000 USDC

Total HM: 20

Participants: 133

Period: 5 days

Judge: hickuphh3

Total Solo HM: 1

Id: 142

League: ETH

Putty

Findings Distribution

Researcher Performance

Rank: 88/133

Findings: 1

Award: $47.18

🌟 Selected for report: 0

🚀 Solo Findings: 0

QA report

  1. Return statement and parameterized return

Code: https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L268

Description: Above code used both parameterized return and a return statement. Since this function is only returning one value, no need to do return twice.

return positionId

Mitigation: Only keep one return

  1. Use of != 0 instead of > 0 for uint parameters

Code: https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L427 https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L293 https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L327 https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L351 https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L498 https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L598-599

Mitigation: Checking for !=0 saves some gas.

  1. Event emitted before transaction is complete

Code: https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L318

Description: In above function, event FilledOrder() is emitted before the transaction is complete. If the purpose of event is just to inform about the order, then this is fine. But if the purpose if leave trace about entire transaction, then this should be last statement in the function.

Mitigation: Please emit only after the transaction is complete.

  1. Code can be pulled into separate function

Code: https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L323-378

Description: Above code can be extracted into a separate function for readaility. Also the conditions can be arranged in much better way for anyone to understand the flow.

Mitigation: Add another internal function processOrder(order)

function processOrder(Order memory order) internal returns (uint256 positionId) { bool isCall = order.isCall; bool isLong = order.isLong

if (isCall) { . . . if (!isCall) { . . return positionId=... } else (isCall) { . . return positionId=... } }

} repeat same for isLong

This will help the readaility, flow and may be make the contract better arranged.

  1. Use of modified for repeated validations Code: https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L395 https://github.com/code-423n4/2022-06-putty/blob/main/contracts/src/PuttyV2.sol#L475

Above two code lines are similar checks. They can be turned into modifiers for readability

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