diff --git a/src/errors/errors.ts b/src/errors/errors.ts index 7b5f24f..5162b7a 100644 --- a/src/errors/errors.ts +++ b/src/errors/errors.ts @@ -31,6 +31,7 @@ export enum ContractErrorCode { NOT_ENOUGH_LIQUIDITY = "OB_NEL", NON_EXISTENT_OPEN_ORDER = "OB_NEO", MARKET_NUMBER_EXCEEDS = "AB_MNE", + OVER_MAXIMUM_PRICE_SPREAD = "CH_OMPS", /* UNISWAP ERROR */ LIQUIDITY_MATH_ERROR_LS = "LS", // https://github.com/Uniswap/v3-core/blob/f03155670ec1667406b83a539e23dcccf32a03bc/contracts/libraries/LiquidityMath.sol#L12 @@ -71,6 +72,7 @@ export enum ErrorName { NOT_ENOUGH_LIQUIDITY_ERROR = "not_enough_liquidity_error", NON_EXISTENT_OPEN_ORDER_ERROR = "non_existent_open_order_error", MARKET_NUMBER_EXCEEDS_ERROR = "market_number_exceeds_error", + OVER_MAXIMUM_PRICE_SPREAD_ERROR = "over_maximum_price_spread_error", /* UNISWAP Error*/ UNISWAP_ERROR = "uniswap_error", @@ -372,6 +374,13 @@ export class MarketNumberExceedsError extends ContractWriteError } } +export class OverMaximumPriceSpreadError extends ContractWriteError { + constructor(data: ContractWriteErrorParams) { + super({ ...data }) + this.name = ErrorName.OVER_MAXIMUM_PRICE_SPREAD_ERROR + } +} + // NOTE: if wanna see the detail message of uniswap error, see the rawError fields export class UniswapV3Error extends ContractWriteError { constructor(data: ContractWriteErrorParams) { diff --git a/src/transactionSender/errorFactory.ts b/src/transactionSender/errorFactory.ts index 60871ff..848bccc 100644 --- a/src/transactionSender/errorFactory.ts +++ b/src/transactionSender/errorFactory.ts @@ -18,6 +18,7 @@ import { isRpcNativeGasTooLowError, isRpcNativeUserDeniedError, MarketNumberExceedsError, + OverMaximumPriceSpreadError, } from "../errors" import { ClearingHouse, Exchange, OrderBook } from "../contracts/type" @@ -101,6 +102,10 @@ export function getTransactionErrorFactory({ ErrorClass = MarketNumberExceedsError break } + case ContractErrorCode.OVER_MAXIMUM_PRICE_SPREAD: { + ErrorClass = OverMaximumPriceSpreadError + break + } default: { ErrorClass = ContractWriteError }