Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gas Optimizations #297

Open
code423n4 opened this issue May 28, 2022 · 0 comments
Open

Gas Optimizations #297

code423n4 opened this issue May 28, 2022 · 0 comments
Labels
bug Something isn't working G (Gas Optimization)

Comments

@code423n4
Copy link
Contributor

Allowing anyone to cancel orders below Dust Limit

Description

According to the OasisDEX documentation, the Dust Limit parameter was designed to filter out small orders, which protects the matching engine from using more gas than necessary. A “small order” is where the order's value is lower than the cost of gas required for its execution in USD terms. (docs)

Rubicon changed the behavior of the can_cancel modifier which prevents cancelling arbitrary dust offers.

Findings

RubiconMarket.sol#L570

modifier can_cancel(uint256 id) override {
    require(isActive(id), "Offer was deleted or taken, or never existed.");
    require(
        isClosed() || msg.sender == getOwner(id) || id == dustId,
        "Offer can not be cancelled because user is not owner, and market is open, and offer sells required amount of tokens."
    );
    _;
}

Recommended mitigation steps

Allow anyone to cancel dust offers to protect matching engine from using more gas than necessary.

In the can_cancel modifier, change the require statement to the following:

require(
    isClosed() || msg.sender == getOwner(id) || offers[id].pay_amt < _dust[address(offers[id].pay_gem)],
    "Offer can not be cancelled because user is not owner, and market is open, and offer sells required amount of tokens."
);

https://oasisdex.com/docs/announcements/oasis1-1

@code423n4 code423n4 added bug Something isn't working G (Gas Optimization) labels May 28, 2022
code423n4 added a commit that referenced this issue May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working G (Gas Optimization)
Projects
None yet
Development

No branches or pull requests

1 participant