Skip to content

Commit

Permalink
Add mints to logs (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
brittcyr authored Oct 10, 2024
1 parent dbfb14f commit 056fadc
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 1 deletion.
36 changes: 36 additions & 0 deletions client/idl/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -870,6 +870,14 @@
{
"name": "creator",
"type": "publicKey"
},
{
"name": "baseMint",
"type": "publicKey"
},
{
"name": "quoteMint",
"type": "publicKey"
}
]
}
Expand Down Expand Up @@ -955,6 +963,14 @@
"name": "taker",
"type": "publicKey"
},
{
"name": "baseMint",
"type": "publicKey"
},
{
"name": "quoteMint",
"type": "publicKey"
},
{
"name": "price",
"type": {
Expand Down Expand Up @@ -1919,6 +1935,16 @@
"name": "creator",
"type": "publicKey",
"index": false
},
{
"name": "baseMint",
"type": "publicKey",
"index": false
},
{
"name": "quoteMint",
"type": "publicKey",
"index": false
}
]
},
Expand Down Expand Up @@ -2045,6 +2071,16 @@
"type": "publicKey",
"index": false
},
{
"name": "baseMint",
"type": "publicKey",
"index": false
},
{
"name": "quoteMint",
"type": "publicKey",
"index": false
},
{
"name": "price",
"type": {
Expand Down
15 changes: 14 additions & 1 deletion client/ts/src/manifest/accounts/CreateMarketLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
);
}

/**
Expand Down Expand Up @@ -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(),
};
}
}
Expand All @@ -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',
Expand Down
10 changes: 10 additions & 0 deletions client/ts/src/manifest/accounts/FillLog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -218,6 +226,8 @@ export const fillLogBeet = new beet.BeetStruct<FillLog, FillLogArgs>(
['market', beetSolana.publicKey],
['maker', beetSolana.publicKey],
['taker', beetSolana.publicKey],
['baseMint', beetSolana.publicKey],
['quoteMint', beetSolana.publicKey],
['price', quoteAtomsPerBaseAtomBeet],
['baseAtoms', baseAtomsBeet],
['quoteAtoms', quoteAtomsBeet],
Expand Down
4 changes: 4 additions & 0 deletions programs/manifest/src/logs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ pub fn emit_stack<T: bytemuck::Pod + Discriminant>(e: T) -> Result<(), ProgramEr
pub struct CreateMarketLog {
pub market: Pubkey,
pub creator: Pubkey,
pub base_mint: Pubkey,
pub quote_mint: Pubkey,
}

#[repr(C)]
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 2 additions & 0 deletions programs/manifest/src/program/processor/create_market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})?;
}

Expand Down
2 changes: 2 additions & 0 deletions programs/manifest/src/state/market.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 056fadc

Please sign in to comment.