Part 2

Zaros
PerpetualsDEXFoundrySolidity
70,000 USDC
View results
Submission Details
Severity: medium
Invalid

Complete code

// SPDX-License-Identifier: MIT
//✅ Excluded address(this) from valid owners
//✅ Bound tradingAccountId to a valid range
//✅ Checked that account was created before verifying sender
//✅ Validated that the stored owner matches the expected owner
pragma solidity 0.8.25;

// Zaros dependencies
import { Base_Test } from "test/Base.t.sol";

contract Create_Unit_Test is Base_Test {
function testFuzz_WhenTheCreateIsCalled(uint128 tradingAccountId, address owner) external {
// Ensure valid owner address
vm.assume(owner != address(0) && owner != address(this));

// Ensure tradingAccountId is within a valid range
tradingAccountId = bound(tradingAccountId, MIN_ACCOUNT_ID, MAX_ACCOUNT_ID);
changePrank({ msgSender: owner });
// Create trading account
perpsEngine.exposed_create(tradingAccountId, owner);
// Verify the account exists
bool exists = perpsEngine.accountExists(tradingAccountId);
assertTrue(exists, "Trading account should be created successfully");
// Ensure correct owner
(address retrievedOwner) = perpsEngine.getOwner(tradingAccountId);
assertEq(owner, retrievedOwner, "Owner should be set correctly");
// Load and verify sender
perpsEngine.exposed_loadExistingAccountAndVerifySender(tradingAccountId);
// Retrieve trading account details
(uint128 tradingAccountIdReceived, address ownerReceived) =
perpsEngine.workaround_getTradingAccountIdAndOwner(tradingAccountId);
// Validate account ID
assertEq(tradingAccountId, tradingAccountIdReceived, "Trading account ID is not correct");
// Validate owner
assertEq(owner, ownerReceived, "Owner is not correct");
}

}

Updates

Lead Judging Commences

inallhonesty Lead Judge 4 months ago
Submission Judgement Published
Invalidated
Reason: Lack of quality

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.