Skip to content

Commit

Permalink
fix(kandel): validate Kandel params for one sided trades. (#110)
Browse files Browse the repository at this point in the history
* fix(kandel): validate Kandel params for one sided trades.

* refactor: Remove console.log statement from validateKandelParams function.

* refactor: Update validity check in view kandel test.
  • Loading branch information
maxencerb authored Jul 16, 2024
1 parent 3fec2c2 commit 5f6343e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sixty-cups-roll.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mangrovedao/mgv": patch
---

Fix validate kandel params when one sided
2 changes: 1 addition & 1 deletion src/actions/kandel/view.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ describe('view kandel', () => {
marketConfig: book.marketConfig,
})

expect(isValid).toBe(false)
expect(isValid).toBe(true) // even though out of range, params are valid

const kandel = await sowAndPopulate(params, minProvision)

Expand Down
3 changes: 2 additions & 1 deletion src/lib/kandel/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ export function validateKandelParams(
marketConfig.gasprice *
BigInt(1e6)

const isValid = askGives >= minAsk && bidGives >= minBid
const isValid =
(nAsks === 0n || askGives >= minAsk) && (nBids === 0n || bidGives >= minBid)

return {
params: {
Expand Down

0 comments on commit 5f6343e

Please sign in to comment.