-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example cross market maker + byproduct utility functions #107
Conversation
waterquarks
commented
Jul 18, 2022
•
edited
Loading
edited
- Adds an ensureOpenOrdersAccount function function, that creates an open orders account for the submitted Serum market if it doesn't already exist. This is tested against an example market maker which is to receive further updates.
- Install KrisM's risk check.
src/scripts/xmm.ts
Outdated
|
||
while (recentFills.length > 256) { | ||
recentFills.shift() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a big fan of this, a better solution would be to just filter the array and override it:
recentFills = recentFills.filter(fill => fill.slot > slot)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, this is a much simpler solution
src/scripts/xmm.ts
Outdated
const queuedBasePosition = perpEventQueue.getUnconsumedEvents() | ||
.filter(event => event.fill !== undefined) | ||
.map(event => event.fill) | ||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code shouldn't ignore any typescript compilation issues
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Patched
src/scripts/xmm.ts
Outdated
expiryTimestamp | ||
), | ||
// @ts-ignore | ||
// tx.add(riskChecker.makeCheckRiskInstruction(perpMarketConfig, perpMarket)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
risk check should be enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-enabled, was just fixing compiler errors
src/scripts/xmm.ts
Outdated
const slots = _.uniq([mangoAccountRaw.context.slot, perpEventQueueRaw.context.slot]) | ||
|
||
if (slots.length !== 1) { | ||
throw new Error('Inconsistent slots on Mango account monitor.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this error is not correctly handled in the calling function, might cause "unhandled promise rejection" issues at runtime which can be really hard to trace, you can either handle the exception or switch to an optional return type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked at the code for getMultipleAccounts
- the context is the same for all elements in the result array: no need for this check, went ahead and removed it
src/scripts/xmm.ts
Outdated
|
||
const recentBlockTime = await connection.getBlockTime( | ||
await connection.getSlot('finalized') | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is so stupidly inefficient, can you please open an issue on solana-labs/solana ?
src/scripts/xmm.ts
Outdated
if (isSnapshot) { | ||
for (const event of data.events.map(parseEvent)) { | ||
const fill = perpMarket.parseFillEvent(event.fill) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit annoying we don't have the slot number here. in general better to remove this unused code and just
if (isSnapshot) return
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah having slot number for each fill in the snapshot message would be handy in this case - removed this bit in the meantime