export enum PoolErrorType { PoolNotFound = 'PoolNotFound', InsufficientLiquidity = 'InsufficientLiquidity', ShardsUnavailable = 'ShardsUnavailable', InvalidFeeRate = 'InvalidFeeRate', InvalidAmountBelowMin = 'InvalidAmountBelowMin', InvalidAmount = 'InvalidAmount', InvalidToken = 'InvalidToken', InvalidPsbt = 'InvalidPsbt', InvalidUtxo = 'InvalidUtxo', InvalidFeeTier = 'InvalidFeeTier', InvalidSignature = 'InvalidSignature', InvalidAssetPair = 'InvalidAssetPair', InvalidRunestone = 'InvalidRunestone', InvalidTxSize = 'InvalidTxSize', InvalidPubkey = 'InvalidPubkey', NotEnoughFunds = 'NotEnoughFunds', NotEnoughFundsForSplittingRune = 'NotEnoughFundsForSplittingRune', PoolAlreadyExists = 'PoolAlreadyExists', FailedToSendArchTransaction = 'FailedToSendArchTransaction', RequestExpired = 'RequestExpired', InvalidNumericValue = 'InvalidNumericValue', InvalidAddress = 'InvalidAddress', ShardPubkeysRequired = 'ShardPubkeysRequired', } interface CommonPoolError { type: PoolErrorType; message: string; } export interface PoolNotFoundErrorByPoolId extends CommonPoolError { type: PoolErrorType.PoolNotFound; poolId: string; } export interface PoolNotFoundErrorByToken extends CommonPoolError { type: PoolErrorType.PoolNotFound; token0: string; token1: string; feeTier?: number; } export interface PoolAlreadyExistsError extends CommonPoolError { type: PoolErrorType.PoolAlreadyExists; poolId: string; } export interface InvalidFeeRateError extends CommonPoolError { type: PoolErrorType.InvalidFeeRate; minFeeRate: number; } export interface InsufficientLiquidityError extends CommonPoolError { type: PoolErrorType.InsufficientLiquidity; token: string; maxAmount: string; } export interface ShardsUnavailableError extends CommonPoolError { type: PoolErrorType.ShardsUnavailable; reason: 'MempoolConstraints' | 'NoBalance'; token: string; } export interface InvalidUtxoError extends CommonPoolError { type: PoolErrorType.InvalidUtxo; utxos: string[]; } export interface InvalidTokenError extends CommonPoolError { type: PoolErrorType.InvalidToken; token: string; } export interface NotEnoughFundsError extends CommonPoolError { type: PoolErrorType.NotEnoughFunds; maxAmount: string; minAmount: string; token: string; } export interface NotEnoughFundsForSplittingRuneError extends CommonPoolError { type: PoolErrorType.NotEnoughFundsForSplittingRune; recommendedRuneAmount: string; currentSatsAmount: string; token: string; } export interface InvalidPsbtError extends CommonPoolError { type: PoolErrorType.InvalidPsbt; } export interface InvalidSignatureError extends CommonPoolError { type: PoolErrorType.InvalidSignature; } export interface InvalidAmountBelowMinError extends CommonPoolError { type: PoolErrorType.InvalidAmountBelowMin; token: string; minAmount: string; } export interface InvalidAmountError extends CommonPoolError { type: PoolErrorType.InvalidAmount; token: string; expectedAmount: string; actualAmount: string; } export interface InvalidAssetPairError extends CommonPoolError { type: PoolErrorType.InvalidAssetPair; } export interface InvalidFeeTierError extends CommonPoolError { type: PoolErrorType.InvalidFeeTier; feeTier: number; } export interface InvalidPubkeyError extends CommonPoolError { type: PoolErrorType.InvalidPubkey; pubkey: string; } export interface FailedToSendArchTransactionError extends CommonPoolError { type: PoolErrorType.FailedToSendArchTransaction; } export interface RequestExpiredError extends CommonPoolError { type: PoolErrorType.RequestExpired; } export interface InvalidRunestoneError extends CommonPoolError { type: PoolErrorType.InvalidRunestone; } export interface InvalidTxSizeError extends CommonPoolError { type: PoolErrorType.InvalidTxSize; } export interface InvalidNumericValue extends CommonPoolError { type: PoolErrorType.InvalidNumericValue; } export interface InvalidAddress extends CommonPoolError { type: PoolErrorType.InvalidAddress; } export interface ShardPubkeysRequiredError extends CommonPoolError { type: PoolErrorType.ShardPubkeysRequired; } export type PoolError = | PoolNotFoundErrorByPoolId | PoolNotFoundErrorByToken | PoolAlreadyExistsError | InvalidFeeRateError | InvalidUtxoError | InvalidTokenError | NotEnoughFundsError | NotEnoughFundsForSplittingRuneError | InvalidPsbtError | InvalidSignatureError | InvalidAmountBelowMinError | InvalidAmountError | InsufficientLiquidityError | ShardsUnavailableError | InvalidAssetPairError | InvalidFeeTierError | InvalidPubkeyError | InvalidRunestoneError | InvalidTxSizeError | InvalidNumericValue | InvalidAddress | FailedToSendArchTransactionError | RequestExpiredError | ShardPubkeysRequiredError; export class PoolErrorException extends Error { error: PoolError; constructor(error: PoolError) { super(error.message); this.name = 'PoolError'; this.error = error; } getError(): PoolError { return this.error; } }