diff --git a/programs/mint_governor/src/events.rs b/programs/mint_governor/src/events.rs index f38f9555..cb902adc 100644 --- a/programs/mint_governor/src/events.rs +++ b/programs/mint_governor/src/events.rs @@ -60,6 +60,7 @@ pub struct MintAuthorityRemovedEvent { pub mint_governor: Pubkey, pub authorized_minter: Pubkey, pub total_minted: u64, + pub mint_authority: Pubkey, } #[event] diff --git a/programs/mint_governor/src/instructions/remove_mint_authority.rs b/programs/mint_governor/src/instructions/remove_mint_authority.rs index bcb0cebe..33e7244a 100644 --- a/programs/mint_governor/src/instructions/remove_mint_authority.rs +++ b/programs/mint_governor/src/instructions/remove_mint_authority.rs @@ -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 diff --git a/programs/performance_package_v2/src/events.rs b/programs/performance_package_v2/src/events.rs index 77900db5..5357bc11 100644 --- a/programs/performance_package_v2/src/events.rs +++ b/programs/performance_package_v2/src/events.rs @@ -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` @@ -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` @@ -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` @@ -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` @@ -63,6 +71,8 @@ pub struct ChangeProposedEvent { pub new_recipient: Option, pub new_oracle_reader: Option, pub new_reward_function: Option, + /// `PerformancePackage.created_at_timestamp` as stamped onto the ChangeRequest + pub pp_created_at_timestamp: i64, } /// Emitted by: `execute_change` @@ -74,6 +84,9 @@ pub struct ChangeExecutedEvent { pub new_recipient: Option, pub new_oracle_reader: Option, pub new_reward_function: Option, + /// 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` @@ -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, } diff --git a/programs/performance_package_v2/src/instructions/change_authority.rs b/programs/performance_package_v2/src/instructions/change_authority.rs index 80c558f3..aacc5b5e 100644 --- a/programs/performance_package_v2/src/instructions/change_authority.rs +++ b/programs/performance_package_v2/src/instructions/change_authority.rs @@ -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(()) diff --git a/programs/performance_package_v2/src/instructions/close_performance_package.rs b/programs/performance_package_v2/src/instructions/close_performance_package.rs index 9c885f44..72e4856d 100644 --- a/programs/performance_package_v2/src/instructions/close_performance_package.rs +++ b/programs/performance_package_v2/src/instructions/close_performance_package.rs @@ -49,9 +49,11 @@ impl ClosePerformancePackage<'_> { } pub fn handle(ctx: Context) -> 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, @@ -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 diff --git a/programs/performance_package_v2/src/instructions/complete_unlock.rs b/programs/performance_package_v2/src/instructions/complete_unlock.rs index 4f8a7e98..43bb0a40 100644 --- a/programs/performance_package_v2/src/instructions/complete_unlock.rs +++ b/programs/performance_package_v2/src/instructions/complete_unlock.rs @@ -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(()) diff --git a/programs/performance_package_v2/src/instructions/execute_change.rs b/programs/performance_package_v2/src/instructions/execute_change.rs index ff11e11c..1b76fba9 100644 --- a/programs/performance_package_v2/src/instructions/execute_change.rs +++ b/programs/performance_package_v2/src/instructions/execute_change.rs @@ -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 diff --git a/programs/performance_package_v2/src/instructions/initialize_performance_package.rs b/programs/performance_package_v2/src/instructions/initialize_performance_package.rs index a8345e93..4d075479 100644 --- a/programs/performance_package_v2/src/instructions/initialize_performance_package.rs +++ b/programs/performance_package_v2/src/instructions/initialize_performance_package.rs @@ -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(()) diff --git a/programs/performance_package_v2/src/instructions/propose_change.rs b/programs/performance_package_v2/src/instructions/propose_change.rs index 2ca0b352..6d968ac8 100644 --- a/programs/performance_package_v2/src/instructions/propose_change.rs +++ b/programs/performance_package_v2/src/instructions/propose_change.rs @@ -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(()) diff --git a/programs/performance_package_v2/src/instructions/start_unlock.rs b/programs/performance_package_v2/src/instructions/start_unlock.rs index f20db405..7c667654 100644 --- a/programs/performance_package_v2/src/instructions/start_unlock.rs +++ b/programs/performance_package_v2/src/instructions/start_unlock.rs @@ -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; @@ -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(()) diff --git a/programs/performance_package_v2/src/state/performance_package.rs b/programs/performance_package_v2/src/state/performance_package.rs index 6d73b033..0221ba82 100644 --- a/programs/performance_package_v2/src/state/performance_package.rs +++ b/programs/performance_package_v2/src/state/performance_package.rs @@ -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. diff --git a/sdk/package.json b/sdk/package.json index 775a0ed1..33014621 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -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", diff --git a/sdk/src/futarchy/v0.6/FutarchyClient.ts b/sdk/src/futarchy/v0.6/FutarchyClient.ts index 125843df..ea76c6d9 100644 --- a/sdk/src/futarchy/v0.6/FutarchyClient.ts +++ b/sdk/src/futarchy/v0.6/FutarchyClient.ts @@ -1011,6 +1011,8 @@ 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; @@ -1018,6 +1020,8 @@ export class FutarchyClient { quoteMint?: PublicKey; transactionIndex: bigint; meteoraConfig?: PublicKey; + launchpadProgramId?: PublicKey; + positionNftMint?: PublicKey; admin?: PublicKey; }) { // Squads accounts @@ -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, ); diff --git a/sdk/src/mint_governor/v0.7/types/mint_governor.ts b/sdk/src/mint_governor/v0.7/types/mint_governor.ts index b2d9b02c..b126ad79 100644 --- a/sdk/src/mint_governor/v0.7/types/mint_governor.ts +++ b/sdk/src/mint_governor/v0.7/types/mint_governor.ts @@ -659,6 +659,11 @@ export type MintGovernor = { type: "u64"; index: false; }, + { + name: "mintAuthority"; + type: "publicKey"; + index: false; + }, ]; }, { @@ -1396,6 +1401,11 @@ export const IDL: MintGovernor = { type: "u64", index: false, }, + { + name: "mintAuthority", + type: "publicKey", + index: false, + }, ], }, { diff --git a/sdk/src/performance_package_v2/v0.7/types/index.ts b/sdk/src/performance_package_v2/v0.7/types/index.ts index e6c7d5bd..25a6141c 100644 --- a/sdk/src/performance_package_v2/v0.7/types/index.ts +++ b/sdk/src/performance_package_v2/v0.7/types/index.ts @@ -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, @@ -17,3 +17,30 @@ export type PerformancePackageV2PackageStatus = IdlTypes["PackageStatus"]; export type PerformancePackageV2ThresholdTranche = IdlTypes["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["PerformancePackageCreatedEvent"]; +export type PerformancePackageV2UnlockStartedEvent = + IdlEvents["UnlockStartedEvent"]; +export type PerformancePackageV2UnlockCompletedEvent = + IdlEvents["UnlockCompletedEvent"]; +export type PerformancePackageV2AuthorityChangedEvent = + IdlEvents["AuthorityChangedEvent"]; +export type PerformancePackageV2ChangeProposedEvent = + IdlEvents["ChangeProposedEvent"]; +export type PerformancePackageV2ChangeExecutedEvent = + IdlEvents["ChangeExecutedEvent"]; +export type PerformancePackageV2ClosedEvent = + IdlEvents["PerformancePackageClosedEvent"]; +export type PerformancePackageV2Event = + | PerformancePackageV2CreatedEvent + | PerformancePackageV2UnlockStartedEvent + | PerformancePackageV2UnlockCompletedEvent + | PerformancePackageV2AuthorityChangedEvent + | PerformancePackageV2ChangeProposedEvent + | PerformancePackageV2ChangeExecutedEvent + | PerformancePackageV2ClosedEvent; diff --git a/sdk/src/performance_package_v2/v0.7/types/performance_package_v2.ts b/sdk/src/performance_package_v2/v0.7/types/performance_package_v2.ts index 0956ed64..64b030d7 100644 --- a/sdk/src/performance_package_v2/v0.7/types/performance_package_v2.ts +++ b/sdk/src/performance_package_v2/v0.7/types/performance_package_v2.ts @@ -744,6 +744,30 @@ export type PerformancePackageV2 = { type: "u8"; index: false; }, + { + name: "oracleReader"; + type: { + defined: "OracleReader"; + }; + index: false; + }, + { + name: "rewardFunction"; + type: { + defined: "RewardFunction"; + }; + index: false; + }, + { + name: "minUnlockTimestamp"; + type: "i64"; + index: false; + }, + { + name: "ppCreatedAtTimestamp"; + type: "i64"; + index: false; + }, ]; }, { @@ -766,6 +790,16 @@ export type PerformancePackageV2 = { type: "i64"; index: false; }, + { + name: "startOracleValue"; + type: "u128"; + index: false; + }, + { + name: "ppCreatedAtTimestamp"; + type: "i64"; + index: false; + }, ]; }, { @@ -803,6 +837,11 @@ export type PerformancePackageV2 = { type: "u64"; index: false; }, + { + name: "ppCreatedAtTimestamp"; + type: "i64"; + index: false; + }, ]; }, { @@ -830,6 +869,11 @@ export type PerformancePackageV2 = { type: "publicKey"; index: false; }, + { + name: "ppCreatedAtTimestamp"; + type: "i64"; + index: false; + }, ]; }, { @@ -887,6 +931,11 @@ export type PerformancePackageV2 = { }; index: false; }, + { + name: "ppCreatedAtTimestamp"; + type: "i64"; + index: false; + }, ]; }, { @@ -934,6 +983,16 @@ export type PerformancePackageV2 = { }; index: false; }, + { + name: "changeRequest"; + type: "publicKey"; + index: false; + }, + { + name: "ppCreatedAtTimestamp"; + type: "i64"; + index: false; + }, ]; }, { @@ -956,6 +1015,11 @@ export type PerformancePackageV2 = { type: "u64"; index: false; }, + { + name: "ppCreatedAtTimestamp"; + type: "i64"; + index: false; + }, ]; }, ]; @@ -1814,6 +1878,30 @@ export const IDL: PerformancePackageV2 = { type: "u8", index: false, }, + { + name: "oracleReader", + type: { + defined: "OracleReader", + }, + index: false, + }, + { + name: "rewardFunction", + type: { + defined: "RewardFunction", + }, + index: false, + }, + { + name: "minUnlockTimestamp", + type: "i64", + index: false, + }, + { + name: "ppCreatedAtTimestamp", + type: "i64", + index: false, + }, ], }, { @@ -1836,6 +1924,16 @@ export const IDL: PerformancePackageV2 = { type: "i64", index: false, }, + { + name: "startOracleValue", + type: "u128", + index: false, + }, + { + name: "ppCreatedAtTimestamp", + type: "i64", + index: false, + }, ], }, { @@ -1873,6 +1971,11 @@ export const IDL: PerformancePackageV2 = { type: "u64", index: false, }, + { + name: "ppCreatedAtTimestamp", + type: "i64", + index: false, + }, ], }, { @@ -1900,6 +2003,11 @@ export const IDL: PerformancePackageV2 = { type: "publicKey", index: false, }, + { + name: "ppCreatedAtTimestamp", + type: "i64", + index: false, + }, ], }, { @@ -1957,6 +2065,11 @@ export const IDL: PerformancePackageV2 = { }, index: false, }, + { + name: "ppCreatedAtTimestamp", + type: "i64", + index: false, + }, ], }, { @@ -2004,6 +2117,16 @@ export const IDL: PerformancePackageV2 = { }, index: false, }, + { + name: "changeRequest", + type: "publicKey", + index: false, + }, + { + name: "ppCreatedAtTimestamp", + type: "i64", + index: false, + }, ], }, { @@ -2026,6 +2149,11 @@ export const IDL: PerformancePackageV2 = { type: "u64", index: false, }, + { + name: "ppCreatedAtTimestamp", + type: "i64", + index: false, + }, ], }, ], diff --git a/yarn.lock b/yarn.lock index 3f05b387..a6f0dfa4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -865,7 +865,7 @@ "@jridgewell/sourcemap-codec" "^1.4.10" "@metadaoproject/programs@./sdk": - version "0.1.0-alpha.2" + version "0.1.0-alpha.5" dependencies: "@coral-xyz/anchor" "^0.29.0" "@noble/hashes" "^1.4.0"