Timeswap contest - hyh's results

Like Uniswap, but for lending & borrowing.

General Information

Platform: Code4rena

Start Date: 04/01/2022

Pot Size: $75,000 USDC

Total HM: 17

Participants: 33

Period: 7 days

Judge: 0xean

Total Solo HM: 14

Id: 74

League: ETH

Timeswap

Findings Distribution

Researcher Performance

Rank: 4/33

Findings: 3

Award: $4,577.76

🌟 Selected for report: 7

πŸš€ Solo Findings: 0

Findings Information

🌟 Selected for report: Rhynorater

Also found by: WatchPug, harleythedog, hyh

Labels

bug
duplicate
3 (High Risk)

Awards

1035.0861 USDC - $1,035.09

External Links

Handle

hyh

Vulnerability details

Impact

The collateral requirements for debt positions created during mint and borrow operations differ. When the quantity of the asset added is low compared to current asset holdings of a pool, a LP has clear incentives to repay its debt right after mint and borrow the same amount of the asset with lower collateral requirements.

This will leave its liquidity shares intact, as repaying the debt doesn't spend them. The collateral in the same time will be freed up due to borrowers’ requirements being less restrictive.

Proof of Concept

BorrowMath.getCollateral scales additional collateral requirements, making them less for the cases when xDecrease < state.x – xDecrease, i.e. for the case of non-whale borrower its collateral requirement is decreased by xDecrease / (state.x – xDecrease):

https://github.com/code-423n4/2022-01-timeswap/blob/main/Timeswap/Timeswap-V1-Core/contracts/libraries/BorrowMath.sol#L72-77

MintMath.getCollateral does not scale the collateral requirement, placing flat 1.0 coefficient in the same formula:

https://github.com/code-423n4/2022-01-timeswap/blob/main/Timeswap/Timeswap-V1-Core/contracts/libraries/MintMath.sol#L100

Consider bringing MintMath.getCollateral in line with BorrowMath.getCollateral for the low asset provision cases. For high asset provision cases it makes sense to avoid penalizing the LPs for bringing in more assets to the pool.

#0 - Mathepreneur

2022-01-24T12:51:27Z

Duplicate from #187

#1 - 0xean

2022-01-25T21:22:46Z

moving to sev-3 to match dupe.

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