Skip to content

Commit 90cd65d

Browse files
authored
add hlmm to decodeUser (#1881)
* add hlmm to decodeUser * throw if unrecognized margin mode * fallback to default margin mode
1 parent 803fc32 commit 90cd65d

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

sdk/src/decode/user.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,15 @@ export function decodeUser(buffer: Buffer): UserAccount {
338338
const marginModeNum = buffer.readUInt8(offset);
339339
if (marginModeNum === 0) {
340340
marginMode = MarginMode.DEFAULT;
341-
} else {
341+
} else if (marginModeNum === 1) {
342342
marginMode = MarginMode.HIGH_LEVERAGE;
343+
} else if (marginModeNum === 2) {
344+
marginMode = MarginMode.HIGH_LEVERAGE_MAINTENANCE;
345+
} else {
346+
console.error(
347+
`Detected unknown margin mode: ${marginModeNum}. Please update @drift-labs/sdk for latest IDL.`
348+
);
349+
marginMode = MarginMode.DEFAULT;
343350
}
344351
offset += 1;
345352

0 commit comments

Comments
 (0)