From 056fadcdc896307fd3597c4a24e7a4c18a986610 Mon Sep 17 00:00:00 2001 From: Britt Cyr Date: Thu, 10 Oct 2024 09:35:57 -0400 Subject: [PATCH] Add mints to logs (#171) --- client/idl/manifest.json | 36 +++++++++++++++++++ .../src/manifest/accounts/CreateMarketLog.ts | 15 +++++++- client/ts/src/manifest/accounts/FillLog.ts | 10 ++++++ programs/manifest/src/logs.rs | 4 +++ .../src/program/processor/create_market.rs | 2 ++ programs/manifest/src/state/market.rs | 2 ++ 6 files changed, 68 insertions(+), 1 deletion(-) diff --git a/client/idl/manifest.json b/client/idl/manifest.json index cbe98c713..6ae5ebdcd 100644 --- a/client/idl/manifest.json +++ b/client/idl/manifest.json @@ -870,6 +870,14 @@ { "name": "creator", "type": "publicKey" + }, + { + "name": "baseMint", + "type": "publicKey" + }, + { + "name": "quoteMint", + "type": "publicKey" } ] } @@ -955,6 +963,14 @@ "name": "taker", "type": "publicKey" }, + { + "name": "baseMint", + "type": "publicKey" + }, + { + "name": "quoteMint", + "type": "publicKey" + }, { "name": "price", "type": { @@ -1919,6 +1935,16 @@ "name": "creator", "type": "publicKey", "index": false + }, + { + "name": "baseMint", + "type": "publicKey", + "index": false + }, + { + "name": "quoteMint", + "type": "publicKey", + "index": false } ] }, @@ -2045,6 +2071,16 @@ "type": "publicKey", "index": false }, + { + "name": "baseMint", + "type": "publicKey", + "index": false + }, + { + "name": "quoteMint", + "type": "publicKey", + "index": false + }, { "name": "price", "type": { diff --git a/client/ts/src/manifest/accounts/CreateMarketLog.ts b/client/ts/src/manifest/accounts/CreateMarketLog.ts index 377011643..5d149984b 100644 --- a/client/ts/src/manifest/accounts/CreateMarketLog.ts +++ b/client/ts/src/manifest/accounts/CreateMarketLog.ts @@ -17,6 +17,8 @@ import * as beet from '@metaplex-foundation/beet'; export type CreateMarketLogArgs = { market: web3.PublicKey; creator: web3.PublicKey; + baseMint: web3.PublicKey; + quoteMint: web3.PublicKey; }; /** * Holds the data for the {@link CreateMarketLog} Account and provides de/serialization @@ -29,13 +31,20 @@ export class CreateMarketLog implements CreateMarketLogArgs { private constructor( readonly market: web3.PublicKey, readonly creator: web3.PublicKey, + readonly baseMint: web3.PublicKey, + readonly quoteMint: web3.PublicKey, ) {} /** * Creates a {@link CreateMarketLog} instance from the provided args. */ static fromArgs(args: CreateMarketLogArgs) { - return new CreateMarketLog(args.market, args.creator); + return new CreateMarketLog( + args.market, + args.creator, + args.baseMint, + args.quoteMint, + ); } /** @@ -140,6 +149,8 @@ export class CreateMarketLog implements CreateMarketLogArgs { return { market: this.market.toBase58(), creator: this.creator.toBase58(), + baseMint: this.baseMint.toBase58(), + quoteMint: this.quoteMint.toBase58(), }; } } @@ -155,6 +166,8 @@ export const createMarketLogBeet = new beet.BeetStruct< [ ['market', beetSolana.publicKey], ['creator', beetSolana.publicKey], + ['baseMint', beetSolana.publicKey], + ['quoteMint', beetSolana.publicKey], ], CreateMarketLog.fromArgs, 'CreateMarketLog', diff --git a/client/ts/src/manifest/accounts/FillLog.ts b/client/ts/src/manifest/accounts/FillLog.ts index c6bec7383..7e54f8c49 100644 --- a/client/ts/src/manifest/accounts/FillLog.ts +++ b/client/ts/src/manifest/accounts/FillLog.ts @@ -24,6 +24,8 @@ export type FillLogArgs = { market: web3.PublicKey; maker: web3.PublicKey; taker: web3.PublicKey; + baseMint: web3.PublicKey; + quoteMint: web3.PublicKey; price: QuoteAtomsPerBaseAtom; baseAtoms: BaseAtoms; quoteAtoms: QuoteAtoms; @@ -45,6 +47,8 @@ export class FillLog implements FillLogArgs { readonly market: web3.PublicKey, readonly maker: web3.PublicKey, readonly taker: web3.PublicKey, + readonly baseMint: web3.PublicKey, + readonly quoteMint: web3.PublicKey, readonly price: QuoteAtomsPerBaseAtom, readonly baseAtoms: BaseAtoms, readonly quoteAtoms: QuoteAtoms, @@ -63,6 +67,8 @@ export class FillLog implements FillLogArgs { args.market, args.maker, args.taker, + args.baseMint, + args.quoteMint, args.price, args.baseAtoms, args.quoteAtoms, @@ -177,6 +183,8 @@ export class FillLog implements FillLogArgs { market: this.market.toBase58(), maker: this.maker.toBase58(), taker: this.taker.toBase58(), + baseMint: this.baseMint.toBase58(), + quoteMint: this.quoteMint.toBase58(), price: this.price, baseAtoms: this.baseAtoms, quoteAtoms: this.quoteAtoms, @@ -218,6 +226,8 @@ export const fillLogBeet = new beet.BeetStruct( ['market', beetSolana.publicKey], ['maker', beetSolana.publicKey], ['taker', beetSolana.publicKey], + ['baseMint', beetSolana.publicKey], + ['quoteMint', beetSolana.publicKey], ['price', quoteAtomsPerBaseAtomBeet], ['baseAtoms', baseAtomsBeet], ['quoteAtoms', quoteAtomsBeet], diff --git a/programs/manifest/src/logs.rs b/programs/manifest/src/logs.rs index 963afd22c..4d45e119b 100644 --- a/programs/manifest/src/logs.rs +++ b/programs/manifest/src/logs.rs @@ -34,6 +34,8 @@ pub fn emit_stack(e: T) -> Result<(), ProgramEr pub struct CreateMarketLog { pub market: Pubkey, pub creator: Pubkey, + pub base_mint: Pubkey, + pub quote_mint: Pubkey, } #[repr(C)] @@ -67,6 +69,8 @@ pub struct FillLog { pub market: Pubkey, pub maker: Pubkey, pub taker: Pubkey, + pub base_mint: Pubkey, + pub quote_mint: Pubkey, pub price: QuoteAtomsPerBaseAtom, pub base_atoms: BaseAtoms, pub quote_atoms: QuoteAtoms, diff --git a/programs/manifest/src/program/processor/create_market.rs b/programs/manifest/src/program/processor/create_market.rs index 4b732a4d6..9a6ccfedf 100644 --- a/programs/manifest/src/program/processor/create_market.rs +++ b/programs/manifest/src/program/processor/create_market.rs @@ -179,6 +179,8 @@ pub(crate) fn process_create_market( emit_stack(CreateMarketLog { market: *market.key, creator: *payer.key, + base_mint: *base_mint.info.key, + quote_mint: *quote_mint.info.key, })?; } diff --git a/programs/manifest/src/state/market.rs b/programs/manifest/src/state/market.rs index e881011d8..c65c1e3dc 100644 --- a/programs/manifest/src/state/market.rs +++ b/programs/manifest/src/state/market.rs @@ -912,6 +912,8 @@ impl< market, maker, taker, + base_mint: fixed.base_mint, + quote_mint: fixed.quote_mint, base_atoms: base_atoms_traded, quote_atoms: quote_atoms_traded, price: matched_price,