Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions programs/mint_governor/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ pub struct MintAuthorityRemovedEvent {
pub mint_governor: Pubkey,
pub authorized_minter: Pubkey,
pub total_minted: u64,
pub mint_authority: Pubkey,
}

#[event]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ impl RemoveMintAuthority<'_> {
mint_governor: mint_governor.key(),
authorized_minter: mint_authority.authorized_minter,
total_minted: mint_authority.total_minted,
mint_authority: mint_authority.key(),
});

// Mint authority account gets closed using close constraint
Expand Down
14 changes: 14 additions & 0 deletions programs/performance_package_v2/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ pub struct PerformancePackageCreatedEvent {
pub recipient: Pubkey,
pub create_key: Pubkey,
pub pda_bump: u8,
pub oracle_reader: OracleReader,
pub reward_function: RewardFunction,
pub min_unlock_timestamp: i64,
pub pp_created_at_timestamp: i64,
}

/// Emitted by: `start_unlock`
Expand All @@ -29,6 +33,8 @@ pub struct UnlockStartedEvent {
pub common: CommonFields,
pub performance_package: Pubkey,
pub start_time: i64,
pub start_oracle_value: u128,
pub pp_created_at_timestamp: i64,
}

/// Emitted by: `complete_unlock`
Expand All @@ -41,6 +47,7 @@ pub struct UnlockCompletedEvent {
pub amount_minted: u64,
/// Cumulative after this unlock
pub total_rewards_paid_out: u64,
pub pp_created_at_timestamp: i64,
}

/// Emitted by: `change_authority`
Expand All @@ -50,6 +57,7 @@ pub struct AuthorityChangedEvent {
pub performance_package: Pubkey,
pub old_authority: Pubkey,
pub new_authority: Pubkey,
pub pp_created_at_timestamp: i64,
}

/// Emitted by: `propose_change`
Expand All @@ -63,6 +71,8 @@ pub struct ChangeProposedEvent {
pub new_recipient: Option<Pubkey>,
pub new_oracle_reader: Option<OracleReader>,
pub new_reward_function: Option<RewardFunction>,
/// `PerformancePackage.created_at_timestamp` as stamped onto the ChangeRequest
pub pp_created_at_timestamp: i64,
}

/// Emitted by: `execute_change`
Expand All @@ -74,6 +84,9 @@ pub struct ChangeExecutedEvent {
pub new_recipient: Option<Pubkey>,
pub new_oracle_reader: Option<OracleReader>,
pub new_reward_function: Option<RewardFunction>,
/// The ChangeRequest PDA that was executed (and closed) by this instruction
pub change_request: Pubkey,
pub pp_created_at_timestamp: i64,
}

/// Emitted by: `close_performance_package`
Expand All @@ -83,4 +96,5 @@ pub struct PerformancePackageClosedEvent {
pub performance_package: Pubkey,
/// Final cumulative amount paid
pub total_rewards_paid_out: u64,
pub pp_created_at_timestamp: i64,
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ impl ChangeAuthority<'_> {
performance_package: pp.key(),
old_authority: ctx.accounts.authority.key(),
new_authority,
pp_created_at_timestamp: pp.created_at_timestamp,
});

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,11 @@ impl ClosePerformancePackage<'_> {
}

pub fn handle(ctx: Context<Self>) -> Result<()> {
let pp = &ctx.accounts.performance_package;
let pp = &mut ctx.accounts.performance_package;
let clock = Clock::get()?;

pp.seq_num += 1;

emit_cpi!(PerformancePackageClosedEvent {
common: CommonFields {
slot: clock.slot,
Expand All @@ -60,6 +62,7 @@ impl ClosePerformancePackage<'_> {
},
performance_package: pp.key(),
total_rewards_paid_out: pp.total_rewards_paid_out,
pp_created_at_timestamp: pp.created_at_timestamp,
});

// The performance_package account is closed automatically via the `close = rent_destination` constraint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ impl CompleteUnlock<'_> {
recipient: pp.recipient,
amount_minted: mint_amount,
total_rewards_paid_out: pp.total_rewards_paid_out,
pp_created_at_timestamp: pp.created_at_timestamp,
});

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ impl ExecuteChange<'_> {
new_recipient: cr.new_recipient,
new_oracle_reader: cr.new_oracle_reader.clone(),
new_reward_function: cr.new_reward_function.clone(),
change_request: ctx.accounts.change_request.key(),
pp_created_at_timestamp: pp.created_at_timestamp,
});

// The change_request account is closed automatically via the `close = rent_destination` constraint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ impl InitializePerformancePackage<'_> {
recipient: pp.recipient,
create_key: pp.create_key,
pda_bump: pp.bump,
oracle_reader: pp.oracle_reader.clone(),
reward_function: pp.reward_function.clone(),
min_unlock_timestamp: pp.min_unlock_timestamp,
pp_created_at_timestamp: pp.created_at_timestamp,
});

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl ProposeChange<'_> {
new_recipient: args.new_recipient,
new_oracle_reader: args.new_oracle_reader,
new_reward_function: args.new_reward_function,
pp_created_at_timestamp: pp.created_at_timestamp,
});

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl StartUnlock<'_> {

// Record start snapshot (no-op for Time oracle, reads AMM for FutarchyTwap)
pp.oracle_reader.record_start(ctx.remaining_accounts)?;
let start_oracle_value = pp.oracle_reader.start_snapshot();

// Transition to Unlocking status
pp.status = PackageStatus::Unlocking;
Expand All @@ -68,6 +69,8 @@ impl StartUnlock<'_> {
},
performance_package: pp.key(),
start_time: clock.unix_timestamp,
start_oracle_value,
pp_created_at_timestamp: pp.created_at_timestamp,
});

