From 97f3253bb489af3b1d9363207fa160030bac5d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Brzezin=CC=81ski?= Date: Fri, 20 Oct 2023 12:31:30 +0200 Subject: [PATCH] fix --- components/instructions/programs/mangoV4.tsx | 33 +++++++++++++++++--- utils/Mango/listingTools.ts | 1 - 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/components/instructions/programs/mangoV4.tsx b/components/instructions/programs/mangoV4.tsx index d1f559276a..07169cdc5c 100644 --- a/components/instructions/programs/mangoV4.tsx +++ b/components/instructions/programs/mangoV4.tsx @@ -238,7 +238,6 @@ const instructions = () => ({ ]) const oracleData = await decodePriceFromOracleAi( - oracle, oracleAi!, connection, proposedOracle.type @@ -668,12 +667,36 @@ const instructions = () => ({ ], getDataUI: async ( connection: Connection, - data: Uint8Array - //accounts: AccountMetaData[] + data: Uint8Array, + accounts: AccountMetaData[] ) => { - const info = await displayArgs(connection, data) + const oracle = accounts[6].pubkey + + const [info, proposedOracle, oracleAi] = await Promise.all([ + displayArgs(connection, data), + getOracle(connection, oracle), + connection.getAccountInfo(oracle), + ]) + + const oracleData = await decodePriceFromOracleAi( + oracleAi!, + connection, + proposedOracle.type + ) try { - return
{info}
+ return ( +
+ {oracleData.uiPrice ? ( +
+
Oracle Price: ${oracleData.uiPrice}
+
Oracle Last known confidence: {oracleData.deviation}%
+
+ ) : ( +
No Oracle Data
+ )} +
{info}
+
+ ) } catch (e) { console.log(e) return
{JSON.stringify(data)}
diff --git a/utils/Mango/listingTools.ts b/utils/Mango/listingTools.ts index 4c0f8aee36..3ba8bec59c 100644 --- a/utils/Mango/listingTools.ts +++ b/utils/Mango/listingTools.ts @@ -488,7 +488,6 @@ export const getBestMarket = async ({ } export const decodePriceFromOracleAi = async ( - oracle: PublicKey, ai: AccountInfo, connection: Connection, type: string