refactor MAX_TRADING_FEE to be in one place

This commit is contained in:
Omar Khan
2022-08-19 21:59:30 -04:00
parent db6d32f98b
commit 78e0a866cd
2 changed files with 6 additions and 7 deletions

View File

@@ -3,7 +3,7 @@ import { Amount } from '../common'
import { BaseTransaction, isAmount, validateBaseTransaction } from './common'
const MAX_TRADING_FEE = 65000
export const AMM_MAX_TRADING_FEE = 65000
/**
* AMMInstanceCreate is used to create AccountRoot and the corresponding
@@ -68,9 +68,9 @@ export function validateAMMInstanceCreate(tx: Record<string, unknown>): void {
throw new ValidationError('AMMInstanceCreate: TradingFee must be a number')
}
if (tx.TradingFee > MAX_TRADING_FEE) {
if (tx.TradingFee > AMM_MAX_TRADING_FEE) {
throw new ValidationError(
`AMMInstanceCreate: TradingFee must not be greater than ${MAX_TRADING_FEE}`,
`AMMInstanceCreate: TradingFee must not be greater than ${AMM_MAX_TRADING_FEE}`,
)
}
}

View File

@@ -1,9 +1,8 @@
import { ValidationError } from '../../errors'
import { AMM_MAX_TRADING_FEE } from './AMMInstanceCreate'
import { BaseTransaction, validateBaseTransaction } from './common'
const MAX_TRADING_FEE = 65000
/**
* AMMVote is used for submitting a vote for the trading fee of an AMM Instance.
*
@@ -52,9 +51,9 @@ export function validateAMMVote(tx: Record<string, unknown>): void {
throw new ValidationError('AMMVote: FeeVal must be a number')
}
if (tx.FeeVal > MAX_TRADING_FEE) {
if (tx.FeeVal > AMM_MAX_TRADING_FEE) {
throw new ValidationError(
`AMMVote: FeeVal must not be greater than ${MAX_TRADING_FEE}`,
`AMMVote: FeeVal must not be greater than ${AMM_MAX_TRADING_FEE}`,
)
}
}