From 1e606d9f67ff2c51816c1f2e01e83124b3c2197e Mon Sep 17 00:00:00 2001 From: chambaz Date: Tue, 26 Nov 2024 11:23:13 -0500 Subject: [PATCH] feat: add code to all static sim errors --- packages/mrgn-utils/src/errors.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/packages/mrgn-utils/src/errors.ts b/packages/mrgn-utils/src/errors.ts index 087c6c8c9b..25d8ffd6e9 100644 --- a/packages/mrgn-utils/src/errors.ts +++ b/packages/mrgn-utils/src/errors.ts @@ -11,33 +11,39 @@ export const STATIC_SIMULATION_ERRORS: { [key: string]: ActionMessageType } = { isEnabled: false, actionMethod: "WARNING", description: "Marginfi client or account not initialized. Please refresh and try again.", + code: 101, }, SLIPPAGE: { isEnabled: false, actionMethod: "WARNING", description: "Slippage tolerance exceeded. Please increase the slippage tolerance in the settings and try again.", + code: 102, }, TX_SIZE: { isEnabled: false, actionMethod: "WARNING", description: "The Jupiter routes for this swap cause the transaction to fail due to size restrictions. Please try again.", + code: 103, }, FL_FAILED: { isEnabled: false, actionMethod: "WARNING", description: "Failed to fetch data. Please choose a different collateral option or refresh the page.", + code: 104, }, CLOSE_POSITIONS_FL_FAILED: { isEnabled: false, actionMethod: "WARNING", description: "Failed to close position. Please try again or manually reduce your position size.", + code: 105, }, KEY_SIZE: { isEnabled: false, actionMethod: "WARNING", description: "This transaction fails due to account restrictions. Please decrease the positions on mrgnlend and try again.", + code: 106, }, STALE_TRADING: { isEnabled: true, @@ -45,6 +51,7 @@ export const STATIC_SIMULATION_ERRORS: { [key: string]: ActionMessageType } = { description: "Trading may fail due to network congestion preventing oracles from updating price data.", link: "https://docs.marginfi.com/faqs#what-does-the-stale-oracles-error-mean", linkText: "Learn more about marginfi's decentralized oracles.", + code: 107, }, STALE_TRADING_OR_HEALTH: { isEnabled: true, @@ -53,68 +60,82 @@ export const STATIC_SIMULATION_ERRORS: { [key: string]: ActionMessageType } = { "Trading may fail due to poor account health or network congestion preventing oracles from updating price data.", link: "https://docs.marginfi.com/faqs#what-does-the-stale-oracles-error-mean", linkText: "Learn more about marginfi's decentralized oracles.", + code: 108, }, USER_REJECTED: { isEnabled: false, actionMethod: "WARNING", description: "User rejected the transaction.", + code: 109, }, DEPOSIT_CAP_EXCEEDED: { isEnabled: false, actionMethod: "WARNING", description: "The maximum deposit capacity for this asset has been reached.", + code: 110, }, UTILIZATION_RATIO_INVALID: { isEnabled: false, actionMethod: "WARNING", description: "Insufficient liquidity for this trade.", + code: 111, }, NO_POSITIONS: { description: "No position found.", isEnabled: false, + code: 112, }, HEALTH_LIQUIDATION_FAILED: { isEnabled: true, actionMethod: "WARNING", description: "Simulating transaction failed. Please try again.", + code: 113, }, NO_COLLATERAL: { description: "No available collateral.", isEnabled: false, + code: 114, }, ALREADY_LENDING: { description: "You're already lending this asset, you need to close that position first to start borrowing.", isEnabled: false, + code: 115, }, ALREADY_BORROWING: { description: "You are already borrowing this asset, you need to repay that position first to start lending.", isEnabled: false, + code: 116, }, EXISTING_BORROW: { description: "You cannot borrow an isolated asset with existing borrows.", isEnabled: false, + code: 117, }, TRANSACTION_EXPIRED: { description: "Transaction failed to land due to network congestion. This is a known issue that marginfi is actively working with Solana Labs to address. Please try again in a few moments.", isEnabled: true, actionMethod: "WARNING", + code: 118, }, INSUFICIENT_LAMPORTS: { description: "You do not have enough SOL to execute the transaction", isEnabled: true, actionMethod: "WARNING", + code: 119, }, INSUFICIENT_FUNDS: { description: "You do not have enough funds to execute the transaction", isEnabled: true, actionMethod: "WARNING", + code: 120, }, INSUFICIENT_FUNDS_REPAY: { description: "Insufficient funds for the transaction, likely due to a bad Jupiter quote. Please select another amount and try again.", isEnabled: true, actionMethod: "WARNING", + code: 121, }, BUILDING_LENDING_TX: { description: "Transaction failed to build, please open a ticket.", @@ -122,6 +143,7 @@ export const STATIC_SIMULATION_ERRORS: { [key: string]: ActionMessageType } = { linkText: "Contact support", isEnabled: false, actionMethod: "WARNING", + code: 122, }, STAKE_SIMULATION_FAILED: { description: "Transaction failed to build. Please try again", @@ -129,11 +151,13 @@ export const STATIC_SIMULATION_ERRORS: { [key: string]: ActionMessageType } = { linkText: "Contact support", isEnabled: false, actionMethod: "WARNING", + code: 123, }, STAKE_SWAP_SIMULATION_FAILED: { description: "Failed to fetch Jupiter qoute. Please try again", isEnabled: true, actionMethod: "WARNING", + code: 124, }, };