Skip to content

Commit

Permalink
Mc/perp ob layout fix (#1003)
Browse files Browse the repository at this point in the history
* v0.33.4

* ts: perp layout decode fix

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>

---------

Signed-off-by: microwavedcola1 <microwavedcola@gmail.com>
  • Loading branch information
microwavedcola1 authored Aug 30, 2024
1 parent 79488f0 commit efcffa2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blockworks-foundation/mango-v4",
"version": "0.33.2",
"version": "0.33.4",
"description": "Typescript Client for mango-v4 program.",
"repository": "https://github.com/blockworks-foundation/mango-v4",
"author": {
Expand Down
4 changes: 4 additions & 0 deletions ts/client/scripts/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ async function main(): Promise<void> {
new PublicKey('78b8f4cGCwmZ9ysPFMWLaLTkkaYnUjwMJYStWe5RTSSX'),
);

await Array.from(group.perpMarketsMapByName.values())
.filter((item) => item.name == 'SOL-PERP')[0]
.loadBids(client);

const allOracles = Array.from(group.banksMapByName.values())
.flat()
.map((b) => [b.name, b.oracle])
Expand Down
12 changes: 10 additions & 2 deletions ts/client/src/accounts/perp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,21 @@ export class BookSide {
static toInnerNode(client: MangoClient, data: [number]): InnerNode {
return (client.program as any)._coder.types.typeLayouts
.get('InnerNode')
.decode(Buffer.from([BookSide.INNER_NODE_TAG].concat(data)));
.decode(
Buffer.from(
[BookSide.INNER_NODE_TAG].concat(data).concat([...Array(8)]),
),
);
}
static toLeafNode(client: MangoClient, data: [number]): LeafNode {
return LeafNode.from(
(client.program as any)._coder.types.typeLayouts
.get('LeafNode')
.decode(Buffer.from([BookSide.LEAF_NODE_TAG].concat(data))),
.decode(
Buffer.from(
[BookSide.LEAF_NODE_TAG].concat(data).concat([...Array(8)]),
),
),
);
}
}
Expand Down

0 comments on commit efcffa2

Please sign in to comment.