Skip to content

Commit

Permalink
fix: update mfi error list
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s authored and chambaz committed Nov 20, 2023
1 parent 0a16f82 commit b42a6ed
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
3 changes: 3 additions & 0 deletions packages/marginfi-client-v2/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,9 @@ class MarginfiClient {
console.log("------ Inspect 👇 ------");
console.log(urlEscaped);

if (response.value.err)
throw new SendTransactionError(JSON.stringify(response.value.err), response.value.logs ?? []);

return versionedTransaction.signatures[0].toString();
} else {
versionedTransaction = await this.wallet.signTransaction(versionedTransaction);
Expand Down
3 changes: 0 additions & 3 deletions packages/marginfi-client-v2/src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,9 @@ export function parseErrorFromLogs(logs: string[], mfiProgramId: PublicKey): Pro

function parseCustomProgramError(logs: string[]): ProgramError | null {
const log = logs.find((log) => log.includes("failed: custom program error"));
console.log("finding:", logs);
console.log("found:", log);
if (!log) return null;
const regex = /^Program (?<program>\S+) failed: custom program error: (?<code>0x[0-9a-fA-F]+)/g;
const match = regex.exec(log);
console.log(match);
if (!match?.groups) return null;
const code = parseInt(match.groups.code);
return { programId: match.groups.program, code };
Expand Down
54 changes: 52 additions & 2 deletions packages/marginfi-client-v2/src/idl/marginfi-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2363,7 +2363,7 @@ export type Marginfi = {
{
code: 6013;
name: "IllegalLiquidation";
msg: "Illegal post liquidation state, account is either not unhealthy or liquidation was too big";
msg: "Illegal liquidation";
},
{
code: 6014;
Expand Down Expand Up @@ -2469,6 +2469,31 @@ export type Marginfi = {
code: 6034;
name: "InvalidSwitchboardDecimalConversion";
msg: "Invalid swithcboard decimal conversion";
},
{
code: 6035;
name: "CannotCloseOutstandingEmissions";
msg: "Cannot close balance because of outstanding emissions";
},
{
code: 6036;
name: "EmissionsUpdateError";
msg: "Update emissions error";
},
{
code: 6037;
name: "AccountDisabled";
msg: "Account disabled";
},
{
code: 6038;
name: "AccountTempActiveBalanceLimitExceeded";
msg: "Account can't temporarily open new balances, please close a balance first";
},
{
code: 6039;
name: "IllegalBalanceState";
msg: "Illegal balance state";
}
];
};
Expand Down Expand Up @@ -4838,7 +4863,7 @@ export const IDL: Marginfi = {
{
code: 6013,
name: "IllegalLiquidation",
msg: "Illegal post liquidation state, account is either not unhealthy or liquidation was too big",
msg: "Illegal liquidation",
},
{
code: 6014,
Expand Down Expand Up @@ -4945,5 +4970,30 @@ export const IDL: Marginfi = {
name: "InvalidSwitchboardDecimalConversion",
msg: "Invalid swithcboard decimal conversion",
},
{
code: 6035,
name: "CannotCloseOutstandingEmissions",
msg: "Cannot close balance because of outstanding emissions",
},
{
code: 6036,
name: "EmissionsUpdateError",
msg: "Update emissions error",
},
{
code: 6037,
name: "AccountDisabled",
msg: "Account disabled",
},
{
code: 6038,
name: "AccountTempActiveBalanceLimitExceeded",
msg: "Account can't temporarily open new balances, please close a balance first",
},
{
code: 6039,
name: "IllegalBalanceState",
msg: "Illegal balance state",
},
],
};

0 comments on commit b42a6ed

Please sign in to comment.