Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

fix: allow 0 gasAdjustmentBps #421

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/util/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class FieldValidator {

public static readonly quoteSpeed = Joi.string().valid('fast', 'standard');

public static readonly bps = Joi.number().greater(0).max(BPS);
public static readonly bps = Joi.number().min(0).max(BPS);

public static readonly classicConfig = Joi.object({
routingType: Joi.string().valid('CLASSIC'),
Expand Down
20 changes: 18 additions & 2 deletions test/unit/lib/handlers/quote/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,22 @@ describe('Post quote request validation', () => {
expect(error).toBeUndefined();
});

it('should validate dutch limit config with gasAdjustmentBps as 0', () => {
const { error } = FieldValidator.dutchLimitConfig.validate({
...DL_CONFIG_JSON,
gasAdjustmentBps: 0,
});
expect(error).toBeUndefined();
});

it('should validate dutch v2 config with gasAdjustmentBps as 0', () => {
const { error } = FieldValidator.dutchV2Config.validate({
...DUTCH_V2_CONFIG_JSON,
gasAdjustmentBps: 0,
});
expect(error).toBeUndefined();
});

it('should reject dutch v2 config as dutch v1', () => {
const { error } = FieldValidator.dutchLimitConfig.validate(DUTCH_V2_CONFIG_JSON);
expect(error).toBeDefined();
Expand All @@ -75,7 +91,7 @@ describe('Post quote request validation', () => {
gasAdjustmentBps: -1,
});
expect(error).toBeDefined();
expect(error?.message).toEqual('"gasAdjustmentBps" must be greater than 0');
expect(error?.message).toEqual('"gasAdjustmentBps" must be greater than or equal to 0');
});

it('should reject invalid gasAdjustmentBps for v2', () => {
Expand All @@ -84,7 +100,7 @@ describe('Post quote request validation', () => {
gasAdjustmentBps: -1,
});
expect(error).toBeDefined();
expect(error?.message).toEqual('"gasAdjustmentBps" must be greater than 0');
expect(error?.message).toEqual('"gasAdjustmentBps" must be greater than or equal to 0');
});

it('should reject invalid slippage', () => {
Expand Down
Loading