Ok(())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ impl OracleReader {
}
}

/// Returns the start snapshot recorded by `record_start`.
/// 0 for `Time` (no snapshot); `start_value` for `FutarchyTwap`.
pub fn start_snapshot(&self) -> u128 {
match self {
OracleReader::Time => 0,
OracleReader::FutarchyTwap { start_value, .. } => *start_value,
}
}

/// Records the end snapshot when unlock completes.
/// For Time oracle, this is a no-op since it just reads current time on demand.
/// For FutarchyTwap, reads the accumulator from the Dao's spot pool oracle.
Expand Down
2 changes: 1 addition & 1 deletion sdk/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@metadaoproject/programs",
"version": "0.1.0-alpha.2",
"version": "0.1.0-alpha.5",
"type": "module",
"main": "dist/index.js",
"module": "dist/index.js",
Expand Down
18 changes: 12 additions & 6 deletions sdk/src/futarchy/v0.6/FutarchyClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1011,13 +1011,17 @@ export class FutarchyClient {
quoteMint = MAINNET_USDC,
transactionIndex,
meteoraConfig = LAUNCHPAD_V0_7_MAINNET_METEORA_CONFIG,
launchpadProgramId = LAUNCHPAD_V0_7_PROGRAM_ID,
positionNftMint = undefined,
admin = this.provider.publicKey,
}: {
dao: PublicKey;
baseMint: PublicKey;
quoteMint?: PublicKey;
transactionIndex: bigint;
meteoraConfig?: PublicKey;
launchpadProgramId?: PublicKey;
positionNftMint?: PublicKey;
admin?: PublicKey;
}) {
// Squads accounts
Expand Down Expand Up @@ -1068,18 +1072,20 @@ export class FutarchyClient {
DAMM_V2_PROGRAM_ID,
);

const [positionNftMint] = PublicKey.findProgramAddressSync(
[Buffer.from("position_nft_mint"), baseMint.toBuffer()],
LAUNCHPAD_V0_7_PROGRAM_ID,
);
const resolvedPositionNftMint =
positionNftMint ??
PublicKey.findProgramAddressSync(
[Buffer.from("position_nft_mint"), baseMint.toBuffer()],
launchpadProgramId,
)[0];

const [positionNftAccount] = PublicKey.findProgramAddressSync(
[Buffer.from("position_nft_account"), positionNftMint.toBuffer()],
[Buffer.from("position_nft_account"), resolvedPositionNftMint.toBuffer()],
DAMM_V2_PROGRAM_ID,
);

const [position] = PublicKey.findProgramAddressSync(
[Buffer.from("position"), positionNftMint.toBuffer()],
[Buffer.from("position"), resolvedPositionNftMint.toBuffer()],
DAMM_V2_PROGRAM_ID,
);

Expand Down
10 changes: 10 additions & 0 deletions sdk/src/mint_governor/v0.7/types/mint_governor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,11 @@ export type MintGovernor = {
type: "u64";
index: false;
},
{
name: "mintAuthority";
type: "publicKey";
index: false;
},
];
},
{
Expand Down Expand Up @@ -1396,6 +1401,11 @@ export const IDL: MintGovernor = {
type: "u64",
index: false,
},
{
name: "mintAuthority",
type: "publicKey",
index: false,
},
],
},
{
Expand Down
29 changes: 28 additions & 1 deletion sdk/src/performance_package_v2/v0.7/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IdlAccounts, IdlTypes } from "@coral-xyz/anchor";
import { IdlAccounts, IdlEvents, IdlTypes } from "@coral-xyz/anchor";
import {
PerformancePackageV2 as PerformancePackageV2Program,
IDL as PerformancePackageV2IDL,
Expand All @@ -17,3 +17,30 @@ export type PerformancePackageV2PackageStatus =
IdlTypes<PerformancePackageV2Program>["PackageStatus"];
export type PerformancePackageV2ThresholdTranche =
IdlTypes<PerformancePackageV2Program>["ThresholdTranche"];

// Event aliases are prefixed because several event names (UnlockStartedEvent,
// UnlockCompletedEvent, ChangeProposedEvent, ChangeExecutedEvent) collide with
// the v1 `price_based_performance_package` module, which also re-exports them
// unqualified from the package root.
export type PerformancePackageV2CreatedEvent =
IdlEvents<PerformancePackageV2Program>["PerformancePackageCreatedEvent"];
export type PerformancePackageV2UnlockStartedEvent =
IdlEvents<PerformancePackageV2Program>["UnlockStartedEvent"];
export type PerformancePackageV2UnlockCompletedEvent =
IdlEvents<PerformancePackageV2Program>["UnlockCompletedEvent"];
export type PerformancePackageV2AuthorityChangedEvent =
IdlEvents<PerformancePackageV2Program>["AuthorityChangedEvent"];
export type PerformancePackageV2ChangeProposedEvent =
IdlEvents<PerformancePackageV2Program>["ChangeProposedEvent"];
export type PerformancePackageV2ChangeExecutedEvent =
IdlEvents<PerformancePackageV2Program>["ChangeExecutedEvent"];
export type PerformancePackageV2ClosedEvent =
IdlEvents<PerformancePackageV2Program>["PerformancePackageClosedEvent"];
export type PerformancePackageV2Event =
| PerformancePackageV2CreatedEvent
| PerformancePackageV2UnlockStartedEvent
| PerformancePackageV2UnlockCompletedEvent
| PerformancePackageV2AuthorityChangedEvent
| PerformancePackageV2ChangeProposedEvent
| PerformancePackageV2ChangeExecutedEvent
| PerformancePackageV2ClosedEvent;
Loading
Loading