From efcffa2de689a86557a2632a1513fe77b34fb8d6 Mon Sep 17 00:00:00 2001 From: microwavedcola1 <89031858+microwavedcola1@users.noreply.github.com> Date: Fri, 30 Aug 2024 06:57:50 +0200 Subject: [PATCH] Mc/perp ob layout fix (#1003) * v0.33.4 * ts: perp layout decode fix Signed-off-by: microwavedcola1 --------- Signed-off-by: microwavedcola1 --- package.json | 2 +- ts/client/scripts/template.ts | 4 ++++ ts/client/src/accounts/perp.ts | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 3a5a23fdc..1861b8efe 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/ts/client/scripts/template.ts b/ts/client/scripts/template.ts index 68515b529..4eddbea44 100644 --- a/ts/client/scripts/template.ts +++ b/ts/client/scripts/template.ts @@ -7,6 +7,10 @@ async function main(): Promise { 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]) diff --git a/ts/client/src/accounts/perp.ts b/ts/client/src/accounts/perp.ts index 9a4933fe9..5f9be056f 100644 --- a/ts/client/src/accounts/perp.ts +++ b/ts/client/src/accounts/perp.ts @@ -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)]), + ), + ), ); } }