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

fix: fix bug in placeLimitOrder and exchange invariant checks #165

Merged
merged 3 commits into from
Jul 5, 2023

Conversation

kingcre
Copy link
Contributor

@kingcre kingcre commented Jul 5, 2023

Description

if !isBatch {
res, err = k.executeOrder(
ctx, market, ordererAddr, isBuy, &price, &qty, nil, false, false)
if err != nil {
return
}
}
if isBatch || qty.Sub(res.ExecutedQuantity).IsPositive() {
deadline := ctx.BlockTime().Add(lifespan)
order, err = k.newOrder(
ctx, orderId, typ, market, ordererAddr, isBuy, price,
qty, qty.Sub(res.ExecutedQuantity), deadline, false)

The bug was because we're trying to use res.ExecutedQuantity when isBatch is true. res was not set when isBatch.

Tasks

  • Fix bug in placeLimitOrder
  • Fix x/exchange invariant checks

@kingcre kingcre self-assigned this Jul 5, 2023
@kingcre kingcre marked this pull request as ready for review July 5, 2023 06:51
@kingcre kingcre merged commit 05203ea into amm-module Jul 5, 2023
@kingcre kingcre deleted the fix-amm-module-1 branch July 5, 2023 08:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants