Skip to content

Why check again after decrease buy's ETH, and decrease seller's token??? #2

@littleanti

Description

@littleanti

In NEW ORDER - BID and ASK ORDER functions, why you check the balance of buyer's ETH and seller's token after decrease ETH and token??
I cannot understand.

// Overflow Check
// 09 Unit Test: balanceEthForAddress[msg.sender] is initially 3000000000000000000 (3 ETH)
require(balanceEthForAddress[msg.sender] >= totalAmountOfEtherAvailable);
require(balanceEthForAddress[msg.sender] - totalAmountOfEtherAvailable <= balanceEthForAddress[msg.sender]);

// Decrease the Buyer's Account Balance of tokens by the amount the Sell Offer Order Entry is willing to accept in exchange for ETH
balanceEthForAddress[msg.sender] -= totalAmountOfEtherAvailable;

// Overflow Checks
require(balanceEthForAddress[msg.sender] >= totalAmountOfEtherAvailable);<<<<<<<<<<<<<<<<<<<<<<<<<<< HERE

and

// Overflow Check
require(tokenBalanceForAddress[msg.sender][tokenNameIndex] >= amountOfTokensNecessary);

// Decrease the Seller's Account Balance of tokens by amount they are offering since the Buy Offer Order Entry is willing to accept it all in exchange for ETH
tokenBalanceForAddress[msg.sender][tokenNameIndex] -= amountOfTokensNecessary;

// Overflow Check
require(tokenBalanceForAddress[msg.sender][tokenNameIndex] >= amountOfTokensNecessary); <<<<<<<<<<<<<<<<<<<<<<<<<< HERE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions