export const ERROR_CODES: Record = { "LA-LIZA-01": "LzApp: endpoint cannot be zero address(0)", "LA-DCNT-01": "LzApp: destination chain is not a trusted source", "CA-FINS-01": "CelerApp: this bridge implementation doesn't support this functionality", "CA-CINM-01": "CelerApp: caller is not message bus", "GS-ASBTZ-02": "GasStation: gasAmount must be greater than 0 in setGasAmount", "GS-ASBTZ-03": "GasStation: gasAmount must be greater than 0 in withdrawNative", "GS-ASBTZ-04": "GasStation: amount of gas request should be <= gasAmount", "GS-ZADDR-01": "GasStation: cannot request gas to zero address(0)", "GS-FAIL-01": "GasStation: send failed in requestGas", "GS-FAIL-02": "GasStation: send failed in withdrawNative", "GS-NFUN-01": "GasStation: unknown function call", "P-OACC-01": "Portfolio: admin account needed for this function", "P-OACC-02": "Portfolio: address can not be address(0)", "P-OACC-03": "Portfolio: only TradePairs contract call this function", "P-OACC-04": "Portfolio: only TradePairs contract or admin can call this function", "P-ALOA-01": "Portfolio: at least one account needed in admin group", "P-ALOA-02": "Portfolio: can not remove PortfolioBridge from PORTFOLIO_BRIDGE_ROLE, use setPortfolioBridge function instead", "P-NTDP-01": "Portfolio: deposits paused", "P-OOWN-01": "Portfolio: only owner can withdraw native token", "P-OOWN-02": "Portfolio: only owner can deposit native token", "P-WNFA-01": "Portfolio: withdrawNative failed", "P-OODT-01": "Portfolio: only owner can deposit erc20 tokens", "P-ZETD-01": "Portfolio: zero erc20 token quantity", "P-GSRO-01": "Portfolio: gasSwapRatio needs to be > 0", "P-ETNS-01": "Portfolio: token is not supported in the subnet", "P-ETNS-02": "Portfolio: token is not supported in the host chain", "P-DOTS-01": "Portfolio: origin and destination addresses should be different", "P-NETD-01": "Portfolio: not enough ERC20 token balance to deposit", "P-OOWT-01": "Portfolio: only owner can withdraw ERC20 tokens", "P-AFNE-01": "Portfolio: available funds not enough while entering order", "P-AFNE-02": "Portfolio: available funds not enough while attempting to transfer tokens between accounts", "P-TNEF-01": "Portfolio: transaction amount not enough to cover fees", "P-TAEX-01": "Portfolio: token already exists", "P-SCEM-01": "Portfolio: source Chain Id should be the same as specified in Portfolio Main", "P-ZADDR-01": "Portfolio: token address cannot be zero address(0)", "P-ZADDR-02": "Portfolio: trader address cannot be zero address(0)", "P-NZBL-01": "Portfolio: cannot remove token if there is non-zero balance", "P-BLTH-01": "Portfolio: subnet wallet balance (Gas Tank) under threshold", "P-DUTH-01": "Portfolio: deposit under threshold", "P-WUTH-01": "Portfolio: withdraw under threshold", "P-CNFF-01": "Portfolio: collect native fee failed", "P-CNAT-01": "Portfolio: cannot add 0 decimals token", "P-OWTF-01": "Portfolio: can only withdraw from treasury or feeAddress", "P-AUCT-01": "Portfolio: can not withdraw/transfer auction token before auction is finalized", "P-TSDM-01": "Portfolio: token symbols do not match", "P-TDDM-01": "Portfolio: Token decimals do not match", "P-PTNS-01": "Portfolio: main processXFerPayload transaction not supported", "P-PTNS-02": "Portfolio: sub processXFerPayload transaction not supported", "P-TTNZ-01": "Portfolio: tokanTotals needs to be 0", "T-POOA-01": "Portfolio: Only PO(PostOnly) Orders allowed for this pair", "P-BANA-01": "Portfolio: account banned", "P-MDML-01": "Portfolio: minimum deposit multipler can not be less than 10 (10/10)", "P-NFUN-01": "Portfolio: unknown function call", "P-TNBC-01": "Portfolio: token not been converted", "P-LENM-01": "Portfolio: length mismatch in array type function parameters", "P-MTNZ-01": "Portfolio: min taker rate can not be 0", "P-NDNS-01": "Portfolio: native deposits not supported", "P-NQTR-01": "Portfolio: native token quantity truncated but refund failed", "P-SBPD-01": "Portfolio: set bridge param incorrect decimals, must be truncated", "P-VLBF-01": "Portfolio: msg.value is less than the native bridge fee for deposit", "T-OACC-01": "TradePairs: admin account needed for this function", "T-LONR-01": "TradePairs: Limit order type cannot be removed", "T-PPAU-01": "TradePairs: Pair paused", "T-PPAU-02": "TradePairs: cancelOrder pair paused", "T-PPAU-04": "TradePairs: Pair should be paused for this operation", "T-AOPA-01": "TradePairs: addOrderPaused paused", "T-IVOT-01": "TradePairs: invalid order type", "T-LTMT-01": "TradePairs: trade amount is less than minTradeAmount for the tradePair", "T-MTMT-01": "TradePairs: trade amount is more than maxTradeAmount for the tradePair", "T-LTPA-01": "TradePairs: trade amount is less than minPostAmount. It can not be posted in the orderbook", "T-OOCC-01": "TradePairs: only owner of the order can cancel", "T-OOCC-02": "TradePairs: only owner of the order can cancel", "T-OAEX-01": "TradePairs: order is already executed and cannot be canceled", "T-TMDQ-01": "TradePairs: too many decimals in the quantity", "T-TMDP-01": "TradePairs: too many decimals in the price", "T-CLOI-01": "TradePairs: client order id has to be unique per trader", "T-T2PO-01": "TradePairs: Post Only order is not allowed to be a taker", "T-OOCA-01": "TradePairs: only msg.sender can add orders", "T-RMTP-01": "TradePairs: orderbook has to be empty to remove the tradePair", "T-MPNA-01": "TradePairs: mirror pair not allowed", "T-MNOE-01": "TradePairs: max number of fills has to be at least 10", "T-AUCT-01": "TradePairs: auction mode should be set to MATCHING", "T-AUCT-02": "TradePairs: too many decimals in the auction price", "T-AUCT-03": "TradePairs: auction price should be > 0 before matchAuctionOrders", "T-AUCT-04": "TradePairs: market orders not allowed in auction mode", "T-AUCT-05": "TradePairs: setAuctionMode can not turn on live trading when orderbook is crossed", "T-STPR-01": "TradePairs: order cancled due to self trade prevention", "T-USCL-01": "TradePairs: unsolicited cancel from exchange", "T-FOKF-01": "TradePairs: FOK order can't be fully filled. Tx reverted", }; export function parseRevertReason(errorMsg: any): string { const errorStr = String(errorMsg); for (const [code, description] of Object.entries(ERROR_CODES)) { if (errorStr.includes(code)) { return `${code}: ${description}`; } } return errorStr; }