From 9debc63a6a95cc89c6c2268ae451e25bbe2440e3 Mon Sep 17 00:00:00 2001 From: microwavedcola1 <89031858+microwavedcola1@users.noreply.github.com> Date: Sun, 3 Apr 2022 05:43:32 +0200 Subject: [PATCH] update idl, add tokenmint to stuboracle for gpa (#34) Signed-off-by: microwavedcola1 --- .../src/instructions/create_stub_oracle.rs | 1 + programs/mango-v4/src/state/oracle.rs | 3 +- ts/instructions.ts | 2 +- ts/mango_v4.ts | 86 +++++++++++++++++++ 4 files changed, 90 insertions(+), 2 deletions(-) diff --git a/programs/mango-v4/src/instructions/create_stub_oracle.rs b/programs/mango-v4/src/instructions/create_stub_oracle.rs index ce214bf84..c03dc854d 100644 --- a/programs/mango-v4/src/instructions/create_stub_oracle.rs +++ b/programs/mango-v4/src/instructions/create_stub_oracle.rs @@ -33,6 +33,7 @@ pub struct CreateStubOracle<'info> { pub fn create_stub_oracle(ctx: Context, price: I80F48) -> Result<()> { let mut oracle = ctx.accounts.oracle.load_init()?; oracle.group = ctx.accounts.group.key(); + oracle.mint = ctx.accounts.token_mint.key(); oracle.price = price; oracle.last_updated = Clock::get()?.unix_timestamp; diff --git a/programs/mango-v4/src/state/oracle.rs b/programs/mango-v4/src/state/oracle.rs index f579a362f..10644e997 100644 --- a/programs/mango-v4/src/state/oracle.rs +++ b/programs/mango-v4/src/state/oracle.rs @@ -17,11 +17,12 @@ pub enum OracleType { #[account(zero_copy)] pub struct StubOracle { pub group: Pubkey, + pub mint: Pubkey, pub price: I80F48, pub last_updated: i64, pub reserved: [u8; 8], } -const_assert_eq!(size_of::(), 32 + 16 + 8 + 8); +const_assert_eq!(size_of::(), 32 + 32 + 16 + 8 + 8); const_assert_eq!(size_of::() % 8, 0); pub fn determine_oracle_type(data: &[u8]) -> Result { diff --git a/ts/instructions.ts b/ts/instructions.ts index 579e1bb1e..4bc2d4fd8 100644 --- a/ts/instructions.ts +++ b/ts/instructions.ts @@ -519,7 +519,7 @@ export async function getStubOracleForMint( await client.program.account.mangoAccount.all([ { memcmp: { - bytes: groupPk.toBase58(), + bytes: group.toBase58(), offset: 8, }, }, diff --git a/ts/mango_v4.ts b/ts/mango_v4.ts index 31da1e5ef..37c5a04c7 100644 --- a/ts/mango_v4.ts +++ b/ts/mango_v4.ts @@ -275,12 +275,22 @@ export type MangoV4 = { { "name": "createStubOracle", "accounts": [ + { + "name": "group", + "isMut": false, + "isSigner": false + }, { "name": "oracle", "isMut": true, "isSigner": false, "pda": { "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "group" + }, { "kind": "const", "type": "string", @@ -295,6 +305,11 @@ export type MangoV4 = { ] } }, + { + "name": "admin", + "isMut": false, + "isSigner": true + }, { "name": "tokenMint", "isMut": false, @@ -323,10 +338,25 @@ export type MangoV4 = { { "name": "setStubOracle", "accounts": [ + { + "name": "group", + "isMut": false, + "isSigner": false + }, + { + "name": "admin", + "isMut": false, + "isSigner": true + }, { "name": "oracle", "isMut": true, "isSigner": false + }, + { + "name": "payer", + "isMut": true, + "isSigner": true } ], "args": [ @@ -1574,6 +1604,10 @@ export type MangoV4 = { "type": { "kind": "struct", "fields": [ + { + "name": "group", + "type": "publicKey" + }, { "name": "price", "type": { @@ -1583,6 +1617,15 @@ export type MangoV4 = { { "name": "lastUpdated", "type": "i64" + }, + { + "name": "reserved", + "type": { + "array": [ + "u8", + 8 + ] + } } ] } @@ -2622,12 +2665,22 @@ export const IDL: MangoV4 = { { "name": "createStubOracle", "accounts": [ + { + "name": "group", + "isMut": false, + "isSigner": false + }, { "name": "oracle", "isMut": true, "isSigner": false, "pda": { "seeds": [ + { + "kind": "account", + "type": "publicKey", + "path": "group" + }, { "kind": "const", "type": "string", @@ -2642,6 +2695,11 @@ export const IDL: MangoV4 = { ] } }, + { + "name": "admin", + "isMut": false, + "isSigner": true + }, { "name": "tokenMint", "isMut": false, @@ -2670,10 +2728,25 @@ export const IDL: MangoV4 = { { "name": "setStubOracle", "accounts": [ + { + "name": "group", + "isMut": false, + "isSigner": false + }, + { + "name": "admin", + "isMut": false, + "isSigner": true + }, { "name": "oracle", "isMut": true, "isSigner": false + }, + { + "name": "payer", + "isMut": true, + "isSigner": true } ], "args": [ @@ -3921,6 +3994,10 @@ export const IDL: MangoV4 = { "type": { "kind": "struct", "fields": [ + { + "name": "group", + "type": "publicKey" + }, { "name": "price", "type": { @@ -3930,6 +4007,15 @@ export const IDL: MangoV4 = { { "name": "lastUpdated", "type": "i64" + }, + { + "name": "reserved", + "type": { + "array": [ + "u8", + 8 + ] + } } ] }