Platform: Code4rena
Start Date: 21/08/2023
Pot Size: $125,000 USDC
Total HM: 26
Participants: 189
Period: 16 days
Judge: GalloDaSballo
Total Solo HM: 3
Id: 278
League: ETH
Rank: 141/189
Findings: 1
Award: $15.93
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: 0xTheC0der
Also found by: 0Kage, 0xDING99YA, 0xHelium, 0xbranded, 836541, ABA, Kow, QiuhaoLi, SpicyMeatball, T1MOH, __141345__, alexfilippov314, ayden, bart1e, bin2chen, chaduke, degensec, jasonxiale, joaovwfreire, nirlin, peakbolt, pep7siup, rvierdiiev, tnquanghuy0512
15.9268 USDC - $15.93
https://github.com/code-423n4/2023-08-dopex/blob/b174dcd7b68a5372d7b9a97c9dd50895e742689c/contracts/perp-vault/PerpetualAtlanticVault.sol#L237-L241 https://github.com/code-423n4/2023-08-dopex/blob/b174dcd7b68a5372d7b9a97c9dd50895e742689c/contracts/perp-vault/PerpetualAtlanticVault.sol#L101
No calculation of fundingDuration in updateFundingDuration()
leads to critical bug.
fundingDuration is later used in calculateFunding()
to calculate the funding of options for the next epoch.
This will return an incorrect fundingAmount
in the process puting protocol and users funds in a critical state.
actual code is
uint256 public fundingDuration = 7 days; function updateFundingDuration( uint256 _fundingDuration ) external onlyRole(DEFAULT_ADMIN_ROLE) { fundingDuration = _fundingDuration ; }
if you call at first fundingDuration
it returns 7 days in uint (604800)
,
now let's update the fundingDuration, by calling updateFundingDuration with any uint: let says 10 ( for 10 days ).
now call fundingDuration to get the updated fundingDuration. It will return just 10 and not 10 days in uint.
manual review and remix
update the function to properly update the fundingDuration. if you want to interpret a function parameter in days, you can in the following way:
function f(uint start, uint daysAfter) public { if (block.timestamp >= start + daysAfter * 1 days) { // ... } }
so applied to this contract you should update the function to be :
function updateFundingDuration( uint256 _fundingDuration ) external { fundingDuration = _fundingDuration * 1 days ; }
this updated code will properly set the fundingDuration to the expected corresponding uint.
for eg: updateFundingDuration(10) will return 864000
which is the correct value.
Invalid Validation
#0 - c4-pre-sort
2023-09-08T06:30:36Z
bytes032 marked the issue as duplicate of #980
#1 - c4-pre-sort
2023-09-11T08:23:15Z
bytes032 marked the issue as sufficient quality report
#2 - c4-judge
2023-10-20T11:09:34Z
GalloDaSballo changed the severity to 2 (Med Risk)
#3 - c4-judge
2023-10-20T11:11:16Z
GalloDaSballo marked the issue as satisfactory