Phuture Finance contest - TerrierLover's results

Crypto index platform, that simplifies your investments through automated, themed index products.

General Information

Platform: Code4rena

Start Date: 19/04/2022

Pot Size: $30,000 USDC

Total HM: 10

Participants: 43

Period: 3 days

Judges: moose-code, JasoonS

Total Solo HM: 7

Id: 90

League: ETH

Phuture Finance

Findings Distribution

Researcher Performance

Rank: 24/43

Findings: 2

Award: $94.90

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

65.6376 USDC - $65.64

Labels

bug
QA (Quality Assurance)

External Links

Consider using nonReentrant modifier at burn function which calls external contracts several times

Target codebase

https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/IndexLogic.sol#L96

burn function calls external contracts several times. It is worth using nonReentrant.

Potential workaround

Add nonReentrant modifier


Should check address(0) at ChainlinkPriceOracle.sol

Target codebase

Following arguments do not have address(0) check. For the safety, it should have address(0) check.

  • _registry argument

https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/ChainlinkPriceOracle.sol#L47

  • _assetAggregator argument

https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/ChainlinkPriceOracle.sol#L60

Potential workaround

Add require check for address(0) at the above mentioned arguments.


Awards

29.2584 USDC - $29.26

Labels

bug
G (Gas Optimization)

External Links

Usage of != 0 instead of > 0 can reduce the gas cost

Target codebase

2022-04-phuture/contracts/IndexLogic.sol 76,44: require(lastAssetBalanceInBase > 0, "Index: INSUFFICIENT_AMOUNT"); 86,17: if (fee > 0) { 98,23: require(value > 0, "Index: INSUFFICIENT_AMOUNT"); 114,21: if (fee > 0) { 141,29: if (lastOrderId > 0) {

2022-04-phuture/contracts/ManagedIndexReweightingLogic.sol 56,19: if (i > 0) { 61,27: if (newWeight > 0) { 98,24: if (shares > 0) {

2022-04-phuture/contracts/PhutureIndex.sol 56,24: if (timePassed > 0) { 64,21: if (fee > 0) {

2022-04-phuture/contracts/TopNMarketCapIndex.sol 56,24: if (weight > 0) {

2022-04-phuture/contracts/TopNMarketCapReweightingLogic.sol 58,32: if (shares > 0) { 79,32: if (weight > 0) { 106,24: if (shares > 0) {

2022-04-phuture/contracts/vToken.sol 160,26: if (_totalSupply > 0) {

2022-04-phuture/contracts/libraries/FullMath.sol 35,37: require(denominator > 0); 122,43: if (mulmod(a, b, denominator) > 0) {

2022-04-phuture/contracts/libraries/IndexLibrary.sol 29,35: require(_assetPerBaseInUQ > 0, "IndexLibrary: ORACLE");

2022-04-phuture/contracts/libraries/NAV.sol 49,24: require(shares > 0, "NAV: INSUFFICIENT_AMOUNT"); 59,24: require(amount > 0, "NAV: INSUFFICIENT_SHARES_BURNED");

Potential workaround

Simply using != instead of > 0 can reduce the gas cost

Not defining 0 can reduce the gas cost

Target codebase

Following codebase sets 0 for uint in the for loop. But setting 0 is not needed, and the gas cost can be reduced by omitting it.

https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/UniswapV2PathPriceOracle.sol#L34

https://github.com/code-423n4/2022-04-phuture/blob/main/contracts/UniswapV2PathPriceOracle.sol#L49

Potential workaround

Simply avoiding setting 0 can reduce the gas cost.

for (uint i; i < path.length - 1; i++) {

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