Skip to content

Commit

Permalink
feat: add code to all static sim errors
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Nov 26, 2024
1 parent add923c commit 1e606d9
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/mrgn-utils/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,40 +11,47 @@ 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,
actionMethod: "WARNING",
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,
Expand All @@ -53,87 +60,104 @@ 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.",
link: "https://support.marginfi.com/",
linkText: "Contact support",
isEnabled: false,
actionMethod: "WARNING",
code: 122,
},
STAKE_SIMULATION_FAILED: {
description: "Transaction failed to build. Please try again",
link: "https://support.marginfi.com/",
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,
},
};

Expand Down

0 comments on commit 1e606d9

Please sign in to comment.