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

Executed amounts - sanity checks #163

Closed
josojo opened this issue Apr 20, 2022 · 0 comments · Fixed by #164
Closed

Executed amounts - sanity checks #163

josojo opened this issue Apr 20, 2022 · 0 comments · Fixed by #164

Comments

@josojo
Copy link
Contributor

josojo commented Apr 20, 2022

Currently, the executed amount of an order is not sanity checked.

We just the parsed order.execution_amount from the order

fn add_to_settlement(&self, settlement: &mut Settlement) -> Result<()> {
        use Execution::*;

        match self {
            LimitOrder(order) => settlement.with_liquidity(&order.order, order.executed_amount()),
}

and then based on it calculate the fee amounts:

fn compute_fee_execution(&self, fee_amount: U256) -> Option<U256> {
        match self.order.creation.kind {
            model::order::OrderKind::Buy => fee_amount
                .checked_mul(self.executed_amount)?
                .checked_div(self.order.creation.buy_amount),
            model::order::OrderKind::Sell => fee_amount
                .checked_mul(self.executed_amount)?
                .checked_div(self.order.creation.sell_amount),
        }
    }

I think we should make sure that the for a partially fillable order the "executed amount <= sell amount" and for a killorfill order "executed amount== sell_amount".
Felix noticed that issue due to a bug in the cow-dex-solver, it's providing too big executed amounts, and then we run into this issue. I will try to fix the bug on the cow-dex solver side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant