From 5f6343ed3675b231d307cf879f376a66a90ba5ec Mon Sep 17 00:00:00 2001 From: Maxence Raballand Date: Tue, 16 Jul 2024 10:41:36 +0200 Subject: [PATCH] fix(kandel): validate Kandel params for one sided trades. (#110) * 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. --- .changeset/sixty-cups-roll.md | 5 +++++ src/actions/kandel/view.test.ts | 2 +- src/lib/kandel/params.ts | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 .changeset/sixty-cups-roll.md diff --git a/.changeset/sixty-cups-roll.md b/.changeset/sixty-cups-roll.md new file mode 100644 index 0000000..427f4b5 --- /dev/null +++ b/.changeset/sixty-cups-roll.md @@ -0,0 +1,5 @@ +--- +"@mangrovedao/mgv": patch +--- + +Fix validate kandel params when one sided diff --git a/src/actions/kandel/view.test.ts b/src/actions/kandel/view.test.ts index e0fe485..fc04c2e 100644 --- a/src/actions/kandel/view.test.ts +++ b/src/actions/kandel/view.test.ts @@ -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) diff --git a/src/lib/kandel/params.ts b/src/lib/kandel/params.ts index b4269ef..123f8a0 100644 --- a/src/lib/kandel/params.ts +++ b/src/lib/kandel/params.ts @@ -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: {